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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int h, w, n;

	cin >> h >> w >> n;

	if (w > h) swap(h, w);
	if (n % h == 0) cout << n / h << endl;
	else cout << n / h + 1 << endl;
}




Measured memory_bytes: 256
import heapq
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_heap=[]
    heapq.heapify(posi_heap)
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            heapq.heappush(posi_heap,-1*diff)
    diff_sum*=(-1)
    i=0
    while diff_sum>0:
        diff_sum+=heapq.heappop(posi_heap)
        i+=1
    print(i+cnt)

Measured memory_bytes: 18520
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  cout << N / 3 << endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll H, W, N;
	cin >> H >> W >> N;

	const ll k = max(H, W);

	ll ans = (N / k);
	if (N % k == 0)
	{
		ans--;
	}

	cout << ans+1 << endl;

	//system("pause");
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int x;
	cin>>x;
	int ans=1,maxi=INT_MAX;
	while(maxi--){
		if((360*ans)%x==0){
			cout<<(360*ans)/x<<endl;
			return 0;
		}
		ans++;
	}
	cout<<INT_MAX<<endl;
	return 0;
}

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

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

Measured memory_bytes: 3084
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
long long A, B, C, K, ans;

int main() {
  cin >> A >> B >> C >> K;
  if (K % 2 == 0) {
    ans = A - B;
  } else {
    ans = B - A;
  }
  if (abs(ans) > LONG_LONG_INF) {
    cout << "Unfair" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <cmath>
    using namespace std;
     
    int main(){
        int n;
        cin >> n;
        vector<int> a(n+2);
        for(int i = 1; i <= n; i++){
            cin >> a[i];
        }
        int sum = 0;
        for(int i = 1; i < n+2; i++)
            sum += abs(a[i] - a[i-1]);
        for(int i = 1; i < n+1; i++){
            cout << sum + (abs(a[i+1] - a[i-1]) - (abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }
    }

Measured memory_bytes: 1664
n,k=map(int,input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))


sunuke=[False]*n
for i in range(len(a)):
    for j in range(len(a[i])):
        sunuke[a[i][j]-1] = True
print(sunuke.count(False))

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0,a+b-n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin, k;
    REP(i, 0, k) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3584
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] abx = Read(Console.ReadLine());
            double a = abx[0];
            double b = abx[1];
            double x = abx[2];

            //水の体積が、水筒の半分以上か否かで場合分け
            if (a * a * b > 2*x)
            {
                Console.WriteLine(Math.Atan((a*b*b)/(2*x)) * 360 / (2 * Math.PI));
                Console.ReadLine();
                return;
            }
            else
            {
                Console.WriteLine(Math.Atan(2*(b-x/(a*a)) / a) * 360 / (2 * Math.PI));
                Console.ReadLine();
                return;
            }
        }
      
        private static int[] Read(string input)
        {
            string[] strings = input.Split(' ');
            int num = strings.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(strings[i]);
            }
            
            return ints;
        }


    }


}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
typedef long long ll;
const int N=20000005;
int n,k,x,t,a,b;
string s;
vector<int>v;
int main(){

	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]){
		cout << "No";
	}else{
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	ll n,a,b;
	cin>>n>>a>>b;
	if((b-a)&1)
	{
		cout<<min(((a-1)+(b-1)+1)/2,((n-a)+(n-b)+1)/2);
	}
	else
	{
		cout<<(b-a)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	color := 1
	for i := 0; i < h; i++ {
		// iが偶数なら左->右, 奇数なら右->左
		for j := (i % 2) * (w - 1); 0 <= j && j < w; j += 1 - (i%2)*2 {
			for a[color-1] == 0 {
				color++
			}
			c[i][j] = color
			a[color-1]--
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if j == w-1 {
				fmt.Printf("%d\n", c[i][j])
			} else {
				fmt.Printf("%d ", c[i][j])
			}
		}
	}
}


Measured memory_bytes: 1280
#include<stdio.h>
int n;
int a,b,c;
int i;

int main()
{
    while(1)
    {
        scanf("%d",&n);
        if(n == 0)break;
        for(i = 0;i < n;i++)
        {
            scanf("%d",&a);
            scanf("%d",&b);
            scanf("%d",&c);
            if(a == 100 || b == 100 || c == 100)printf("A\n");
            else if((a + b) / 2 >= 90)printf("A\n");
            else if((a + b + c) / 3 >= 80)printf("A\n");
            else if((a + b + c) / 3 >= 70)printf("B\n");
            else if((a + b + c) / 3 >= 50 && (b >= 80 || a >= 80) )printf("B\n");
            else printf("C\n");
        }
    }
    return 0;
}

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

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

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

int main(){
	string o,e;
	cin >> o >> e;
	string out;
	bool flag = true;
	for(int i=0;i<(o.length()+e.length());++i){
		if(flag) {
			out.push_back(o[i/2]);
			flag=false;
		}
		else {
			out.push_back(e[i/2]);
			flag=true;
		}
	}
	cout << out << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var numx = ReadInts();
        var n = numx[0];
        var singled = Enumerable.Repeat(1, n).Select(_ => ReadInts()).Select(p => p[0]).ToLookup(p => p).Select(p => p.Count()).Count(p => p % 2 == 1);

        Console.WriteLine(singled);
    }

    static int Caloc(int v, int w, int n)
    {
        n++;
        var vp = GetParents(v-1, n);
        var wp = GetParents(w-1, n);
        var pp = vp.Zip(wp, (p, q) => new Point(p, q)).TakeWhile(p => p.X == p.Y).Select(p => p.X).ToArray();
        return GetNode(pp, n) + 1;
    }


    static int GetNode(IEnumerable<int> source, int n)
    {
            return source.Aggregate(0, (a, p) => a * n + p);
    }
    static IEnumerable<int> GetParents(int v, int n)
    {
        return GetParentsItr(v, n).Reverse();
    }
    static IEnumerable<int> GetParentsItr(int v, int n)
    {
        while (v > 0)
        {
            yield return v % n;
            v /= n;
        }
    }

    #region Utils
    static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    #endregion
}

