akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

typedef long long li;

// const int mod = 1e9 + 7, inv2 = mod + 1 >> 1;
// inline int Add(int x) { return x >= mod ? x - mod : x; }
// inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
// inline int Sub(int x) { return x < 0 ? x + mod : x; }
// inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
// inline int Mul(int x, int y) { return (li)x * y % mod; }

// int Pow(int x, int y) {
//   int z = 1;
//   for (; y; y >>= 1) {
//     if (y & 1) z = Mul(z, x);
//     x = Mul(x, x);
//   }
//   return z;
// }

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

typedef pair<int, int> pii;

const int maxn = 5000;
int n, k;
char s[maxn + 1], minc;
char s1[maxn * 2 + 1];

int a[maxn], a1[maxn * 2];
char ans[maxn + 1];
char now[maxn + 1];

void Advance(void) {
  copy(a, a + n, a1);
  copy(a, a + n, a1 + n);
  reverse(a1 + n, a1 + 2 * n);
  int r = n;
  while (r < 2 * n && a1[r] == -1) {
    ++r;
  }
  int l = r - n;
  copy(a1 + l, a1 + r, a);
}

void AdvanceEnd(void) {
  copy(a, a + n, a1);
  copy(a, a + n, a1 + n);
  reverse(a1 + n, a1 + 2 * n);
  int l = n - 1;
  while (l - 1 >= 0 && a1[l - 1] == -1) {
    --l;
  }
  int r = l + n;
  copy(a1 + l, a1 + r, a);
}

void Solve1(void) {
  bool first = true;
  for (int l = 0, r = n; l <= n; ++l, ++r) {
    copy(s1 + l, s1 + r, now);
    now[n] = '\0';
    if (first || strcmp(now, ans) < 0) {
      strcpy(ans, now);
      first = false;
    }
  }
  puts(ans);
}

int main(void) {
  scanf("%d%d%s", &n, &k, s);
  minc = *min_element(s, s + n);
  if (k >= 15) {
    for (int i = 0; i < n; ++i) {
      putchar(minc);
    }
    putchar('\n');
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    s1[i] = s1[2 * n - i - 1] = s[i];
  }

  if (k == 1) {
    Solve1();
    return 0;
  }
  
  int len = 0;
  {
    int now = 0;
    for (int i = 0; i < 2 * n; ++i) {
      if (s1[i] == minc) {
        ++now;
        len = max(len, now);
      } else {
        now = 0;
      }
    }
    for (int i = 0; i < len; ++i) {
      a[n - i - 1] = -1;
    }
    for (int i = 0; i < n - len; ++i) {
      a[i] = i;
    }
  }

  for (int i = 0; i < k - 2; ++i) {
    Advance();
  }
  AdvanceEnd();
  bool first = true;
  for (int l = 0, r = n; l <= n; ++l, ++r) {
    if (count(s1 + r - len, s1 + r, minc) == len) {
      for (int i = 0; i < n; ++i) {
        if (a[i] == -1) {
          now[i] = minc;
        } else {
          now[i] = s1[l + a[i]];
        }
      }
      now[n] = '\0';
      if (first || strcmp(now, ans) < 0) {
        first = false;
        strcpy(ans, now);
      }
    }
  }

  puts(ans);
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  if (0==A.at(0)) A.erase(A.begin());
  while (1<A.size()) {
    long a=A.at(0);
    for (int i=1; i<A.size(); i++) A.at(i) %= a;
	sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    if (0==A.at(0)) A.erase(A.begin());
  }
  cout << A.at(0) << endl;
  return 0;
}
	

Measured memory_bytes: 1024
N, Q = map(int, input().split())
S = input()

ans = [0]
num = 0
for x, y in zip(S[:-1], S[1:]):
    if x == 'A' and y == 'C':
        num += 1
        ans.append(num)
    else:
        ans.append(num)

for _ in range(Q):
    l, r = map(int, input().split())
    if l == 1:
        print(ans[r-1])
    else:
        b = ans[r-1]-ans[l-2]
        if S[l-1] == 'C' and S[l-2] == 'A':
            print(b-1)
        else:
            print(b)

Measured memory_bytes: 55944
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

struct node{
  int parent, left, right;
};

node x[25];

int d[25], h[25];

void setdepth(int u, int p){
  d[u] = p;
  if(x[u].right != -1) setdepth(x[u].right, p+1);
  if(x[u].left != -1) setdepth(x[u].left, p+1);
}

