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

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		
		while(true){
			int n = s.nextInt();
			int x = s.nextInt();
			
			if(n == 0 && x == 0) break;
			
			int counter = 0;
			
			for(int i = 1; i <= n-2; i++){
				for(int j = i + 1; j <= n-1; j++){
					for(int k = j + 1; k <= n; k++){
						if((i + j + k ) == x && i != j && j != k && k != i){
							counter ++;	
						}
					}
				}
			}
			System.out.println(counter);
		}
		s.close();
	}

}



Measured memory_bytes: 26604
import java.util.*

fun main(args: Array<String>) {

    val s = readLine()!!.split(" ").map { it.toLong() }
    val x = s[0]
    val y = s[1]
    val list = mutableListOf<Long>()
    var now = x
    while(true) {
        if (now > y) break
        list.add(now)
        now = now * 2;
    }
    println(list.size)
}

Measured memory_bytes: 37824
#include <stdio.h>

int main(void)
{
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);

    long long A[100][100], B[100][100], C[100][100] = {0};

    int i, j;
    for(i = 0; i < n; ++i)
    {
        for(j = 0; j < m; ++j)
        {
            scanf("%lld", &A[i][j]);
        }
    }

    for(i = 0; i < m; ++i)
    {
        for(j = 0; j < l; ++j)
        {
            scanf("%lld", &B[i][j]);
        }
    }

    int k;
    for(i = 0; i < n; ++i)
    {
        for(j = 0; j < m; ++j)
        {
            for(k = 0; k < l; ++k)
            {
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }

    for(i = 0; i < n; ++i)
    {
        for(j = 0; j < l; ++j)
        {
            printf("%lld%s", C[i][j], j + 1 != l ? " " : "\n");
        }
    }

    return 0;
}

Measured memory_bytes: 844
#include <stdlib.h>
#include <string.h>
#include <iostream>

const int maxn = 500 + 5;
int mp[maxn][maxn], vis[maxn];
int match[maxn];
int n;

struct node {
	int a, b;
} p[105], q[105];

int Find(int x)
		{
	for (int i = 1; i <= n; i++)
		if (!vis[i] && mp[i][x])
				{
			vis[i] = 1;
			if (match[i] == -1 || Find(match[i]))
					{
				match[i] = x;
				return 1;
			}
		}
	return 0;
}

int main(void) {
	std::cin >> n;
	memset(mp, 0, sizeof(mp));
	memset(match, -1, sizeof(match));
	for (int i = 1; i <= n; i++)
		std::cin >> p[i].a >> p[i].b;
	for (int i = 1; i <= n; i++)
		std::cin >> q[i].a >> q[i].b;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (p[i].a < q[j].a && p[i].b < q[j].b)
				mp[i][j] = 1;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		if (Find(i))
			ans++;
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d",&a,&b);
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d && c>=e)
        printf("%d",c);

    else if(d>=e && d>=c)
        printf("%d",d);

    else if(e>=c && e>=d)
        printf("%d",e);
        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;


int main(){
  int n; cin>>n;
  vector<int> a(n);
  vector<int> p(n);
  vector<int> q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  rep(i,n) a[i]=i+1;
  // ☆昇順の配列の階上を全列挙
  int A,B;
  int c=0;
  do{
    c++;
    bool f=1;
    rep(i,n){
      if(a[i]!=p[i]){
        f=0;
        break;
      }
    }
    if(f) A=c;
    f=1;
    rep(i,n){
      if(a[i]!=q[i]){
        f=0;
        break;
      }
    }
    if(f) B=c;
  }while(next_permutation(a.begin(),a.end()));

  A=abs(A-B);
  cout<<A<<endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, x = 4.times.map { gets.to_i }

count = 0

(0..a).each do |k|
  (0..b).each do |j|
     (0..c).each do |l|
       count += 1 if x == 500*k+ 100*j + 50*l
     end
  end
end

puts count

Measured memory_bytes: 1788
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        char x;
        cin>>x;
        cout<<char(x+1);
    }
    return 0;
}

Measured memory_bytes: 256
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf 1e9 + 1
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define MAX 3000
 
int dp[MAX+1][MAX+1];
string getLCS(string& s, string& t, int len)
{
        string LCS;
        int i = 0, j = 0;
        while(len > 0)
        {
            if(s[i] == t[j])
            {
                LCS.push_back(s[i]);
                i++;
                j++;
                len--;
            }
            else
            {
                if(dp[i][j+1] > dp[i+1][j])
                    j++;
                else i++;
            }
        }
        return LCS;
}
 
