akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]


odd = v[::2]
even = v[1::2]

odd2 = Counter(odd)
even2 = Counter(even)

if len(list(set(v))) == 1:
    print(n//2)

else:
    if odd2.most_common()[0][0] == even2.most_common()[0][0]:
        if odd2.most_common()[0][1] > even2.most_common()[0][1]:
            print(n - odd2.most_common()[0][1] - even2.most_common()[1][1])
        elif odd2.most_common()[0][1] < even2.most_common()[0][1]:
            print(n - odd2.most_common()[1][1] - even2.most_common()[0][1])
        else:
            if odd2.most_common()[1][1] > even2.most_common()[1][1]:
                print(n - odd2.most_common()[1][1] - even2.most_common()[0][1])
            else:
                print(n - odd2.most_common()[0][1] - even2.most_common()[1][1])
    else:
        print(n - odd2.most_common()[0][1] - even2.most_common()[0][1])


Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  typedef pair<int, int> P;

  vector<P> A(N);
  rep(i, N) {
    cin >> A[i].fi;
    A[i].se = i + 1;
  }

  sort(all(A));

  rep(i, N) {
    cout << A[i].se << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<ll,ll>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int main(){

  int N, M;
  cin >> N >> M;

  priority_queue<ipair> q;

  rep(i, N){
    int a, b;
    cin >> a >> b;

    q.push(make_pair(-a, b));
  }

  ll ans = 0;
  priority_queue<int> checked;


  rep(i, M){
    int remain_day = i+1;
    int q_max=-1;
    int checked_max=-1;

    while(remain_day >= -q.top().first && !q.empty()){
      checked.push(q.top().second);
      q.pop();
    }

    if(!checked.empty()){
      // cout << checked.top() << endl;
      ans += checked.top(); checked.pop();
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2672
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC146B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var S = NS;
            Func<char, long, char> get = (x, num) =>
            {
                var tmp = x + num;
                if (tmp > 'Z') tmp -= 26;
                return (char)tmp;
            };
            foreach (var item in S)
            {
                Console.Write(get(item, N));
            }
            Console.WriteLine();
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12768
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int dp[50];

int main(){
  int n;
  cin >> n;
  dp[0] = 1;
  dp[1] = 1;
  for(int i=2; i<=n+1; i++){
    dp[i] = dp[i-1] + dp[i-2];
  }
  cout << dp[n] << endl;
}



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


int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) {
    cout << 1;
  } else if (b == 0) {
    cout << 2;
  } else if (c == 0) {
    cout << 3;
  } else if (d == 0) {
    cout << 4;
  } else {
    cout << 5;
  }
}

Measured memory_bytes: 3636
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int h = int.Parse(input[2]);
        int m = int.Parse(input[3]);

        double h_angle = (h * 30) + (m * 0.5);
        double m_angle = m * 6;
        double angle = Math.Abs(h_angle - m_angle);
        if(angle > 180){
            angle = 360 - angle;
        }
        double radian = angle * Math.PI / 180;

        double c = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(radian));
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 27924
'use strict';

function Main(INPUT) {
    let input = INPUT.split("\n").slice(1);
    input.sort();
    let ans = "";
    for (let i = 0; i < input.length; i++) {
        ans += input[i];
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
import java.util.*;

public class Main{

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

        // input
        char[] input = scan.next().toCharArray();


        // search
        int answer = input.length / 2;
        for(int i = 0; i < Math.ceil(input.length / 2); i++){
            if(input[i] == input[input.length - 1 - i]){
                answer--;
            } 
        }

        // answer
        System.out.println(answer);

    }
}

Measured memory_bytes: 23764
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,n,t,i,j,xoo=0;
    cin>>n;
    vll v;
    for(i=0;i<n;++i){
    	cin>>x;
    	v.pb(x);
    	xoo=(xoo^x);
	}
	for(i=0;i<n;++i){
		cout<<(xoo^v[i])<<" ";
	}
}

Measured memory_bytes: 5264
import sys
from copy import deepcopy
sys.setrecursionlimit(10**7)


def dfs(now):
    global ans
    if len(now) == N:
        tmp_ans = 0
        for a, b, c, d in query:
            a -= 1
            b -= 1
            if now[b] - now[a] == c:
                tmp_ans += d
        ans = max(tmp_ans, ans)
    else:
        for i in range(now[-1], M+1):
            tmp = deepcopy(now)
            tmp.append(i)
            dfs(tmp)


N, M, Q = map(int, input().split())  # N個の数列, 上限M, Q個のクエリ
query = [list(map(int, input().split())) for _ in range(Q)]

A = [1]
ans = 0
dfs(A)
print(ans)


Measured memory_bytes: 9348
k,n = map(int,input().split())
a = list(map(int,input().split()))
lists = []
for i in range(n-1):
    lists.append(abs(a[i] - a[i+1]))
lists.append(k - a[-1] + a[0])
jyogai = lists.index(max(lists))
cnt = 0
for i in range(len(lists)):
    if i != jyogai:
        cnt += lists[i]
print(cnt)

Measured memory_bytes: 25580
#include<iostream>
using namespace std;
#include<complex>
#include<vector>
void dft(vector<complex<double> >&A,int sign)
{
	int N=A.size()>>1;
	if(N==0)return;
	vector<complex<double> >F(N),G(N);
	for(int i=0;i<N;i++)
	{
		F[i]=A[i<<1];
		G[i]=A[i<<1|1];
	}
	dft(F,sign);
	dft(G,sign);
	complex<double>z(cos(M_PI/N),sin(M_PI/N)*sign),p=1;
	for(int i=0;i<N;i++)
	{
		A[i]=F[i]+p*G[i];
		A[i+N]=F[i]-p*G[i];
		p*=z;
	}
}
vector<long long>multiply(const vector<int>&A,const vector<int>&B)
{
	if(A.empty()||B.empty())
	{
		return(vector<long long>){};
	}
	int N=1;
	vector<long long>ret(A.size()+B.size()-1);
	while(N<ret.size())N<<=1;
	vector<complex<double> >F(N),G(N);
	for(int i=0;i<A.size();i++)F[i]=A[i];
	for(int i=0;i<B.size();i++)G[i]=B[i];
	dft(F,1);
	dft(G,1);
	for(int i=0;i<N;i++)F[i]*=G[i];
	dft(F,-1);
	for(int i=0;i<ret.size();i++)ret[i]=llround((F[i]/=N).real());
	return ret;
}
int N,M,K,L;
string B[500];
main()
{
	cin>>N>>M>>K>>L;
	vector<int>b(M*M);
	for(int i=0;i<N;i++)
	{
		cin>>B[i];
		for(int j=0;j<N;j++)
		{
			b[i*M+j]=B[i][j]=='X';
		}
	}
	string S;cin>>S;
	vector<int>c(M*M);
	int x=0,y=0;
	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='U')y--;
		else if(S[i]=='D')y++;
		else if(S[i]=='L')x--;
		else x++;
		c[y*M+x]+=1;
	}
	vector<long long>A=multiply(b,c);
	int cnt=0;
	for(int i=0;i<M*M;i++)cnt+=A[i]>=K;
	cout<<cnt<<endl;
}