struct Point
{
    public Point(int x, int y)
    {
        X = x;
        Y = y;
    }

    public int X { get; }
    public int Y { get; }
}



Measured memory_bytes: 29200
#include <iostream>
using namespace std;
int main () {
  int n = 0;
  cin >> n;
  int v[20], c[20];
  
  for (int i = 0; i < n; i++) {
  	cin >> v[i];
  }
  int out = 0;
  for (int i = 0; i < n; i++) {
  	cin >> c[i];
    if (v[i] - c[i] > 0)
      out += v[i] - c[i];
  }
  
  cout << out;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",s[0]==s[1]?"Yes":"No");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
n=int(input())
l=list(input())
check=False
cnt=0
cnt1=0
s=[]
for i in range(n):
    if l[i]=='#':
        cnt+=1
s.append(cnt)
for i in range(n-1,-1,-1):
    if l[i]=='.':
        cnt+=1
    else:
        cnt+=-1
    s.append(cnt)
print(min(s))

Measured memory_bytes: 12836
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << std::min(A, B) + std::min(C, D) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	
	for (i = 1; i < 10; i++){
		for (j = 1; j < 10; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
[n, m, q] = [int(x) for x in input().split(' ')]

a = []
b = []
c = []
d = []

for _ in range(q):
  tmp = [int(x) for x in input().split(' ')]
  a.append(tmp[0]-1)
  b.append(tmp[1]-1)
  c.append(tmp[2])
  d.append(tmp[3])

x = [1] * n

def next(x):
  for i in range(n-1, -1, -1):
    if x[i] != m:
      x[i] += 1
      for j in range(i, n):
        x[j] = x[i]
      return True
  else:
    return False

def score(x):
  s = 0
  for i in range(q):
    if x[b[i]] - x[a[i]] == c[i]:
      s += d[i]
  return s

ans = score(x)
while next(x):
  ans = max(ans, score(x))

print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> vec(N);
  
  for (int i = 0; i < K; i++) {
       int d;
       cin >> d;
    
       vector<int> vec2(d);
    for (int j = 0; j < d; j++) {
      cin >> vec2.at(j);
      vec.at(vec2.at(j) - 1)++;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 0) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

    

Measured memory_bytes: 3604
#include<cstdio>
#include<set>
#include<cstdlib>
#include<chrono>
#include<vector>
#include<utility>

using namespace std;

int d, c[100], s[400][100];
int m;
set<int> app[100];

int last(int d, int i) {
  return *(--app[i].upper_bound(d));
}

int next(int d, int i) {
  return *app[i].upper_bound(d);
}

int random(int x, int y) {
  return rand() % (y - x + 1) + x;
}

pair<int, vector<int>> init() {
  int sat = 0;
  vector<int> t(1);
  for (int i = 1; i <= d; i++) {
    int best = -2e9, best_j = 0;
    for (int j = 1; j <= 26; j++) {
       int tmp = 0;
       tmp += s[i][j];
       for (int k = 1; k <= 26; k++) {
         if (j == k) {
           continue;
         }
         tmp -= c[k] * (i - last(i, k));
       }
       if (tmp > best) {
         best = tmp;
         best_j = j;
       }
    }
    t.push_back(best_j);
    sat += s[i][t[i]];
    app[t[i]].insert(i);
    for (int j = 1; j <= 26; j++) {
      sat -= c[j] * (i - last(i, j));
    }
  }
  return {sat, t};
}

pair<int, vector<int>> climb(auto start, int sat, vector<int> t) {
  auto end = chrono::steady_clock::now();
  while (chrono::duration_cast<chrono::nanoseconds>(end - start).count() < 1.9e9) {
    int best = -2e9, best_i = 0, best_j = 0;
    for (int i = 1; i <= d; i++) {
      for (int j = 1; j <= 26; j++) {
        if (j == t[i]) {
          continue;
        }
        int tmp = 0;
        tmp -= s[i][t[i]];
        tmp -= c[t[i]] * (next(i, t[i]) - i) * (i - last(i - 1, t[i]));

        tmp += s[i][j];
        tmp += c[j] * (next(i, j) - i) * (i - last(i, j));
        if (tmp > best) {
          best = tmp;
          best_i = i;
          best_j = j;
        }
      }
    }
    if (best > 0) {
      app[t[best_i]].erase(best_i);
      app[best_j].insert(best_i);
      t[best_i] = best_j;
      sat += best;
    } else {
      break;
    }
    end = chrono::steady_clock::now();
  }
  return {sat, t};
}

int main() {
  scanf("%d", &d);
  for (int i = 1; i <= 26; i++) {
    scanf("%d", &c[i]);
    app[i].insert(0);
    app[i].insert(d+1);
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= 26; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  auto start = chrono::steady_clock::now();
  auto tmp = init();
  auto res = climb(start, tmp.first, tmp.second);
  for (int i = 1; i <= d; i++) {
    printf("%d\n", res.second[i]);
  }
}


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

long long n,num,minnum = 0x7fffffffffffffff, sum,m;

int main()
{
	scanf("%lld",&n);
	for ( long long i = 0 ; i < n ; i++ )
	{
		scanf("%lld",&num);
		if ( num < 0 )
		{
			num = -num;
			m++;
		}
		minnum = min(minnum,num);
		sum += num;
	}
	printf("%lld",m&1?sum-2*minnum:sum);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  a = list(map(int, input().split()))

  for i in range(100):
    if not X - i in a:
      print(X - i)
      break
    elif not X + i in a:
      print(X + i)
      break

Measured memory_bytes: 8836
n=int(input())
X=list(map(int,input().split()))
ave=sum(X)/n
a=float('inf')
d=a
for i in range(1,101):
    if abs(ave-i)<=d:
        a=i
        d=abs(ave-i)
ans=0
for x in X:
    ans+=(x-a)**2
print(ans)

Measured memory_bytes: 38448
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	string s[101];
	bool same = false;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		for (int j = 0; j < i; j++)
		{
			if (s[i] == s[j]) same = true;
		}
		if (i != 0)
		{
			if (s[i - 1][s[i-1].length()-1] != s[i][0]) same = true;
		}
	}
	if (same) cout << "No" << endl;
	else cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
n,i,a=0,b,c=0,m=100;main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&b);a+=b;if(b%10){c++;m=(b<m?b:m);}}
	if(a%10==0)a-=m;
	if(!c)a=0;
	printf("%d",a);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,cnt_odd=0,cnt_even=0;
    cin >> n;
    long long A;
    rep(i,n){
        cin >> A;
        if(A%2 == 0)
            cnt_even++;        
    }

    if((n - cnt_even)%2 == 1)
        cout << "NO" << endl;
        else
        {
            cout << "YES" << endl;
        }
        


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,vis[99],tot,no;
int main(){
	cin>>n;
	for(int i=n,a;i;i--){
		cin>>a;
		if(a<3200)vis[a/400]=1;
		else tot++;
	}
	for(int i=0;i<=7;i++)if(!vis[i])no++;
	printf("%d %d",max(1,8-no),min(n,8-no+tot));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if((A==1 && B==2)||(A==2&&B==1))
    {
        printf("3\n");
    }
    else if((A==2 && B==3)||(A==3&&B==2))
    {
        printf("1\n");
    }
    else
    {
        printf("2\n");
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
    int A[3];
    int B[3];
    int c[3][3];
    for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) cin >> c[i][j];
    for (int A1 = 0; A1 <= 100; ++A1) for (int A2 = 0; A2 <= 100; ++A2) for (int A3 = 0; A3 <= 100; ++A3) {
        A[0] = A1;
        A[1] = A2;
        A[2] = A3;
        B[0] = c[0][0]-A1;
        B[1] = c[0][1]-A1;
        B[2] = c[0][2]-A1;
        bool f = true;
        for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) if(A[i]+B[j] != c[i][j]) f = false;
        if(f) {
            cout << "Yes" << std::endl;
            return 0;
        }
    }
    cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        int num2 = scan.nextInt();
        
        int n = (num1*(num1-1))/2;
        int m = (num2*(num2-1))/2;
      
        int sum = n + m;
 
        System.out.println(sum);
        scan.close();
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer temp;
  temp=nil;
  while(1)
    {
      temp = temp->next;
      if(temp->key == key)
	{
	  return temp;
	}
      if(temp == nil)
	{
	  return NULL;
	}
    }
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->next->prev=t->prev;
  t->prev->next=t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  NodePointer temp;
  temp = listSearch(key);
  if(temp == NULL) return;
  deleteNode(temp);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /* your code */
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;

void solve() {

  int n,m,k,ans=0;
  cin>>n>>m>>k;
  vi a(n+1),b(m+2);
  fr(i,1,n)
    cin>>a[i], a[i]+=a[i-1];
  fr(i,1,m)
    cin>>b[i], b[i]+=b[i-1];
  b.back()=infl;
  fr(i,0,n){
    int t = k-a[i];
    if(t<0)
      break;
    int x = ub(all(b),t)-b.begin();
    ans=max(ans,i+x-1);
  }
  cout<<ans;

}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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

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

int main()
{
   ll n;
   cin>>n;
   vector<ll> arr(n+1);
   for(ll i=1;i<=n;i++)
      cin>>arr[i];
   vector<ll> left(n+2);
   vector<ll> right(n+2);
   left[0] = right[n+1] = 0;

   for(ll i=1;i<=n;i++)
      left[i] = __gcd(left[i-1],arr[i]);
   for(ll i = n;i>=1;i--)
      right[i] = __gcd(right[i+1],arr[i]);

   ll ans = 1;
   for(int i=0;i<=(n+1);i++)
      ans = max(ans, __gcd(left[i-1],right[i+1]));
   
   cout<<ans;
   return 0;
}


Measured memory_bytes: 5520
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            var result = long.MaxValue;

            var b = new List<int>();
            for (var i = 0; i < n; i++)
            {
                b.Add(a[i] - (i + 1));
            }

            b.Sort();

            if (n % 2 == 0)
            {
                var b1 = n / 2;
                var b2 = b1 + 1;
                for (var i = b1; i <= b2; i++)
                {
                    result = Math.Min(result, calc(a, b[i]));
                }
            }
            else
            {
                result = calc(a, b[n / 2]);
            }

            Console.WriteLine(result);
        }

        static long calc(List<int> list, int b)
        {
            var result = 0L;
            for (var i = 0; i < list.Count; i++)
            {
                result += Math.Abs(list[i] - (b + i + 1));
            }
            return result;
        }
    }
}