int setheight(int h[], int u){
  int h1 = 0, h2 = 0;

  if(x[u].right != -1) h1 = setheight(h, x[u].right) + 1;
  if(x[u].left != -1) h2 = setheight(h, x[u].left) + 1;

  h[u] = max(h1, h2);

  return h[u];
}

int main(){
  int n;


  cin >> n;

  for(int i = 0; i < n; i++){
    x[i].parent = x[i].left = x[i].right = -1;
  }

  int id, k;

  for(int i = 0; i < n; i++){
    cin >> id;

    int c1;

    for(int j = 0; j < 2; j++){
      cin >> c1;
      if(j == 0){
        x[id].left = c1;
      }
      else{
        x[id].right = c1;
      }
      if(c1 != -1){
        x[c1].parent = id;
      }
    }
  }

  int root;


  for(int i = 0; i < n; i++){
    if(x[i].parent == -1) root = i;
  }

  setdepth(root, 0);

  setheight(h, root);

  for(int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << x[i].parent << ", sibling = ";

    if(x[i].parent == -1) cout << -1;

    else if(x[x[i].parent].left == i){
      cout << x[x[i].parent].right;
    }
    else cout << x[x[i].parent].left;

    cout << ", degree = ";

    if(x[i].left == -1 && x[i].right == -1) cout << 0;
    else if(x[i].left != -1 && x[i].right != -1) cout << 2;
    else cout << 1;

    cout << ", depth = " << d[i] << ", ";

    cout << "height = " << h[i] << ", ";

    if(x[i].parent == -1) cout << "root";
    else if(x[i].left == -1 && x[i].right == -1) cout << "leaf";
    else cout << "internal node";

    cout << endl;

  }

  return 0;
}



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