Measured memory_bytes: 42652
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int num1 = sc.nextInt();
      int num2 = sc.nextInt();
      int num3 = sc.nextInt();
      if(21 >= (num1 + num2 + num3)){
            System.out.println("win");
      }
      else{
            System.out.println("bust");
      }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    int m = 0;
    int c = 0;
    for (int j = 0; j < S[i].size(); j++){
      if (S[i][j] == '('){
        c++;
      } else {
        c--;
        m = min(m, c);
      }
    }
    L[i] = -m;
  }
  vector<int> R(N);
  for (int i = 0; i < N; i++){
    int m = 0;
    int c = 0;
    for (int j = S[i].size() - 1; j >= 0; j--){
      if (S[i][j] == '('){
        c--;
        m = min(m, c);
      } else {
        c++;
      }
    }
    R[i] = -m;
  }
  /*
  for (int i = 0; i < N; i++){
    cout << L[i] << ' ' << R[i] << endl;
  }
  */
  long long Lsum = 0;
  long long Rsum = 0;
  for (int i = 0; i < N; i++){
    Lsum += L[i];
    Rsum += R[i];
  }
  if (Lsum != Rsum){
    cout << "No" << endl;
  } else {
    vector<pair<int, int>> I;
    vector<pair<int, int>> D;
    for (int i = 0; i < N; i++){
      if (R[i] >= L[i]){
        I.push_back(make_pair(L[i], R[i] - L[i]));
      } else {
        D.push_back(make_pair(R[i], L[i] - R[i]));
      }
    }
    sort(I.begin(), I.end());
    sort(D.begin(), D.end());
    int X = 0;
    bool flg = true;
    for (int i = 0; i < I.size(); i++){
      if (X < I[i].first){
        flg = false;
        break;
      } else {
        X += I[i].second;
      }
    }
    if (!flg){
      cout << "No" << endl;
    } else {
      int Y = 0;
      for (int i = 0; i < D.size(); i++){
        if (Y < D[i].first){
          flg = false;
          break;
        } else {
          Y += D[i].second;
        }
      }
      if (!flg){
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
      }
    }
  }
}

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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
// #define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;

