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

int main(void){
  
  int h,w,i,j;
  cin>>h>>w;
  string c1,dc1;
  for(i=0;i<h*w;i++){
  c1+="a";
  }
  for(i=0;i<h*w;i++){
  cin>>c1.at(i);
  }
  
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      dc1+=c1.at(i*w+j);
  	}
    for(j=0;j<w;j++){
      dc1+=c1.at(i*w+j);
  	}
  }

  for(i=0;i<2*h;i++){
    for(j=0;j<w;j++){
      cout<<dc1.at(i*w+j);
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sum = 0;
    for(int i=0;i<s.size();i++)
    {
        sum += s[i]-48;
    }
    /// cout << sum << endl;
    int n;
    n = stoi(s);
    if(n%sum==0)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

}


Measured memory_bytes: 3576
#include<stdio.h>

int main(){
	int a,b,c, five, seven;
	five = 0;
	seven = 0;
	scanf("%d %d %d", &a, &b, &c);
	if(a == 5)five++;
	if(b == 5)five++;
	if(c == 5)five++;
	if(a == 7)seven++;
	if(b == 7)seven++;
	if(c == 7)seven++;
	if(five == 2 && seven == 1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

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

using namespace std;
int main(){
long long int a,b,c,d[100010],ans=0,ant=1,anu=1;
  cin >> a >> b >> c;
  
  for(int i=0;i<a;i++){
    cin >> d[i];
  }
        
  
  sort(d,d+a);
  
  ans =d[0];
  
  for(int i=1;i<a;i++){
    
    if(d[i]<=ans+c && ant<b){   
      ant++;
    }
    
    else{
      ant =1;
      anu++;
      ans = d[i];
    }
    
  }
  
  cout << anu << endl;
}
    


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a,b,c,d,ha,hb,ka,kb,i,hg,kg;
	scanf("%d%d%d%d",&ha,&hb,&ka,&kb);
	scanf("%d%d%d%d",&a,&b,&c,&d);
	hg=ha*a+(ha/10)*c+hb*b+(hb/20)*d;
	kg=ka*a+(ka/10)*c+kb*b+(kb/20)*d;
	if(hg>kg){
		printf("hiroshi\n");
	}
	else if(hg<kg){
		printf("kenjiro\n");
	}
	else{
		printf("even\n");
	}
	return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
S = input()

l = 0
c = S[0]
con = [0] if S[0] == '0' else []
for s in S:
    if c == s:
        l += 1
    else:
        con.append(l)
        l = 1
        c = s
con.append(l)
if S[-1] == '0':
    con.append(0)

lc = len(con)
if lc <= K * 2 + 1:
    print(sum(con))
else:
    tl = K * 2 + 1
    cur = sum(con[:tl])
    ans = cur
    turn = False
    for l, r in zip(con[:lc - tl], con[tl:]):
        cur -= l
        cur += r
        if turn:
            ans = max(ans, cur)
        turn = not turn
    print(ans)

Measured memory_bytes: 6132
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()

A = [0] * N; B = [0] * N
for i in range(N):
  (A[i], B[i]) = reads()
S = sum(A)

if A == B:
  print(0)
else:
  M = min(B[i] for i in range(N) if A[i] > B[i])
  print(S - M)

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

int main(){
 int n; cin >> n;
 int item[n];
 int max = 0, index = 0;
 for(int i=0; i<n; ++i){
 	cin >>  item[i];
   if(max < item[i]){
     max = item[i]; index = i;
   }
 }
  item[index] /= 2;
  int sum = 0;
  for(int i=0; i<n; ++i) sum += item[i];
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

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

    printIf(c < b/a,c,b/a)
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	unsigned long long int x,r;
	scanf("%llu",&x);
	r+=((x/11)*2);
	x%=11;
	if(7 <= x){r+=2;}
	if(1 <= x && x <= 6){r+=1;}
	printf("%llu\n",r);
	return 0;
}

Measured memory_bytes: 128
import sys
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
      if i*10000+j*5000+(n-i-j)*1000==y:
        print(*[i,j,n-i-j])
        sys.exit()
print(*[-1,-1,-1])
    


Measured memory_bytes: 2940
# ABC169 E

N=int(input())
AB=[tuple(map(int,input().split())) for _ in [0]*N]

def med(A):
    N=len(A)
    if N%2:
        return A[(N+1)//2-1]
    else:
        return (A[N//2-1]+A[N//2])/2
    
A=[i[0] for i in AB]  
B=[i[1] for i in AB]
medA=med(sorted(A))
medB=med(sorted(B))

if N%2:
    print(medB-medA+1)
else:
    print(int(2*medB-2*medA+1))

Measured memory_bytes: 133180
#include <stdio.h>
int main(){
  int n,i,j,candy,candy_max=0;
  int a[100][2];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i][0]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i][1]);
  }
  
  for(i=0;i<n;i++){
    candy=0;
    for(j=0;j<n;j++){
      if(j<=i){
        candy+=a[j][0];
      }
      if(j>=i){
        candy+=a[j][1];
      }
    }
    
    if(candy_max < candy){
      candy_max=candy;
    }
  }
  printf("%d",candy_max);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const ll m = 1234567;
const long double pi = 3.141592653589793;
int main() {
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll ans = 0;
	chmax(ans, ((n + a - 1) / a) + 4);
	chmax(ans, ((n + b - 1) / b) + 4);
	chmax(ans, ((n + c - 1) / c) + 4);
	chmax(ans, ((n + d - 1) / d) + 4);
	chmax(ans, ((n + e - 1) / e) + 4);
	cout << ans << endl;
	return 0;
}

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

int main () {
  int n;  cin >> n;
  double ans=0;
  for (int i=0;i<n;i++) {
    double x; cin >> x;
    ans += 1 / x;
  }
  cout << fixed << setprecision(6);
  cout <<  1 / ans;
}
  


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

using namespace std;

int main()
{
  int N;
  while(cin >> N, N) {
    string S;
    for(int i = 0; i < N; i++) {
      string T;
      cin >> T;
      S += T;
    }

    queue< string > que;
    map< string, int > v;
    que.emplace(S);
    v[S] = 0;

    bool flag = false;
    while(!que.empty()) {
      string p = que.front();
      int cost = v[p];
      que.pop();
      if(count(begin(p), end(p), '#') == 0) {
        cout << cost << endl;
        flag = true;
        break;
      }
      auto pos = p.find('@');
      int x = pos % N, y = pos / N;
      for(int i = -1; i <= 1; i++) {
        for(int j = -1; j <= 1; j++) {
          if(i == 0 && j == 0) continue;
          int nx = x + i, ny = y + j;
          if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
          if(p[nx + ny * N] == '#') continue;
          swap(p[nx + ny * N], p[pos]);
          string T = p;
          for(int k = 0; k < N; k++) {
            for(int l = 0; l < N; l++) {
              int ret = 0;
              for(int m = -1; m <= 1; m++) {
                for(int n = -1; n <= 1; n++) {
                  if(m == 0 && n == 0) continue;
                  int vx = k + m, vy = l + n;
                  if(vx < 0 || vy < 0 || vx >= N || vy >= N) continue;
                  ret += p[vx + vy * N] != '.';
                }
              }
              if(p[k + l * N] == '#') T[k + l * N] = ret == 2 || ret == 3 ? '#' : '.';
              else if(p[k + l * N] == '.') T[k + l * N] = ret == 3 ? '#' : '.';
            }
          }
          if(!v.count(T)) {
            v[T] = cost + 1;
            que.emplace(T);
          }
          swap(p[nx + ny * N], p[pos]);
        }
      }
    }
    if(!flag) cout << -1 << endl;
  }
}

Measured memory_bytes: 6708
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node
{
  int key;
  Node *parent, *left, *right;
};

Node *root, *nil;

void insert(int i)
{
  Node *n = (Node *)malloc(sizeof(Node));
  n->key = i;
  n->left = nil;
  n->right = nil;

  Node *node = root;
  Node *parent = nil;
  while (node != nil)
  {
    parent = node;
    if (n->key < node->key) node = node->left;
    else node = node->right;
  }
  n->parent = parent;

  if (parent == nil) root = n;
  else if (n->key < parent->key) parent->left = n;
  else parent->right = n;
}

Node *find(Node *n, int i)
{
  if (n == nil || n->key == i) return n;
  if (i < n->key) return find(n->left, i);
  else return find(n->right, i);
}

Node *getNext(Node *n)
{
  if (n->left != nil) return getNext(n->left);
  return n;
}

void del(Node *n, int i)
{
  Node *node = find(n, i);
  if (node == nil) return;

  if (node->left != nil && node->right != nil)
  {
    Node *next = getNext(node->right);
    node->key = next->key;
    del(next, next->key);
    return;
  }

  Node *p = node->parent;
  Node *l = p->left;
  Node *r = p->right;

  if (node->left == nil && node->right == nil)
    if (l == node) p->left = nil;
    else p->right = nil;
  else
  {
    Node *child = (node->left == nil) ? node->right : node->left;
    if (node == l) p->left = child;
    else p->right = child;
    child->parent = p;
  }

  free(node);
}

void preorderPrint(Node *n)
{
  if (n == nil) return;
  printf(" %d", n->key);
  preorderPrint(n->left);
  preorderPrint(n->right);
}

void inorderPrint(Node *n)
{
  if (n == nil) return;
  inorderPrint(n->left);
  printf(" %d", n->key);
  inorderPrint(n->right);
}

int main()
{
  int m, num;
  char order[7];
  scanf("%d", &m);

  for (int i = 0; i < m; i++)
  {
    scanf("%s", order);
    if (order[0] == 'p')
    {
      inorderPrint(root);
      printf("\n");
      preorderPrint(root);
      printf("\n");
    }
    else
    {
      scanf("%d", &num);
      if (order[0] == 'i') insert(num);
      else if (order[0] == 'f')
        if (find(root, num) != nil) printf("yes\n");
        else printf("no\n");
      else del(root, num);
    }
  }

  return 0;
}

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            for(int x = 1; x <= n; ++x)
            {
                if (x % 3 == 0 || x % 10 == 3 || x.ToString().Contains("3"))
                {
                    Console.Write(" {0}", x);
                }
            }

            Console.WriteLine();

        }
    }
}