int main() {
  int N, M; 
  map<int, int> D, T;
  cin >> N;
  rep(i, N) {
    int d;
    cin >> d;
    if (D.count(d)) {
      D[d]++;
    }
    else {
      D[d] = 1;
    }
  }
  cin >> M;
  rep(i, M) {
    int t;
    cin >> t;
    if (T.count(t)) {
      T[t]++;
    }
    else {
      T[t] = 1;
    }
  }
  for (auto p : T) {
    int pnum = p.first;
    int pcont = p.second;
    if (!D.count(pnum) || D[pnum] < pcont) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  // rep(i, 10) {
  //   cout << i << endl;
  // }

  int N, K, Q;
  cin >> N;
  cin >> K;
  cin >> Q;
  vector<int> a(1000000);
  vector<int> score(1000000, K + -1 * Q);

  rep(i, Q) {
    cin >> a[i];
    score[a[i]-1]++;
  }

  rep(i, N) {
    if (score[i] > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define reg register

const int maxn = 1000005;

int N;

char S[maxn];
char T[maxn];

int main(){
        scanf("%d", &N);
        scanf("%s%s", S+1, T+1);
        int flag = 1;
        for(reg int i = 1; i <= N; i ++)
                if(S[i] != T[i]){ flag = 0; break ; }
        if(flag){ printf("0\n"); return 0; }
        int Min_l = N, Ans = 1;
        std::queue <int> Q;
        for(reg int i = N; i >= 1; i --){
                Min_l = std::min(i, Min_l);
                if(T[i] == T[i-1]) continue ;
                while(Min_l && S[Min_l] != T[i]) Min_l --;
                if(!Min_l){ printf("-1\n"); return 0; }
                while(!Q.empty()){
                        if(Q.front()-Q.size()+1 > i) Q.pop();
                        else break ;
                }
                Q.push(Min_l);
                if(Min_l != i) Ans = std::max(Ans, (int)Q.size() + 1);
        }
        printf("%d\n", Ans);
        return 0;
}

Measured memory_bytes: 6272
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=new string[s[0]];
		char c='0',d='1';
		for(int i = 0;i<s[0];i++) {
			if(i==s[3]){c='1';d='0';}
			a[i]=new string(c,s[2]);
			a[i]+=new string(d,s[1]-s[2]);
		}
		Console.WriteLine(String.Join("\n",a));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

using namespace std;

int main(){
  int k,n,i,x;
  int max = 0;
  int s = 0;
  cin >> n >> k;
  int m[k] = {};
  int p[n] = {};
  for(i = 0; i < k; i++){
    cin >> p[i];
    s += p[i];
    max = s;
    m[i] = p[i];
  }
  for(i = k; i < n; i++){
    cin >> p[i];
    s += p[i];
    s -= p[i - k];
    if(max <= s){
      max = s;
      for(x = 0; x < k; x++){
        m[x] = p[i - x];
      }
    }
  }
  double ans;
  for(i = 0; i < k; i++){
    ans += (m[i] + 1.0) / 2.0;
  }
  cout << std::setprecision(10) << ans;
}


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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

map<ll, int> m;

int main () {
    int n;
    scanf("%d", &n);
    ++m[0];
    ll sum = 0, ans = 0;
    fto(i, 1, n) {
        int x; scanf("%d", &x);
        sum += x;
        ans += m[sum];
        ++m[sum];
    }

    cout << ans;

    return 0;
}


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

int main()
{
    char str[50];
    cin>>str;

    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]=='7')
        {
            str[i]='8';
            break;
        }
    }

    cout<<str;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
 
using namespace std;
 
typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int DP[2000] = {};

int main(){
	
	int N, M;
	cin >> N >> M;
	
	for(int i = 0; i < M; i++){
		int c, d;
		cin >> c >> d;
		DP[c]++;
		DP[d]--;
	}
	
	int ans = N + 1;
	
	int cur = 0;
	for(int i = 0; i <= N + 1; i++){
		cur += DP[i];
		if(cur > 0){
			ans += 2;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3120
import queue

n, m = [int(i) for i in input().split(" ")]

g = [[] for i in range(0, n + 1)]
v = [0] * (n + 1)
v_asn = [False] * (n + 1)
f = True

for i in range(0, m):
    l, r, d = [int(i) for i in input().split(" ")]
    g[l].append([r, d])
    g[r].append([l, -d])

for i in range(1, n + 1):
    if not v_asn[i]:
        q = queue.Queue()
        v_asn[i] = True
        q.put(i)
        while not q.empty():
            qi = q.get()
            for a in g[qi]:
                if not v_asn[a[0]]:
                    v_asn[a[0]] = True
                    v[a[0]] = v[qi] + a[1]
                    q.put(a[0])
                else:
                    if v[a[0]] != v[qi] + a[1]:
                        f = False
                        break
        if not f:
            break

if f:
    print("Yes")
else:
    print("No")

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

int n, x, t;

int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a%b);
}

int main() {
	cin >> n >> t;
	for(int i=0; i<n-1; i++){
		cin >> x;
		t = gcd(t, x);
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
CD = [tuple(map(int,input().split())) for i in range(M)]

for a,b in AB:
    x = z = 10**9
    for i,(c,d) in enumerate(CD):
        dist = abs(a-c) + abs(b-d)
        if dist < x:
            x = dist
            z = i+1
    print(z)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(b % a == 0) {
			System.out.println(a + b);
		} else {
			System.out.println(b - a);
		}
	}
}


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

#define N_MAX 100

int main() {
    long n, m, c;
    long A[20][20], B[20];
    cin >> n >> m >> c;
    for (long i = 0; i < m; i++) {
        cin >> B[i];
    }
    for (long i = 0; i < n; i++) {
        for (long j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    long cnt = 0;
    for (long i = 0; i < n; i++) {
        long score = 0;
        score += c;
        for (long j = 0; j < m; j++) {
            score += B[j] * A[i][j];
        }
        if (score > 0) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

long long a[500005];

void A(){
  a[0]=0;
  for(int i=1;i<500005;i++){
    a[i]=a[i-1]+i;
  }
}

int main(){
  A();
  string s;
  cin>>s;
  int n=s.size();
  long long ans=0;
  vector<int> R,L;
  int cnt=1;
  
  char mem=s[0];
  for(int i=1;i<n;i++){
    if(mem==s[i]) cnt++;
    else{
      if(mem=='<') R.push_back(cnt);
      else L.push_back(cnt);
      cnt=1;
    }
    mem=s[i];
  }
  if(mem=='<') R.push_back(cnt);
  else L.push_back(cnt);
  
  int r=R.size(),l=L.size();
 if(s[0]=='<'){
  if(r==l){
    for(int i=0;i<r;i++){
      ans+=a[R[i]]+a[L[i]]-min(R[i],L[i]);
    }
  }
  else{
    for(int i=0;i<l;i++){
      ans+=a[R[i]]+a[L[i]]-min(R[i],L[i]);
    }
    ans+=a[R[l]];
  }
 }
 else{
   if(r!=l){
     ans+=a[L[0]];
   	 for(int i=0;i<r;i++){
     ans+=a[R[i]]+a[L[i+1]]-min(R[i],L[i+1]);
     }
   }
   else{
     ans+=a[L[0]];
   	 for(int i=0;i<r-1;i++){
     ans+=a[R[i]]+a[L[i+1]]-min(R[i],L[i+1]);
     }
     ans+=a[R[r-1]];
   }
 } 
  cout<<ans<<endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string s; cin>>s; n--;
	map<char,int> x;
	for (char ch : s)
		x[ch]++;
	while(n-->0) {
		cin>>s;
		map<char,int> y;
		for (char ch : s)
			y[ch]++;
		for (char ch='a'; ch<='z'; ch++)
			x[ch]=min(x[ch],y[ch]);
	}
	for (char ch='a'; ch<='z'; ch++)
		while(x[ch]-->0)
			cout<<ch;
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define lint long long
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	lint a,b;
	std::cin>>a>>b;
	std::cout<<a*b<<std::endl;
	return 0;
}


Measured memory_bytes: 3652
n,m = map(int,input().split())
data = []
for i in range(m):
    k,*s = map(int,input().split())
    data.append(set(s))
p = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
    on = set()
    for j in range(n):
        if i>>j&1:on.add(j+1)
    if all([len(on&data[l])%2==p[l] for l in range(m)]):ans+=1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef long long int ll;
using namespace std;
const int M=1e9+7;
ll bm[300005],bM[300005],cm[300005],cM[300005];
int main() {
    ios;
    string s,t;cin>>s>>t;
    ll n,m;cin>>n>>m;
    string u;cin>>u;
    if(u==s)
    --n;
    else
    --m;
    cout<<n<<" "<<m;
}

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

int main() {
	int time[5], a[5], t[5], wait = 10, wait_x, result = 0;
	for (int i = 0; i < 5; i++) {
		cin >> time[i];
		a[i] = time[i] % 10;
		if (a[i] > 0) t[i] = time[i] + 10 - a[i];
		else t[i] = time[i];
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] > 0 && a[i] < wait) {
			wait = a[i];
			wait_x = i;
		}
	}
	if (wait == 10) {
		wait_x = -1;
	}
	for (int i = 0; i < 5; i++) {
		if (wait_x == i) result += time[i];
		else result += t[i];
	}
	cout << result << endl;
	return 0;
}

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

using namespace std;

int main()
{
    long long n,d;
    cin>>n>>d;
    long long count = 0;
    long long b = d*d;
    while(n--)
    {
        long long x,y;
        cin>>x>>y;
        long long a = x*x + y*y;
        if(a <= b)
        {
            count++;
        }
    }

    cout<<count;
    
    return 0;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef int64_t s64;
typedef uint64_t u64;
typedef uint32_t u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=2000+5;
vector<int>lk[N];
char s[N];
int sum[N],sum1[N],cnt[N];

void dfs(int x,int fr)
{
	sum[x]=cnt[x]=0;
	int mx=0,mx1=0;
	for(auto y:lk[x])
	if(y!=fr)
	{
		dfs(y,x);
		sum[x]+=sum[y]+cnt[y];
		cnt[x]+=cnt[y];
		if(sum[y]+cnt[y]>mx){mx=sum[y]+cnt[y];mx1=sum1[y]+cnt[y];}
	}
	sum1[x]=max(sum[x]%2,mx1-(sum[x]-mx));
	cnt[x]+=s[x]=='1';
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	scanf("%s",s+1);
	rep(i,1,n-1)
	{
		int x=read(),y=read();
		lk[x].push_back(y);
		lk[y].push_back(x);
	}
	int ans=1e9;
	rep(x,1,n)
	{
		dfs(x,0);
		if(sum1[x]==0)chmin(ans,sum[x]/2);
	}
	if(ans==1e9)puts("-1");
	else cout<<ans;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  while(1){
    int n,k;
    scanf("%d%d", &n, &k);

    if(n==0&&k==0) break;

    int max[k];
    int dat[k];

    int i,j;
    for(i=0;i<k;i++) scanf("%d", max+i);

    for(i=0;i<k;i++) dat[i] = 0;

    int ok=1;

    for(i=0;i<n;i++){
      for(j=0;j<k;j++){
        int v;
        scanf("%d", &v);
        
        dat[j]+=v;
        if(dat[j] > max[j]) ok = 0;
      }
    }
    if(ok) puts("Yes");
    else puts("No");
  }
}

Measured memory_bytes: 732
N = int(input())
table = [0] * 26
for j in range(N):
  s = list(input())
  for i in range(26):
    c = chr(ord("a") + i)
    i = ord(c) - ord("a")
    if j:
      table[i] = min(table[i], s.count(c))
    else:
      table[i] = s.count(c)
res = ""
for i in range(26):
  res += chr((i + ord("a"))) * table[i]
print(res)

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

using namespace std;

int main() {
    int r,D,x;
    cin >> r >> D >> x;
    int ans=x;
    for(int i=0;i<10;i++){
        ans=r*ans-D;
        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n" 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N,W;
  cin>>N>>W;
  vector<ll>w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  vector<vector<ll>>dp(N+1,vector<ll>(W+1,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j-w[i]>=0)dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }

  ll ans=0;
  for(int i=0;i<=W;i++)ans=max(ans,dp[N][i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
int main()
{
   int S, h, m, s;

   scanf("%d", &S);

   if (S >= 0 && S < 86400){
      h = S / 3600;
      m = (S - h * 3600) / 60;
      s = S - h * 3600 - m * 60;
      printf("%d:%d:%d\n", h, m, s);
   }
   return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n),b(n);
    vector<tuple<int,int,int>>t;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    rep(i,m){
        int c,d;
        cin>>c>>d;
        t.push_back(make_tuple(c,d,i+1));
    }
    rep(i,n){
        ll x=1e18;
        int num=0;
        rep(j,m){
            ll d=abs(a[i]-get<0>(t[j]))+abs(b[i]-get<1>(t[j]));
            if(x>d){
                x=d;
                num=get<2>(t[j]);
            }
        }
        cout<<num<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N=1e5+3;
ll dp[N];
int main()
{
    ll n,arr[N];
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++){
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
k=m//2
for i in range (0,k):
    a=i+1
    b=2*k+1-i
    print (a,b)
c=2*k+2
k=(m+1)//2
j=1
#print(c,k)
for i in range (c,c+k):
    a=i
    b=c+2*k-j
    j+=1
    print(a,b)

Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
pi P[2][100010];
int D[100010];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> D[i];
	rep(i, 0, 2) {
		map<int, int> M;
		rep(j, 0, N / 2) {
			M[D[i + j * 2]]++;
		}
		int n = 0;
		for(auto p : M) {
			P[i][n++] = pi(-p.sec, p.fst);
		}
	}
	rep(i, 0, 2) sort(P[i], P[i] + N / 2);
	bool found = false;
	rep(i, 0, 2) {
		if(P[i][0].sec == P[i][1].sec) found = true;
	}
	if(found) {
		cout << N + P[0][0].fst + P[1][0].fst << "\n";
	}
	else if(P[0][0].sec != P[1][0].sec) {
		cout << N + P[0][0].fst + P[1][0].fst << "\n";
	}
	else {
		cout << min(N + P[0][0].fst + P[1][1].fst, N + P[0][1].fst + P[1][0].fst) << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//コンソールに入力した値を取得
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a*b);

		sc.close();
	}
}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
}

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

int main() {
    int a, b, c, n;
    while(cin >> a >> b >> c >> n){
        vector<int> state(a + b + c, 2);
        vector<vector<int> > tests(n, vector<int>(4));
        rep(i, n) rep(j, 4) cin >> tests[i][j];
    
        rep(i,n){
            if(tests[i][3] == 1){
                rep(j, 3) state[tests[i][j]-1] = 1;
            }
        }
        rep(i,n){
            if(tests[i][3] == 0){
                int cnt = 0, fail;
                rep(j, 3){
                    if (state[tests[i][j]-1] == 1) cnt++;
                    else
                        fail = j;
                }
                if(cnt == 2){
                    state[tests[i][fail]-1] = 0;
                }
            }
        }
        rep(i, a+b+c){
            cout << state[i] << endl;
        }
    }

}


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

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(vector<T> v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) の和を取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};

int main()
{
  int n, q;
  cin >> n >> q;
  auto f = [](int a, int b) { return a + b; };
  SegmentTree<int> sg(n, f, 0);
  for (int qi = 0; qi < q; qi++)
  {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) // 変更クエリ
      sg.update(x - 1, sg.get(x - 1) + y);
    else // 求値クエリ
      cout << sg.query(x - 1, y) << "\n";
  }
  return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
using namespace std;
priority_queue<int> A,B,C;
vector<int> AA, BB, CC, DD;
 
int main()
{
    int x, y, a, b, c;
    long long ans = 0;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i) {
        int t; cin >> t;
        AA.push_back(t);
    }
    for (int i = 0; i < b; ++i) {
        int t; cin >> t;
        BB.push_back(t);
    }
    for (int i = 0; i < c; ++i) {
        int t; cin >> t;
        CC.push_back(t);
    }
    sort(AA.begin(), AA.end(), greater <int>());
    sort(BB.begin(), BB.end(), greater <int>());

    for (int i = 0; i < x; ++i) {
        DD.push_back(AA[i]);
    }
    for (int i = 0; i < y; ++i) {
        DD.push_back(BB[i]);
    }
    sort(DD.begin(), DD.end());
    sort(CC.begin(), CC.end(), greater <int>());
    
    for (int i = 0; i < x + y; ++i){
        if (i < CC.size() && CC[i] > DD[i]) ans += CC[i];
        else ans += DD[i];
    } 
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 2552
#include<cstdio>
using namespace std;
int n,k;
int main() {
	scanf("%d%d",&n,&k);
	long long suma=0;
	long long sumb=0;
	for (int i=1; i<=n; i++) {
		if (i%k==0) suma=suma+1;
		if (i%k==k/2) sumb=sumb+1;
	}
	if (k%2==0) 
		printf("%lld",suma*suma*suma+sumb*sumb*sumb);
		else printf("%lld",suma*suma*suma);
	return 0;
}

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

int main()
{
	int a, A, N;
	std::cin >> N >> A;
	
	a = N % 500;

	if (a <= A) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

    return 0;
}



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

struct Card{
	char suit,value;
};

void bubble(struct Card A[],int n){
	int i,j;
	for(i=0;i<n;i++){
		for(j=n-1;j>=i+1;j--){
			if(A[j].value<A[j-1].value)
				swap(A[j],A[j-1]);
		}
	}
}

void selection(struct Card A[],int n){
	int i,j,mini;
	for(i=0;i<n;i++){
		mini=i;
		for(j=i;j<n;j++){
			if(A[j].value<A[mini].value) mini=j;
		}
		swap(A[i],A[mini]);
	}
}

void print(struct Card A[],int n){
	for(int i=0;i<n;i++){
		if(i>0) cout<<" ";
		cout<<A[i].suit<<A[i].value;
	}
	cout<<endl;
}

bool isStable(struct Card C1[],struct Card C2[],int n){
	for(int i=0;i<n;i++)
		if(C1[i].suit!=C2[i].suit) return false;
	return true;
}

int main(){
	Card C1[101],C2[101];
	int n,i;
	cin>>n;
	for(i=0;i<n;i++) cin>>C1[i].suit>>C1[i].value;
	for(i=0;i<n;i++) C2[i]=C1[i];
	bubble(C1,n);
	selection(C2,n);
	print(C1,n);
	cout<<"Stable"<<endl;
	print(C2,n);
	if(isStable(C1,C2,n)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	return 0;
}


Measured memory_bytes: 3108
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(Math.abs(a[n-1] - a[0]));
	}

}

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

int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  int maxh = -1;

  for(int i=0;i<n;++i){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>maxh){
      maxh = h[i];
    }
  }

  for(int cx=0;cx<=100;++cx){
    for(int cy=0;cy<=100;++cy){
      for(int hi=maxh;hi<maxh+120;++hi){
        bool flag = true;
        for(int i=0;i<n;++i){
          int hh = max(hi-abs(cx-x[i])-abs(cy-y[i]), 0);
          if(h[i]!=hh){
            flag = false;
            break;
          }
        }
        if(flag){
          cout<<cx<<" "<<cy<<" "<<hi<<endl;
          return 0;
        }
      }
    }
  }
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int count = 0;
    
    for (int i = 1; i <= N; i++) {
        if (10 <= i && i < 100) {
            continue;
        }
        if (1000 <= i && i < 10000) {
            continue;
        }
        if (100000 <= i && i < 1000000) {
            continue;
        }
        
        count++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    ll n,m,c;
    cin >> n >> m >> c;
    ll b[30],a[30][30];
    REP(i,0,m) cin >> b[i];
    REP(i,0,n) REP(j,0,m) cin >> a[i][j];
    ll ans=0;
    REP(i,0,n){
        ll tmp=0;
        REP(j,0,m) tmp += a[i][j]*b[j];
        if(tmp+c>0) ans++;
    }
    cout << ans << ENT;
    return 0;
}

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


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

using namespace std;

int main()
{
  int n, k, q;

  cin >> n >> k >> q;

  map<int, int> p;

  for (int i = 0; i < q; i++)
  {
    int a;
    cin >> a;
    p[a - 1]++;
  }

  for (int i = 0; i < n; i++)
  {
    int ans = k - q;
    auto it = p.find(i);
    if (it != p.end())
    {
      ans += p[i];
    }

    if (0 < ans)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   ll N, Q; cin >> N;
   map<ll, ll> A;
   rep(i, 0, N) {
     ll a; cin >> a;
     A[a]++;
   }
   cin >> Q;

   ll ans = 0;
   for (auto p: A) {
     ans += p.first * p.second;
   }

   rep(i, 0, Q) {
     ll B, C; cin >> B >> C;
     A[C] += A[B];
     ans += A[B] * (C - B);
     A[B] = 0;
     cout << ans << endl;
   }
 }


Measured memory_bytes: 9572
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=301;

int N,M;
vi A[MAXN];
int ans = MAXN;
bool open[MAXN];
queue<int> Q[MAXN];

int main() {
	rii(N,M);
	FOR(i,0,N) FOR(j,0,M) {
		int x; ri(x); x--;
		Q[i].push(x);
	}
	FOR(i,0,N) A[Q[i].front()].pb(i);
	ms(open,true);
	FOR(k,0,M) {
		int idx = 0;
		FOR(i,0,M) if(A[i].size() > A[idx].size()) idx = i;
		open[idx] = false;
		ans = min(ans, (int) A[idx].size());
		FOR(i,0,A[idx].size()) {
			int j = A[idx][i];
			while(!Q[j].empty() && !open[Q[j].front()]) Q[j].pop();
			if(!Q[j].empty()) A[Q[j].front()].pb(j);
		}
		A[idx].clear();
	}
	printf("%d\n",ans);
}


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

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

int main(){
    int x,y;
    cin>>x>>y;
    int a,b;
    a=4*x-y;
    b=y-2*x;
    if(a%2||b%2||a<0||b<0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;


    return 0;
}

Measured memory_bytes: 3632
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    int sumx = 0;
    for (int i = 1; i <= n; i++) {
        int keta_sum = 0;
        int tmp = i;
        while (tmp > 0) {
            keta_sum += tmp % 10;
            tmp /= 10;
        }
        if (a <= keta_sum && keta_sum <= b)
            sumx += i;
    }
    cout << sumx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if (H==0 && W==0)break;
        else{
            for (int a=0;a<W;a++) cout<<"#";
            cout<<endl;
            for (int b=0;b<H-2;b++){
                cout<<"#";
                for (int c=0;c<W-2;c++) cout<<".";
                cout<<"#"<<endl;
            }
            for (int d=0;d<W;d++) cout<<"#";
            cout<<endl;
        }cout<<endl;
    }
}


Measured memory_bytes: 3088
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int d = reader.nextInt(), T = reader.nextInt(), s = reader.nextInt();
		if (s * T >= d) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
}


Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s;
  int k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
    if(s[i]!='a'){
      if(k-(26-(s[i]-97))>=0){
        k=k-(26-(s[i]-97));
        s[i]='a';
      }
    }
  }
  if(k%26!=0){
    k%=26;
    s[s.size()-1]+=k;
  }
  cout<<s<<"\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <vector> 
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n;
    cin >> n;

    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    
    std::sort(v.begin(),v.end());
    //for(int i=0; i<n; i++){
    //    cout << v[i] << ", ";
    //}
    //cout << endl;
    int cnt = 0;

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                //cout << v[i] << ", " << v[j] << ", " << v[k];
            if(v[i]+v[j] > v[k]){
                //cout << endl;
                cnt++;
            }else{
                //cout << "-> NG!!" << endl;
            }
            }
        }
    }

    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
max_A = max(A)
min_B = min(B)

for Z in range(X+1,Y+1):
  if max_A < Z and Z <= min_B:
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n, W;
long long f[109][100000];
struct gt
{
    int w;
    long long v;
};
gt a[109];
void init()
{
    cin >> n >> W;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i].w >> a[i].v;
    }
}
void process()
{
    for(int i = 1; i <= n; ++ i)
    {
        for(long j = 1; j <= W; ++ j)
        {
            f[i][j] = f[i - 1][j];
            if(a[i].w <= j)
            {
                f[i][j] = max(f[i - 1][j], f[i - 1][j - a[i].w] + a[i].v);
            }
        }
    }
    cout << f[n][W];
}
int main()
{
    init();
    process();
    return 0;
}