string s;

int32_t main()
{
    cin >> s;
    int n = s.size();

    vector<int> A(n,1);

    for(int i = 0; i < n ; ++i){
        if(s[i]=='R' && s[i+1]=='R'){
            A[i+2] += A[i];
            A[i] = 0;
        }
    }

    for(int i = n-1 ; i >= 0 ; --i){
        if(s[i]=='L' && s[i-1]=='L'){
            A[i-2] += A[i];
            A[i] = 0;
        }
    }

    for(int i = 0 ; i < n ; ++i){
        if(i==0) cout << A[i] ;
        else cout << ' ' << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3788
n,m = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(m)]
for i in range(10**n):
    a = str(i)
    if len(a)!=n: continue
    for s,c in x:
        if a[s-1]!=str(c): break
    else:
        print(i)
        exit()
print(-1)


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n;
    cin >> n;
    string s;
    cin >> s;
    Int q;
    cin >> q;
    vector<set<Int>> st(26);
    for (Int i = 0; i < 26; i++) {
        st[i].insert(-INF);
        st[i].insert(INF);
    }
    for (Int i = 0; i < n; i++) {
        st[s[i] - 'a'].insert(i);
    }
    for (Int i = 0; i < q; i++) {
        Int a;
        cin >> a;
        if (a == 1) {
            Int b;
            char c;
            cin >> b >> c;
            b--;
            st[s[b] - 'a'].erase(b);
            st[c - 'a'].insert(b);
            s[b] = c;
        }
        else {
            Int b, c;
            cin >> b >> c;
            b--;
            c--;
            Int cnt = 0;
            for (Int j = 0; j < 26; j++) {
                if (*st[j].lower_bound(b) <= c) {
                    cnt++;
                }
            }
            dump(cnt);
        }
    }
    return 0;
}


Measured memory_bytes: 24196
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N = z()
a = zz()
ans = []
all_xor = 0
for _a in a:
    all_xor ^= _a

for i in range(N):
    tmp = -(all_xor ^ (~a[i])) - 1
    ans.append(tmp)
print(*ans)
# i番目以外のxorの合計がai


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

const int maxn=5e5+10;

int N,Q;
int bit[26][maxn];
char str[maxn];

void Add(int x,int v,int p){
        for (;x<=N;x+=x&-x)
                bit[p][x]+=v;
}

int Sum(int x,int p){
        int tmp=0;
        for (;x;x-=x&-x)
                tmp+=bit[p][x];
        return tmp;
}

int main (){
        scanf("%d%s%d",&N,str+1,&Q);
        for (int i=1;i<=N;i++)
                Add(i,1,str[i]-'a');
        for (int i=1,t;i<=Q;i++){
                scanf("%d",&t);
                if (t==1){
                        int pos;
                        char c;
                        scanf("%d %c",&pos,&c);
                        Add(pos,-1,str[pos]-'a');
                        Add(pos,1,(str[pos]=c)-'a');
                }else {
                        int ans=0,L,R;
                        scanf("%d%d",&L,&R);
                        for (int j=0;j<26;j++)
                                ans+=bool(Sum(R,j)-Sum(L-1,j));
                        printf("%d\n",ans);
                }
        }
        return 0;
}



Measured memory_bytes: 51584
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {	
    	char ch1;
    	cin>>ch1;
    	for(char ch='A';ch<='Z';++ch)
    	{
    		if(ch==ch1)
    		{
    			cout<<"A";
    			return 0;
    		}
    	}
    	cout<<'a';		
    }
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 11234567890;
LL N;
std::vector<std::vector<LL>>memo;
std::vector<std::vector<std::vector<LL>>>cost;

