akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		boolean error = false;
		for (int i = 0; i < m; i++) {
			int s = scan.nextInt();
			int c = scan.nextInt();
			if (map.containsKey(s) && map.get(s) != c) {
				error = true;
				continue;
			}
			map.put(s, c);
		}

		int number = -1;
		for (int i = 0; i <= 999; i++) {
			if (String.valueOf(i).length() == n && check(n, i, map)) {
				number = i;
				break;
			}
		}

		System.out.println(!error ? number : -1);
		scan.close();
	}

	private static boolean check(int n, int number, HashMap<Integer, Integer> map) {
		for (int key : map.keySet()) {
			int dn1 = (int)Math.pow(10, n - key + 1);
			int dn2 = (int)Math.pow(10, n - key);
			int dn3 = (number % dn1) / dn2;
			if (dn3 != map.get(key)) {
				return false;
			}
		}

		return true;
	}
}

Measured memory_bytes: 23124
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI
#include <numeric>	//gcd

using namespace std;

int main() {

	int a, b;
	cin >> a >> b;

	if (a <= b * 2) {
		cout << 0 << endl;
		return 0;
	}

	cout << a - (b * 2) << endl;

	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "OK" << endl;
  exit(0);
}

void no() {
  cout << "NG" << endl;
  exit(0);
}

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if (i % k == 0) {
      yes();
    }
  }
  no();
}

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

int bubbleSort(int A[], int n)
{
    bool flat = true;
    int j = 0,
        sw = 0;

    while (flat)
    {
        flat = false;

        for (int i = n-1; i > j; --i)
        {
            if (A[i-1] > A[i])
            {
                flat = true;
                swap(A[i-1], A[i]);
                ++sw;
            }
        }

        ++j;
    }

    return sw;
}