Measured memory_bytes: 47068
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t A, B, C, D;
    intmax_t ans = 0;

    scanf("%jd%jd%jd%jd", &A, &B, &C, &D);

    while (1) {
        C -= B;
        if (C <= 0) {
            puts("Yes");
            return 0;
        }
        A -= D;
        if (A <= 0) {
            puts("No");
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    int n,a[100];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		
	}
	for(int i=1;i<=n;i++){
	  sort(a,a+i);
		for(int j=0;j<n;j++){
			if(j==n-1)cout << a[j] << "\n";
			else cout << a[j] << " ";
		}
	}
    return 0;
}

Measured memory_bytes: 1176
package main

import "fmt"

func main() {
	var n, m, k, a, ans int
	fmt.Scan(&n, &m)
	f := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			fmt.Scan(&a)
			f[a]++
		}
	}
	for _, v := range f {
		if v == n {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int a[4];
void func(int num,string s,int ans);
void func(int num,string s,int ans){
    if(num==4){
        if(ans==7){
            cout <<  a[0] << s[0] << a[1] << s[1]<<a[2]<<s[2]<<a[3]<<"=7";
            exit(0);
        }
    }
    else{
        s.push_back('+');
        func(num+1,s,ans+a[num]);
        s.pop_back();
        s.push_back('-');
        func(num+1,s,ans-a[num]);
        s.pop_back();
    }
}

int main(void){
    int ans=0;
    cin >> ans ;
    a[0]=ans/1000;
    a[1]=ans/100%10;
    a[2]=ans/10%10;
    a[3]=ans%10;
    ans=0;
    string s;
    func(1,s,a[0]);
    
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    vector<vector<int>> tree(N + 1);
    REP(i, N - 1) {
        int A, B;
        cin >> A >> B;
        tree[A].push_back(B);
        tree[B].push_back(A);
    }

    vector<int> dt(N + 1, IINF);
    queue<int> tkhs;

    dt[u] = 0;
    tkhs.push(u);
    for(;!tkhs.empty();) {
        int f = tkhs.front();
        tkhs.pop();
        for(int c : tree[f]) {
            if(c == v) {
                continue;
            }
            if(dt[c] == IINF) {
                tkhs.push(c);
                dt[c] = dt[f] + 1;
            }
        }
    }

    vector<int> da(N + 1, IINF);
    queue<int> aok;
    da[v] = 0;
    aok.push(v);
    for(;!aok.empty();) {
        int f = aok.front();
        aok.pop();
        for(int c : tree[f]) {
            if(da[c] == IINF) {
                aok.push(c);
                da[c] = da[f] + 1;
            }
        }
    }

    vector<int> tail;
    FOR(i, 1, N + 1) {
        if(tree[i].size() == 1) {
            tail.push_back(i);
        }
    }

    int res = -1;
    for(int t : tail) {
        int x = dt[t];
        int y = da[t];
        if(x < y) {
            res = max(res, y - 1);
        }
    }
    cout << res << endl;
    return 0;
}



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

int main() {
  string st;
  cin>>st;
  
  if(st[0]==st[1] && st[2]==st[3] && st[2]!=st[1])
    cout<<"Yes"<<endl;
  else if(st[0]==st[2] && st[1]==st[3] && st[2]!=st[1])
    cout<<"Yes"<<endl;
  else if(st[0]==st[3] && st[2]==st[1] && st[2]!=st[3])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0568
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] yotei = new int[x[0]];
            for (int i = 0; i < x[1]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                yotei[a[0] - 1] = a[1];
            }
            int[,,] dp = new int[x[0],4,4];//day,today,yesterday
            if (yotei[0] == 0) for (int i = 0; i < 4; i++) dp[0,i,0] = 1;
            else dp[0,yotei[0],0] = 1;
            for (int i = 1; i < x[0]; i++)//day
            {
                for (int j = 1; j < 4; j++)//today
                {
                    if (yotei[i] == j || yotei[i] == 0)//flag
                    {
                        for (int k = 1; k < 4; k++)//yesterday
                        {
                            for (int l = 0; l < 4; l++)//2days ago
                            {
                                if (j == k && k == l) continue;
                                dp[i,j,k] += dp[i - 1,k,l];
                                dp[i,j,k] %= 10000;
                            }
                        }
                    }
                }
            }
            int ret = 0;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    ret += dp[x[0] - 1,i,j];
                    ret %= 10000;
                }
            }
            Console.WriteLine(ret);
        }
    }
}


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