LL dp(LL i, LL j)
{
	if (i == N && j == N) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	LL res1 = inf, res2 = inf;
	if (i < N) res1 = cost[i][j][0] + dp(i + 1, j);
	if (j < N) res2 = cost[i][j][1] + dp(i, j + 1);
	return memo[i][j] = std::min(res1, res2);
}

int main()
{
	in >> N;
	std::vector<char>c(2 * N);
	std::vector<LL>a(2 * N);
	rep(i, 2 * N) in >> c[i] >> a[i];

	std::vector<std::vector<std::vector<LL>>>cntR(2 * N + 1, std::vector<std::vector<LL>>(N + 2, std::vector<LL>(2)));
	std::vector<std::vector<LL>>originalPos(N + 1, std::vector<LL>(2)), border(N + 1, std::vector<LL>(2, inf));
	rep(i, 2 * N)
	{
		LL type = (c[i] == 'W' ? 0 : 1);
		++cntR[i + 1][a[i]][type];
		originalPos[a[i]][type] = i + 1;
		rep(j, a[i]) if (border[j][type] == inf) border[j][type] = i + 1;
	}
	for (LL i = 2 * N - 1; i >= 0; --i) for (LL j = 1; j <= N; ++j) rep(k, 2) cntR[i][j][k] += cntR[i + 1][j][k];
	for (LL i = 0; i <= 2 * N; ++i) for (LL j = 1; j <= N; ++j) rep(k, 2) cntR[i][j][k] += cntR[i][j - 1][k];

	cost.resize(N + 1, std::vector<std::vector<LL>>(N + 1, std::vector<LL>(2)));
	for (LL i = 0; i <= N; ++i)
	{
		for (LL j = 0; j <= N; ++j)
		{
			if (i == N && j == N) continue;
			LL pos = std::min(border[i][0], border[j][1]);
			if (i < N)
			{
				LL wantW = i + 1, wantW_pos = originalPos[wantW][0];
				LL cntR_sumW1 = cntR[pos][i][0] + cntR[pos][j][1];
				LL cntR_sumW2 = cntR[wantW_pos][i][0] + cntR[wantW_pos][j][1];
				cost[i][j][0] = (wantW_pos - pos) - (cntR_sumW1 - cntR_sumW2);
			}
			if (j < N)
			{
				LL wantB = j + 1, wantB_pos = originalPos[wantB][1];
				LL cntR_sumB1 = cntR[pos][i][0] + cntR[pos][j][1];
				LL cntR_sumB2 = cntR[wantB_pos][i][0] + cntR[wantB_pos][j][1];
				cost[i][j][1] = (wantB_pos - pos) - (cntR_sumB1 - cntR_sumB2);
			}
		}
	}

	memo.resize(N + 1, std::vector<LL>(N + 1, -1));
	out << dp(0, 0) << std::endl;
}


Measured memory_bytes: 689280
def sieve(n):
	p=[True]*(n+1)
	p[0]=p[1]=False
	for i in range(2,int((n+1)*0.5)+1):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	prime=[]
	for i in range(n+1):
		if p[i]==True:
			prime.append(i)
	return prime

def solve(n):
	i=0
	while True:
		if n>prime[i]:
			a=prime[i]
		elif n==prime[i]:
			a=prime[i-1]
		else:
			b=prime[i]
			break
		i+=1
	print(a,b)

prime=sieve(50021)
while True:
	try:
		n=int(input())
		solve(n)
	except EOFError:
		break

Measured memory_bytes: 7792
#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;


int N;
int A[100010],B[100010],C[100010];
ll ans;
int main() {
	cin>>N;
	REP(i,0,N) cin>>A[i];
	REP(i,0,N) cin>>B[i];
	REP(i,0,N) cin>>C[i];
	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	REP(i,0,N) {
		ans += (lower_bound(A,A+N,B[i])-A) * (C+N-lower_bound(C,C+N,B[i]+1));
	}
	p(ans);
	return 0;
}

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

typedef long long ll;
const int mod = 1e9 + 7;

ll N, M;

vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue;
        res.push_back(n/i);
    }
    return res;
}