Measured memory_bytes: 6420
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = list(input())
    zero, one = 0, 0
    for i in range(len(s)):
        if i%2 == 0:
            if s[i] == '1':
                zero += 1
            else:
                one += 1
        else:
            if s[i] == '1':
                one += 1
            else:
                zero += 1
    print(min(zero, one))
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9632
#include<stdio.h>

int mergesort(int A[], int left, int right, int count[]);
int merge(int A[], int left, int mid, int right, int count[]);


int main(void){
	
	int n;
	scanf("%d", &n);
	
	int S[n], i, count[1]={0};
	for(i=0; i<n; i++){
		scanf("%d", &S[i]);
	}
	
	count[0]=mergesort(S, 0, n, count);
	
	for(i=0; i<n-1; i++){
		printf("%d ", S[i]);
	}
	printf("%d\n", S[i]);
	
	printf("%d\n", count[0]);
	
	return 0;
}
int merge(int A[], int left, int mid, int right, int count[]){
	int n1, n2;
	
	n1 = mid - left;//左配列の長さ
	n2 = right - mid;//右配列の長さ
	
	/*L[0...n1], R[0...n2] を生成*/
	int L[n1], R[n2];
	int i;
	for(i = 0; i<n1; i++) {
		L[i] = A[left + i];//生成
	}
	for(i = 0; i<n2; i++) {
		R[i] = A[mid + i];//生成
	}
	int j, k;
	
	i=0;
	j=0;
	for(k=left; k<right; k++){//全体回数
		if(n1==i){
			A[k]=R[j];
			j++;
			count[0]++;
		}
		else if(n2==j){
			A[k]=L[i];
			i++;
			count[0]++;
		}
		else if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
			count[0]++;
		}
		else if(R[j] <= L[i]){
			A[k] = R[j];
			j++;
			count[0]++;
		}
	}
	return count[0];
}