using namespace std;
using ll = long long;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> dp(m + 1, vector<int>(1 << n, 1e9)); //i個目まで見た時に, 状態jを作り出すための最小値
    dp[0][0] = 0;

    for(int i = 0; i < m; i++) {

        int a, b;
        cin >> a >> b;
        int cur = 0;
        for(int j = 0; j < b; j++) {
            int c; cin >> c; c--;
            cur |= (1 << c);
        }


        //cerr << bitset<2>(cur) << endl;
        for(int bit = 0; bit < (1 << n); bit++) {
            dp[i + 1][bit] = min(dp[i + 1][bit], dp[i][bit]);
            dp[i + 1][bit | cur] = min(dp[i + 1][bit | cur], dp[i][bit] + a);
        }
        
    }
    int ans = 0;
    for(int i = 0; i < n; i++)ans |= (1 << i);
    cout << ( dp[m][ans] == 1e9 ? -1 : dp[m][ans] )<< endl;
}

Measured memory_bytes: 16256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	int rem = max(0, A-2*B);

		cout << rem << "\n";

	return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val fs = (0 until n).map {
        val f = readLine()!!.split(' ').map { it.toInt() }
        f.mapIndexed { i, v -> v shl i }.sum()
    }.toIntArray()
    val ps = (0 until n).map {
        readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    }.toTypedArray()

    val dp = IntArray((1 shl 10)) { Int.MIN_VALUE }
    for (i in 1 until (1 shl 10)) {
        var p = 0
        for (j in 0 until n) {
            var x = fs[j] and i
            var cnt = 0
            while (x > 0) {
                cnt += x and 1
                x = x shr 1
            }
            p += ps[j][cnt]
        }
        dp[i] = Math.max(p, dp[i - 1])
    }

    println(dp.last())
}