int lenLCS(string& s, string& t, int i, int j)
{
        if(i >= s.length() || j >= t.length())
            return 0;
        
        if(dp[i][j] != -1)
            return dp[i][j];
 
        if(s[i] == t[j])
            return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
        else 
        {
            return dp[i][j] = max(lenLCS(s,t,i,j+1), lenLCS(s,t,i+1,j));
        }
}
 
string solve(string s, string t)
{
        memset(dp, -1, sizeof dp);
        int len = lenLCS(s,t,0,0);
        return getLCS(s,t,len);
}
 
int main() {
    string s, t;
    cin >> s >> t;
    cout << solve(s, t);
}

Measured memory_bytes: 39252
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7


class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y]


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, input().split())
        uf.union(a, b)
    for i in range(N):
        uf.find(i)
    print(len(set(uf.parents))-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 81900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a,b,c,d,ac,bd,ad,bc;
  cin >> a >> b >> c >> d;
  ac=a*c;
  bd=b*d;
  ad=a*d;
  bc=b*c;
  
  cout << max({ac,bd,ad,bc}) << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	int X = 0;
	int Y = 0;

	cin >> X;
	cin >> Y;


	if (X >= 1 && Y <= 100 && (Y % 2) == 0) {
		Y /= 2;
		cout << X + Y << endl;
	}
	else {
		cout << "error" << endl;
	}

	

}

Measured memory_bytes: 256
ny = list(map(int,input().split()))
n = ny[0]
y = ny[1]

ans = [-1, -1, -1]
for i in range(n+1):
	for j in range(n+1):
		tmp = 10000*i + 5000*j + 1000*(n - i - j)
		if tmp == y and (n - i - j) >= 0:
			ans[0] = i
			ans[1] = j
			ans[2] = n - i - j
			break
			

print(" ".join(list(map(str, ans))))


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