int mergesort(int A[], int left, int right, int count[]) {
	int mid;
	int c;
	if(2<=right-left){
		mid=(left+right)/2;
		mergesort(A, left, mid, count);//分ける
		mergesort(A, mid, right, count);
		c=merge(A, left, mid, right, count);
	}
	return c;
}



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

int main() {
	int c1,c2,c3,c4,c5,c6,c7,c8,c9;
	cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6 >> c7 >> c8 >> c9;
	string k = "No";
	if(c1 == c4 + c3 - c6 &&
	   c2 == c5 + c3 - c6 &&
	   c8 == c5 + c7 - c4 &&
	   c9 == c6 + c7 - c4)
	{
		k = "Yes";
	}
	cout << k << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (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; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int dp[200100];

int main() {
  int n; cin >> n;
  int p[n];
  FOR(i,0,n-1) cin >> p[i];

  int ans = 0;

  FOR(i,0,n-1){
    dp[p[i]] = dp[p[i]-1] + 1;
    chmax(ans,dp[p[i]]);
  }

  cout << n-ans << endl;

}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> time(n);
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    time[i] = a*60 + b;
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    if(count(time.begin(),time.end(),a*60+b)<1){
      time.push_back(a*60+b);
    }
  }
  sort(time.begin(),time.end());
  for(int i=0;i<time.size();i++){
    if(i!=0){
      cout<<" ";
    }
    cout<<time[i]/60<<":";
    if(time[i]%60<10){
      cout<<0;
    }
    cout<<time[i]%60;
    if(i==time.size()-1){
      cout<<endl;
    }
  }
}


Measured memory_bytes: 3172
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


class CumulativeSum:
    def __init__(self, l):
        self.dp = [0] * (len(l) + 1)
        for i, v in enumerate(l):
            self.dp[i + 1] = v + self.dp[i]

    # return sum(l[left] + l[left + 1] + ... + l[right])
    def total(self, left, right):
        assert 0 <= left <= right < len(self.dp)
        return self.dp[right + 1] - self.dp[left]