Measured memory_bytes: 38372
#include <stdio.h>
#include <stdbool.h>

int main(void) 
{

	int N,M;
	int a[3] = { -1, -1, -1 };
	int b[5][2];
	char c[3] = { 0, 0, 0 };
	int i;
	bool bFail;


	scanf("%d %d", &N, &M);
	for ( i = 0; i < M; i++ ) {
		scanf("%d %d", &b[i][0], &b[i][1]);
	}

	bFail = false;
	for ( i = 0; i < M; i++ ) {
		if ( a[b[i][0]-1] == -1 ) {
			a[b[i][0]-1] = b[i][1];
		} else {
			if ( a[b[i][0]-1] != b[i][1] ) {
				bFail = true;
				break;
			}
		}
	}

	if ( bFail ) {
		printf("-1\n");
		return 0;
	}

	switch(N) {
		case 1:
			if ( a[0] == -1 ) {
				printf("0\n");
				return 0;
			} else {
				printf("%d\n", a[0]);
				return 0;
			}
			break;

		case 2:
			if ( a[0] == 0 ) {
				printf("-1\n");
				return 0;
			} else if ( a[0] == -1 ) {
				printf("1");
			} else {
				printf("%d", a[0]);
			}
			if ( a[1] == -1 ) {
				printf("0\n");
			} else {
				printf("%d\n", a[1]);
			}
			break;

		case 3:
			if ( a[0] == 0 ) {
				printf("-1\n");
				return 0;
			} else if ( a[0] == -1 ) {
				printf("1");
			} else {
				printf("%d", a[0]);
			}
			if ( a[1] == -1 ) {
				printf("0");
			} else {
				printf("%d", a[1]);
			}
			if ( a[2] == -1 ) {
				printf("0\n");
			} else {
				printf("%d\n", a[2]);
			}
			break;

	}

	return 0;

}