Measured memory_bytes: 79360
#include<stdio.h>
int main()
{
    int a,b,c,i,n;
    char ans[4];
    ans[0] = 'N';
    ans[1] = 'o';
    ans[2] = '\0';
    scanf("%d%d", &a,&b);
    if (b < 10)
        c = a * 10 + b;
    else
    {
        if (b < 100)
            c = a * 100 + b;
        else
            c = a * 1000 + b;
    }
    for (i = 1; i < 500; i++)
    {
        n = i * i;
        if (c == n)
        {
            ans[0] = 'Y';
            ans[1] = 'e';
            ans[2] = 's';
            ans[3] = '\0';
        }
    }
    printf("%s", ans);
    fflush(stdout);
    return 0;
}

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

namespace AtCoderMake.ABC166
{
    class ABC166A
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s=="ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}


Measured memory_bytes: 25796
#include <iostream>
using namespace std;
int ap[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    int poz=1;
    char s;
    while(1)
    {
        s=cin.get();
        if(s=='\n')
            break;
        if(poz%2)
            cout<<s;
        poz++;
    }
    return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll N; cin >> N;
    ll ans = 0;
    for (ll i = 1; i*i <= N; i++) {
        if (N % i == 0) {
            ll q = i;
            ll m1 = N/q;
            if (q < m1 - 1) {
                //cout << q << " " << m1 << '\n';
                ans += m1-1;
            }
        }
    }
    cout << ans << '\n';

    return 0;
}



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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	string s;
	cin >> s;
	ll sum=0;
	for(ll i=0;i<s.size();i++)
	{
		ll val = s[i] - '0';
		sum+=val;
	}
	if(sum%9)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;	
}


