akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    string s;
    cin >> s;

    int l=0;
    int r = s.size() - 1;

    int ans = 0;

    while(l<r){
        if(s[l] == s[r]){
            l++;
            r--;
        }else if(s[l] == 'x'){
            l++;
            ans++;
        } else if (s[r] == 'x') {
            r--;
            ans++;
        }else{
            ans = -1;
            break;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3736
# 辞書順の差を答える
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a = -1
b = -1
count = 1
for x in itertools.permutations(range(1, N+1)):
    if P == list(x):
        a = count
    if Q == list(x):
        b = count
    count += 1

print(abs(a-b))


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

N = int(input())
x = [[0, 0] for _ in range(N)]
for i in range(N):
    x[i][1], x[i][0] = map(int, input().split())
x.sort()
t = 0
for xx in x:
    t += xx[1]
    if t > xx[0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 36252
using System;
using System.Text;
using System.Collections.Generic;

namespace Prog {
	struct Process {
		internal string name;
		internal int time;
	}

	class Prog {
		static void Main() {
			string[] a = Console.In.ReadLine().Split();
			int n = Int32.Parse(a[0]);
			int q = Int32.Parse(a[1]);
			
			const int maxsize = 500000;
			int size = (n < maxsize) ? n : maxsize;
			string[] text = Console.In.ReadToEnd().Split();
			var queue = new Queue<Process>(size);
			Process p;
			for (int i = 0; i < text.Length; ) {
				p.name = text[i++];
				p.time = Int32.Parse(text[i++]);
				if (i < text.Length && text[i] == "") i++;
				queue.Enqueue(p);
			}
			
			int elapsed = 0;
			var b = new StringBuilder(size * 20);
			while (queue.Count != 0) {
				do {
					var proc = queue.Dequeue();
					if (proc.time <= q) {
						elapsed += proc.time;
						b.Append(proc.name);
						b.Append(' ');
						b.Append(elapsed);
						b.AppendLine();
					} else {
						elapsed += q;
						proc.time -= q;
						queue.Enqueue(proc);
					}
				} while (queue.Count % maxsize != 0);
				Console.Out.Write(b.ToString());
				b.Length = 0;
			}
		}
	}
}

Measured memory_bytes: 21452
n,x = map(int, input().split())
a= list(map(int, input().split()))
 
cnt = 0
 
if a[0] > x:
	cnt+= (a[0]-x)
	a[0]-= (a[0]-x)
 
for i in range (n-1):
	if a[i]+a[i+1] > x:
		cnt+= (a[i]+a[i+1])-x
		a[i+1]-= (a[i]+a[i+1])-x
    
print(cnt)

Measured memory_bytes: 20044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long min = 0;
		for (int i = 0; i < N; i++) {
			long A = scn.nextLong();
			min = yuk(A, min);
		}
		System.out.println(min);
	}

	public static long yuk(long A, long min) {
		if (min == 0)
			return A;

		long ans;
		while (A % min != 0) {
			A %= min;
			long buf = A;
			A = min;
			min = buf;
		}
		return min;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> p[i], p[i]--;
    mp[p[i]] = i;
  }
  ll ans = 0;
  multiset<int> s = {-1, -1, n, n};
  for (int x = n - 1; x >= 0; x--) {
    int i = mp[x];
    s.insert(i);
    auto it = s.find(i);
    int l1 = *prev(it);
    int l2 = *prev(prev(it));
    int r1 = *next(it);
    int r2 = *next(next(it));
    ll c = (l1 - l2) * (r1 - i) + (r2 - r1) * (i - l1);
    ans += c * (x + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9984
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0)break;

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

		for (int i = 0; i < 10; i++) {
			if (v[i] != 0) {
				for (int j = 0; j < v[i]; j++) cout << "*";
				cout << endl;
			}
			else cout << "-" << endl;
		}
	}

	

	


	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
template<typename T> inline T& Min(T &x,const T &y) {return x>y?(x=y):x;}
const int maxn=2e3+10;
int n,k,q,a[maxn],ord[maxn];
int sid[maxn],cnt,size[maxn];
inline bool cmp(int x,int y) {
	return a[x]<a[y];
}
int check(int x) {
	int val=a[ord[x]];
	cnt=1;
	for (int i=1;i<=n;++i) size[i]=0,sid[i]=0;
	for (int i=1;i<=n;++i) {
		if (a[i]<val) ++cnt; else
		sid[i]=cnt,++size[cnt];
	}
	int now=x,lst;
	if (size[sid[ord[x]]]<k) return INT_MAX;
	for (int i=0;i<q;++i,++now) {
		while (now<=n && size[sid[ord[now]]]<k) ++now;
		if (now>n) return INT_MAX;
		int p=ord[now];
		lst=a[p];
		--size[sid[p]];
	}
	return lst-val;
}
int main() {
	n=read(),k=read(),q=read();
	for (int i=1;i<=n;++i) {
		a[i]=read();
		ord[i]=i;
	}
	sort(ord+1,ord+n+1,cmp);
	int ans=INT_MAX;
	for (int i=1;i<=n;++i) {
		int tmp=check(i);
		Min(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int m,n;

struct nodeInfo{
    int depth;
};

map<string,int> id;
vector<int> G[1010];
nodeInfo nif[1010];

int backNode(int cnode,int cnt){
    for(int i = 0; i < cnt; i++){
        for(int j = 0; j < G[cnode].size(); j++){
            // ツ親ツノツーツドツづ個づ卍つ、ツつェツ深ツつウツつェツ静ウツつ「
            if(nif[G[cnode][j]].depth<nif[cnode].depth){
                cnode=G[cnode][j];
                break;
            }
        }
    }
    return cnode;
}
bool isChild(int n1idx,int n2idx){
    return n2idx==backNode(n1idx,1);
}
bool isAncestor(int n1idx,int n2idx){
    int cnode=n2idx;
    while(1){
        if(cnode==n1idx)
            return true;
        // ツ親ツづ可つウツつゥツづ個づ堋づゥ
        if(cnode==0)
            return false;
        else
            cnode=backNode(cnode,1);
    }
}

int main(){
    while(cin>>n>>m&&!(n==0&&m==0)){
        id.clear();
        string str;
        getline(cin,str);
        for(int i = 0; i < 1010; i++)G[i].clear();
        int depth=-1;
        int cp=-1;
        for(int i = 0; i < n; i++){
            getline(cin,str);
            int cnt=0;
            for(int j = 0; ;j++){
                if(str[j]==' ')
                    continue;
                else{
                    str=str.substr(j);
                    cnt=j;
                    break;
                }
            }
            id[str]=i;
            // cntツづ個青板つセツつッツ親ツづ可姪淞づィツ、ツつサツつアツづ可ノツーツドツづーツ挿ツ禿シツつキツづゥ
            if(cp!=-1){
                if(depth<cnt){
                    G[cp].push_back(i);
                    G[i].push_back(cp);
                }
                else{
                    int back=backNode(cp,depth-cnt+1);
                    G[back].push_back(i);
                    G[i].push_back(back);
                }
            }
            cp=i;
            depth=cnt;
            nif[i].depth=depth;
        }
        for(int j = 0; j < m; j++){
            string name1,name2,tmp,order;
            cin>>name1>>tmp>>tmp>>order>>tmp>>name2;
            name2=name2.substr(0,name2.size()-1);
            int n1idx=id[name1];
            int n2idx=id[name2];
            bool match=false;
            if(order=="child")
                match=isChild(n1idx,n2idx);
            else if(order=="ancestor")
                match=isAncestor(n1idx,n2idx);
            else if(order=="sibling"){
                int cnode=backNode(n1idx,1);
                for(int i = 0; i < G[cnode].size(); i++){
                    int to=G[cnode][i];
                    match=(nif[n1idx].depth==nif[to].depth&&to==n2idx);
                    if(match)
                        break;
                }
            }
            else if(order=="parent")
                match=isChild(n2idx,n1idx);
            else
                match=isAncestor(n2idx,n1idx);
            if(match)
                cout<<"True"<<endl;
            else
                cout<<"False"<<endl;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 1000000007;
const int BASE = 27;
const int oo = 1e9;
const double EPS = 1e-9;
const int MX = 2000 + 1;

int n , k, cnt, ans;
vector<pii> E;
vector<int> g[MX];


void dfs(int u , int p , int dist) {
  if (dist > k / 2)cnt++;
  for (auto v : g[u])
    if (v != p)
      dfs(v, u, dist + 1);
}

int main() {
  cin >> n >> k;
  for (int a, b, i = 0; i < n - 1; ++i) {
    scanf("%d%d", &a, &b);
    g[a].pb(b);
    g[b].pb(a);
    E.pb(mp(a, b));
  }
  ans = n;
  for (int it = 0; it < 2; ++it) {
    if (k % 2 == 0) {
      for (int i = 1; i <= n ; ++i) {
        cnt = 0;
        dfs(i, -1, 0);
        ans = min(ans, cnt);
      }
    }
    if (k % 2 == 1) {
      for (auto v : E) {
        cnt = 0;
        dfs(v.x, v.y, 0);
        dfs(v.y, v.x, 0);
        ans = min(ans, cnt);
      }
    }
    k--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val F = LongArray(N + 1)
    for (i in 1..N) {
        for (j in i..N step i) F[j]++
    }
    val ans = (1..N).map { it * F[it] }.sum()
    println(ans)
}

Measured memory_bytes: 593656
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
struct doll{
    int r;
    int h;
};
vector<doll> dolls;
int hen[1010][1010];
int dollnum;
int dp[210];

int solve(int n)
{
    if(dp[n]!= -1){ return dp[n];}
    int ans = 0;
    int temp=0;
    for(int i=0;i<dollnum;i++)
    {
        if(hen[n][i]==1) {temp = solve(i)+1; ans = max(temp,ans);}
    }
    dp[n] = ans;
    return ans;
}
int main()
{
    int n,m;
    while(cin>>n)
    {
        memset(dp,-1,sizeof(dp));
        dolls.clear();
        memset(hen,0,sizeof(hen));
        if(n==0)break;
        doll temp;
        temp.h=0;temp.r=0;
        dolls.push_back(temp);
        for(int i=0;i<n;i++)
        {
            cin>>temp.h>>temp.r;
            dolls.push_back(temp);
        }
        cin>>m;
        for(int i=0;i<m;i++)
        {
            cin>>temp.h>>temp.r;
            dolls.push_back(temp);
        }
        dollnum = dolls.size();
        for(int i=0;i<dollnum-1;i++)
        {
            for(int j=0;j<dollnum;j++)
            {
                if(dolls[i].h<dolls[j].h && dolls[i].r<dolls[j].r){hen[i][j] =1;}
                if(dolls[i].h>dolls[j].h && dolls[i].r>dolls[j].r){hen[j][i] =1;}
            }
        }
        cout << solve(0)<< endl;
    }
    
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int ti[200010],ri[200010],ans[200010],a[200010],n,t1,t2;
long long int k;
int main(){
	int i,j,l;
	cin>>n>>k;
	k++;
	for(i=1;i<=n;i++)cin>>a[i];
	ti[1]=1,ans[1]=1,ri[1]=1;
	for(i=2;i<=n;i++){
		int aa=ans[i-1];
		ans[i]=a[aa];
		aa=ans[i];
		if(i==k){
			cout<<ans[i];return 0;
		}
		if(ri[aa]){
			t1=ti[aa],t2=i;break;
		}
		ti[ans[i]]=i;ri[ans[i]]++;
	}
	k-=t1;k++;k%=(t2-t1);
	if(!k)k=t2-t1;
	cout<<ans[t1-1+k];
}

Measured memory_bytes: 6604
#include<bits/stdc++.h>
using namespace std;
class mairala
{
public:
    void solve()
    {
        long long a, b, c, d, arr[4];
        cin>>a>>b>>c>>d;
        arr[0] = a * c;
        arr[1] = a * d;
        arr[2] = b * c;
        arr[3] = b * d;
        sort(arr, arr + 4);
        cout<<arr[3]<<endl;
    }
};

int main(void)
{
    mairala m;
    m.solve();
}



Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] science = new int[4];
		int minsc = 100;
		int sumsc = 0;
		for(int i = 0; i < 4; i++) {
			science[i] = sc.nextInt();
			minsc = Math.min(minsc, science[i]);
			sumsc += science[i];
		}
		sumsc -= minsc;
		
		int sumso = sc.nextInt();
		int x = sc.nextInt();
		if(sumso < x) {
			sumso = x;
		}
		
		System.out.println(sumsc + sumso);
	}
}


Measured memory_bytes: 26120
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

template <typename T = int>
struct Edge {
  int to;
  T cost;
  Edge(int to, T cost) : to(to), cost(cost) {}
};

template <typename T = int>
class Graph {
  public:
    int n;
    vector<vector<Edge<T>>> graph;

    Graph(int n) {
      this->n = n;
      this->graph.assign(n, vector<Edge<T>>());
    }

    void addEdge(int from, int to, T cost) {
      this->graph[from].push_back(Edge<T>(to, cost));
    }
};

int main() {
  int n, m;
  cin >> n >> m;
  Graph<int> g = Graph<int>(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    g.addEdge(a-1, b-1, 1);
    g.addEdge(b-1, a-1, 1);
  }

  rep(i, n) {
    cout << g.graph[i].size() << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String InStr = scan.nextLine();
		String[] AryStr = InStr.split(" ");

		int A;
		int B;

		A = Integer.parseInt(AryStr[0]);
		B = Integer.parseInt(AryStr[1]);

		if (A < B) {
			A = B--;
        } else if (A > B) {
            B = A--;
        }
                   
        System.out.println(A + B);
	}
}


Measured memory_bytes: 23124
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	im := IntMap{}

	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		im.increment(a)
	}

	aa := make([]int, 0)
	for a, c := range im {
		if c < 2 {
			continue
		}
		aa = append(aa, a)
	}
	var ans int64
	ans = 0
	l := len(aa)
	if l > 0 {
		sort.Ints(aa)
		if im.get(aa[l-1]) >= 4 {
			ans = int64(aa[l-1]) * int64(aa[l-1])
		} else if l > 1 {
			aa = aa[l-2:]
			ans = int64(aa[0]) * int64(aa[1])
		}
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define m 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,i,j,temp;
	cin>>n>>k;
	vector<int>h(n);
	vector<int>dp(n);
	for(i=0;i<n;++i)
		cin>>h[i];
	dp[0]=0;
  	for(i=1;i<n;++i)
  	{
  		dp[i]=INT_MAX;
  		for(j=1;j<=k && i-j>=0;++j)
  		{
  			if(dp[i] > dp[i-j]+abs(h[i-j]-h[i]))
  				dp[i]=dp[i-j]+abs(h[i-j]-h[i]);
  		}
  	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int sum=a+b+c;
    if(sum>=22)
    {
        puts("bust");
    }
    else puts("win");
    return 0;
}
































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

#define ll long long int
int main()
{
	ll n;
	cin>>n;
	string a[n+1];
	map<string,ll>m;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	ll b[n+1]={0};
	for(ll i=0;i<n;i++)
	{
		if(m[a[i]]>=1)
		{
			b[i]=m[a[i]];
			m[a[i]]=-1;
		}
	}
	
	ll c[n+1];
	for(ll i=0;i<n;i++)
	c[i]=b[i];
	
    sort(b,b+n);
    if(b[n-1]!=b[n-2])
    {
    	for(ll i=0;i<n;i++)
    	{
    		if(b[n-1]==c[i])
    		cout<<a[i];
    	}
    }
    else
    {
    	ll max=b[n-1];
    	vector<string>v;
    	for(ll i=0;i<n;i++)
    	{
    		if(max==c[i])
    		v.push_back(a[i]);
    	}
    	sort(v.begin(),v.end());
    	for(ll i=0;i<v.size();i++)
    	cout<<v[i]<<"\n";
    }
}

Measured memory_bytes: 31604
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
	set<string>s;
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		string a, b; cin >> a >> b;
		if (a[0] == 'i') 
			s.insert(b);
		else{
			if (s.find(b) != s.end())cout << "yes\n";
			else cout << "no\n";
		}
	}
}

Measured memory_bytes: 32132
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2 && b%2 && c%2){
    cout<<min({a*b,b*c,c*a})<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int i, j, k, n, A[N][N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d%d", &A[i][0], &A[i][1]);
    for(j=0; j<A[i][1]; j++){
      scanf("%d", &A[i][j+2]);
    }
  }

  for(i=0; i<n; i++){
    k=2;
    for(j=0; j<n; j++){
      if(A[i][k] == j+1){
	printf("1");
	k++;
      }
      else printf("0");
      if(j == n-1)printf("\n");
      else printf(" ");
    }
  }

  return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    string str;
    while (cin>>str, str != "0") {
        int a = 0;
        int b = 0;
        str.erase(str.begin());
        for (char s : str) {
            if (s == 'A') a++;
            if (s == 'B') b++;
        }
        if (a > b) a++;
        else b++;
        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3044
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        long x = in.nextLong();
        long ans = (x/500)*1000;
        x%=500;
        ans += (x/5)*5;
        out.println(ans);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long m, dig, sum;
long d[200005];
long c[200005];

int main(){
    scanf("%ld", &m);
    for(int i = 0; i < m; i++){
        scanf("%ld%ld", d+i, c+i);
        dig += c[i];
        sum += d[i] * c[i];
    }
    printf("%ld\n", dig - 1 + (sum - 1) / 9);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int A,B;
    cin >> A >> B;
    A = (A+11)%13;
    B = (B+11)%13;
    if(A>B)cout << "Alice" << endl;
    else if(A<B)cout << "Bob" << endl;
    else cout << "Draw" << endl;
}


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

int main() {
   int n;
   cin >> n;
   set<string>s;
   rep(i,n){
		string t;  
    cin>>t;
		s.insert(t);
	}
	 cout <<(s.size()==3 ? "Three" : "Four")<< endl;
}

Measured memory_bytes: 256
object Main extends App {
  val abck =  scala.io.StdIn.readLine()
  val abckArray =  abck.split(" ").map(_.toInt).toSeq
  val a = abckArray(0)
  val b = abckArray(1)
  val c = abckArray(2)
  val k = abckArray(3)

  var temp = k
  var result = 0

  if (temp - a <= 0) {
    println(temp)
  } else {
    result = a
    temp = temp - a
    if (temp - b <= 0) {
      println(result)
    } else {
      temp = temp - b
      println(result - temp)
    }
  }
}

Measured memory_bytes: 54748
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int n;
    cin >> n;

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

    ll ans = 0;
    while (true) {
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += a[i] / n;
            a[i] = a[i] % n - a[i] / n;
        }

        ans += cnt;

        bool flag = true;
        for (int i = 0; i < n; i++) {
            a[i] += cnt;
            if (a[i] >= n) flag = false;
        }

        if (flag) break;
    }

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

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    s += 'R';

    int pos = 0;
    bool fr = true;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] != s[i + 1]) {
            if (fr) {
                for (int j = pos; j <= i; j++) {
                    if ((i - j) % 2 == 0) cnt[i]++;
                    else cnt[i + 1]++;
                }
            } else {
                for (int j = pos; j <= i; j++) {
                    if ((j - pos) % 2 == 0) cnt[pos]++;
                    else cnt[pos - 1]++;
                }
            }
            fr = !fr;
            pos = i + 1;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << cnt[i] << " \n"[i + 1 == n];
    }
    return 0;
}


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

int main(){
  int N,K;
  int ans=1;
  cin >> N >> K;
  
  for(int i=0;i<N;i++){
    if(ans<K) ans*=2;
    else ans+=K;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h, a;
  cin >> h >> a;

  cout << (h + a - 1) / a << en;

  return 0;
}

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

int main(){
    string s; cin>>s; int n=0;
    vector<int> list(26);
    for(int i=0;i<s.size();i++) list.at(s.at(i)-'a')++;
    for(int i=0;i<26;i++){
        if(list.at(i)>1){
            n++;
            break;
        }
    }
    if(n==0) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL << 60)

typedef long long ll;
struct edge { ll to, cost; };
typedef pair<ll, ll> P;   // firstは最短距離、secondは頂点の番号

const ll MAX_V = 110000, MAX_E = 510000;

ll V, E;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
	// greater<P>を指定することでfirstが小さい順に取り出せるようにする
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	// 始点 s の距離は０
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		// PQ内にあるものの中で最も距離の短いものを取り出す
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		// 頂点 v と隣接している頂点を調べる
		for (ll i = 0; i<G[v].size(); i++) {
			edge e = G[v][i];
			// この時点での頂点 e.to への最短距離より頂点 v を経由して頂点 e.to に行く経路の方が短いとき最短距離を更新する
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	ll r;
	cin >> V >> E >> r;
	for (ll i = 0; i < E; i++) {
		ll s, t, cost;
		cin >> s >> t >> cost;
		G[s].push_back(edge{ t, cost });
	}

	dijkstra(r);
	
	for (ll i = 0; i < V; i++) {
		if(d[i]==INF) cout << "INF" << endl;
		else cout << d[i] << endl;
	}
}



Measured memory_bytes: 19756
N = int(input())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))

#  iの階乗
x = [1] * (N + 1)

for i in range(1, N + 1):
    x[i] = x[i - 1] * i
    

res1 = 1
res2 = 1

s1 = [i for i in range(1, N + 1)]
s2 = [i for i in range(1, N + 1)]

for p in P:
    for i in range(len(s1)):
        if p == s1[i]:
            s1.pop(i)
            t = i - 1
            break

    res1 += t * x[len(s1)]

for q in Q:
    for i in range(len(s2)):
        if q == s2[i]:
            s2.pop(i)
            t = i - 1
            break

    res2 += t * x[len(s2)]

print(abs(res1 - res2))

Measured memory_bytes: 9172
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

ll n,P,f[105][105];

int main() {
	n=rd(),P=rd(),f[0][0]=1;
	For (i,1,n) {
		int x=rd()%2;
		f[i][0]=f[i-1][0]+f[i-1][x];
		f[i][1]=f[i-1][1]+f[i-1][x^1];
	}
	printf("%lld\n",f[n][P]);
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long long s(long long left,long long right,vector<long long> &k,long long key){
  long long mid=(left+right)/2;
  if(mid==left)return left;
  if(k[mid]<=key)return s(mid,right,k,key);
  else return s(left,mid,k,key);
}
int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<long long> c(a+2);
  vector<long long> d(b+2);
  c[a+1]=2000000000000000;
  d[b+1]=c[a+1];
  c[0]=-100000000000000;
  d[0]=c[0];
  rep(i,a){
    cin >> c[i+1];
  }
  rep(i,b)cin >> d[i+1];
  rep(i,q){
    long long z;
    cin >> z;
    int y=s(0,a+1,c,z);
    int p=y+1;
    int m=s(0,b+1,d,z);
    int w=m+1;
    //cout << y << " " << m  << " " << c[y] << " " << c[p] << " " << d[m] << " " << d[w] << endl;
    long long ans=max(c[p]-z,d[w]-z);
    ans=min(ans,max(z-c[y],z-d[m]));
    //cout << ans << endl;
    ans=min(ans,2*c[p]-z-d[m]);
    ans=min(ans,2*d[w]-z-c[y]);
    //cout << ans << endl;
    ans=min(ans,z+d[w]-2*c[y]);
    ans=min(ans,z+c[p]-2*d[m]);
    cout << ans << endl;
  }
  
}


Measured memory_bytes: 2944
H,W,K = map(int,input().split(' '))
default_line = [input() for i in range(H)]
H_list,W_list = ['0','1'],['0','1']
for i in range(H-1):
	H_list = [i+j for i in ['0','1'] for j in H_list]
for i in range(W-1):
	W_list = [i+j for i in ['0','1'] for j in W_list]
  
def draw_red_H(s,line__):
  for l in range(len(s)):
    if s[l] == '1' : line__[l] = ','*W
  return line__

def draw_red_W(s,line_):
  for k in range(len(s)):
    if s[k] == '1':
      for j in range(H):
        line_[j] = line_[j][:k]+','+line_[j][k+1:] 
  return line_
count = 0
for i in W_list:
  line = default_line.copy()
  line = (draw_red_W(i,line))
  for ii in H_list:
    lines = line.copy()
    lines = (draw_red_H(ii,lines))
    if sum([iii.count('#') for iii in lines])==K:count += 1
print(count)

Measured memory_bytes: 9224
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) cin >> B[i];
    for (int x = 0; x <= N - M; ++x)
    {
        for (int y = 0; y <= N - M; ++y)
        {
            bool areSame = true;
            for (int i = 0; i < M; ++i)
            {
                for (int j = 0; j < M; ++j)
                {
                    if (A[x + i][y + j] != B[i][j])
                    {
                        areSame = false;
                        break;
                    }
                }
                if (!areSame) break;
            }
            if (areSame)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string a,b;
	int ans=0;
	cin>>a;
	cin>>b;
	for(int i=0;i<3;i++)
	{
		if(a[i]==b[i])
			ans+=1;
	}
	cout<<ans<<endl;
	return 0;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    sort(all(a), greater<int>());
    ans += a[0];
    int j = 1;
    for(int i = 1; j < n - 1; i++) {
        ans += a[i];
        j++;
        if(j >= n - 1) break;
        ans += a[i];
        j++;
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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;
}


Measured memory_bytes: 4048
#coding:utf-8
import copy

a1 = input().split()
a2 = input().split()
a3 = input().split()
n = int(input())
binhot = [0,0,0,0,0,0,0,0,0]
memo = [0,0,0,0,0,0,0,0,0]
ans = "No"

for i in range(n):
  b = str(input())
  count = 0
  for f in a1:
    if(b == f):
      binhot[count] = 1
    count += 1
  for f in a2:
    if(b == f):
      binhot[count] = 1
    count += 1
  for f in a3:
    if(b == f):
      binhot[count] = 1
    count += 1

saver = binhot
teacher = [[1,1,1,0,0,0,0,0,0],
           [0,0,0,1,1,1,0,0,0],
           [0,0,0,0,0,0,1,1,1],
           [1,0,0,1,0,0,1,0,0],
           [0,1,0,0,1,0,0,1,0],
           [0,0,1,0,0,1,0,0,1],
           [1,0,0,0,1,0,0,0,1],
           [0,0,1,0,1,0,1,0,0]]

for i in teacher:
  memo = copy.deepcopy(saver)
  for j in range(9):
    memo[j] = i[j] * memo[j]
  if(memo == i):
    ans = "Yes"

print("{}".format(ans))

Measured memory_bytes: 3444
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int gcd(int x,int y)
 {
   return y==0 ? x: gcd(y,x%y);    
 }
 
 int main()
 {
   int x,y;
   cin>>x>>y;
   int result=gcd(x,y);
   cout<<result<<endl;
   //while(1);
   return 0;
 }
 
 
 

Measured memory_bytes: 3088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        m: i32,
    }
    let mut ans = None;
    for i in 0..n+1 {
        for j in 0..n-i+1 {
            let k: i32 = n - i - j;
            if (i*10000 + j*5000 + k*1000) == m {
                ans = Some((i,j,k));
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);
}


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

int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	int check=k%2;
	if(abs(a-b)>1000000000000000000){
		cout<<"Unfair"<<endl;
		return 0;
	}
	a-=b;
	for(int i=0; i<check; i++)a*=-1;
	cout<<a<<endl;;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C >> K;
    if (K > A) {
        K -= A;
        ans += 1 * A;
        if (K > B) {
            K -= B;
            ans += 0 * B;
            ans -= K;
        } else {
            ans += 0 * B;
        }
    } else {
        ans += K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int i,n,m;
  cin>>n>>m;
  vector <long long int> s1(n);
  //vector <string> s2(m);
  //int s1[n];
  long long int ac=0,waa=0;
  vector <long long int> wa(n);
  for(i=0;i<n;i++){
    s1[i]=0;
  }
  long long int p=0;
  string s;
  long long int j=0;
  for(i=0;i<m;i++){
    cin>>p>>s;
    if(s=="WA"&&s1[p-1]==0){
      wa[p-1]++;
      //cout<<wa;
    }
    else if(s=="AC"&&s1[p-1]==0){
      ac++;
      waa+=wa[p-1];
     // cout<<endl<<s[p]<<p<<endl;
      s1[p-1]++;
    }
  }
  cout<<ac<<endl<<waa<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    double a = sc.nextDouble();
	    solve(a);
	}
    }

    void solve(double a){
	double s = a;
	double prev = a;
	for(int i=2; i<11; i++){
	    if(i%2==0){
		s += prev*2;
		prev = prev*2;
	    }
	    else {
		s += prev/3;
		prev = prev/3;
	    }
	}
	System.out.println(s);
    }
}