Measured memory_bytes: 128
<?php

$input_line = "";
while (($buffer = fgets(STDIN)) !== false) {
    $input_line.= $buffer;
}
                                                                                                                                            $input_line = trim($input_line);
$input_array =  explode("\n", $input_line);
preg_match("/([0-9]+) ([0-9]+)/", array_shift($input_array), $number);

$count = 0;
foreach (explode(" ", array_shift($input_array)) as $idx1 => $val1) {
    if ($val1 >= $number[2]) {
        $count++;
    }
}
echo $count;

Measured memory_bytes: 21764
#include<atcoder/all>
#include<iostream>
using namespace std;
using namespace atcoder;

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(N), B(M);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int j = 0; j < M; j++) cin >> B[j];
  vector<int> C = convolution(A, B);
  for (int c : C) cout << c << endl;
}

Measured memory_bytes: 19024
/*==================================
 Author : Mozaddid Babar
 Dept   : CSE, HSTU
 Email  : babar.mozaddid@gmail.com
 ===================================*/

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

// Faster I/O
#define fast ios_base::sync_with_stdio(false)

// Debug
#define dbg(x) cerr << #x << ": " << x << endl;

// DataTypes
typedef long long LL;
typedef unsigned long long LLU;
typedef long      L;
typedef int       I;
typedef float     F;
typedef double    D;
typedef char      C;