def main():
    N, K = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = [max(0, a) for a in a_list]

    cs_a = CumulativeSum(a_list)
    cs_b = CumulativeSum(b_list)

    ans = -INF
    total = sum(b_list)
    for i in range(N - K + 1):
        a = max(0, cs_a.total(i, i + K - 1))
        rest = total - cs_b.total(i, i + K - 1)
        ans = max(ans, rest + a)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
template<typename T>inline void check_min(T a,T &b){if(a<b)b=a;}
namespace unbelivable
{
	const int N=1000100;
	char s[N],t[N];
	std::stack<int> stk[26];
	int n;
	bool initialize()
	{
		scanf("%d",&n);
		scanf("%s",s+1),scanf("%s",t+1);
		bool flag=1;
		for(int i=1;i<=n;i++)
			stk[s[i]-'a'].push(i),flag&=(s[i]==t[i]);
		return flag;
	}
	int a[N],b[N],tot;
	bool prework()
	{
		tot=0;

		int top=n;

		for(int i=n,j;i;i=j-1)
		{
			for(j=i;j>1 && t[j-1]==t[j];j--);

			for(int k=j+1;k<=top;k++)stk[s[k]-'a'].pop();
			check_min(j,top);

			a[++tot]=j;
			if(stk[t[j]-'a'].empty())return 0;
			b[tot]=stk[t[j]-'a'].top();

			for(int k=b[tot];k<=top;k++)stk[s[k]-'a'].pop();
			check_min(b[tot]-1,top);
		}
		std::reverse(a+1,a+tot+1);
		std::reverse(b+1,b+tot+1);

		return 1;
	}
	int work()
	{
		if(!prework())return -1;

//		for(int i=1;i<=tot;i++)printf("%d ",a[i]);printf("\n");
//		for(int i=1;i<=tot;i++)printf("%d ",b[i]);printf("\n");

		int ret=0;
		for(int i=1;i<=tot;i++)
			while(i+ret<=tot && b[i+ret]-ret<a[i])ret++;
		return ret+1;
	}
	void solve()
	{
		if(initialize()){printf("0\n");return;}
		printf("%d\n",work());
	}
}
int main()
{
	unbelivable::solve();
	return 0;
}


Measured memory_bytes: 13916
list =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(list[K-1])


Measured memory_bytes: 38256
S = input()

def judge() -> bool:
    for i in range(len(S)):
        if S[i] == 'U' or S[i] == 'D':
            continue
        elif (i+1) % 2 == 0 and S[i] != 'L':
            return False
        elif (i+1) % 2 == 1 and S[i] != 'R':
            return False
    return True

if judge():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int x = Math.abs(a-b);
    int y = Math.abs(b-c);
    int z = Math.abs(a-c);

    if (x <= d && y <= d || z <= d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }




  }
}


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

int main() {

    int A,B;

    string op;

    cin >> A >> op >> B;

    if ( op == "+" ){

        cout << A + B << endl;

    }

    else if ( op == "-" ){

        cout << A - B << endl;

    }

    else {

        cout << "error" << endl;

    }

}

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

int main(int argc, char const *argv[]) {
  int x, y;
  cin >> x >> y;
  while (!(x == 0 && y == 0)) {
    if (x < y)
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;
    cin >> x >> y;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int y = x/100;
    int z = 105*y;

    if(x <= z) {
        cout << 1;
    } 
    else {
        cout << 0;
    }

    cout << endl;
    return 0;
}

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

int N, M;
vector<vector<int> > A;

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

    A = vector<vector<int> >(N, vector<int>(M));

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            scanf("%d", &A[i][j]);
            A[i][j]--;
        }
    }

    int mn = 1e9;
    for(int i = 0; i < M; i++) {
/*
        for(int a = 0; a < N; a++) {
            for(int b = 0; b < A[a].size(); b++) {
                cout << A[a][b] << ' ';
            }
            cout << endl;
        }
//*/
        vector<int> cnt(M, 0);
        for(int j = 0; j < N; j++) {
            cnt[ A[j][0] ]++;
        }
        int mx = -1;
        int mpos;
        for(int j = 0; j < M; j++) {
            if(mx < cnt[j]) {
                mx = cnt[j];
                mpos = j;
            }
        }
        mn = min(mn, mx);
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < A[j].size(); k++) {
                if(A[j][k] == mpos) {
                    for(int a = k + 1; a < A[j].size(); a++) {
                        A[j][a - 1] = A[j][a];
                    }
                    A[j].pop_back();
                    break;
                }
            }
        }
    }
    printf("%d", mn);
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
#include <stdio.h>
#include <math.h>
#define PI 3.141592653
int main(){
  int A;
  int X;
  cin >> X >> A;
  if(X < A){
    cout << 0 << endl;
  }
  else cout << 10 << endl;

  return 0;
}



// ./compile.sh main