int main() {
    cin >> N >> M;
    vector<ll> target = divisors(M);
    sort(target.begin(), target.end());

    ll limit = M / N;
    ll ans = 1;
    rep(i, target.size()) {
        if (limit < target[i]) break;
        ans = target[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

void GotoSchool() 
{
  int n;
  cin >> n;
  vector<int> order(n);
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    order[a - 1] = i+1;
  }

  for (int i = 0; i < n; i++) cout << order[i] << " ";
  cout << endl;
  return ;
}


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

Measured memory_bytes: 1152
#include <iostream>
#include <string>

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int h, w;
    int a[30] = {};
    string str;
    cin >> h>>w;
    for(int i = 0; i < h; i++){
        cin >> str;
        for(int j = 0; j < w; j++){
            a[str[j] - 'a'] += 1;
        }
    }

    if(h%2==0 && w%2==0){
        for(int i = 0; i < 30; i++){
            if(a[i]%4 != 0){
                cout << "No\n";
                return 0;
            }
        }
    }else if((h%2==0 && w%2==1) || (h%2==1 && w%2==0)){
        int stock = 0;
        for(int i = 0; i < 30; i++){
            if(a[i]%2 != 0){
                cout << "No\n";
                return 0;
            }
            if((a[i]%4) == 2){
                stock++;
            }
        }
        if(h%2==0 && w%2==1){
            if(stock>h/2){
                cout << "No\n";
                return 0;
            }
        }else if(h%2==1 && w%2==0){
            if(stock>w/2){
                cout << "No\n";
                return 0;
            }
        }
    }else{
        int ki=0;
        int st = 0;
        for(int i = 0; i < 30; i++){
            if(a[i]%2 != 0){
                if(ki == 0) ki++;
                else{
                    cout << "No\n";
                    return 0;
                }
            }
            if((a[i]%4) == 2){
                st++;
            }
        }
        if(st > w/2 + h/2){
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
<?php
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));

$sum = 0;
$maxLeft = 0;
for($i = 0; $i < 5; $i++){
    $sum += ceil($a[$i] / 10 ) * 10;
    $maxLeft = max(ceil($a[$i] / 10 ) * 10 - $a[$i], $maxLeft);
}
echo $sum - $maxLeft;


Measured memory_bytes: 4856
#include<stdio.h>
#include<string.h>
int main(){
    int n1=0,n2=0,i;
    char *s=(char*)malloc(50000*sizeof(char));
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
        if(s[i]=='0') n1++;
        else n2++;
    }
    if(n1>=n2){
        printf("%d",2*n2);
    }
    else{
        printf("%d",2*n1);
    }
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

c = Counter(A)
c_c = defaultdict(int)
for key, value in c.items():
    c_c[key] = value * (value - 1) // 2
wa = 0
for key, value in c_c.items():
    wa += value

ruiseki = [0] * N

for i in range(N):
    new_value = c[A[i]] - 1    
    ruiseki[i] = wa - c_c[A[i]] + new_value * (new_value - 1) // 2
    # value * (value - 1) // 2
    # c_c[A[i]]
print(*ruiseki, sep= "\n")


Measured memory_bytes: 39332
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

use std::collections::BinaryHeap;

fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.cin();
    let w: usize = sc.cin();
    let inf: i64 = 100000000;
    let mut fs = vec![vec![inf; w]; h];
    let mut q = BinaryHeap::new();
    for i in 0..h {
        let cs: Vec<char> = sc.cin::<String>().chars().collect();
        for j in 0..w {
            if cs[j] == '#' {
                fs[i][j] = 0;
                q.push((0, i, j))
            }
        }
    }
    let mut ans = 0;
    while let Some((_, i, j)) = q.pop() {
        ans = max(ans, fs[i][j]);
        // trace!((i, j), fs[i][j]);
        if i > 0 && fs[i-1][j] > fs[i][j] + 1 {
            fs[i-1][j] = fs[i][j] + 1;
            q.push((-fs[i][j]-1, i - 1, j));
        }
        if i < h-1 && fs[i+1][j] > fs[i][j] + 1 {
            fs[i+1][j] = fs[i][j] + 1;
            q.push((-fs[i][j]-1, i + 1, j));
        }
        if j > 0 && fs[i][j-1] > fs[i][j] + 1 {
            fs[i][j-1] = fs[i][j] + 1;
            q.push((-fs[i][j]-1, i, j-1));
        }
        if j < w-1 && fs[i][j+1] > fs[i][j] + 1 {
            fs[i][j+1] = fs[i][j] + 1;
            q.push((-fs[i][j]-1, i, j+1));
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 36852
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int A = sc.nextInt();
      int B = sc.nextInt();
      // 6歳以上 12 歳以下の人はその半額で乗ることができ、
      // さらに5 歳以下の人は無料
      int ans = B;
      if (A <= 12) {
        ans = B / 2;
        if (A <= 5) {
          ans = 0;
        }
      }
 
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 21844
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a;cin>>a;
	if(a<1200) cout<<"ABC"<<endl;
	else if(a<2800) cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
static int C[20][3] = {{5,4,1},{6,0,2},{7,1,3},{8,2,4},{9,3,0},{0,11,10},{1,12,11},{2,13,12},{3,14,13},{4,10,14},{15,9,5},{16,5,6},{17,6,7},{18,7,8},{19,8,9},{10,16,19},{11,17,15},{12,18,16},{13,19,17},{14,15,18}};
static const int dx[3] = {0, -1, 1};
static const int dy[3] = {1, 0, 0};
static const int MAX = 205;
static const int SHIFT = 102;

class State{
public:
  int x, y, b, r, c;
  State(){}
  State(int x, int y, int b, int r):x(x), y(y), b(b), r(r){ c = 0;}
};

State getNext(State u, int r){
  int nx = dx[r];
  int ny = dy[r];
  if ( (u.x + u.y)%2  ){ nx *= (-1); ny *= (-1); }
  nx += u.x;
  ny += u.y;

  int bt[3], nt[3], nb, nr;

  rep(i, 3) bt[i] = C[u.b][i];
  rotate(bt, bt + u.r, bt + 3);
  nb = bt[r]; // next bottom
  rep(i, 3) nt[i] = C[nb][i];
  nr = -1; // next rotate
  rep(i, 3){
    if ( u.b == nt[r] ){ nr = i; break; }
    rotate(nt, nt+1, nt+3);
  }

  return State(nx, ny, nb, nr);
}

int bfs(int gx, int gy, int gb){
  bool vis[MAX][MAX][20][3];
  queue<State> Q;
  rep(i, MAX)rep(j, MAX) rep(k,20) rep(l,3) vis[i][j][k][l] = false;

  Q.push(State(SHIFT, SHIFT, 0, 0));
  vis[SHIFT][SHIFT][0][0] = true;
  State u, v;

  while(1){
    u = Q.front(); Q.pop();
    if( u.c > 150 ) return -1;
    if ( u.x == gx && u.y == gy && u.b == gb ) return u.c;
    rep(r, 3){
      v = getNext(u, r);
      if ( !vis[v.x][v.y][v.b][v.r] ){
	vis[v.x][v.y][v.b][v.r] = true;
	v.c = u.c + 1;
	Q.push(v);
      }
    }
  }
}

main(){
  int gx, gy, gb;
  while(1){
    cin >> gx >> gy >> gb;
    if ( gx == 0 && gy == 0 && gb == 0 ) break;
    gx += SHIFT;
    gy += SHIFT;
    cout << bfs(gx, gy, gb) << endl;
  }
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
template <typename T>
bool PN(T x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

const long long MOD = 1e9+7;

void solve()
{
  int n, m; cin >> n >> m;
  int road[51][51] = {};
  for(int i = 0; i < m; ++i){
    int a, b; cin >> a >> b;
    road[a][b]++;
    road[b][a]++;
  }
  for(int i = 1; i <= n; ++i){
    int cnt = 0;
    for(int j = 1; j <= n; ++j){
      cnt += road[i][j];
    }
    cout << cnt << endl;
  }
     
}

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

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

int main()
{
    int n,q;
    cin>>n>>q;
    char t[100050];
    int  s[100050]={0};
    scanf("%s",t);
    for(int i=1;i<sizeof(t);i++)
    {
        if(t[i]=='C'&&t[i-1]=='A')
            s[i]++;
            s[i]+=s[i-1];
    }
    for(int j=0; j<q; j++)
    {
        int l,r;
        cin>>l>>r;
        //if(t[l]=='C'&&t[l-1]=='A')
        cout<<s[r-1]-s[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    
    int n;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1];
    int c = 0, mx = 0;
    for(int i=0;i<n;i++)
    {
        if(a[i][0] == a[i][1])
            c++;
        else
            c = 0;
        mx = max(mx,c);
    }
    if(mx >= 3)
        cout<<"Yes";
    else
        cout<<"No";

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

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

using namespace std;

int main()
{
    long long X;
    cin >> X;
    long long num500,num5;
    num500 = X / 500;
    X = X % 500;
    num5 = X / 5;
    cout << 1000*num500 + 5*num5 << endl;
}

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

int main(){
  int N,A;
  int mod;
  
  cin >> N >> A;
  
  mod = N % 500;
  
  if ( A < mod){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
}  

Measured memory_bytes: 3556
import sys

sys.setrecursionlimit(20000)

n, m = map(int, input().split())
lst = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    lst[x].append(y)

def rec_dp(x):
    global dp
    if dp[x] != -1:
        return dp[x]
    else:
        ans = 0
        for y in lst[x]:
            ans = max(ans, rec_dp(y) + 1)
        dp[x] = ans
        return dp[x]
      
dp = [-1] * n
ans = 0
for _ in range(n):
    ans = max(ans, rec_dp(_))
print(ans)


Measured memory_bytes: 152908
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]

    def find2(x):
        if par2[x] < 0:
            return x
        else:
            par2[x] = find2(par2[x])
            return par2[x]
    def unite2(x, y):
        x = find2(x)
        y = find2(y)
        if x == y:
            return False
        else:
            if par2[x] > par2[y]:
                x, y = y, x
            par2[x] += par2[y]
            par2[y] = x
            return True
    def members2(x):
        root2 = find2(x)
        return [i for i in range(n) if find2(i) == root2]

    n, k, l = map(int, input().split())
    par = [-1] * n
    par2 = [-1] * n
    for _ in range(k):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        unite(a, b)
    for _ in range(l):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        unite2(c, d)

    root_pairs = defaultdict(int)
    for i in range(n):
        root_pairs[find(i), find2(i)] += 1

    for i in range(n):
        print(root_pairs[find(i), find2(i)], end=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 122412
#include <stdio.h>
#include <string.h>

int main(){
	char str[1000];
	char table[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int i,j;
	int length;
	
	scanf("%s", &str);
	
	length = (int)strlen(str);
	//printf("%d", length);
	
	for(i=0; i<length;i++){
		for(j=0;j<26;j++){
			if( table[j] == str[i] ) break;
		}
		
		//printf("%c", str[i]);
		str[i] = table[(26+(j-3))%26];
	}
	
	printf("%s\n", str);
	
	return 0;
}

Measured memory_bytes: 948
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const long double EPS = 1e-14;
const long double INF = 1e+20;
const long double PI = acos(-1);
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	if(c-b==b-a)printf("YES\n");
	else printf("NO\n");
}

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



int main (){
    int N, P; cin >> N >> P;
    vector<ll> dp(N+1);
    dp[0] = !P;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        if(a%2==0) dp[i+1] = 2 * dp[i];
        else dp[i+1] = pow(2, i);
    }
    
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

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

    int sum = 1;
    int count = 0;
    while(sum < B){
        sum += A-1;
        count++;
    }
    cout << count << endl;

    return 0;
}

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

public class Main {
	private static final Integer Z = Integer.valueOf(0);

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m;
		TreeSet<Integer> _1 = new TreeSet<Integer>();
		TreeSet<Integer> _2 = new TreeSet<Integer>();
		_1.add(Integer.valueOf(0));
		while ((n = in.nextInt()) > 0 && (m = in.nextInt()) > 0) {
			_1.clear();
			_1.add(Integer.valueOf(0));
			_2.clear();
			_2.add(Integer.valueOf(0));
			int floor = 0;
			for (int i = 0; i < n && floor < m; i++) {
				final int sc = in.nextInt();
				_1.add(Integer.valueOf(sc));
				for (Integer pt : _1) {
					int pti = pt.intValue();
					pti += sc;
					if (pti <= m)
						_2.add(Integer.valueOf(pti));
				}
			}
			for (Integer pt : _2) {
				int pti = pt.intValue();
				final int i = m - pti;
				int _2floor = _2.floor(Integer.valueOf(i)).intValue();
				floor = Math.max(floor, _2floor + pti);
				if (floor == m) {
					break;
				}
			}
			System.out.println(floor);

		}
	}
}

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

int main()  
{  
	int ans = 0;
	int r, g, b, n; cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int t = i*r + j*g;
			if (n >= t && (n-t) % b == 0)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;   
}  



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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    long K,A,B;
    scanf("%ld %ld %ld",&K,&A,&B);

    long ans;
    if((B-A)<=1){
        ans=1+K;
    }
    else{
        int count=K;
        //もしK回使ってもA枚(換金可能)まで増やせないなら
        if(K<=(A-1)){
            ans=1+K;
        }
        //換金できるまで増やせたら
        else{
            ans=A;//現在クッキーA枚
            //printf("%ld\n",ans);
            count=K-(A-1);//残りcount回使える
            while(count!=0){
                if(count==1){
                    ans++;//もしあと一回しかない(換金したままクッキーに戻せないなら、一回叩いた方がいい)
                    count--;
                }
                else{//そうじゃない(残り2回以上行動できる)なら換金
                    ans=ans-A+B;
                    //printf("%ld\n",ans);
                    count=count-2;
                }
            }
        }
    }

    printf("%ld\n",ans);

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll A, B, K;

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

  std::cin >> A >> B >> K;

  ll n = std::min(A, K);
  A -= n;
  K -= n;

  ll m = std::min(B, K);
  B -= m;

  std::cout << A << " " << B << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int a = Integer.parseInt(sc.next()) ;
        int b = Integer.parseInt(sc.next()) ;
        if(a*b%2==0) System.out.println("Even");
        else System.out.println("Odd");
    }
}


Measured memory_bytes: 22736
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<array<int, 3>> XL(N);
  rep(i, N) {
    int x, l;
    cin >> x;
    cin >> l;
    XL[i][0] = x;
    XL[i][1] = x - l;
    XL[i][2] = x + l;
  }
  sort(XL.begin(), XL.end());
  int sub = 0;
  for (int i = 1; i < N; ++i) {
    if (XL[i][1] < XL[i - 1][2]) {
      if (XL[i][2] > XL[i - 1][2]) {
        XL[i] = XL[i - 1];
      }
      sub++;
    }
  }
  int ans = N - sub;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<10;i++)
    {
        for(int j=1;j<10;j++)
        {
            if((i*j)==n)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    double d, t, s;
    cin >> d >> t >> s;
    double min = d / s;
    if (min <= t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3680
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int min = 0;
    int max = 100000;

    for(int i = 0;i < M;i++){
      int L = sc.nextInt();
      int R = sc.nextInt();
      
      if(min < L)min = L;
      if(max > R)max = R;
    }
    if(max - min >= 0)System.out.println(max - min+1); 
    else System.out.println("0"); 
  }
}

Measured memory_bytes: 64736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] n = br.readLine().split(" ");
		Integer[] num = new Integer[N];

		double sum = 0;

		for (int i = 0; i < N; i++) {
			n.toString().split(" ");
			num[i] = Integer.parseInt(n[i]);
			sum += num[i];
		}

		for (int i = 0; i < N; i++) {
		}

		double ave = Math.round(sum / N);

		int cost = 0;

		for (int i = 0; i < N; i++) {
			cost +=  Math.pow((num[i] - ave), 2);
		}
		System.out.println(cost);

	}

}


Measured memory_bytes: 8404
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int maxA = -1;
    int maxB = -1;
    for (int i = 0; i < N; i++) {
      int A = sc.nextInt();
      int B = sc.nextInt();
      if (A > maxA) {
        maxA = A;
        maxB = B;
      }
    }
    System.out.println(maxA+maxB);
  }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

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

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

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

Measured memory_bytes: 51020
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << "\n";
            return 0;
        }
    }
    cout << "Good" << "\n";
}

Measured memory_bytes: 256
X,N=map(int, input().split())
if N==0:
  print(X)
  exit()
else:
  P=list(map(int,input().split()))
  for i in range(101):
    if (X+i not in P) and (X-i not in P):
      print(min(X+i, X-i))
      exit()
    elif (X+i not in P):
      print(X+i)
      exit()
    elif (X-i not in P):
      print(X-i)
      exit()
    else:
      X+=0

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

int h, w, d, px[90005], py[90005], q, l[100005], r[100005], sum[90005];

int main() {
    cin >> h >> w >> d;
    rep(i, h)rep(j, w) {
        int a;
        cin >> a;
        px[a] = i;
        py[a] = j;
    }
    for (int i=d+1; i<=h*w; i++) {
        sum[i] = sum[i-d] + abs(px[i] - px[i-d]) + abs(py[i] - py[i-d]);
    }
    cin >> q;
    rep(i, q) cin >> l[i] >> r[i];
    rep(i, q) {
        cout << (sum[r[i]] - sum[l[i]]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2944