Measured memory_bytes: 19388
import functools

n = int(input())
l = list(map(lambda x: int(x), input().split()))
    
longest = functools.reduce(lambda x,y: x if x > y else y, l)
sum = functools.reduce(lambda x,y: x + y, l) - longest

if longest >= sum:
	print('No')
else:
	print('Yes')



Measured memory_bytes: 3572
judge :: Integral a => a -> a -> String -> [Bool]
judge a b = f 0 0
    where
        f _ _ [] = []
        f c d (x : xs)
            | x == 'a' && c < a + b = True : f (c + 1) d xs
            | x == 'b' && c < a + b && d < b = True : f (c + 1) (d + 1) xs
            | otherwise = False : f c d xs

main :: IO ()
main = do
    [_, a, b] <- fmap read . words <$> getLine :: IO [Int]
    xs <- getLine
    putStr . unlines . fmap (\x -> if x then "Yes" else "No") $ judge a b xs


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

int main(){
    int r,D,x2000; cin>>r>>D>>x2000;
    int x[10];
    x[0]=r*x2000-D;
    REP(i,9){
      x[i+1]=r*x[i]-D;
    }
    REP(i,10){
      cout<<x[i]<<endl;
    }
}


Measured memory_bytes: 256
function Main(input) {
	var str0 = input.charAt(0);
  	var str1 = input.charAt(1);
  	var str2 = input.charAt(2);
  	var str3 = input.charAt(3);
  	if (str0 == str1 && str0 == str2 && str0 == str3){
      console.log("No");
    } else if (str0 == str1 && str2 == str3) {
          console.log("Yes");
    } else if (str0 == str2 && str1 == str3){
          console.log("Yes");
   	} else if (str0 == str3 && str1 == str2){
	  console.log("Yes");
    } else {
      console.log("No");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif
int N;
char alpha[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

void dfs(int n, int kind, string s) {
  if (n == N) {
    cout << s << endl;
    return;
  }
  rep(i, kind)
    dfs(n+1, kind, s + alpha[i]);
  dfs(n+1, kind+1, s + alpha[kind]);
}
int main() {
  cin >> N;

  dfs(1, 1, "a");

  return 0;
}


Measured memory_bytes: 1536
"use strict"
function main(arg) {
    arg = arg.trim().split("\n")[0].split(" ").map(Number)
    var A = arg[0]
    var P = arg[1]
    var k = A * 3 + P
    console.log(Math.floor(k / 2))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22204