Measured memory_bytes: 256
from bisect import bisect_left as bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def combination(X):
    res = 0
    for i in range(N):
        j = bisect(A,X-A[i])
        res += N-j
    return res
l = 0
r = 2*10**5+1
m = (l+r)//2
for i in range(20):
    c = combination(m)
    if c < M:
        r = m
    else:
        l = m
    m = (l+r)//2
    
if combination(m) >= M:
     m += 1

S = [0]*(N+1)
for i in range(N):
    S[i]=S[i-1]+A[i]

ans = 0
for i in range(N):
    j = bisect(A,m-A[i])
    ans += A[i]*(N-j)
    ans += S[N-1]-S[j-1]
ans += (M-combination(m))*(m-1)
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> ans(n+1);
  for(int x = 1; x*x <= n; x++) {
    for(int y = 1; y*y <= n; y++) {
      for(int z = 1; z*z <= n; z++) {
        int v = x*x + y*y + z*z + x*y + x*z + y*z;
        if(v <= n) ans[v]++;
      }
    }
  }
  for(int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define all(x) (x).begin(),(x).end()
#define desc greater<int>()
#define pb(x) push_back(x)
ll gcd(ll a, ll b) { return (!a)?b:gcd(b%a,a);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
void pArr(int arr[], int s);
void pVec(vector<int> v);
bool isPrime(int x);
int binarySearch(int arr[], int l, int r, int x);
int vBinarySearch(vector<ll> v, int l, int r, ll x);
int nChoosek( int n, int k );
int mod=1e9+7;

void solve(){
    string a,b;
    cin >> a >> b;
    int ct=0;
    for (int i=0;i<a.length();i++){
        if (a.at(i)!=b.at(i)){
            ct++;
        }
    }
    cout << ct << endl;
}



int main(){
/*
    string temp;
    int t;
    cin >> t;
    getline(cin, temp);
    while (t--){
        solve();
    }
*/
    solve();
    return 0;
}


void pArr(int arr[], int s){
    for (int i=0;i<s;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
void pVec(vector<int> v){
    for (int i=0;i<v.size();i++){
        cout << v.at(i) << " ";
    }
    cout << endl;
}
bool isPrime(int x){
    if (x==1){
        return false;
    }
    if(x==2){
        return true;
    }
    for (int i=2;i<=(int)(pow(x,0.5));i++){
        if (x%i==0){
            return false;
        }
    }
    return true;
}

int vBinarySearch(vector<ll> v, int l, int r, ll x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (v.at(m) == x)
            return m;
        if (v.at(m) < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //bigger
    return r+1;
}

int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //smaller
    return r;
}

int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>
int main(){
	long long int n;
	int index = 0;
	scanf("%lld" , &n);
	char s[50];
	while(n>0){
		n--;
		s[index]=(char)'a'+n%26;
		n/=26;
		index++;	
	}
	for(int i = index - 1 ; i >= 0 ; i--){
		printf("%c" , s[i]);
	}
	
	
	return 0;
}

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

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++)
    cin>>h[i];
  vector<int> dp(n,1500000009);
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i-j<0)break;
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
	int n;
	while(cin>>n){
		int S = 0;
		
		for(int i = 0;600 - i*n != 0;i++){
			S += (i*n)*(i*n) * n;
		}
		
		cout << S << endl;
	}
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl
#define absi(a) (((a) >= 0) ? (a) : (-(a))) 

ll f(vector<ll> l, ll a, ll b, ll c) {
	ll ret = 0x7FFFFFFFFFFFFFFF;
	rep(i, l.size()) {
		rep(j, l.size()) {
			if(i == j) continue;
			rep(k, l.size()) {
				if(i == k || j == k) continue;
				ll tmp = absi(a-l[i]) + absi(b-l[j]) + absi(c-l[k]);
				if(tmp < ret) ret = tmp;
			}
		}
	}

	if(l.size() == 3) return ret;

	auto la = l;
	rep(i, l.size()) {
		repd(j, i+1, l.size()) {
			l[i] += l[j];
			l[j] = l.back();
			l.resize(l.size() - 1);

			ll tmp = 10 + f(l, a, b, c);
			if(tmp < ret) ret = tmp;

			l = la;
		}
	}

	return ret;
}

int main(int argc, const char* argv[]) {
	ll n, a, b, c;
	cin >> n >> a >> b >> c;

	vector<ll> l(n);
	rep(i, n) cin >> l[i];

	cout << f(l, a, b, c) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void) {
	double	x = 0.0, y = 0.0;
	double arg = M_PI / 2.0;
	int Arg , Len;
	while (1) {
		scanf("%d,%d", &Len, &Arg);
		if (Len == 0 && Arg == 0) {
			break;
		}
		else {
			x += cos(arg)*(double)Len;
			y += sin(arg)*(double)Len;
			arg += (-Arg % 360)*M_PI / 180.0;
			continue;
		}
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

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

#define MAX 16777217
#define L 14

int Hash[MAX];

int getChar(char);
int getKey(char*);
int find(char*);
int insert(char*);

int main(){
  int n, h;
  char order[7],str[L];

  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,order ,str);

    if(order[0] == 'i'){
      h = insert(str);
      Hash[h] = 1;
    }else{
      if(find(str)){
	puts("yes");
      }else{
	puts("no");
      }
    }
  }

  return 0;
}

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(char str[]){
  int sum = 0, p = 1, i;

  for(i = 0 ; i < (int)strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  int key = getKey(str);

  if(Hash[key]){
    return 1;
  }
  return 0;
}

int insert(char str[]){
  return getKey(str);
}

Measured memory_bytes: 38620
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 1000000
#define LL long long
#define MO 998244353
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	if(k==1) printf("0\n");
	else printf("%d\n",n-k);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int num;
  int dig;
  int sum = 0;

  scanf("%d", &num);
  int b=num;

  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  
  if(b%sum==0) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int A[10001];
int B[501];
int LinearSearch(int A[],int n1,int B[],int n2){
    int num = 0;
    for(int i=0;i<n2;i++){
        int v = B[i];
        for(int j=0;j<n1;j++){
            if(A[j]==v){
                num++;
                break;
            }
        }
    }
    return num;
}
int main()
{
    int n1,n2;
    cin>>n1;
    for(int i=0;i<n1;i++){
        cin>>A[i];
    }
    cin>>n2;
    for(int i=0;i<n2;i++){
        cin>>B[i];
    }
    int num = LinearSearch(A,n1,B,n2);
    cout<<num<<endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////

int main(){
    int n;cin>>n;
    int a[2][n];for(int i=0;i<=1;i++)for(int j=0;j<=n-1;j++)cin>>a[i][j];
    for(int i=1;i<=n-1;i++){
        a[0][i]+=a[0][i-1];
    }
    for(int i=n-2;i>=0;i--){
        a[1][i]+=a[1][i+1];
    }
    
    int ans=0;
    for(int i=0;i<=n-1;i++){
        int b=a[0][i]+a[1][i];
        if(ans<b)ans=b;
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
count = [1]
count_index = 0
for i in range(1, N):
    if A[i] > A[i-1]:
        count.append(1)
        count_index += 1
    else:
        count[count_index] += 1
for i in range(count_index + 1):
    count[i] = 1 - count[i] % 2
print(count_index + 1 - sum(count) % 2)

Measured memory_bytes: 14388
def A():
    print(int(input())**2)

def B():
    length = int(input())
    s = str(input())
    if length%2 != 0 or s[:length//2]!=s[length//2:]:
        print('No')
    else:
        print('Yes')

import math
def C():
    length = int(input())
    coords = []
    for i in range(length):
        coords.append([int(k) for k in input().split()])
    def dist(p1, p2):
        return math.sqrt((p2[0]-p1[0])**2+(p2[1]-p1[1])**2)

    distances = []
    for i in range(length):
        for j in range(i+1, length):
            distances.append(dist(coords[i], coords[j]))
    #2 for ex1, 0 for ex2
    # a, b, c, d
    # ab, ac, ad, bc, bd, cd
    m = length*(length-1)/2
    print(sum(distances)/m*(length-1))

C()

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int []a = new int[n];
		for(int b = 0; b<n ; ++b){
			a[b]=sc.nextInt();
		}
		for(int b=n-1 ; b>=0 ; --b){
			if(b!=0){
				System.out.print(a[b]+" ");
			}else{
				System.out.println(a[b]);
			}
		}
	}

}

Measured memory_bytes: 26412
#include<bits/stdc++.h>
#define ll long long

using namespace std;

set<string>q;
set<string>a[10];

int s[10];

int main()
{

    int n;
    string ss;
    scanf("%d", &n);
    while(n--)
    {
        cin>>ss;
        if(ss[0] == 'M')
            a[0].insert(ss);
        else if(ss[0] == 'A')
            a[1].insert(ss);
        else if(ss[0] == 'R')
            a[2].insert(ss);
        else if(ss[0] == 'C')
            a[3].insert(ss);
        else if(ss[0] == 'H')
            a[4].insert(ss);

    }
    ll sum = 0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                sum+=(1ll*(a[i].size()))*(1ll*(a[j].size()))*(1ll*(a[k].size()));
            }
        }
    }
    printf("%lld\n", sum);
    return 0;

}


Measured memory_bytes: 9600
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

const int limit = 50;

int n,m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v] = true;
    for(int v2 = 0; v2 < n; v2++){
        if(graph[v][v2] == false) continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}

int main(void)
{
    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < m; i++){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j = 0; j < n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for(int j = 0; j < n; j++){
            if(visited[j] == false) bridge = true;
        }
        if(bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  n <- readLn
  s <- replicateM n getLine
  m <- readLn
  t <- replicateM m getLine
  print $ max 0 (maximum (map (f s t) (nub (s++t))))
  
f xs ys z = length (filter (== z) xs) - length (filter (== z) ys)


Measured memory_bytes: 636
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>

using namespace std;
int main() {
	int n;
	int div0=0;
	int div1=0;
	int div2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		if(temp%4==0){
			div2++;
		}else if(temp%2==0){
			div1++;
		}else{
			div0++;
		}
	}
	if(div1==0){
		if(div2+1>=(div0)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(div2>=div0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}


	return 0;

}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

z = []
w = []

for x, y in xy:
    z.append(x + y)
    w.append(x - y)

ans = max(max(z) - min(z), max(w) - min(w))

print(ans)


Measured memory_bytes: 61268
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;i++)
#define rp(i,n) for(i=0;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

ll dp[110][100010];

int main()
{
    FIO;
    ll n,w,wt,val,mx,i,j;
    cin>>n>>w>>wt>>val;
    fr(i,1e5) dp[1][i]=2e9;
    dp[1][val]=wt;
    for(i=2;i<=n;i++)
    {
        cin>>wt>>val;
        fr(j,1e5) dp[i][j]=dp[i-1][j];
        for(j=val;j<=1e5;j++)
            dp[i][j]=min(dp[i][j], dp[i-1][j-val]+wt);
    }
    mx=0;
    fr(i,1e5) if(dp[n][i]<=w) mx=max(mx, i);
    cout<<mx<<endl;
    return 0;
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
int prime[1001001];
bool is_prime[1001001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i < n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j = 2*i; j < n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}
*/

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(12);

  int N;
  cin >> N;
  V<int> x(N),y(N);
  REP(i,N) cin >> x[i] >> y[i];

  V<int> cities(N);
  REP(i,N) cities[i] = i;
  double ans = 0;
  auto d = [&](int x1, int y1, int x2, int y2) -> float {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  };
  int perm_count = 0;
  do {
    REP(i,N-1) {
      int from = cities[i];
      int to = cities[i+1];
      ans += d(x[from], y[from], x[to], y[to]);
    }
    perm_count++;
  } while(next_permutation(ALL(cities)));

  ans /= perm_count;

  print(ans);
}



Measured memory_bytes: 3820
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    string S;
    cin >> S;
    
    int num1 , num2;
    num1 = atoi(S.c_str());
    num2 = num1 % 100;
    num1 /= 100;

    //cout << "num1:" << num1 <<endl;
    //cout << "num2:" << num2 << endl;

    if(num2 >= 1 && num2 <= 12){
        (num1 >= 1 && num1 <= 12) ? cout << "AMBIGUOUS" << endl : cout << "YYMM" <<endl;
    }else{
        (num1 >= 1 && num1 <= 12) ? cout << "MMYY" << endl : cout << "NA" <<endl;
    }
}


Measured memory_bytes: 256
def main2():
    t = (input().split(' '))
    t = [int(v) for v in t]
    if t[0] * 10000 < t[1]:
        print('-1 -1 -1')
        exit(0)
    for i in range(t[0] + 1):
        for j in range((t[0] + 1) - i):
            if (10000 * i) + (5000 * j) + ((t[0] - i - j) * 1000) == t[1]:
                print(i, j, (t[0] - i - j))
                exit(0)

    print('-1 -1 -1')


if __name__ == '__main__':
    main2()

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a > c)swap(a, c);
	if (b > c)swap(b, c);
	//printf("%c%c%c\n", a[0]+'A'-'a',b[0]+'A'-'a',c[0]+'A'-'a');
	//cout << (a+b)*h/2 << endl;
	printf((a==5&&b==5&&c==7) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
const int INF=1001001001;

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

	return 0;
}





Measured memory_bytes: 256
n = int(input())
alist = list(map(int,input().split()))
count = 1
broken = 0
flag = False
for i in range(0,n):
    if alist[i] == count:
        count += 1
    else:
        broken += 1

if 1 in alist:
    print(broken)
else:
    print('-1')

Measured memory_bytes: 77644
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

struct player{
	public:
		player(char a, int b, int c):dir(a), posX(b), posY(c){}
		void actU(vector<vector<char> > &table){
			if(posY-1<0){
				table[posY][posX] = '^';
				dir = '^';
				return;
			}
			if(table[posY-1][posX] == '.'){
				table[posY--][posX] = '.';
				table[posY][posX] = '^';
			}
			else table[posY][posX] = '^';
			dir = '^';
		}
		void actD(vector<vector<char> > &table){
			if(posY+1>=table.size()){
				table[posY][posX] = 'v';
				dir = 'v';
				return;
			}
			if(table[posY+1][posX] == '.'){
				table[posY++][posX] = '.';
				table[posY][posX] = 'v';
			}
			else table[posY][posX] = 'v';
			dir = 'v';
		}
		void actL(vector<vector<char> > &table){
			if(posX-1<0){
				table[posY][posX] = '<';
				dir = '<';
				return;
			}
			if(table[posY][posX-1] == '.'){
				table[posY][posX--] = '.';
				table[posY][posX] = '<';
			}
			else table[posY][posX] = '<';
			dir = '<';
		}
		void actR(vector<vector<char> > &table){
			if(posX+1>=table[0].size()){
				table[posY][posX] = '>';
				dir = '>';
				return;
			}
			if(table[posY][posX+1] == '.'){
				table[posY][posX++] = '.';
				table[posY][posX] = '>';
			}
			else table[posY][posX] = '>';
			dir = '>';
		}
		void actS(vector<vector<char> > &table){
			int progressX = 0;
			int progressY = 0;
			if(dir == '^') progressY = -1;
			else if(dir == 'v') progressY = 1;
			else if(dir == '<') progressX = -1;
			else if(dir == '>') progressX = 1;
			int sposX = posX+progressX, sposY = posY+progressY;
			while((sposX>=0&&sposX<table[0].size())&&(sposY>=0&&sposY<table.size())){
				if(table[sposY][sposX] == '*' || table[sposY][sposX] == '#'){
					if(table[sposY][sposX] == '*') table[sposY][sposX] = '.';
					break;
				}
				sposX += progressX;
				sposY += progressY;
			}
		}
		char dir;
		int posX;
		int posY;
};

void action(char act, player &p, vector<vector<char> > &table){
	switch(act){
	case 'U':
		p.actU(table);
		break;
	case 'D':
		p.actD(table);
		break;
	case 'L':
		p.actL(table);
		break;
	case 'R':
		p.actR(table);
		break;
	case 'S':
		p.actS(table);
		break;
	default:
			break;
	}

}

int main(){
	int n = 0;
	cin >> n;
	while(n--){
		int h = 0, w = 0;
		cin >> h >> w;
		vector<vector<char> > table(h, vector<char>(w, ' '));
		player p(' ', -1, -1);
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> table[i][j];
				if(table[i][j]=='^'||table[i][j]=='v'||table[i][j]=='<'||table[i][j]=='>'){
					p.dir = table[i][j];
					p.posX = j;
					p.posY = i;
				}
			}
		}
		int m = 0;
		cin >> m;
		vector<char> act(m, ' ');
		for(int i = 0; i < m; i++){
			cin >> act[i];
		}

		for(int i = 0; i < m; i++){
			action(act[i], p, table);
		}

		for(int i = 0; i < table.size(); i++){
			for(int j = 0; j < table[0].size(); j++){
				cout << table[i][j];
			}
			cout << endl;
		}
		if(n)cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s;
    cin>>s;
    if(s[5]=='1'||s[6]>='5'){
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;

static const int INF=1e9;
typedef long long ll;

bool compare_by_second(pair<ll, ll> a,pair<ll, ll> b)
{
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }    
}

int main(){
    int N,M;
    cin >> N >> M;
    int k[11];
    int s[11][11];
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s[i][j];
        }
    }
    int p[11];
    for(int i=0;i<M;i++){
        cin >> p[i];
    }
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        int res=0;
        for(int i=0;i<M;i++){
            int cnt=0;
            for(int j=0;j<k[i];j++){
                if(bit&(1<<s[i][j]-1)){
                    cnt++;
                }
            }
            if(cnt%2==p[i]) res++;
        }
        if(res==M) ans++;
    }
    cout << ans << endl;
}


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

int n,i;
double ang,deg,a[2];

int main(){
	while(1){
		for(i=0;i<2;i++){
			scanf("%d",&n);
			if(n==0)break;
			a[i]=0;
			for(ang=360;n>1;n--){
				scanf("%lf",&deg);
				ang-=deg;
				deg=deg/180*3.1415926535897932384626433832795;
				a[i]+=cos(deg/2)*sin(deg/2);

			}
			ang=ang/180*3.1415926535897932384626433832795;
			a[i]+=cos(ang/2)*sin(ang/2);
		}
		if(i==0)break;
		if(a[0]>a[1])printf("1\n");
		else if(a[0]<a[1])printf("2\n");
		else printf("0\n");

	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int odd=0;
  int four =0;
  int two =0;
  for(int i=0;i<N;i++){
    if(a[i]%4==0) four++;
    if(a[i]%2==1) odd++;
    if(a[i]%4!=0 && a[i]%2==0) two++;
  }
  if(two>0){
    if(four>=odd) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(four+1>=odd) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 640