Measured memory_bytes: 3752
def main():
    N = int(input())

    if N % 2 == 1:
        print(0)
        exit()
    
    ans = 0
    d = 10
    while d <= N:
        ans += (N // d)
        d *= 5
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int mod=1000000007;
typedef long long ll;

int fac[4000010],inv[4000010],dp[2010][2010];

int power(int x,int y)
{
	int t=1;
	while (y)
	{
		if (y&1) t=ll(t)*x%mod;
		x=ll(x)*x%mod;y>>=1;
	}
	return t;
}

int c(int n,int m)
{
	return ll(fac[n])*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k;scanf("%d%d",&n,&k);
	if (k==1) {puts("1");return 0;}
	int M=n*k;
	fac[0]=1;for (int i=1;i<=M;i++) fac[i]=ll(fac[i-1])*i%mod;
	inv[M]=power(fac[M],mod-2);for (int i=M;i;i--) inv[i-1]=ll(inv[i])*i%mod;
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		dp[i][0]=1;
		for (int j=1;j<=i;j++)
			dp[i][j]=(ll(dp[i][j-1])*c(M-i-j-(j-1)*(k-2),k-2)+dp[i-1][j])%mod;
	}
	printf("%d\n",ll(dp[n][n])*fac[n]%mod);
	return 0;
}


Measured memory_bytes: 47232
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a)
		cin >> i;
	int ct = 0;
	for (int i = 0; i < n; ++i)
		if (a[i] & 1)
			++ct;
	cout << ((ct & 1) ? "NO" : "YES") << endl;
}

Measured memory_bytes: 3692
#include<stdio.h>
int N = 100;

int main(){
 int M[N][N];
 int n;
 int i,j;
 int u,k,v;
 scanf("%d",&n);
 for(i=0;i<n;i++){
   for(j=0;j<n;j++) M[i][j] = 0;
 }


for(i=0;i<n;i++){
  scanf("%d",&u);
  scanf("%d",&k);
  u--;
  for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    M[u][v] = 1;
  }
 }

for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j) printf(" ");
    printf("%d",M[i][j]);
  }
  printf("\n");
 }
return 0;
}



Measured memory_bytes: 2052