int main()
{
    int A[100], n, sw;

    cin >> n;

    for (int i = 0; i != n; ++i)
    {
        cin >> A[i];
    }

    sw = bubbleSort(A, n);

    for (int i = 0; i != n; ++i)
    {
        if (i > 0)
        {
            cout << " ";
        }

        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;

    return 0;
}


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

bool isprime(int p){
	if(p==1) return false;
	for(int i=2;i<p;i++)
		if(p%i==0) return false;
	return true;
}

int main(){
	int n; cin >> n;
	for(int i=7;i<=55555;i+=5){
		if(isprime(i)){
			if(i!=7) cout << " ";
			cout << i;
			n--;
		}
		if(n==0) break;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
op_cnt = len(S) - 1

ans = 0

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    
    formula = ""
    for p_n, p_o in zip(S, op + [""]):
        if p_o == "+":
            formula += (p_n + p_o)
        else:
            formula += p_n
    ans += eval(formula)

print(ans)

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n, t = 0, cnt = 0;
    while (cin >> n, n)
    {
        cnt = 0;

        reps(i, 1, n + 1)
        {
            t = 0;
            reps(j, i, (n + 1) / 2 + 1)
            {
                t += j;
                if (t == n && j != i)
                {
                    cnt++;
                }
                if (t > n)
                {
                    break;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



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

int const maxn = 1e5 + 10;

int N, a[maxn], b[maxn];

int main()
{
  scanf("%d", &N);

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

  bool vis[maxn] = {};
  function<void(int, int)> dfs = [&](int cur, int mn) {
    if(cur == N+1) {
      for(int i = 1; i <= N; i++) printf("%d ", b[i]);
      putchar('\n');
      exit(0);
    }

    if(cur > 1 && !vis[a[b[cur-1]]] && deg[a[b[cur-1]]] == N-cur) return;

    while(vis[mn]) mn++;

    for(int v = mn; v <= N; v++) {
      if(vis[v] || (cur > 1 && v == a[b[cur-1]])) continue;
      b[cur] = v;
      vis[v] = true;
      deg[a[v]]--;
      dfs(cur+1, v==mn? mn+1 : mn);
      deg[a[v]]++;
      vis[v] = false;
    }
  };

  dfs(1, 1);
  puts("-1");

  return 0;
}


Measured memory_bytes: 9856
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	sort.Ints(l)

	ans := 0
	for i := 0; i < n-2; i++ {
		a := l[i]
		for j := i + 1; j < n-1; j++ {
			b := l[j]
			t := l[j+1:]
			left, right := 0, len(t)-1
			mid := -1
			for left <= right {
				mid = (left + right) / 2
				if t[mid] < a+b {
					left = mid + 1
				} else {
					right = mid - 1
				}
			}
			ans += left
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
N = int(input())
st, sx, sy = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - st
    dr = abs(x - sx) + abs(y - sy)
    if not (dt >= dr and (dt - dr) % 2 == 0):
        print('No')
        break
else:
    print('Yes')

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

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

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

    sort(d.begin(),d.end());

    int count = 1;
    for (int i = 0; i<N; i++) {
        int ii = i+1;
        if (ii<N && d.at(i) != d.at(ii)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import math
import heapq
from bisect import bisect_right, bisect_left
from collections import defaultdict, Counter
import itertools
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = []
    for i in range(n):
        l.append([a[i], 1+i])
    l = sorted(l, key=lambda x: x[0])
    ansl = []
    for i in range(n):
        ansl.append(l[i][1])
    print(*ansl)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23996
#include <stdio.h>

int main(void) {
    int x, i, a, b, c;
    
    scanf("%d", &x);
    
    for(i=0;i<x;i++){
    	scanf("%d %d %d", &a, &b, &c);
    	
    	if((a*a==b*b+c*c || b*b==a*a+c*c) || c*c==a*a+b*b)
    	printf("YES\n");
    	
    	else printf("NO\n");
    }
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	string s;
	int sum = 0, sum2 = 0;

	cin >> s;

	if (s.length() == 1) {
		cout << stoi(s)  << endl;
	}
	else {

		for (int i = 0; i < s.length() ; i++) {
			sum += (int)s[i] - '0';
		}

		for (int i = s.length() - 1; i >= 1;  i--) {
			sum2 += 9;
		}

		sum2 += ((int)s[0] - '0' - 1);

		if (sum2 < sum) {
			cout << sum << endl;
		}
		else {
			cout << sum2 << endl;
		}
	}
	

	  
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	tmp = Number(input[0])
  	let list = {}
  	for(let i = 1; i <= tmp; i++) {
      if(!list[input[i]]) list[input[i]] = 0
      else list[input[i]] += 1
    }
	console.log(Object.keys(list).length)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 83512
#include <stdio.h>

int main () {
	int A, B, C, D, E, temp;
	scanf ("%d %d", &A, &B);

		C = A + B;
		D = A - B;
		E = A * B;

	if (C < D) {
	temp = C;
	C = D;}
	
	if (C < E) {
	C = E;
	}
	printf ("%d", C); 
	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	bool ans = true;
	for (auto ch : s)
		if (s[0] != ch) ans = false;

	if (ans == true)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >>n;
  cout << (n+1)/2 << endl;
}

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

int main()
{
int mx=848954,cnt=0;
int n,m,a,b; cin>>n>>m;
while(n--)
{
    cin>>a>>b;
    if(b<=m)mx=min(mx,a);

}
if(mx!=848954)cout<<mx<<endl;
else cout<<"TLE"<<endl;


    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e6+3;
typedef long long ll;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define per(i,a,b) for(int i=(a);i<b;i++)
#define rep(i,a,b) for(int i=(a);i<=b;i++)
#define pi acos(-1.0)
#define mid ((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int a[maxn];
int main()
{
	int n;
	read(n);
	int ans=0;
	rep(i,1,n)read(a[i]);
	sort(a+1,a+1+n);
	int x=a[n/2],y=a[n/2+1];
	ans=y-x;
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<vector>
#include<cmath>

using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



int main()
{
	int i,j,k,l,m,n,sum,flag,N,M,X,H, W;
	char S[4];
	k = 0;
	cin >> S;
	for (i = 0; i <= 2; i++) {
		if (S[i] == 'o') {
			k++;
		}
	}
	cout << 700 + k * 100 << endl;

	flag = sum = 0;
	
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {


	int i, g, s;
	int n, y;
	int x = 0;


	scanf("%d%d", &n, &y);

	
	for (i = n; i >= 0; i--) {

	
		if (y == 10000 * i) {
			if (i == n) {
				printf("%d 0 0 ", i);
				x = 1;

				goto out;

			}
		}
		if (10000 * i < y) {

			for (g = n - i; g >= 0; g--) {




				if (10000 * i + 5000 * g == y && i + g == n) {


					printf("%d %d 0 ", i, g);
					x = 1;

					goto out;
				}
				if (10000 * i + 5000 * g < y) {

					for (s = n - g - i; s >= 0; s--) {


						if (s + g + i == n && 1000 * s + 5000 * g + 10000 * i == y) {
							printf("%d %d %d", i, g, s);
							x = 1;

							goto out;
						}
					}

				}

			}
		}
	}

out:
	if (x == 0) {
		printf("-1 -1 -1");

	}


}




Measured memory_bytes: 128
while 1:
  h,w=map(int,raw_input().split())
  if h==w==0: break
  A=[list(raw_input()) for _ in range(h)]
  x,y=0,0
  while 1:
    s=A[y][x]
    A[y][x]='x'
    if s==">": x+=1
    elif s=="<": x-=1
    elif s=="v": y+=1
    elif s=="^": y-=1
    elif s==".": B=[x,y]; break
    else: B=["LOOP"]; break
  for e in B: print e,
  print

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

using namespace std;


int main()
{
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0;i<n;i++){
        cin >> ar[i];
    }
    sort(ar,ar+n);
    int t = 0;
    for(int i = 0;i<n-2;i++){
        for(int j = i+1;j<n-1;j++){
            for(int k = j+1;k<n;k++){
                if(ar[k]<ar[i]+ar[j]){
                    t++;
                }
            }
        }
    }
    cout << t;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n;
    cin >> n;

    set<int> a;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }

    if (a.size() == n) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>
#include<memory>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


class UnionFind {
public:
	vector<int>rank, parent;
	//������
	UnionFind(int size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		REP(i, size)parent[i] = i;
	}
	//�؂̍������߂�
	int find(int x) {
		if(parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}
	//x��y�̑�����W���𕹍�
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y)return;
		if(rank[x] < rank[y])
			parent[x] = y;
		else {
			parent[y] = x;
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	//x��y�������W���ɑ����邩�ۂ�
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
	//parent�̓��e���o��
	void debug() {
		for(auto num : parent) {
			cout << num << " ";
		}
		cout << "more:" << endl;
		REP(i, parent.size()) {
			cout << find(i) << " ";

		}
		cout << endl << "more:" << endl;
		for(auto num : parent) {
			cout << num << " ";
		}
		cout << endl;
	}
};


//�ϐ�
int N,M;
vector<vector<int>> L;





//�T�u�֐�
//����
void input()
{
	cin>>N>>M;
	L.resize(N);
	int k;
	REP(i, N)
	{
		cin>>k;
		L[i].resize(k);
		REP(j,k)cin>>L[i][j];
	}
}


//�v�Z
void calc()
{
	UnionFind uf(N);
	map<int,vector<int>> mp;
	REP(i, N)
	{
		for(auto num : L[i])
		{
			mp[num].push_back(i);
		}
	}

	for(auto itr = mp.begin(); itr != mp.end(); ++itr)
	{
		auto v = itr->second;
		if(v.size() > 1)
		{
			REP(i, (int)(v.size() - 1))
			{
				uf.unite(v[i],v.back());
			}
		}
	}
	
	REP(i, N-1)
	{
		if(!uf.same(i, N - 1))
		{
			cout<<"NO"<<endl;
			return;
		}
	}
	cout << "YES"<<endl;
}


//�o��
void output()
{

}


//�f�o�b�O
void debug()
{
    int N;
    cin>>N;
}


//���C���֐�
int main()
{
    input();
    calc();
    output();
    debug();
    
    return 0;
}


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

int main(){
  char a,b;
  cin >> a >> b;
  if(a == 'H'){
    cout << b << endl;
  }
  else {
    if(b == 'H') cout << 'D' << endl;
    else cout << 'H' << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){	
	int Num, zikan, hun, byou;
	
	scanf("%d", &Num);
	
	zikan =  Num / 3600;
	Num -= zikan * 3600;
	hun =  Num / 60;
	Num -= hun * 60;
	byou = Num;
	
	printf("%d:%d:%d\n", zikan, hun, byou);
	return 0;
}

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


int main() {
	int x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	int d1 = x2 - x1;
	int d2 = y2 - y1;
	int sign = 1;
	if( d1 == 0 ) {
		sign = -1;
	}
	int x3 = x2 - d2;
	int y3 = y2 + d1 * sign;
	int x4 = x3 - d1;
	int y4 = y3 - d2;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}


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

using namespace std;
int main (){
    string s,v;
    cin >> s;
    int len=0;
    for (int i = 0; i < s.size(); i++){
        if(s[i]!='B') v+=s[i];
        else          v=v.substr(0,v.size()-1);
    }
    cout << v << "\n";
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll n, m, v, p;
vll a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> v >> p;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));

    ll low = 0, high = n;
    while (low < high) {
        ll mid = (low + high) / 2;
        if (mid < p) {
            low = mid + 1;
            continue;
        }
        if (a[mid] + m < a[p - 1]) {
            high = mid;
            continue;
        }

        ll rem = p * m;
        for (int i = p - 1; i < mid; i++) rem += a[mid] + m - a[i];
        rem += (n - mid -1) * m;

        if (rem >= m * v) low = mid + 1;
        else high = mid;
    }

    cout << low << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

int main() {
	Int a; cin >> a;
	int n, w;

	double h = 0.0;
	
	for (int n = 1; n <= 3500; n++) {
		for (int w = 2; w <= 3500; w++) {
			h = 1.0*(a * n * w) / (4 * n * w - a * n - a * w);
			//cout << n << " " << w << " " << h << endl;
			if (integer(h)&&h>=1&&h<=3500) {
				cout << n << " " << w << " " << h << endl;
				return 0;
			}
		}
	}


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# C問題
N, K = map(int, input().split())
ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))
ab.sort()
tmp_k = 0
tmp_i = 0
for i in range(N):
    tmp_k += ab[i][1]
    if tmp_k >= K:
        tmp_i = i
        break
print(ab[tmp_i][0])        

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;

// n の k 乗を mod で割った余りを計算
long long power_mod(long long n, long long k, long long mod) {
    long long result = 1;
    // k を右シフトしつつ n を 2 乗していく
    while (k > 0) {
        // k の最下ビットが 1 なら、今の n を答えに掛ける
        if ((k & 1) == 1) result = (result * n) % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return result;
}

int main(){

    
    ll n,a,b;
    cin >> n >> a >> b;
    ll ka=1,kb=1;
    for(int i=1; i<=a; i++) ka=ka*i%mod;
    for(int i=1; i<=b; i++) kb=kb*i%mod;

    ll ans=power_mod(2,n,mod)-1;
    // cout << ans << endl;
    ll sum=1;
    for(ll i=0; i<a; i++) sum=sum*(n-i)%mod;
    sum=sum*power_mod(ka,mod-2,mod)%mod;
    ans=(ans-sum+mod)%mod;
    // cout << sum << endl;

    sum=1;
    for(ll i=0; i<b; i++) sum=sum*(n-i)%mod;
    sum=sum*power_mod(kb,mod-2,mod)%mod;
    ans=(ans-sum+mod)%mod;
    // cout << sum << endl;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<vector>
int main(void){
    int n,a;
    scanf("%d",&n);
    std::vector<int> vec(n);

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

Measured memory_bytes: 1152
//ARC061-C(たくさんの数式)
#include<iostream>
#include<string>
#include<numeric>
using namespace std;

string S;
long long a[11];

int main(){
    cin>>S;
    int si=S.size();
    
    long long sum=0;
    
    //bit全探索
    for(long long bit=0; bit<(1<<(si-1)); bit++){
        
        //a[]の初期化
        for(int i=0; i<si; i++)a[i]=S[i]-'0';
        
        //どこに'+'を入れるか
        for(int i=0; i<si-1; i++){
            if(bit & (1<<i)){
                //'+'をiとi+1の間に入れない
                a[i+1]=a[i]*10+a[i+1];
                a[i]=0;
            }
        }
        
        sum+=accumulate(a,a+si,0LL);
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int h, n;
    cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
vector <int> n;

int main(){
	string s,c;
	bool rev=true;
	int q,t,f;
	cin>>s>>q;
	for(int i=0;i<q;i++){
		cin>>t;
		if(t==1){
			if(rev){
				rev=false;
			}else{
				rev=true;
			}
		}else{
			cin>>f>>c;
			if(f==1){
				if(rev){
					c+=s;
					s=c;
				}else{
					s+=c;
				}
			}else{
				if(rev){
					s+=c;
				}else{
					c+=s;
					s=c;
				}
			}
		}
	}
	if(rev){
		cout<<s<<endl;
	}else{
		for(int i=s.size()-1;i>=0;i--){
			cout<<s[i];
		}
		cout<<endl;
	}
	return 0;
}

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


Measured memory_bytes: 3100
n = input()
a = len(n)
if a == 6:
  print(9+900+90000)
elif a == 5:
  print(9+900+int(n)-10000+1)
elif a == 4:
  print(909)
elif a == 3:
  print(9+int(n)-100+1)
elif a == 2:
  print(9)
elif a == 1:
  print(n)

Measured memory_bytes: 38384
import fractions

N=int(input())

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

M=[2]
while M[-1]<N:
    M.append(M[-1]*2)

A=A+[0]*(M[-1]-len(A))
A=A[::-1]

for i in range(len(A)-1):
    A.append(fractions.gcd(A[2*i],A[2*i+1]))

A=A[::-1]

#print(A)

ans=0
for index in range(len(A)-M[-1],len(A)-M[-1]+N):
    temp=A[index+1] if index%2==1 else A[index-1]
    index=((index-1) if index%2==1 else (index-2))//2
    #print(index)
    while index!=0:
        if index%2==1:
            temp=fractions.gcd(temp,A[index+1])
            index=(index-1)//2
        else:
            temp=fractions.gcd(A[index-1],temp)
            index=(index-2)//2
        #print("temp"+str(temp))
    ans=max(temp,ans)
    #print("=======================")
print(ans)


Measured memory_bytes: 16572
#include<stdio.h>
int main(){
    int H, W;

    while(1){
    scanf("%d %d",&H,&W);

	if(H==0 && W==0) break;

    for(int i=1;i<=H;i++){
        printf("#");
        for(int k=1;k<=W-1;k++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    }
}



Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

using Edge = pair<int, int>;

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

	vector<Edge> E(M);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;

		E[i] = Edge(a, b);
	}

	int count = 0;
	for (int i = 0; i < M; ++i)
	{
		queue<int> q;
		vector<bool> b(N, false);

		q.push(0);
		do {
			int v = q.front();
			q.pop();

			b[v] = true;

			for (int j = 0; j < M; ++j)
			{
				if (i == j)
				{
					continue;
				}

				if (E[j].first == v && !b[E[j].second])
				{
					q.push(E[j].second);
				}
				else if(E[j].second == v && !b[E[j].first])
				{
					q.push(E[j].first);
				}
			}
		} while (!q.empty());

		for (int j = 0; j < N; ++j)
		{
			if (!b[j])
			{
				++count;
				break;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      int e = sc.nextInt();
      int k = sc.nextInt();
      int[] S = new int[]{a,b,c,d,e};
      
      int max = S[0];
      int min = S[0];
      for (int i = 0; i < S.length; i++) {
        int v = S[i];
        if(v > max){
          max = v;
        }if(v < min){
          min = v;
        }
      }
      
      if(max-min <= k){
        System.out.println("Yay!");
      }else{
        System.out.println(":(");
      }
    }
}

Measured memory_bytes: 35720
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

ll prime[MAX];

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

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

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

//sieve();

string str;
  cin>>str;
  if(str[2]==str[3] && str[4]==str[5])
    cout<<"Yes\n";
  else
    cout<<"No\n";



return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  string s;
  cin >> s;
  if(s == "ABC")cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3516
use io::*;
use std::cmp::min;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let a: Vec<i64> = sc.next_vec(n);

    let calc = |b: i64| -> i64 {
        let mut ret = 0;
        for i in 0..a.len() {
            ret += (a[i] - (b + i as i64)).abs();
        }
        ret
    };

    let mut l = -1000000001;
    let mut r = 1000000001;

    while (r - l) >= 3 {
        let m0 = (l * 2 + r) / 3;
        let m1 = (l + r * 2) / 3;

        if calc(m0) < calc(m1) {
            r = m1;
        } else {
            l = m0;
        }
    }

    let ans = calc(l);
    let ans = min(ans, calc(l + 1));
    let ans = min(ans, calc(l + 2));
    let ans = min(ans, calc(l + 3));

    println!("{}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8444
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    
    int ispoor = 0;
    if(A==B&&B!=C) ispoor = 1;
    if(B==C&&C!=A) ispoor = 1;
    if(C==A&&A!=B) ispoor = 1;
    if(ispoor){
    
    
    printf("Yes");
        }
        
    else{
    printf("No");
        }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n;
		while ((n = in.nextInt()) != 0) {
			char[][] h = new char[n][2];
			for (char[] c : h) {
				c[0] = in.next().charAt(0);
				c[1] = in.next().charAt(0);
			}
			int m = in.nextInt();
			sb.setLength(0);
			for (int i = 0; i < m; i++) {
				char ac = in.next().charAt(0);
				for (char[] c : h) {
					if (ac == c[0]) {
						ac = c[1];
						break;
					}
				}
				sb.append(ac);
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 68784
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a <= 5){
        cout << 0 <<endl;
        return 0;
    }
    else if(6 <= a && a <= 12){
        cout << (b/2) <<endl;
        return 0;
    }
    else if(a >=13){
        cout << b <<endl;
        return 0;
    }
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N=cin.nextInt();
		while(N--!=0){
			int[][] a = new int[5][5];
			for(int i = 0;i<5;i++){
				for(int j=0;j<5;j++){
					a[i][j]=cin.nextInt();
				}
			}
			int max=0;
			for(int i = 0;i<5;i++){
				for(int j = 0;j<5;j++){
					for(int k=1;k+i<=5;k++){
						for(int l=1;l+j<=5;l++){
							boolean f = true;
							for(int x=i;x<k+i;x++){
								for(int y=j;y<l+j;y++){
									if(a[x][y]==0){
										f=false;
									}
								}
							}
							if(f){
							max=Math.max((k)*(l),max);
							}
						}
					}
				}
			}
			System.out.println(max);
		}

	}

}

Measured memory_bytes: 12000
ans=0
n,m=map(int,input().split())
l1=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
for i in range(2**n):
    a=[]
    for j in range(n):
        if i>>j&1:
            a.append(j+1)
    for j in range(m):
        if len(set(a)&set(l1[j][1:]))%2==p[j]:
            continue
        else:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] H = new int[N];
		long ans = 0;
		
		for (int i=0; i<N; i++) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);
		
		for (int i=0; i<N-K; i++) {
			ans += H[i];
		}
		System.out.println(ans);
	}
}

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

from itertools import accumulate
ac=list(accumulate(a))

ans=float("inf")
l=0
r=1
for i in range(1, n-2):
    while abs(ac[i]-2*ac[l+1]) < abs(ac[i]-2*ac[l]) and l < i+1:
        l+=1
    while abs(ac[-1]-2*ac[r+1]+ac[i]) < abs(ac[-1]-2*ac[r]+ac[i]) and r < n-2:
        r+=1
    t=[ac[l], ac[i]-ac[l], ac[r]-ac[i], ac[-1]-ac[r]]
    ans=min(ans, max(t)-min(t))
print(ans)


Measured memory_bytes: 31476
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
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 (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int main() {
	string s;
    cin >> s;
    rep(i, 4) {
        cout << s[i];
    }
    cout << " " ;
    REP(i, 4, s.size()) {
        cout << s[i];
    }
    cout << endl;
    
	
	
    return 0;
}


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

using namespace std;

int main(void){

	deque<char> sa, sb, sc;
	char tmp;
	while ((tmp = getchar()) != '\n') {
		sa.push_back(tmp);
	}
	while ((tmp = getchar()) != '\n') {
		sb.push_back(tmp);
	}
	while ((tmp = getchar()) != '\n') {
		sc.push_back(tmp);
	}

	char card='a';
	while (1) {

		switch (card) {
		case 'a':
			if (sa.empty() == true) {
				cout << "A" << endl;
				return 0;
			}
			card = sa.front();
			sa.pop_front();

			break;
		case 'b':
			if (sb.empty() == true) {
				cout << "B" << endl;
				return 0;
			}
			card = sb.front();
			sb.pop_front();
			break;
		case 'c':
			if (sc.empty() == true) {
				cout << "C" << endl;
				return 0;
			}
			card = sc.front();
			sc.pop_front();
			break;

		}
	}

	return 0;
}

Measured memory_bytes: 256
def solve():
    n = int(input())
    if n > 81:
        print('No')
        return
    for i in range(1, 10):
        (q, mod) = divmod(n, i)
        if n % i == 0 and q <= 9:
            print('Yes')
            return
    print('No')
    return

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

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

    for (int i = 0; i < m; ++i) {
        int x ;
        cin >> x;
        n -= x;
    }
    if (n < 0) {
        n = -1;
    }

    cout << n << "\n";



    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
/*
 *  OO  IIII  Jjjj  lllL
 *  OO  iiii  JJJj  lLLL
 *
 *  L IIII LLL
 *  LLL iiii L
 *
 *  L IIII J
 *  LLL  JJJ
 */
enum tile_t { I, O, T, J, L, S, Z };
ll f(array<ll, 7> a, int jil) {
    a[I] -= jil;
    a[J] -= jil;
    a[L] -= jil;
    if (a[I] < 0 or a[J] < 0 or a[L] < 0) return -1;
    ll k = 0;
    k += jil * 3;
    k += a[I] / 2 * 2; a[I] %= 2;
    k += a[J] / 2 * 2; a[J] %= 2;
    k += a[L] / 2 * 2; a[L] %= 2;
    k += a[O]; a[O] = 0;
    return k;
}
int main() {
    array<ll, 7> a; repeat (i,7) cin >> a[i];
    ll k = 0;
    repeat (jil,3) setmax(k, f(a, jil));
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  set<char> st; 
  bool ok = s.length() == 4;
  rep(i, s.length()) st.insert(s[i]); 
  ok &= st.size() == 2;
  ok();
  return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

bool check(int n){
    int a = n / 100;
    int b = (n % 100) / 10;
    int c = n % 10;
    if (a != b || a != c || b != c)
        return false;
    return true;
}

int main()
{
    int n;
    cin >> n;
    while (!check(n))
        n++;
    cout << n;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) cout << 1 << endl;
    else cout << (h * w + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

// using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	ll calcS(std::vector<ll>& s, ll h, ll w) {
		ll mi = infll;
		Rep(i, 1, w) {
			s[0] = i * h;
			if (h % 2) {
				s[1] = (w - i) * (h / 2);
				s[2] = (w - i) * (h / 2 + 1);
			}
			else {
				s[1] = s[2] = (w - i) * (h / 2);
			}
			std::sort(allof(s));
			mi = std::min(mi, s[2] - s[0]);
		}
		return mi;
	}

	ll calcS2(ll h, ll w) {
		if (h < 3) return infll;
		// なるべく均等になるように3本の線を入れる
		return w;
	}
}

int main() {

	ll h, w;
	std::cin >> h >> w;

	// 各ピースは長方形
	// 3つすべてを近づけると考えても同じ

	// h or wが3の倍数なら同じ方向の線を3本入れて終わり ans = 0
	// そうじゃないなら 同じ方向の線が2本，違う方向の線が1本が最適
	// 一応同じ方向3本のときも確かめる

	if (!(h % 3) || !(w % 3)) {
		std::cout << 0 << std::endl;
		return 0;
	}

	// 横だけをみて，幅を1からwまで全探索
	ll ans = infll;
	std::vector<ll> s(3);
	ans = std::min(ans, calcS(s, h, w));
	ans = std::min(ans, calcS(s, w, h));
	ans = std::min(ans, calcS2(h, w));
	ans = std::min(ans, calcS2(w, h));

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
  char name[21];
  int p;
}data;

void solve(int n,data a[]){
  int w,l,d,i,j;
  data t;
  for(i=0;i<n;i++){
    scanf("%s %d %d %d",a[i].name,&w,&l,&d);
    a[i].p=w*3+d;
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j-1].p<a[j].p){
	t=a[j];
	a[j]=a[j-1];
	a[j-1]=t;
      }
    }
  }
  for(i=0;i<n;i++)
    printf("%s,%d\n",a[i].name,a[i].p);
}

int main(void){
  int n;
  data a[10];
  scanf("%d",&n);
  solve(n,a);
  while(scanf("%d",&n),n){
    puts("");
    solve(n,a);
  }
  return 0;
}

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

int H, W, K;
string board[10];

bool func(int x, int y) {
    vector<vector<int>> red(H, vector<int>(W, 1));
    for (int i = 0; i < H; i++) {
        if (x & (1 << i)) {
            for (int j = 0; j < W; j++) red[i][j] = 0;
        }
    }
    for (int i = 0; i < W; i++) {
        if (y & (1 << i)) {
            for (int j = 0; j < H; j++) red[j][i] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (red[i][j] == 1 && board[i][j] == '#') cnt++;
        }
    }
    return (cnt == K);
}

int main() {
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++) cin >> board[i];

    int ans = 0;
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < (1 << W); j++) {
            if (func(i, j)) ans++;
        }
    }

    cout << ans << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
string s;
void solve() {
    cin >> n >> s;

    int ans = 0;
    char before = ' ';
    rep(i, n) {
        if (s[i] != before)++ans;
        before = s[i];
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int turns = sc.nextInt();
		int score1 = 0;
		int score2 = 0;
		
		for(int i=0; i<turns; i++){
			String word1 = sc.next();
			String word2 = sc.next();
			int cp = word1.compareTo(word2);
			
			if (cp < 0) {
				score2+=3;
			} else if (cp == 0) {
				score1+=1;
				score2+=1;
			} else {
				score1+=3;
			}
			
		}
		
		
		System.out.printf("%d %d", score1, score2);
		System.out.println();
		
	}
}


Measured memory_bytes: 30180