const int maxn=10001;
string s;
int main()
{
    fast;
#ifndef filein
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    // start code
    cin >> s;
    I l=s.length(), fa, fz;
    for(int i=0; ; i++){
        if(s[i]=='A') { fa=i; break; }
    }
    for(int i=l-1; ; i--){
        if(s[i]=='Z') { fz=i; break; }
    }
    cout << abs(fz-fa)+1 << endl;
    return 0;
}




Measured memory_bytes: 720
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X==500*a+100*b+50*c:
                count+=1
                
print(count)

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

typedef long long ll;

int main(){
    int h, w, ans = 0;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    for(int j=0;j<w-1;j++){
        vector<vector<int> > dp(h+1, vector<int>(h+1, INT_MAX));
        vector<vector<int> > cost(h+1, vector<int>(h+1,0));
        for(int i1=0;i1<h;i1++){
            for(int i2=0;i2<h;i2++){
                if(i1==0 || i2==0){
                    for(int k=0;k+max(i1,i2)<h;k++){
                        if(s[k+i2][j]==s[k+i1][j+1]) cost[i1][i2]++;
                    }
                }
                cost[i1+1][i2+1] = cost[i1][i2] - (s[h-1-i1][j] == s[h-1-i2][j+1] ? 1 : 0);
            }
        }
        dp[0][0] = 0;
        for(int i1=0;i1<=h;i1++){
            for(int i2=0;i2<=h;i2++){
                if(i1 < h) dp[i1+1][i2] = min(dp[i1+1][i2], dp[i1][i2]+cost[i1][i2]);
                if(i2 < h) dp[i1][i2+1] = min(dp[i1][i2+1], dp[i1][i2]+cost[i1][i2]);
            }
        }
        ans += dp[h][h];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	ll n;
	cin>>n;
	ll ans=n/2+n%2;
	cout<<ans<<endl;

	return(0);
}


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

int main()
{
    long long int n,a,b,ans=0;
    cin>>n>>a>>b;
    ans+=(n/(a+b))*a;
    n=n%(a+b);
    if(n<=a) ans+=n;
    else ans+=a;
    cout<<ans;
}

Measured memory_bytes: 3644
import sys
from pprint import pprint

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(sys.stdin.readline().strip())

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            nums = [a, b, c]
            ans += gcd_list(nums)
            
print(ans)

Measured memory_bytes: 70316
s=input()
n=len(s)
d=[]
for i in range(n):
  d.append(int(s[i]))
s1=[0]
s2=[1]
for i in range(1,n):
  if s1[i-1]==0:
    s1.append(1)
  else:
    s1.append(0)
  if s2[i-1]==1:
    s2.append(0)
  else:
    s2.append(1)
a,b=0,0
for i in range(n):
  if d[i]!=s1[i]:
    a+=1
  if d[i]!=s2[i]:
    b+=1
print(min(a,b))

Measured memory_bytes: 89464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int N, M,s[10], c[10];

int keta(int k) {

	if (k == 0) { return 1; }

	int ret = 0;

	while (k > 0) { ret++; k /= 10; }

	return ret;
}

int check(int k, int j) {

	int h = N - s[j];

	for (int i = 1; i <= h; i++) { k /= 10; }
	if ((k%10) == c[j]) { return 1; }

	return -1;
}

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> s[i] >> c[i];
	}

	int ans = -1;

	for (int k = 0; k <= 999;k++) {
		int sign = 1;
		if (keta(k) != N) { continue; }

		for (int j = 1; j <= M; j++) {
			if (check(k,j) == -1) { sign = -1; }
			//cout << "check=" << check(k, j) << endl;
		}
		//cout << k << "  " << sign << endl;
		if (sign == 1) { ans = k; break; }
	}

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

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

int N;
int L[100];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>L[i];
	}
	sort(L,L+N);
	int c=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(L[i]==L[j])continue;
			for(int k=j+1;k<N;k++){
				if(L[i]==L[k]||L[j]==L[k])continue;
				if(L[k]<L[i]+L[j])c++;
			}
		}
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3592
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N;
	cin >> N;
	vector<ll> ais(N);
	rep(i,0,N) {
		cin >> ais[i];
	}
	ll ans = numeric_limits<ll>::max();
	rep(p,0,2) {
		bool neg = (p == 0);
		ll sum = 0;
		ll ans_loc = 0;
		rep(i,0,N) {
			ll term = 0;
			if (!neg) {
				if (ais[i] + sum > 0) {
					term = ais[i];
				} else {
					term = -sum + 1;
				}
			} else {
				if (ais[i] + sum < 0) {
					term = ais[i];
				} else {
					term = -sum - 1;
				}
			}
			ans_loc += abs(term - ais[i]);
			neg = !neg;
			sum += term;
		}
		ans = min(ans, ans_loc);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024