akhauriyash/Code-Regression huggingface dataset:
import sys
from io import StringIO
import unittest
import os
import heapq

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())
    a_s = list(map(int, input().split()))

    a_s.sort(reverse=True)

    que = []
    heapq.heapify(que)

    ans = 0
    for cnt, a in enumerate(a_s):
        a = -a
        if cnt == 0:
            heapq.heappush(que, a)
            continue

            # キューから値の取り出し
        target = heapq.heappop(que)
        ans += -target
        heapq.heappush(que, a)
        heapq.heappush(que, a)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
2 2 1 3"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """7
1 1 1 1 1 1 1"""
        output = """6"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def test_1original_1(self):
        test_input = """4
2 2 3 3"""
        output = """9"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 104232
// SeeAlso: https://atcoder.jp/contests/abc053/tasks/abc053_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string s;

int main() {
    
    cin >> s;

    int l = s.length();
    int start = l;
    int end = 0;

    REP(i, l) {
        if(s[i]=='A') {
            start = min(start, i);    
        }
        if(s[l-i-1]=='Z') {
            end = max(end, l-i-1);
        }
    }

    print(end-start+1);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int A, B, C;
  cin>>A>>B>>C;

  int i = 1, j = 0;
  while(1){
    while(1){
      if(A*i < B*j){
        j = 0;
        break;
      }
      int tmp = A*i - B*j;
      if(tmp == C){
        cout<<"YES"<<endl;
        return 0;
      }
      if(tmp == 0){
        cout<<"NO"<<endl;
        return 0;
      }
      j++;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 256
l,r = map(int,input().split())

for i in range(l, min(l + 2040, r + 1)):
        if i % 2019 == 0:
                print(0)
                exit()

res = 10 ** 100
for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
                res = min(res, i * j % 2019)
print(res)

Measured memory_bytes: 41964
#!/usr/bin/env python3
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [0]*m
c = [0]*m
for i in range(m):
    b[i],c[i] = map(int,input().split())
c,b = zip(*sorted(zip(c,b)))#c でソートする
# 整数列a からmin からc にb枚まで帰る操作を繰り返した時のsumのmaxを求める
# C の大きい順から、Nを超えないまで並べていく
# もし、そのtotalがN を超える場合は、そのできた配列とaをソートしたものを比べて、
# aをソートしたものの方が大きいところがあれば修正する
# もしtotla がNを超えないなら、小さい順から置き換えたもののそのままでOK
# 実装としては、ソートしたaを前から順番にc[i]より大きいか比べていく
cb = 0
idx = 0
for i in range(n):
    if cb == m:break
    else:
        if a[i] < c[m-1-cb]:a[i] = c[m-1-cb]
        idx += 1
        if idx == b[m-1-cb]:
            idx = 0
            cb += 1
print(sum(a))


Measured memory_bytes: 81644
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <utility>
#define EPS 1e-10
using namespace std;

double add(double a,double b){
    if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0;
    return a+b;
}

class P{
public:
    double x,y;
    P(double xx=0,double yy=0){
        x=xx;
        y=yy;
    }
    P operator +(P p){
        return P(add(x,p.x),add(y,p.y));
    }
    P operator -(P p){
        return P(add(x,-p.x),add(y,-p.y));
    }
    P operator *(double d){
        return P(x*d,y*d);
    }
    P operator /(double d){
        return P(x/d,y/d);
    }
    bool operator<(const P &p)const{
        if(add(x,-p.x)==0.0)return y<p.y;
        return x<p.x;
    }
};

typedef P Vector;

double norm(P p){
    return p.x*p.x+p.y*p.y;
}

double abs(P p){
    return sqrt(norm(p));
}

double dot(Vector a,Vector b){
    return add(a.x*b.x,a.y*b.y);
}

double cross(Vector a,Vector b){
    return add(a.x*b.y,-a.y*b.x);
}

class Segment{
public:
    P p1,p2;
    Segment(P pp1=P(),P pp2=P()){
        p1=pp1;
        p2=pp2;
    }
};

typedef Segment Line;

P project(Segment s,P p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

class Circle{
public:
    P c;
    double r;
    Circle(P cc=P(),double rr=0.0){
        c=cc;
        r=rr;
    }
};

double getDistanceLP(Line l,P p){
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}


bool intersect(Circle c,Line l){
    return getDistanceLP(l,c.c)<=c.r;
}

pair<P,P> getCrossPoints(Circle c,Line l){
    assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));
    return make_pair(pr+e*base,pr-e*base);
}


int main(void){
    Circle c;
    scanf("%lf %lf %lf",&c.c.x,&c.c.y,&c.r);
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        Line l;
        scanf("%lf %lf %lf %lf",&l.p1.x,&l.p1.y,&l.p2.x,&l.p2.y);
        pair<P,P> res=getCrossPoints(c,l);
        if(res.second<res.first)swap(res.first,res.second);
        printf("%.9f %.9f %.9f %.9f\n",res.first.x,res.first.y,res.second.x,res.second.y);
    }
    return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int m, n, k = 1;
    bool a[7500000];
    while (true) {
        for (int i = 1; i <= 7400000; i++) a[i] = false;
        k = 1;
        cin >> m >> n;
        if (m == 0 && n == 0) break;
        else {
            while (k <= n) {
                a[m] = true;
                for (int i = 1; m * i <= 7400000; i++) a[m * i] = true;
                while (a[m] == true) {
                    m++;
                }
                k++;
            }
            cout << m << endl;
        }
    }
    return 0;
}



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

int main(){
  int n; cin >> n;
  vector<long long> a(5);
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s[0] == 'M') a[0]++;
    else if (s[0] == 'A') a[1]++;
    else if (s[0] == 'R') a[2]++;
    else if (s[0] == 'C') a[3]++;
    else if (s[0] == 'H') a[4]++;
  }
  long long ans = 0;
  for(int i = 0; i < 5; i++){
    for(int j = i + 1; j < 5; j++){
      for(int k = j + 1; k < 5; k++){
        ans += a[i]*a[j]*a[k];
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;
int main() {
	string S;
	cin >> S;
	long long sumCount = 0;
	long long countW = 0;
	for (int k = 0;k < S.length();++k) {
		if (S[k] == 'W'){
			sumCount += countW;			
		}
		else {
			++countW;
		}
	}
	cout << sumCount << endl;
	system("pause");
}

Measured memory_bytes: 832
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
long long num[N],dif[N],pos[N];
long long mov[N],dfn[N],col[N];
vector<long long> cir[N];
long long n,m,k,cnt,las;
void DFS(long long nde,long long len)
{
	dfn[nde]=len,col[nde]=cnt;
	cir[cnt].push_back(nde);
	if(!col[pos[nde]])
		DFS(pos[nde],len+1);
}
int main ()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&num[i]),pos[i]=i,dif[i-1]=num[i]-num[i-1];
	scanf("%lld%lld",&m,&k);
	for(int i=1;i<=m;i++)
		scanf("%lld",&mov[i]),swap(pos[mov[i]],pos[mov[i]-1]);
	for(int i=1;i<=n;i++)
		if(!dfn[i]) cnt++,DFS(i,0);
	las=num[1],printf("%lld\n",las);
	for(int i=1;i<n;i++)
		printf("%lld\n",las+=dif[cir[col[i]][(dfn[i]+k)%cir[col[i]].size()]]);
	return 0;
}

Measured memory_bytes: 12276
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
using namespace std;

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    if(N%2==0)cout << N/2-1;
    else cout << (N+1)/2-1;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long K) {
  int digit = 0;
  while(N>0){
    N /= K;
    digit++;
  }
  cout << digit << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long K;
  std::cin >> K;
  solve(N, K);
  return 0;
}


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

ll n, m, ans;
int main() {
    cin >> n >> m;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    if (n == m) {
        ans = 2;
    } else {
        ans = 1;
    }
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }
    for (int i = 1; i <= m; i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
N=int(input())
S=input()
count=0

if N%2==0:
    for a in range(0,(round(N/2))):
        if S[a]==S[(round(N/2))+a]:
            count=count+1
        else:
            break
else:
    pass

if count==(N/2):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using V = vector<int>;
using VV = vector<vector<int>>;
int Inf = (1<<30);
ll inf = (1LL<<60);
const int MOD = 1e9 + 7;
int main() {
	ll n, k;
	cin >> n >> k;
	V a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll count = 0;
	for (i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) count++;
		}
	}
	ll count2 = 0;
	for (i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] > a[j]) count2++;
		}
	}
	ll ans = 0;
	ans += count * k;
	ans %= MOD;
	ll tmp = (k * (k - 1)) / 2 % MOD;
	ans += count2 * tmp;
	ans %= MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a, b, N, s[1000] = {}, f[1000] = {},co=0;
	cin >> a >> b >> N;
	for (int i = 0; i < N; i++){
		cin >> s[i] >> f[i];
		if (s[i]<=a&&b<=f[i]){
			co++;
		}
		else if (a<=s[i]&&s[i]<b){
			co++;
		}
		else if (a<f[i] && f[i] <= b){
			co++;
		}
		else if (a < s[i] && f[i]<b){
			co++;
		}
	}
	if (co>0){
		co = 1;
	}
	cout << co << endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	string even, odd, ans = "";
	cin >> even >> odd;
	REP(i, even.size())
	{
		ans += even[i];
		if (i < odd.size())
		{
			ans += odd[i];
		}

	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
AB = [0]*N
for i in range(N):
    AB[i] = list(map(int, input().split()))
AB.sort()
ans = 0

for j in range(len(AB)):
    if AB[j][1] < M:
        ans += AB[j][0] * AB[j][1]
        M -= AB[j][1]
    else:
        ans += AB[j][0] * M
        break
print(ans)

Measured memory_bytes: 27760
#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 x;
    cin>>x;
    if(x==7||x==5||x==3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main(){
  long long N,P,ans;
  cin>>N>>P;
  ans=P;
  for(int i=sqrt(P);N>1 && i>0 ;--i){
    long long t=pow(i,N);
    if(t>P) continue;
    if(P%t == 0){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}
    

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

int main(){
    string s; cin>>s;
    int n = s.size();
    int ans = 0;
    if(n%2==0){
        for(int i=0;i<s.size()/2;i++){
            ans += 9*pow(10,2*i);
        }
    }
    else{
        for(int i=0;i<(s.size()-1)/2;i++){
            ans += 9*pow(10,2*i);
        }
        ans += stoi(s)-pow(10,s.size()-1)+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    a,b,c = inpm()
    if a==b and b!=c:
        print('Yes')
    elif a==c and b!=c:
        print('Yes')
    elif c==b and b!=a:
        print('Yes')
    else:
        print('No')
if __name__ == "__main__":
    main()




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

using namespace std;

struct P {
    double x, y;
    bool operator<(const P &r) const {
        return x < r.x;
    }
};

int main() {

    int n;
    char split;
    double a, b, c, x, y, z, s = 0;
    P p[20];

    for(n = 0; cin >> x >> split >> y; ++n) {

        p[n].x = x;
        p[n].y = y;

    }

    for(int i = 0; i < n - 2; ++i) {

        a = hypot(p[0].x - p[i + 1].x, p[0].y - p[i + 1].y);
        b = hypot(p[0].x - p[i + 2].x, p[0].y - p[i + 2].y);
        c = hypot(p[i + 1].x - p[i + 2].x, p[i + 1].y - p[i + 2].y);

        z = (a + b + c) / 2;

        s += sqrt(z * (z - a) * (z - b) * (z - c));

    }

    printf("%.6f\n", s);

}

Measured memory_bytes: 1252
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S, W = In.ints()

if W>=S:
    Out.str("unsafe")
else:
    Out.str("safe")

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void) {
    long long  A, B, K;
    long long resA, resB;
    
    cin >> A >> B >> K;
    
    resA = A - K;
    resB = B;
    if (resA < 0) {
        resA = 0;
        resB = B - abs(A - K);
        if (resB < 0) {
            resB = 0;
        }
    }
    
    cout << resA << " " << resB << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
arr = []

for _ in range(N):
    arr.append(input())

print(f'AC x {arr.count("AC")}')
print(f'WA x {arr.count("WA")}')
print(f'TLE x {arr.count("TLE")}')
print(f'RE x {arr.count("RE")}')


Measured memory_bytes: 16280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        r += n >= 10 ? 0 : (10-n) * 100;
        System.out.println(r);
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.sync_with_stdio(0); cout.tie(0);
#define Bye return 0
const int MAX = 1e6+1;
#define int long long

int minCost(int h[], int i, int n){
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    for (int i=2; i<n; i++)
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),  dp[i-2] + abs(h[i] - h[i-2]));

    return dp[n-1];
}



void solve(){
    int n; cin>>n;
    int height[n];

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

    cout<<minCost(height, 0, n)<<endl;
}

int32_t main()
{
    IOS;
    solve();
    Bye;
}

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

int func(int x){
    if (x<10) return x;
    return func(x/10)+x%10;
}
int main() {
    int N, A, B, sum=0;
    cin >> N >> A >> B;
    for (int i=0; i<=N; i++){
        if (A<=func(i) && func(i)<=B) sum+=i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var t = create(c, s, d);
		var max = score(c, s, t, d);
		for (var i = 0; i < d; i++) {
			for (var j = 1; j < K; j++) {
				var t2 = new int[d];
				for (var k = 0; k < d; k++) {
					t2[k] = t[k];
				}
				t2[i] = (t2[i] + j) % K + 1;
				var sum = score(c, s, t2, d);
				//System.out.println(sum);
				if (max < sum) {
					t = t2;
					max = sum;
				}
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		//System.out.printf("%d %d %d\r\n", value, sum, index);
		return index;
	}
}


Measured memory_bytes: 55192
import sys
input = sys.stdin.readline

mod = 998244353

N,S = map(int,input().split())
A = list(map(int,input().split()))

dp0 = [[0]*(S+1) for _ in range(N+1)]
dp1 = [[0]*(S+1) for _ in range(N+1)]
dp2 = [[0]*(S+1) for _ in range(N+1)]
###dp[i][j][k]:Aのindex[i-1]まで見て和がjになっているもの
###kの意味は解説の通り


dp0[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp0[i+1][j] += dp0[i][j]
        dp0[i+1][j] %= mod

        dp1[i+1][j] += dp0[i][j] + dp1[i][j]
        dp1[i+1][j] %= mod

        dp2[i+1][j] += dp0[i][j] + dp1[i][j] + dp2[i][j]
        dp2[i+1][j] %= mod

        if j+A[i] <= S:
            dp1[i+1][j+A[i]] += dp0[i][j] + dp1[i][j]
            dp1[i+1][j+A[i]] %= mod
        
            dp2[i+1][j+A[i]] += dp0[i][j] + dp1[i][j]
            dp2[i+1][j+A[i]] %= mod

print(dp2[N][S])

Measured memory_bytes: 247048
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n],dp[n];
	memset(dp,1000000,sizeof(dp));
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if((i+j)<n){
				dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> subord(N + 1, 0);
    for(int i = 0; i < N - 1; i++){
        int A;
        cin >> A;
        subord[A]++;
    }
    for(int i = 1; i <= N; i++) cout << subord[i] << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

const long long int llinf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define Endl endl
#define pr(x) cout << x << endl
#define FOR(i,a,b) for(int i = a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define atcoder int(1e9) +7;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
#define all(x) x.begin,x.end();

char cn[100][100],cm[100][100];

int main() {

	int n, m;
	cin >> n >> m;

	rep(i, n) rep(j, n) cin >> cn[i][j];

	rep(i, m) rep(j, m) cin >> cm[i][j];

	rep(i, n - m+1) {
		rep(j, n - m+1) {
			bool flag = true;
			rep(k, m) {
				rep(l, m) {
					if (cn[i + k][j + l] != cm[k][l])flag = false;
				}
			}
			if (flag) {
				pr("Yes");
				return 0;
			}
		}
	}

	pr("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int modulo=1000000007;
int h, w;
long long dp[1001][1001];
char arr[1001][1001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> arr[i][j];
		}
	}
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			if(i==0 or j==0){
				dp[i][j]=0;
			}
			else if(i==1 && j==1){
				dp[i][j]=1;
			}
			else{
				if(arr[i][j]=='#'){
					dp[i][j]=0;
				}
				else{
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modulo;
				}
			}
		}
	}
	cout << dp[h][w]%modulo << '\n';
}

Measured memory_bytes: 9088
using System;

namespace ITP1_5_B {
    class Program {
        static void Main(string[] args) {
            while(true) {
                string[] s = Console.ReadLine().Split(' ');
                int H = int.Parse(s[0]);
                int W = int.Parse(s[1]);
                if(H == 0 && W == 0) break;
                string a = new string('#', W);
                string b = new string('.', W - 2);
                for(int i = 0; i < H; i++) {
                    if(i == 0) {
                        Console.WriteLine(a);
                    } else if(i == H - 1) {
                        Console.WriteLine(a);
                    } else {
                        Console.WriteLine("#" + b + "#");
                    }
                }
                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 8876
#include<stdio.h>
#include<math.h>
double d,r,s,z[6];
int n,i,j,a[50];
int main(){
	for(scanf("%d",&n);n--;){
		for(i=0;i<6;i++)
			scanf("%lf",z+i);
		r=z[2];
		s=z[5];
		d=hypot(*z-z[3],z[1]-z[4]);
		printf("%d\n",a[j++]=d>r+s?0:r>d+s?2:s>d+r?-2:1);
	}
	
	i=a[7];
	if(i==2)puts("");
	else if(i==-2)while(1);
	else if(i==1)return 1;
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  int size = s.size(), i, j;

  std::vector<std::pair<char, int>> a;

  char c;

  for (int i = 0; i < size; i ++)
    if ((c = s[i]) != 'x')
      a.emplace_back(c, i);

  if (a.empty()) {
    std::cout << 0 << std::endl;

    return 0;
  }

  for (i = 0, j = a.size() - 1; i < j; i ++, j --)
    if (a[i].first != a[j].first) {
      std::cout << -1 << std::endl;

      return 0;
    }

  if (a.size() % 2) {
    assert(i == j);

    int ii = a[i].second - 1;
    int jj = a[i].second + 1;

    i = ii;
    j = jj;
  }
  else {
    int ii = a[j].second - 1;
    int jj = a[i].second + 1;

    i = ii;
    j = jj;
  }

  int C = 0;

  for ( ; i >= 0 || j < size; ) {
    if (i < 0) {
      j ++;
      C ++;
    }
    else if (j >= size) {
      i --;
      C ++;
    }
    else if (s[i] == s[j]) {
      i --;
      j ++;
    }
    else if (s[i] == 'x') {
      i --;
      C ++;
    }
    else {
      j ++;
      C ++;
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,m; cin>>n>>m;
	if(n==m) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

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

template <typename T = int64_t>
static constexpr auto inf = static_cast <T> (0x0de0b6b43b9aca00);

template <typename T, typename U>
constexpr auto max (T && t, U && u) noexcept
{
  return t < u ? forward <U> (u) : forward <T> (t);
}

struct edge_t {
  size_t from, to;
  int64_t weight;
};

template <typename Edges, typename ResultContainer>
auto bellman_ford (const Edges & edges, ResultContainer & d, size_t start = 0)
{
  using weight_t = typename iterator_traits <decltype (begin (d))>::value_type;
  fill (begin (d) , end (d), inf <weight_t>);
  d [start] = 0;
  rep (i, d.size () * 2)
  {
    for (auto && edge : edges)
    {
      if (d [edge.from] >= inf <>) continue;
      if (d [edge.to] > d [edge.from] + edge.weight)
      {
        d [edge.to] = d [edge.from] + edge.weight;
        if (i >= d.size ())
        {
          d [edge.to] = - inf <weight_t>;
        }
      }
    }
  }
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  int64_t p;
  cin >> n >> m >> p;

  vector <edge_t> edges;
  rep (i, m)
  {
    size_t a, b;
    int64_t c;
    cin >> a >> b >> c;
    edges.push_back (edge_t {a, b, p - c});
  }

  vector <int64_t> d (n + 1);
  bellman_ford (edges, d, 1);

#ifdef LOCAL
  for (auto && elem : d) cerr << elem << " ";
  cerr << endl;
#endif

  auto ans = - d [n];
  if (ans >= inf <>)
  {
    cout << "-1" << endl;
  }
  else
  {
    cout << max (ans, 0) << endl;
  }
}


Measured memory_bytes: 576
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
struct Edge {
	int to,id;
};

vector<vector<Edge>> g;
vector<int> ans;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
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;
}

void dfs(int v, int c = -1, int p = -1) {
	int k = 1;
	rep(i, g[v].size()) {
		int u = g[v][i].to, ei = g[v][i].id;
		if (u == p) continue;
		if (k == c) ++k;
		ans[ei] = k; ++k;
		dfs(u, ans[ei], v);
	}
}

void solve() {
		int n; cin >> n;
		g.resize(n);
		ans = vector<int>(n - 1);
		rep (i, n - 1) {
			int a; cin >> a;
			int b; cin >> b;
			a--; b--;
			g[a].push_back((Edge){b, i});
			g[b].push_back((Edge){a, i});
		}
		dfs(0);
		int mx = 0;
		rep (i, n) {
			mx = max(mx, int(g[i].size()));
		}
		cout << mx << endl;
		rep(i, n - 1) {
			cout << ans[i] << endl;
		}
    return;
}

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



Measured memory_bytes: 8320
package main

import "fmt"

func main() {
	var s, t string
	var cnt int
	fmt.Scan(&s, &t)
	ss := []rune(s)
	tt := []rune(t)
	for i, v := range ss {
		if v != tt[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 5004
#include <stdio.h>

int main(){
	double a,b,c,d,e,f, x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)>0){
			x=(a*f-c*d)/(a*e-b*d);
			y=(c-x*b)/a;
			printf("%.3f %.3f\n",y,x);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n; cin>>n;
    int kk[4];
    FOR(i,0,4){
        kk[i]=n%10;
        n/=10;
    }
    int d[2]={1,-1};
    string h[2]={"+","-"};
    FOR(i,0,2){
        FOR(j,0,2){
            FOR(k,0,2){
                if(kk[3]+kk[2]*d[i]+kk[1]*d[j]+kk[0]*d[k]==7){
                    cout<<kk[3]<<h[i]<<kk[2]<<h[j]<<kk[1]<<h[k]<<kk[0]<<"=7"<<endl;
                    exit(0);
                }
            }
        }
    }
    return 0;
}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a <= 5)
    cout << 0;
  else if (a <= 12)
    cout << b / 2;
  else
    cout << b;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Max(xx,yy) (xx > yy ? xx : yy);
#define Min(xx,yy) (xx < yy ? xx : yy);

using namespace std;
 
bool isDebug;
 
template<typename... T>
void dbg(T... args){
	if(!isDebug)
		return;
	
	#ifdef LOCAL
		((cout << args << " "),...) << "\n";
	#endif
}
               
int t,n;
    
int main(int argc, char* argv[]){
	ios_base :: sync_with_stdio(false);
	cout.tie(NULL), cin.tie(NULL);
	isDebug = (argc > 1 && string(argv[1]) == "debug");
	                              
	int n,a,b;
	cin >> n >> a >> b;
	
	for(int i = a;i <= b;i++){
	 	if(i % n == 0){
	 	 	cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c);
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >> b;
	if (a == b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

int asort(const void *A,const void *B){
    return *(long long*)A>*(long long*)B?1:0;
}

int dsort(const void *A,const void *B){
    return *(long long*)A<*(long long*)B?1:0;
}

long long gcd(long long A,long long B){
    return B?gcd(B,A%B):A;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

int main(void){
    long long n,a,b,c;
    scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
    long long l[n];
    long long ans=1e9;
    for (int i=0; i<n; i++){
        scanf("%lld",&l[i]);
    }
    bool takena[n],takenb[n];
    for (long long i=0; i<(1<<n); i++){
        long long tmpa=0,counta=0;
        for (int p=0; p<n; p++){
            takena[p]=false;
        }
        for (long long j=0; j<n; j++){
            if ((1&i>>j)==1){
               takena[j]=true;
               tmpa+=l[j];
               counta++;
           }
        }
        if (tmpa==0){
            continue;
        }
        for (long long i2=0; i2<(1<<n); i2++){
            long long tmpb=0,countb=0;
            for (int q=0; q<n; q++){
                takenb[q]=false;
            }
            for (long long j2=0; j2<n; j2++){
                if ((1&i2>>j2)==1 && takena[j2]==false){
                    takenb[j2]=true;
                    tmpb+=l[j2];
                    countb++;
                }
            }
            if (tmpb==0){
                continue;
            }
            for (long long i3=0; i3<(1<<n); i3++){
                long long tmpc=0,countc=0;
                for (long long j3=0; j3<n; j3++){
                    if ((1&i3>>j3)==1 && takena[j3]==false && takenb[j3]==false){
                        tmpc+=l[j3];
                        countc++;
                    }
                }
                if (tmpc==0){
                    continue;
                }
                ans=min(ans,llabs(tmpa-a)+llabs(tmpb-b)+llabs(tmpc-c)+10*(counta+countb+countc-3));
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn.readInt

object Main {
   def main(args: Array[String]) = {
     val n = readInt()
     val r0 = readInt()
     val r1 = readInt()
     var max = r1 - r0
     var min = if(r0 > r1) r1 else r0

     for( i <- 2 to n-1 ) {
       val m = readInt()
       if( max < m - min) {
         max = m - min
       }
       if( min > m ) {
         min = m
       }
     }
     println(max)
  }
}

Measured memory_bytes: 63580
n, a = map(int, input().split())
x = list(map(int, input().split()))

max_x = max(x)
dp = [[0 for _  in range(n * 2 * max_x + 1)] for _ in range(n + 1)]

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)

Measured memory_bytes: 5740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        sc.close();

        boolean ans = false;

        if (s.equals("a") || s.equals("i") || s.equals("u") || s.equals("e") || s.equals("o")) {
            ans = true;
        }

        System.out.println(ans ? "vowel" : "consonant");
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <climits>
#include <algorithm>

const int MAX_N = 200000;

int a[MAX_N + 1];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n, min = INT_MAX;
  std::cin >> n;

  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  std::sort(a + 1, a + n + 1, std::greater<int>());
  int l = 2;
  if (n <= 1) {
    std::cout << 0;
    return 0;
  }
  long long ans = a[1];
  n -= 2;
  while (n) {
    if (n >= 2) {
      ans += 2 * a[l++];
      n -= 2;
    } else {
      n--;
      ans += a[l];
    }
  }
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 4420
#include<iostream>
#include<string>
using namespace std;
int main(){
    for(int i=0;i<9;i++){
        string str;
        cin>>str;
        int before,after;
        cin>>before>>after;
        cout<<str<<" "<<before+after<<" "<<before*200+after*300<<endl;
    }
    return 0;
}

Measured memory_bytes: 1204
k = STDIN.gets().split(" ")[0].to_i
a = STDIN.gets().split(" ")

dmax = 0
pointer = 0

for i in 0..(a.length-2)
	d = a[i+1].to_i-a[i].to_i
	if d > dmax
		pointer = i
		dmax = d
	end
end
d = k - a[a.length-1].to_i + a[0].to_i
if d > dmax
	puts a[a.length-1].to_i - a[0].to_i
else
	puts k - (a[pointer+1].to_i-a[pointer].to_i)
end


Measured memory_bytes: 13836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

map<int, int> ctA, ctB;
int n, A[200005], B[200005], rotL = 0, rotR = 0;
void solve()
{
	
	cin >> n;
	rep(i,0,n) cin >> A[i], ctA[A[i]]++;
	rep(i,0,n) cin >> B[i], ctB[B[i]]++;
	
	rep(i,0,n) {
		if (ctA[A[i]] + ctB[A[i]] > n) {
			cout << "No\n";
			return;
		}
	}
	
	map <int, pii> sieiA, sieiB;
	rep(i,0,n) {
		if (sieiA[A[i]] == pii{0, 0}) sieiA[A[i]] = {i+1, i+1};
		sieiA[A[i]].ss = i+1;
		
		if (sieiB[B[i]] == pii{0, 0}) sieiB[B[i]] = {i+1, i+1};
		sieiB[B[i]].ss = i+1;
	}
	
	for (auto w: sieiA) {
		auto u = w.ss;
		auto v = sieiB[w.ff];
		
		rotL = max(rotL, max(0LL, v.ss - u.ff + 1));
		rotR = max(rotR, max(0LL, u.ss - v.ff + 1));
	}
	
	bool ok = true;
	rep(i,0,n) {
		if (A[i] == B[(i+rotL)%n]) ok = false;
	}
	
	if (ok) {
		cout << "Yes\n";
		rep(i,0,n) cout << B[(i+rotL)%n] << " ";
		return;
	}
	rep(i,0,n) {
		if (A[i] == B[(i-rotR+n)%n]) ok = false;
	}
	
	if (ok) {
		cout << "Yes\n";
		rep(i,0,n) cout << B[(i-rotR+n)%n] << " ";
		return;
	}
	cout << "No\n";
}
	
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 56620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
    
            if (h == 0 && w == 0) {
                scanner.close();
                return;
            }

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    if (y == 0 || y == h - 1 || x == 0 || x == w - 1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 32532
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> 

using namespace std;

int ne,no,a;

int main()
{
	int n;
	scanf("%d",&n);
	if(n == 1){
		printf("YES\n");
		return 0;
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&a);
		if(a % 2)
			ne++;
		else
			no++;
	}
	if(ne % 2)
		printf("NO\n");
	else
		printf("YES\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdlib>





int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++)
  {
    cin >> a.at(i);
  }

  int ans = 0;
  for (int i=0; i<N; i++)
  {
    if (i%2 == 0 && a.at(i)%2 == 1)
    {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;


}


Measured memory_bytes: 3624
S = list(input())
s = ['k','e','y','e','n','c','e']
a = 0
for i in range(len(s)):
    if S[i] == s[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()


ss = s[a:]


for i in range(len(ss)):
    if ss[i] == S[len(S)-len(ss)+i]:
        continue
    else:
        print('NO')
        exit()

else:
    print('YES')
    

Measured memory_bytes: 3060
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	static int C = 1;
	public static void main(String[] args) {
		for (C = 1; read(); C++)
			solve();
	}
	
	static int W, N;
	static int[] w = new int[1000], v = new int[1000];
	static boolean read() {
		W = sc.nextInt();
		if (W == 0) return false;
		N = sc.nextInt();
		String[] str;
		for (int i = 0; i < N; i++) {
			str = sc.next().split(",");
			v[i] = Integer.parseInt(str[0]);
			w[i] = Integer.parseInt(str[1]);
		}
		return true;
	}

	static void solve() {
		int[][] dp = new int[N + 1][W + 1];
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= W; j++) {
				if (j >= w[i - 1]) {
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}
		int wt = 0, val = 0;
		for (int i = 0; i <= W; i++) {
			if (val < dp[N][i]) {
				wt = i; val = dp[N][i];
			}
		}
		System.out.println("Case " + C + ":");
		System.out.println(val);
		System.out.println(wt);
	}	
}

Measured memory_bytes: 16000