int main(){
    int a, b ,c;
    cin >> a >> b >> c;

    int cnt = 0;
    for(int i = 0; i < 100; i++){
        if(a%2!=0 || b%2!=0 || c%2!=0){
            cout << cnt << endl;
            return 0;
        }

        int a_even = a/2, b_even = b/2, c_even = c/2;
        a = b_even+c_even;
        b = c_even+a_even;
        c = a_even+b_even;
        cnt++;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
N, T = gets.split.map(&:to_i)

ts = gets.split.map(&:to_i)

res = T
last_push_t = 0
ts.each do |t|
  t_diff = t - last_push_t
  rest_time = [0, T - t_diff].max
  last_push_t = t
  res += T - rest_time
end

puts res

Measured memory_bytes: 19844
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main()
{
	ll n, m, d;
	cin>>n>>m>>d;
	double ans;
	if(d>0){
		ans=2.0*((double)n-(double)d)*((double)m-1)/(double)n/(double)n;
	}else{
		ans=((double)m-1)/(double)n;
	}
	printf("%.8lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<vector<int>> graph(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }

  set<int> s;
  s.insert(0);
  s.insert(graph[0][0]);

  auto f = [&](int next, vector<int> &ans){
    while(1){
      int v = next;
      bool flag = true;
      for(auto u : graph[v]){
        if(!s.count(u)){
          flag = false;
          next = u;
        }
      }
      if(flag) break;
      ans.emplace_back(next);
      s.insert(next);
    }
  };

  vector<int> ri;
  ri.emplace_back(0);

  vector<int> le;
  le.emplace_back(graph[0][0]);
  f(0, ri);

  f(graph[0][0], le);

  cout << ri.size()+le.size() << "\n";
  RREP(i, le.size()){
    cout << le[i]+1 << " ";
  }
  REP(i, ri.size()){
    cout << ri[i]+1; SPBR(i, ri.size());
  }


  return 0;
}

Measured memory_bytes: 11380
#include <iostream>
using namespace std;
int main(){
  int N, T, min=1001;
  cin >> N >> T;
  for(int i=0; i<N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T && c < min){
      min = c;
    }
  }
  if(min == 1001)
    cout << "TLE" << endl;
  else
    cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
a = [*0..9]
n, k = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)
a = (a - d).map(&:to_s)
x = n
loop{
    if x.to_s.split('') - a == []
        p x
        break
    end
    x += 1
    }

Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        string s = sc.Next();

        bool ok = true;
        if (s.Where(c => c == '-').Count() != 1)
        {
            ok = false;
        }
        if (s.IndexOf('-') != a)
        {
            ok = false;
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main() {
    char str;
    int count[26] = {0};

    while(cin >> str) {
		if (islower(str)) count[str - 'a']++;
		if (isupper(str)) count[str - 'A']++;
    }
    
    for(int i=0;i<26;i++){
        cout << (char)('a'+i) << " : " << count[i] << endl;
    }
}


Measured memory_bytes: 3076
def collatz(num):
    if num % 2 == 0:
        return num // 2
    elif num % 2 == 1:
        return num * 3 + 1

n = int(input())
collatz_list = [n]

for i in range(10**6):
    n = collatz(n)
    if not n in collatz_list:
        collatz_list.append(n)
    else:
        print(i+2)
        break

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

int bubbleSort(vector<int> *A, int N)
{
    int change_count = 0;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int j = N - 1; j > 0; j--)
        {
            if (A->at(j) < A->at(j - 1))
            {
                swap(A->at(j), A->at(j - 1));
                flag = true;
                change_count++;
            }
        }
    }
    return change_count;
}
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    int change = bubbleSort(&A, n);
    cout << A[0];
    for (int i = 1; i < n; i++)
    {
        cout << " " << A[i];
    }
    cout << "\n"
         << change << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1005;
int n, a, b, c, d, dp[N][N], fac[N * N], ifac[N * N], lol[N][N];
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
void rem(int &x, int y) {
	x -= y;
	if (x < 0) x += mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fpow(int a, int p) {
	if (!p) return 1;
	int tmp = fpow(a, p >> 1);
	tmp = mul(tmp, tmp);
	if (p & 1) tmp = mul(tmp, a);
	return tmp;
}
int inv(int a) {
	return fpow(a, mod - 2);
}
int C(int n, int k) {
	if (n < k || k < 0) return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c >> d;
	fac[0] = ifac[0] = 1;
	fw (i, 1, N * N) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		ifac[i] = inv(fac[i]);
	}
	
	fw (i, 1, N) fw (j, 1, N) {
		lol[i][j] = mul(fac[i * j], inv(fpow(fac[j], i)));
		lol[i][j] = mul(lol[i][j], inv(fac[i]));
//		if (i < 5 && j < 5) cout << "lol[" << i << "][" << j << "] = " << lol[i][j] << "\n";
	}
	
	dp[0][0] = 1;
	
	fw (i, 1, b + 1) fw (j, 0, n + 1) {
		add(dp[i][j], dp[i - 1][j]);
		if (i >= a) {
			fw (k, c, d + 1) {
				if (j - k * i < 0) continue;
				add(dp[i][j], mul(dp[i - 1][j - k * i], mul(C(n - j + k * i, k * i), lol[k][i])));
			}
		}
//		cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << "\n";
	}
	cout << dp[b][n];
	return 0;
}

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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new DoublyLinkedList();

            var n = int.Parse(Console.ReadLine());

            for(var i = 0; i < n; ++i)
            {
                var ops = Console.ReadLine().Split(' ');
                switch(ops[0])
                {
                    case "insert":
                        list.Insert(int.Parse(ops[1]));
                        break;
                    case "delete":
                        list.Delete(int.Parse(ops[1]));
                        break;
                    case "deleteFirst":
                        list.DeleteFirst();
                        break;
                    case "deleteLast":
                        list.DeleteLast();
                        break;
                }
            }
            list.Print();
        }
    }

    internal class DoublyLinkedList
    {
        private int[] _list = new int[2000000];
        private int First { set; get; }
        private int Last { set; get; }

        public DoublyLinkedList()
        {
            First = _list.Length;
            Last = _list.Length - 1;
        }

        internal void Insert(int v)
        {
            First--;
            _list[First] = v;
        }

        internal void Delete(int v)
        {
            if (_list[First] == v)
            {
                DeleteFirst(); return;
            }
            for(var i = First + 1; i <= Last; ++i)
            {
                if(_list[i] == v)
                {
                    _list[i] = -1;
                    if (i == Last) DeleteLast();
                    break;
                }
            }
        }

        internal void DeleteFirst()
        {
            First++;
        }

        internal void DeleteLast()
        {
            Last--;
        }

        public void Print()
        {
            var isOut = false;
            for(var i = First; i <= Last; ++i)
            {
                var v = _list[i];
                if (v >= 0)
                {
                    if (isOut) Console.Write(" ");
                    Console.Write(v);
                    isOut = true;
                }
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 23984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
	ll N, ans,buf;
	ans = 0;
	map<char, ll> chara;
	string s;
	char march[5] = { 'M','A','R','C','H' };
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		chara[s[0]]++;
	}
	for (int i = 0; i < (1 << 5); i++) {
		buf = 1;
		if (__builtin_popcount(i) == 3) {
			for (int j = 0; j < 5; j++) {
				if(i>>j&1)buf *= chara[march[j]];
			}
		}
		else {
			continue;
		}
		ans += buf;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
"use strict";
function main(input) {
  let a1 = input[0].trim().split(" ");
  let a2 = input[1].trim().split(" ");
  let a3 = input[2].trim().split(" ");
  let n = parseInt(input[3]);
  let b = [];

  for(let i=0;i<n;i++){
    b[i] = parseInt(input[i+4]);
  }

  let a = [[{},{},{}],[{},{},{}],[{},{},{}]];

  for(let i=0;i<3;i++){
    a[0][i].value = parseInt(a1[i]);
    a[1][i].value = parseInt(a2[i]);
    a[2][i].value = parseInt(a3[i]);
  }

  for(let i=0;i<3;i++){
    for(let j=0;j<3;j++){
      a[i][j].flag = false;
    }
  }

  for(let k=0;k<n;k++){
    for(let i=0;i<3;i++){
      for(let j=0;j<3;j++){
        if(a[i][j].value===b[k]){
          a[i][j].flag = true;
        }
      }
    }
  }

  let flag = false;

  if((a[0][0].flag===true) && (a[1][1].flag===true) && (a[2][2].flag===true)){
    flag = true;
  }else if((a[0][2].flag===true) && (a[1][1].flag===true) && (a[2][0].flag===true)){
    flag = true;
  }

  for(let i=0;i<3;i++){
    if((a[i][0].flag===true) && (a[i][1].flag===true) && (a[i][2].flag===true)){
      flag = true;
    }
    if((a[0][i].flag===true) && (a[1][i].flag===true) && (a[2][i].flag===true)){
      flag = true;
    }
  }
  flag?console.log("Yes"):console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 21064
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int main() {
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        map<int, Int> of;
        vector<int> ids;
        int c = 0;
        rep (_, n) {
            int id, p, q;
            scanf("%d%d%d", &id, &p, &q);
            ids.push_back(id);
            of[id] += (Int)p*q;
        }
        rep (i, n) if (of[ids[i]] >= 1000000) {
            printf("%d\n", ids[i]);
            of[ids[i]] = 0;
            c++;
        }
        if (c == 0) puts("NA");
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

long pmod(long n, long r, long mod) {
  if (r == 0) return 1;
  long t = pmod(n, r / 2, mod);
  t = (t * t) % mod;
  if (r % 2 == 1)
    t = (t * n) % mod;
  return t;
}

long comb_mod(long n, long k, long mod) {
  long m = 1, d = 1;
  for (int i = 0; i < k; i++) {
    m = (m * (n - i)) % mod;
    d = (d * (i + 1)) % mod;
  }
  d = pmod(d, mod - 2, mod);
  return (m * d) % mod;
}

int main() {
  long n, a, b;
  cin >> n >> a >> b;
  long mod = pow(10, 9) + 7;
  long sum = pmod(2, n, mod) - 1 - comb_mod(n, a, mod) - comb_mod(n, b, mod);
  while (sum < 0)
    sum += mod;
  sum %= mod;
  cout << sum << endl;
  
  return 0;
}

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

int main(){
  int N, M;
  int i, j, k, ans;

  scanf("%d %d", &N, &M);
  long long int H[N+1];
  int flag[N+1];
  flag[0] = 0;
  for(i=1; i<N+1; i++)flag[i]=1;
  for(i=1; i<N+1; i++){
    scanf("%lld", &H[i]);
  }
  for(i=0; i<M; i++){
    scanf("%d %d", &j, &k);
    if(H[j] > H[k]){
      flag[k] = 0;
    }else if(H[j] < H[k]){
      flag[j] = 0;
    }else{
      flag[j] = flag[k] = 0;
    }
  }
  ans = 0;
  for(i=0; i<N+1; i++){
    //printf(" %d\n", flag[i]);
    if(flag[i] == 1)ans++;
  }

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

}

Measured memory_bytes: 2868
import java.util.Scanner;
// B
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int max=0,cnt=0;
		String str=scn.next();
		for(int i=0;i<str.length();i++) {
			if(str.charAt(i)=='A'||str.charAt(i)=='T'||str.charAt(i)=='C'||str.charAt(i)=='G') {
				cnt=1;
				for(int j=i+1;j<str.length();j++) {
					if(str.charAt(j)=='A'||str.charAt(j)=='T'||str.charAt(j)=='C'||str.charAt(j)=='G') {
						cnt++;
					}else {
						break;
					}
				}
				if(max<cnt) {
					max=cnt;
				}
			}
			
			//System.out.println(max);
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23764
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
for i in range(N-1 , 0, -1):
    # print(i)
    if H[i] - H[i-1] < -1:
        print('No')
        break
    elif H[i] - H[i-1] == -1:
        H[i-1] += -1
    if i == 1:
        print('Yes')

Measured memory_bytes: 14252
#include <stdio.h>
typedef unsigned int uint;

inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}
#define H 200000
uint v[H] __attribute__((aligned(64)));
int main(void){
    const uint h = gl();
    gl();
    const uint n = gl();
    for(uint i=0; i<H; i++){ v[i] = 0xffffff; }
    for(uint i=0; i<n; i++){
        const uint x = gl()-1;
        const uint y = gl()-1;
        v[x] = y<v[x] ? y : v[x];
    }
    uint right = 0;
    for(uint x=1; x<h; x++){
        const auto b = v[x];
        const auto r = right+1;
        if(b<r){
            printf("%d\n", x);
            return 0;
        }else if(b>r){
            right=r;
        }
    }
    printf("%d\n", h);
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	string s;
	int ans=0;
	cin>>s;
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
a,b,q = map(int, input().split())

sl = [int(input()) for _ in range(a)]
tl = [int(input()) for _ in range(b)]
xl = [int(input()) for _ in range(q)]

for x in xl:
    ans = 10**11

    curr_dist = 0
    ind_s = bisect.bisect_left(sl, x)
    ind_t = bisect.bisect_left(tl, x)
    
    for next_s in [ind_s, ind_s-1]:
        if 0 <= next_s < a:
            curr_dist = abs(x-sl[next_s])
            curr_pos = sl[next_s]
            ind_t2 = bisect.bisect_left(tl, curr_pos)
            if ind_t2 == 0:
                curr_dist += abs(tl[0] - curr_pos)
            elif ind_t2 == b:
                curr_dist += abs(tl[b-1] - curr_pos)
            else:
                curr_dist += min( abs( tl[ind_t2-1] - curr_pos), abs(tl[ind_t2]-curr_pos))
            ans = min(curr_dist, ans)


    for next_t in [ind_t, ind_t-1]:
        if 0 <= next_t < b:
            curr_dist = abs(x-tl[next_t])
            curr_pos = tl[next_t]
            ind_s2 = bisect.bisect_left(sl, curr_pos)
            if ind_s2 == 0:
                curr_dist += abs(sl[0] - curr_pos)
            elif ind_s2 == a:
                curr_dist += abs(sl[a-1] - curr_pos)
            else:
                curr_dist += min( abs( sl[ind_s2-1] - curr_pos), abs(sl[ind_s2]-curr_pos))
            ans = min(curr_dist, ans)

    print(ans)

Measured memory_bytes: 95448
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

signed main()
{
	int N, M;cin>>N>>M;
	vi A(M);
	rep(i,M)cin>>A[i];
	rep(i,M)N-=A[i];
	if (N<0)cout<<-1<<endl;
	else cout<<N<<endl;
}




Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    REP(i,s.size()) cout<<'x';
    cout<<endl;
}


Measured memory_bytes: 256
using System;

namespace SortingThreeNumbers
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input = Console.ReadLine();

			char[] CharSeparators = new char[] {' '};
			string[] array = input.Split(CharSeparators);

			Array.Sort(array);
			Console.WriteLine (array[0]+" "+array[1]+" "+array[2]);
		}
	}
}

Measured memory_bytes: 6376
#include <cstdio>
#include <iostream>
#include <algorithm>



int main() {
  int a;
  scanf("%d ", &a);
  while (a) {
    int count = 0;
    int b = 1;
    for (int n = 100; n >=2; n--) {
      while (n*(2*b+n-1) / 2<a) {
        b++;
      }
      if (n*(2*b + n-1) / 2 == a)
        count++;

    }
    printf("%d\n", count);
    scanf("%d", &a);

  }
  return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
int main() {
	int x, y;
	while (1) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x < y) {
			printf("%d %d\n", x, y);
		}
		else {
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int> > hw(h+1,vector<int>(w+1,0));
  int all=0;
  for(int i=0;i<h;i++){
    int tmp=0;
    for(int j=0;j<w;j++){
      cin>>hw[i][j];
      tmp+=hw[i][j];
      all+=hw[i][j];
    }
    hw[i][w]=tmp;
  }
  hw[h][w]=all;
  for(int i=0;i<w;i++){
    int tmp=0;
    for(int j=0;j<h;j++){
      tmp+=hw[j][i];
    }
    hw[h][i]=tmp;
  }

  for(int i=0;i<h+1;i++){
    for(int j=0;j<w+1;j++){
      cout<<hw[i][j];
      if(j!=w)cout<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3200
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int main(){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long ret=mod*mod;
     
    for(int i=2;i<400000;i++){
        long long t=0;
        long long tmp=a;
        while(tmp){
            t+=tmp%i;
            tmp/=i;
        }
        if(t==b)ret=min(ret,(long long)i);
    }
    long long g=a-b;
    if(g==0)ret=min(ret,b+1);
    if(g>0){
        for(long long i=1;i*i<=g;i++){
            if(g%i)continue;
            long long A=i;
            long long X=g/i+1;
            long long B=b-A;
            if(0<=A&&A<X&&0<=B&&B<X){
                ret=min(ret,X);
            }
            A=g/i;
            X=i+1;
            B=b-A;
            if(0<=A&&A<X&&0<=B&&B<X){
                ret=min(ret,X);
            }
        }
    }
    if(ret>=mod*mod)ret=-1;
    printf("%lld\n",ret);
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define x first
#define y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7, MAX_FACT = 1e6 + 10;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 ) a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 ) return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 ) return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
   return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
   if ( x == 1 )
	   return 0;
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
		   return 0;
	return 1;
}

ll fact[ MAX_FACT ];

void initfact()
{
	fact[ 0 ] = 1;
	FOR( i, 1, MAX_FACT )
	{
		fact[ i ] = MUL( fact[ i - 1 ], i );
	}
}

ll CHOOSE( ll n, ll k )
{
	return DIV( fact[ n ], MUL( fact[ k ], fact[ n - k ] ) );
}

const int MAXN = 2e5 + 10;

int n, k;
ll A[ MAXN ];

int main()
{
   ios_base::sync_with_stdio( false );
   cin.tie( 0 );
   initfact();
   
	cin >> n >> k;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
	}

	sort( A, A + n );
	ll maxi = 0, mini = 0;
	FOR( i, 0, n )
	{
		if ( n - i - 1 >= k - 1 )
			mini = ADD( mini, MUL( CHOOSE( n - i - 1, k - 1 ), A[ i ] ) );
		if ( i >= k - 1 )
			maxi = ADD( maxi, MUL( CHOOSE( i, k - 1 ), A[ i ] ) );
	}
	
	cout << SUB( maxi, mini ) << "\n";
   return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
typedef set<int>s;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
/*note

*/
int main()
{
    int ar[5],ans;
    fr(i,0,5){cin>>ar[i]; if(ar[i]==0)ans=i;}
    cout<<ans+1<<endl;




}


Measured memory_bytes: 3592
n,m = map(int,input().split())

x = []
y = []

for _ in range(n):
    a,b = map(int,input().split())
    x.append((a,b))

for _ in range(m):
    c,d = map(int,input().split())
    y.append((c,d))

for i in range(n):
    ans = []
    for j in range(m):
        ans.append(abs(x[i][0]-y[j][0]) + abs(x[i][1]-y[j][1]))
    ind = ans.index(min(ans))
    print(ind + 1)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n,-1); }

  int root(int x){
    if(par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  bool merge(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  int N,K,L;
  cin >> N >> K >> L;
  UnionFind uf1(N),uf2(N);
  for(int i=0; i<K; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    uf1.merge(a,b);
  }
  for(int i=0; i<L; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    uf2.merge(a,b);
  }
  map<P,int> mp;
  for(int i=0; i<N; i++){
    P p;
    p = make_pair(uf1.root(i),uf2.root(i));
    mp[p]++;
  }
  for(int i=0; i<N; i++){
    P p;
    p = make_pair(uf1.root(i),uf2.root(i));
    cout << mp[p];
    if(i != N-1){
      cout << " ";
    }else{
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 13568
from collections import Counter
import copy
from itertools import combinations


def A(x):
  return 1000 - x % 1000 if x % 1000 != 0 else 0


def B(n, ss):
  keys_values = Counter(ss)
  orders = ['AC', 'WA', 'TLE', 'RE']
  for order in orders:
    if order in keys_values:
      print("{} x {}".format(order, keys_values[order]))
    else:
      print("{} x {}".format(order, 0))


def _get_num_black(c_list, r_list, h, w, g):
  num_black = 0
  for i in range(h):
    if i in r_list:
      continue
    for j in range(w):
      if j in c_list:
        continue
      num_black += (1 if g[i][j] == '#' else 0)
  return num_black


def C(h, w, k, g):

  num_choice = 0
  for i in range(k + 1):
    for j in range(k - i + 1):
      comb_c = list(combinations(range(w), j))
      comb_r = list(combinations(range(h), i))
      for c_list in comb_c:
        for r_list in comb_r:
          num_black = _get_num_black(c_list, r_list, h, w, g)
          if num_black == k:
            num_choice += 1
          print(h, i, r_list, w, j, c_list, num_black, k)
  return num_choice


def C2(H, W, K, g):
  """All copied."""
  c = []
  for i in range(H):
    c.append([])
    for j in range(W):
      c[i].append(g[i][j])

  ans = 0
  for h in range(H + 1):
    for w in range(W + 1):
      for h2 in combinations(list(range(H)), h):
        for w2 in combinations(list(range(W)), w):
          paint = copy.deepcopy(c)
          for h3 in h2:
            for i in range(W):
              paint[h3][i] = "r"
          for i in range(H):
            for w3 in w2:
              paint[i][w3] = "r"
          count_black = 0
          for i in range(H):
            count_black += paint[i].count("#")
            #print(count_black,paint[i])
          if count_black == K:
            ans += 1

  return ans


def C3(H, W, K, g):
  """Change the calculation of count_black."""
  c = []
  for i in range(H):
    c.append([])
    for j in range(W):
      c[i].append(g[i][j])

  ans = 0
  for h in range(H + 1):
    for w in range(W + 1):
      for h2 in combinations(list(range(H)), h):
        for w2 in combinations(list(range(W)), w):
          if _get_num_black(w2, h2, H, W, c) == K:
            ans += 1

  return ans


def main():
  h, w, k = map(int, input().split())
  g = []
  for i in range(h):
    g.append(input())
  print(C3(h, w, k, g))


if __name__ == '__main__':
  main()


Measured memory_bytes: 9636
#include<iostream>
#include<map>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    int count = 0;
    map<int, int> mp;
    int menu = 0;
    for (int i = 1; i < 31; i++){
        mp[i] = 0;
    }
    
    for (int l = 0; l < n; l++){
        int k; cin >> k;
        for (int i = 0; i < k; i++){
            cin >> menu;
            mp[menu] = mp[menu] + 1;
        }
    }
    
    for (int i = 0; i < 30; i++){
        if (mp[i+1] == n){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;

	vector<int> v;
	int c = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		c += t;
		v.push_back(t);
	}
	int res = 0x3f3f3f3f;
	int t = 0;
	for (int i = 0; i < n - 1; i++) {
		t += v[i];
		res = min(res, abs(c - t - t));
	}
	cout << res << endl;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N], dp[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	memset(dp, 31, sizeof dp);
	dp[1] = 0;
	for(int i = 2; i <= n; i ++)
	{
		dp[i] = min(dp[i], min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2])));
	}
	cout << dp[n] << '\n';



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

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

using namespace std;

int main(){
  int n,m,x;cin>>n>>m>>x;
  int l=0,r=0;
  rep(i,m){
    int t;cin>>t;
    if(t<x){
      l++;
    }else{
      r++;
    }
  }

//  cout<<l<<' '<<r<<endl;  
  cout<<min(l,r);  

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int H,W;
int i,j;
while(1){
scanf("%d %d",&H,&W);
if(H==0 && W==0){break;}
for(j=0;j<W;j++){
	printf("#");
}
printf("\n");
for(i=0;i<H-2;i++){
	printf("#");
	for(j=0;j<W-2;j++){
		printf(".");
	}
	printf("#\n");
}
for(j=0;j<W;j++){
	printf("#");
}
printf("\n\n");
}

	return 0;
}

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

int main(){
  string b;
  cin >> b;
  if(b == "A")cout << "T";
  if(b == "T")cout << "A";
  if(b == "C")cout << "G";
  if(b == "G")cout << "C";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int N, tmp=1;
    std::string ans = "Yes";
    std::cin >> N;

    for (int i=0; i<N; ++i){
        int h;
        std::cin >> h;
        if (tmp < h){
            tmp = h - 1;
        } else if (tmp > h){
            ans = "No";
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3596
K = int(input())

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


if A[-1] != 2:
    print(-1)
    exit()

big = 2
small = 2
for i in reversed(range(K)):
    """
    smallのときにai人組つくると脱落者なし
    bigのときにai人組作るとai-1人脱落

    """


    # smallは元のsmall以上かつ、脱落者なし
    small = ((small - 1) // A[i] + 1) * A[i]
        
    # bigは元のbig以上かつ、脱落者がai-1
    big = (big // A[i]) * A[i] + A[i] - 1

    if big < small:
        print(-1)
        exit()


print(small, big)


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

using namespace std;

vector<int> apply(vector<int> p, vector<int> q) {
  int n = (int) p.size();
  assert(n == (int) q.size());
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = p[q[i]];
  }
  return ret;
}

vector<int> power(vector<int> p, long long e) {
  int n = (int) p.size();
  vector<int> ret(n);
  iota(ret.begin(), ret.end(), 0);
  while (e > 0) {
    if (e & 1) {
      ret = apply(ret, p);
    }
    p = apply(p, p);
    e >>= 1;
  }
  return ret;
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<int> d(n - 1);
  for (int i = 0; i + 1 < n; i++) {
    d[i] = x[i + 1] - x[i];
  }
  int m;
  long long k;
  cin >> m >> k;
  vector<int> a(m);
  vector<int> p(n - 1);
  iota(p.begin(), p.end(), 0);
  for (int i = 0; i < m; i++) {
    int y;
    cin >> y;
    y--;
    swap(p[y], p[y - 1]);
  }
  vector<int> q = power(p, k);
  vector<long long> ans(n);
  ans[0] = x[0];
  ans[n - 1] = x[n - 1];
  for (int i = 0; i < n - 1; i++) {
    ans[i + 1] = ans[i] + d[q[i]];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 4184
#include <stdio.h>
int main(void)
{
    int S,h,m,s;
    scanf("%d",&S);
    h = S/3600;
    m = (S-3600*h)/60;
    s = S-(3600*h+60*m);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

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

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const vector<T>& v){
  for(const T& t: v)
  cout << t << " ";
  cout << "\n";
}
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<int> a(n),b(n);
  rep(i,n){
    a[i]=i+1; b[i]=n-i;
    a[i]*=n;  b[i]*=n;
  }
  rep(i,n){
    int p; cin >>p;
    a[p-1]+=i;
  }
  print(a);
  print(b);
}


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

int main(void) {
  char s[100];
  char t[100];
  int leng1;
  int leng2;
  int judge = 1;
  scanf("%s", s);
  scanf("%s", t);
  leng1 = strlen(s);
  leng2 = strlen(t);
  for(int i = 0; i < leng1; i++) {
    if(s[i] != t[i]) {
      judge = 0;
    }
  }
  if(judge == 1 && leng2 - leng1 == 1) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


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

int main() {
  int N,M;
  int ans = 0;

  cin >> N >> M;
  for(int i=N;i<=M;++i){
      if(i / 10000 == i % 10 && i / 1000 % 10 == i % 100 / 10) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main() {
	let nk = read_line().split_whitespace().map(|e|e.parse().unwrap()).collect::<Vec<i32>>();
	let mut l = read_line().split_whitespace().map(|e|e.parse().unwrap()).collect::<Vec<i32>>();
	l.sort_by(|a,b|b.cmp(a));
	let e = nk[1] as usize;
	let l = &l[0..e];
	let mut c = 0;
	for i in l.iter() {
		c+=*i;
	}
	println!("{}",c);

}


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

int main()
{
    int a;
    cin >> a;
    
    int d = a/100;
    int e = (a%100)%10;
    
    if(d==e)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}




Measured memory_bytes: 3088
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


vector<vector<int>> v(200020);
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int ans = 0;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        if(i%2==0 && a%2)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 7776