akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    int N,K;cin>>N>>K;
    int h[N];
  for(int i=0;i<N;i++) cin>>h[i];
    int count=0;
    for(int i=0;i<N;i++)if(h[i]>=K){
        count++;
    }
    cout<<count<<endl;
}




Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>

int main(int argc, char **argv)
{
    std::string S;
    std::cin >> S;
    int v = std::atoi(S.c_str());
    int A, B, C, D;
    
    D = v % 10; v /= 10;
    C = v % 10; v /= 10;
    B = v % 10; v /= 10;
    A = v % 10; v /= 10;

         if(A + B + C + D == 7) std::cout << A<<"+"<<B<<"+"<<C<<"+"<<D;
    else if(A + B + C - D == 7) std::cout << A<<"+"<<B<<"+"<<C<<"-"<<D;
    else if(A + B - C + D == 7) std::cout << A<<"+"<<B<<"-"<<C<<"+"<<D;
    else if(A + B - C - D == 7) std::cout << A<<"+"<<B<<"-"<<C<<"-"<<D;
    else if(A - B + C + D == 7) std::cout << A<<"-"<<B<<"+"<<C<<"+"<<D;
    else if(A - B + C - D == 7) std::cout << A<<"-"<<B<<"+"<<C<<"-"<<D;
    else if(A - B - C + D == 7) std::cout << A<<"-"<<B<<"-"<<C<<"+"<<D;
    else if(A - B - C - D == 7) std::cout << A<<"-"<<B<<"-"<<C<<"-"<<D;
    std::cout << "=7" << std::endl;
    
}


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

int main()
{
    bool isValid = true;
    int n;
    std::cin >> n;
    std::set <std::string> words;
    std::string word, prev;
    std::cin >> prev;
    words.insert(prev);

    while (--n)
    {
        std::cin >> word;

        if (isValid && words.find(word) == words.end() && word[0] == prev[prev.size()-1])
        {
            words.insert(word);
            prev = word;
        }
        else
            isValid = false;
    }

    std::cout << (isValid ? "Yes" : "No") << std::endl;
}

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


int main(){
    int N,M; cin >> N >> M;
    int temp;
    int Ltemp,Rtemp; cin >> Ltemp >> Rtemp;
    
 
        for(int i = 1;i < M;i++){
            int L,R; cin >> L >> R;

            if(Ltemp <= L){
                Ltemp = L;
        
            }
            if(Rtemp >= R){
                Rtemp = R;
            }
        }
        int res = Rtemp - Ltemp + 1 ;
        if(Rtemp < Ltemp)res = 0;
        cout << res << endl;




    
 
}

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

using namespace std;

template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

struct Vertex
{
	int color;
	Vertex(int a) : color(a) {}
	Vertex() : color(0) {}
};

using vertex = Vertex;

struct Edge
{
	int to;
	Edge(int t) : to(t) {}
	Edge() {}
};
using edge = Edge;
using graph = Graph<vertex, edge>;

long long res[3];

template<class V, class E>
bool is2graph_dfs(Graph<V, E>& G, int pos, int par = -1, int color = 1)
{
	if (par == -1) {
		if (G.v[pos].color) return true;
	}
	if (G.v[pos].color && G.v[pos].color != color) return false;
	if (G.v[pos].color) return true;
	G.v[pos].color = color;
	res[color]++;
	for (auto& n : G.e[pos]) {
		if (n.to == par) continue;
		if (!is2graph_dfs(G, n.to, pos, 3 - color)) return false;
	}
	return true;
}

template<class V, class E>
bool is2graph(Graph<V, E>& G)
{
	for (int i = 0; i < G.size(); i++) {
		if (!is2graph_dfs(G, i)) return false;
	}
	return true;
}

int main()
{
	int N, M;
	cin >> N >> M;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G.add_edge(a, b);
		G.add_edge(b, a);
	}
	if (is2graph(G)) {
		cout << res[1] * res[2] - M << endl;
	} else {
		cout << (long long) N * (N - 1) / 2 - M << endl;
	}
}


Measured memory_bytes: 6656
from heapq import heappop, heappush
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
hs = {}
val = A[0]+B[0]+C[0]
heappush(q, (-val, 0, 0, 0))
hs[(0, 0, 0)] = 1
for _ in range(K):
    ans, a, b, c = heappop(q)
    t_a = (a+1, b, c)
    t_b = (a, b+1, c)
    t_c = (a, b, c+1)
    print(-ans)
    if a<X-1 and t_a not in hs:
        hs[t_a] = 1
        heappush(q, ((-(A[a+1]+B[b]+C[c]),)+t_a))
    if b<Y-1 and t_b not in hs:
        hs[t_b] = 1
        heappush(q, ((-(A[a]+B[b+1]+C[c]),)+t_b))
    if c<X-1 and t_c not in hs:
        hs[t_c] = 1
        heappush(q, ((-(A[a]+B[b]+C[c+1]),)+t_c))

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

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

ll bubble(string from, string to) {
    ll N = from.size();
    
    queue<ll> cidx[26];
    rep(i, N) {
        cidx[from[i] - 'a'].push(i);
    }

    vector<ll> idx(N);
    rep(i, N) {
        idx[i] = cidx[to[i] - 'a'].front();
        cidx[to[i] - 'a'].pop();
    }
    
    BIT<int> bit(N + 1);

    ll ans = 0;
    rep(i, N) {
        ans += bit.sum(N - idx[i]);
        bit.add(N - idx[i], 1);
    }

    return ans;
}

int main() {
    string S;
    cin >> S;

    vector<ll> cnt(26, 0);
    for (char c : S) {
        cnt[c - 'a']++;
    }

    ll oddcnt = 0;
    rep(i, 26) {
        oddcnt += cnt[i] % 2;
    }
    if (oddcnt > 1) {
        cout << -1 << endl;
        return 0;
    }

    string pre;
    vector<ll> appear(26, 0);
    for (char c : S) {
        if (appear[c - 'a'] < cnt[c - 'a'] / 2) {
            pre.push_back(c);
            appear[c - 'a']++;
        }
    }

    string to = pre;
    
    rep(i, 26) {
        if (cnt[i] % 2 > 0) {
            to.push_back(i + 'a');
        }
    }

    reverse(pre.begin(), pre.end());
    to += pre;

    cout << bubble(S, to) << endl;
    return 0;
}

Measured memory_bytes: 8156
a,b,c,x,y = map(int, input().split())
c_p = 2*c*min(x,y)
if x==y and (a+b)>c*2:
    print(c_p)
else:
    if x > y:
        price = min(c_p + (x-y)*a, c_p+(x-y)*c*2, a*x+b*y)
        print(price)
    elif x < y:
        price = min(c_p + (y-x) * b, c_p+(y-x)*c*2, a*x+b*y)
        print(price)
    else:
        print(a*x+b*y)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, r;
    cin >> n >> r;

    if(n >= 10)
    	cout << r << endl;
    else
    	cout << r + 100*(10 - n) << endl;
}

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

int main(void) {
	int x;
	cin >> x;
	for (int i = x;; i++) {
		bool no = false;
		for (int j = 2; j < i; ++j) {
			if (i % j == 0) {
				no = true;
				break;
			}
		}
		if (!no) {
			cout << i;
			return 0;
		}
	}
}


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

#ifndef MAX
#define MAX 800000
#endif

//Range Update Query+Range Minimum Query
template<class T>
class RUQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};

int bit[300000];
void add(int k,int x){
	k++;
	while(k<300000){
		bit[k]+=x;
		k+=k&-k;
	}
}
int sum(int k){
	k++;
	int ans=0;
	while(k){
		ans+=bit[k];
		k-=k&-k;
	}
	return ans;
}
RUQ_RMQ<P>tree;
int main(){
	string s;int k;cin>>s>>k;
	rep(i,s.size()-1)add(i+1,1);
	tree.init(s.size(),[](P a,P b){return a<b;},P(INT_MAX,INT_MAX));
	rep(i,s.size())tree.update(i,P(s[i],i));
	string ans;
	rep(i,s.size()){
		int l=1,r=s.size();
		while(l!=r){
			int t=(l+r)/2;
			if(r-l==1)t=r;
			if(sum(t-1)<=k)l=t;
			else r=t-1;
		}
		P p=tree.query(0,l);
		ans+=p.first;
		k-=sum(p.second);
		add(p.second+1,-1);
		tree.update(p.second,P(INT_MAX,i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16844
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,k,i=1,count=0;
    cin>>a>>b>>k;
    vi v;
    while(i<=min(a,b))
    {
       if(a%i==0&&b%i==0)
       {
        count++;
        v.pb(i);
       }
       i++;
    }
    cout<<v[v.size()-k]<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  char s[10];
  string String[200000];
  
  cin >> N;
  
  for(int j = 0; j < N; j++)
  {
    for(int i = 0; i < 10; i++)
    {  
      cin >> s[i];
    }
    sort(s, s+10);
    String[j] = s;
    //cout << String[j] << endl;
  }
  
  sort(String, String + N);
  
  int itchi = 0;
  long long pair = 0;
  long long total = 0;

  for(int i = 1; i < N+1; i++)
  {
    //cout << String[i] << ' ';
    if (String[i] == String[i-1])
    {
      itchi++;
    }
    else
    {
      //階乗計算
      for(int j = 1; j <= itchi; j++)
      {
        pair += j;
      }
      
      total += pair;
      
      itchi = 0;
      pair = 0;
      
    }
    //cout << total << endl;
  }
  
  cout << total << endl;
}

Measured memory_bytes: 9848
#include <cstdio>
#include <deque>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int,int> ii;
int n,m;
char arr[100005];

deque<ii> dq;
int pv[100005];
vector<int> v;

int main(){
    scanf("%d%d",&n,&m);
    scanf("%s",&arr);
    
    dq.push_back(ii(0,0));
    
    ii temp;
    for (int x=1;x<=n;x++){
        if (arr[x]=='1') continue;
        while (!dq.empty() && dq.front().second+m<x){
            dq.pop_front();
        }
        if (dq.empty()){
            printf("-1\n");
            return 0;
        }
        
        pv[x]=dq.front().second;
        temp=ii(dq.front().first+1,x);
        while (dq.back().first>temp.first) dq.pop_back();
        dq.push_back(temp);
    }
    
    int curr=n;
    while (curr){
        v.push_back(curr-pv[curr]);
        curr=pv[curr];
    }
    
    while (!v.empty()){
        printf("%d ",v.back());
        v.pop_back();
    }
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt=0;
  int k;
  string s;
  cin>>s;
  cin>>k;
  string a[25000];
  for(i=0;i<s.size();i++){
    for(j=1;j<=min(k,(int)s.size()-i);j++){
      a[cnt++]=s.substr(i,j);
    }
  }
  sort(a,a+cnt);
  if(k==1){
    cout<<a[0]<<endl;
    return 0;
  }
  for(i=1;;i++){
    if(a[i-1]!=a[i])k--;
    if(k==1){
      cout<<a[i]<<endl;
      return 0;
    }
  }
}

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

int main(){
  ll x;
  ll t;
  scanf("%lld", &x);
  t = x % 11;

  ll ans;
  ans = x/11;

  if(t == 0){
    ans = 2*ans;
  }

  else if(t <= 6) ans = ans*2 + 1;

  else ans = ans*2 + 2;

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

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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 main() {
    ll n; cin >> n;
    ll res = 0, num = 10;
    if(n%2 == 0){
        while(num <= n){
            res += n / num;
            num *= 5;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int l = cin.nextInt();
			int r = cin.nextInt();
			if (r - l >= 2018) Console.WriteLine("0");
			else
			{

				long min = 2019;
				for (long i = l; i <= r; i++)
				{
					for (long j = i + 1; j <= r; j++)
					{
						min = Math.Min(min, (i * j) % 2019);
					}
				}
				Console.WriteLine(min);

			}
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[12][12];
int C[12];
int h[12][12][200];
int w[12][12][200];
int n[12][12][200];
int sz[12][12];
int P[12][12];
int H,W;
int valid(int a,int b,int t){
	if(a<0||b<0||a+t>H||b+t>W)return 0;
	for(int i=0;i<t;i++)for(int j=0;j<t;j++)if(!c[a+i][b+j])return 0;
	return 1;
}
int lim;
int dfs(int a,int b,int v){
	if(a==H)return 1;
	if(b==W)return dfs(a+1,0,v);
	if(((C[a]>>(b*2))&3)!=1)return dfs(a,b+1,v);
	if(v==lim)return 0;
	int last[12];
	for(int i=0;i<H;i++)last[i]=C[i];
	for(int i=0;i<sz[a][b];i++){
		for(int j=0;j<n[a][b][i];j++)C[h[a][b][i]+j]|=P[w[a][b][i]][w[a][b][i]+n[a][b][i]-1];
		if(dfs(a,b+1,v+1))return 1;
		for(int j=0;j<n[a][b][i];j++)C[h[a][b][i]+j]=last[h[a][b][i]+j];
	}
	return 0;
}
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		
		H=a;W=b;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&c[i][j]);
		for(int i=0;i<a;i++)C[i]=0;
		
		for(int i=0;i<b;i++)for(int j=i;j<b;j++){
			P[i][j]=0;
			for(int k=i;k<=j;k++){
				P[i][j]+=1<<(k*2+1);
			}
	//		printf("%d %d: %d\n",i,j,P[i][j]);
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)sz[i][j]=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			for(int k=1;k<=min(a,b);k++){
				if(valid(i,j,k)&&!valid(i-1,j-1,k+1)&&!valid(i-1,j,k+1)&&!valid(i,j-1,k+1)&&!valid(i,j,k+1)){
					for(int l=0;l<k;l++)for(int m=0;m<k;m++){
						h[i+l][j+m][sz[i+l][j+m]]=i;
						w[i+l][j+m][sz[i+l][j+m]]=j;
						n[i+l][j+m][sz[i+l][j+m]]=k;
						sz[i+l][j+m]++;
					//	printf("%d %d %d %d %d\n",i,j,k,i+l,j+m);
					}
				}
			}
		}
		//for(int j=0;j<b;j++)for(int k=0;k<sz[i][j];k++);
		//	printf("%d %d: %d %d %d\n",i,j,h[i][j][k],w[i][j][k],n[i][j][k]);
		int ad=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			int M=0;
			for(int k=0;k<sz[i][j];k++)M=max(M,n[i][j][k]);
			if(M==1){
				ad++;
				c[i][j]=0;
			}
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)C[i]+=(c[i][j]<<(j*2));
		for(int i=0;;i++){
			lim=i;
			if(dfs(0,0,0)){
				printf("%d\n",ad+i);
				break;
			}
		}
	}
}

Measured memory_bytes: 1300
a = list(input()+"A")
b = list(input()+"B")
c = list(input()+"C")

def card(x):
  first = x.pop(0)
  if first.isupper():
    print(first)
    return
  elif first == "a":
    card(a)
  elif first == "b":
    card(b)
  else:
    card(c)
    
card(a)

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

int main() {
 
long long h,w,ans;
cin>>h>>w;

if(h==1) {ans=1; }
else if(w==1) {ans=1; }

else if(h%2==0||w%2==0) {ans=h *w/2 ; }
else  {ans=h *(w-1)/2+(h/2)+1 ; }

cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    cin >> x;
    for (int i = -500; i <= 500; i++)
    {
        for (int j = -500; j <= 500; j++)
        {
            if ((pow(i,5) -pow( j,5)) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  vector<int> times(n+2,0);
  vector<int> speed(n+2,0);
  vector<int> time_sum(n+2,0);
  rep(i,1,n+1)times[i]=in()*2;
  rep(i,1,n+1)speed[i]=in()*2;
  rep(i,n+1)time_sum[i+1]=time_sum[i]+times[i];
  ll ans = 1;
  int c_time = 0;
  int c_speed = 0;
  int c_pos = 0;
  while(c_time<=time_sum.back()){
    while(c_pos<n and c_time >= time_sum[c_pos+1])++c_pos;
    int next;
    per(i,-1,2){
      int n_speed = c_speed + i;
      int n_time = c_time + 1;
      if(n_speed>speed[c_pos])continue;
      bool flag = true;
      rep(j,c_pos+1,n+2){
        if(n_speed+n_time>time_sum[j]+speed[j]){
          flag = false;
          break;
        }
      }
      if(flag){
        next = i;
        break;
      }
    }
    ans += c_speed;
    ans += next;
    c_speed += next;
    c_time += 1;
  }

  printf("%.16lf\n",ans*0.25);


  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int,int>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr ll INF=1e18;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,x;cin>>n>>x && n|x;){
		vi a(n);
		rep(i,n) cin>>a[i];

		ll res=INF;
		vi mins=a;
		rep(i,n){
			rep(j,n) mins[j]=min(mins[j],a[(j-i+n)%n]);
			res=min(res,(ll)i*x+accumulate(all(mins),0ll));
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int input[200][3];
	int N,i,j;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d%d%d",
		&input[i][0],&input[i][1],&input[i][2]);
	for(i=0;i<N;i++) {
		int ok[3]={1,1,1};
		for(j=0;j<N;j++) {
			if(j==i)continue;
			if(input[i][0]==input[j][0])ok[0]=0;
			if(input[i][1]==input[j][1])ok[1]=0;
			if(input[i][2]==input[j][2])ok[2]=0;
		}
		printf("%d\n",
			input[i][0]*ok[0]+input[i][1]*ok[1]+input[i][2]*ok[2]);
	}
	return 0;
}

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int s;
  int t;
  if(A%D!=0){
    s=A/D+1;
  }
  else{
    s=A/D;
  }
  if(C%B!=0){
    t=C/B+1;
  }
  else{
    t=C/B;
  }
  if(s>=t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
  
  
}

Measured memory_bytes: 3596
/*
	atcoder ARC094
	C Same Integers 
*/
#include <bits/stdc++.h>
typedef long long ll;
const int N = 65;
const int inf = 100000;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int A, B, C, dp[N][N][N];
inline int dfs(int A, int B, int C) {
	if (A == B && B == C) return dp[A][B][C] = 0;
	if (A > 60 || B > 60 || C > 60) return inf - 10;
	if (dp[A][B][C] < inf) return dp[A][B][C];
	down(dp[A][B][C], dfs(A + 2, B, C));
	down(dp[A][B][C], dfs(A, B + 2, C));
	down(dp[A][B][C], dfs(A, B, C + 2));
	down(dp[A][B][C], dfs(A + 1, B + 1, C));
	down(dp[A][B][C], dfs(A + 1, B, C + 1));
	down(dp[A][B][C], dfs(A, B + 1, C + 1));
	++dp[A][B][C];
	return dp[A][B][C];	
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> A >> B >> C;
    for (int i = 0; i <= 60; ++i)
    	for (int j = 0; j <= 60; ++j)
    		for (int k = 0; k <= 60; ++k) dp[i][j][k] = inf;
    std::cout << dfs(A, B, C) << '\n';
	return 0;
}


Measured memory_bytes: 4660
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int h = s.nextInt();
    int w = s.nextInt();
    while (h != 0 && w != 0) {
      for (int i = 0; i < h; i++) {
        String st = "";
        for (int j = 0; j < w; j++) {
          if ((i == 0 || i == h-1))
            st += "#";
          else if (j == 0 || j == w-1)
            st += "#";
          else
            st += ".";
        }
        System.out.println(st);
      }
      System.out.println();
      h = s.nextInt();
      w = s.nextInt();
    }
    s.close();
  }
}



Measured memory_bytes: 49804
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    ll a = 1, b = 1;

    REP(i, n) {
        ll c, d; cin >> c >> d;

        ll g = __gcd(c, d);
        c /= g, d /= g;

        ll t = max(c, d);
        ll ng = 0, ok = (1e18 + t - 1) / t;
        while(ok - ng > 1) {
            ll k = (ng + ok) / 2;

            if (c * k >= a && d * k >= b) ok = k;
            else ng = k;
        }

        a = ok * c;
        b = ok * d;
    }

    print(a + b);
    
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,k,data[200]={0},j=1;
cin >> a >> b >> k;
map <int,int> s;
for (int i=min(a,b);i > 0;i--){
    if(a%i==0&&b%i==0){
        s[j]=i;
        //cout << s[j] << endl;
        j++;
    }
}
for (int i = 1;i <= j;i++){
    //cout << s[i] << endl;
    if(i==k){
        cout << s[i] << endl;
        break;
    }
}
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

template<typename T>
struct toedge {
  int to;
  T cost;

  toedge(int to) : to(to), cost((T)1) {}

  toedge(int to, T cost) : to(to), cost(cost) {}
};

template<typename T>
using ToEdges = vector<vector<toedge<T>>>;

template<typename T>
void dijkstra(std::vector<T> &distance, const ToEdges<T> &edges, const int s) {

  using P = std::pair<T, int>;
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;

  distance[s] = 0;
  que.emplace(distance[s], s);
  while(!que.empty()) {
    P p = que.top();
    que.pop();
    T cost = p.first;
    int v = p.second;
    if(distance[v] < cost) continue;
    for(auto &e : edges[v]) {
      if(distance[e.to] > distance[v] + e.cost) {
        distance[e.to] = distance[v] + e.cost;
        que.emplace(distance[e.to], e.to);
      }
    }
  }
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ToEdges<int> edges(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  VI dist1(n, INF), distn(n, INF);
  dijkstra<int>(dist1, edges, 0);
  dijkstra<int>(distn, edges, n-1);
  int c1, cn;
  c1 = cn = 0;
  rep(i, n) {
    dist1[i] > distn[i] ? cn++ : c1++;
  }
  c1 > cn ? out("Fennec") : out("Snuke");
  return 0;
}


Measured memory_bytes: 7408
import math

EPS = 1e-10

def equals(a, b):
    return abs(a - b) < EPS


class Point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __add__(self, p):
        return Point(self.x + p.x, self.y + p.y)

    def __sub__(self, p):
        return Point(self.x - p.x, self.y - p.y)

    def __mul__(self, a):
        return Point(self.x * a, self.y * a)

    def __rmul__(self, a):
        return self * a

    def __truediv__(self, a):
        return Point(self.x / a, self.y / a)

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

    def __lt__(self, p):
        if self.x != p.x:
            return self. x < p.x
        else:
            return self.y < p.y

    def __eq__(self, p):
        return equals(self.x, p.x) and equals(self.y, p.y)


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2


class Circle:
    def __init__(self, c=Point(), r=0):
        self.c = c
        self.r = r


def dot(a, b):
    return a.x * b.x + a.y * b.y


def cross(a, b):
    return a.x * b.y - a.y * b.x


def project(s, p):
    base = s.p2 - s.p1
    r = dot(p - s.p1, base) / base.norm()
    return s.p1 + base * r


def getCrossPoint(c, l):
    pr = project(l, c.c)
    e = (l.p2 - l.p1) / (l.p2 - l.p1).abs()
    base = math.sqrt(c.r * c.r - (pr - c.c).norm())
    return (pr + e * base, pr - e * base)


if __name__ == '__main__':
    cx, cy, r =  [int(v) for v in input().split()]
    c = Circle(Point(cx, cy), r)
    q = int(input())
    ans = []
    for i in range(q):
        x1, y1, x2, y2 = [int(v) for v in input().split()]
        l = Segment(Point(x1, y1), Point(x2, y2))
        v1, v2 = getCrossPoint(c, l)
        if v2 < v1:
            v1, v2 = v2, v1
        ans.append([v1.x, v1.y, v2.x, v2.y])

    for v in ans:
        print('{0[0]:.8f} {0[1]:.8f} {0[2]:.8f} {0[3]:.8f}'.format(v))


Measured memory_bytes: 5764
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

map<string, int> m;

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >>n;
    string s;
    for(int i = 0; i<n; i++){
        cin >>s; m[s]++;
    }

    cout <<"AC x " <<m["AC"] <<endl;
    cout <<"WA x " <<m["WA"] <<endl;
    cout <<"TLE x " <<m["TLE"] <<endl;
    cout <<"RE x " <<m["RE"] <<endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
int main(void){
    ll n,k;
    cin >> n >> k;
    n = n % k;
    ll b;
    b = k - n;
    cout << min(n,b) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        long input = in.nextLong();

        long round = input / 11;
        long mod = input % 11;

        long result = round * 2;

        if (0 < mod) {
            result++;
        }
        if (6 < mod) {
            result++;
        }

        out.print(result);
    }
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
}


Measured memory_bytes: 9684
import copy
S = [s for s in input()]
A, B = copy.deepcopy(S), copy.deepcopy(S)
li = [A, B]
count = [0, 1]

if S[0] == '0':
    B[0] = '1'
else:
    B[0] = '0'

for C in range(2):
    for i in range(1, len(li[C])):
        if li[C][i - 1] == li[C][i]:
            if li[C][i] == '0':
                li[C][i] = '1'
            else:
                li[C][i] = '0'
            count[C] += 1

print(min(count))

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



int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	int a,b,c,ax=0,bx=0,cx=0,x=1;
	string ans="No";
	
	
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(), v.end());

	a=v[0];ax++;
	for(int i=1;i<n;i++){
		if(v[i-1]!=v[i]){
			x++;
		}

		if(x==1){
			ax++;
		}
		if(x==2){
			b=v[i];
			bx++;
		}
		if(x==3){
			c=v[i];
			cx++;
		}
	}

	if((x==1) && (a==0))ans="Yes";
	if((x==2) && (a==0) && (2*ax==bx))ans="Yes";

	if(x==3){
		if(((a|b)-(a&b)==c) && ((b|c)-(b&c)==a) && ((c|a)-(c&a)==b)){
			if(ax==bx && bx==cx && cx==ax){
				ans="Yes";
			}
			if(a==0){
				ans="No";
			}
		}
	}
	cout<<ans<<endl;

}



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

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var res = 0;

            for(var i = 0; i < N - 1; i++)
            {
                for(var j = i + 1; j < N; j++)
                {
                    res += d[i] * d[j];
                }
            }
            Console.WriteLine(res);
        }
    }
}


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

typedef long long ll;
ll N, M, X;
vector<pair<ll, vector<ll>>> vec;
ll const INF = 1e9;
bool possible(vector <ll> vec){
    for(int i = 0; i < vec.size(); i++){
        if(vec[i] < X){
            return false;
        }
    }
    return true;
}

vector<ll> add(vector<ll> a, vector<ll> b){
    for(int i = 0; i < a.size(); i++){
        a[i] += b[i];
    }
    return a;
}

ll res(ll n, vector<ll> a, ll c){
    if(n == N){
        if(possible(a)) return c;
        else return INF;
    }
    ll result = min(res(n + 1, add(a, vec[n].second), c + vec[n].first), res(n + 1, a, c));

    return result;
}


int main(){
    cin >> N >> M >> X;
    vec = vector<pair<ll, vector<ll>>> (N, make_pair(0, vector<ll>(M, 0)));

    for(int i = 0; i < N; i++){
        cin >> vec[i].first;
        for(int j = 0; j < M; j++){
            cin >> vec[i].second[j];
        }
    }
    
    ll result = res(0, vector<ll>(M, 0), 0);
    if(result == INF){
        cout << -1 << endl;
    }
    else{
        cout << result << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int N,D;
    cin >> N >> D;
    int a = N/(D*2 + 1);
    if (N==(D*2 +1)*a){
            cout << N/(D*2 + 1) << endl;
    }else { 
        cout << N/(D*2 + 1) + 1 << endl;
    }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

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

  int n;
  cin >> n;

  vector<int> cs(1001);
  for (int k = 2; k <= n; k++) {
    // cout << "k: " << k << endl;
    int x = k;
    for (int a = 2; a * a <= x; a++) {
      while (x % a == 0) {
        x /= a;
        cs[a]++;
        // cout << a << endl;
      }
    }
    if (x > 1) {
      cs[x]++;
      // cout << x << endl;
    }
  }

  FiniteField r = 1;
  for (int i = 2; i <= 1000; i++) {
    r *= (cs[i] + 1);
  }
  cout << r << endl;
}

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

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int ACcount [110000] = {};
    ACcount[0] = 1;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'A'  &&  s[i+1] == 'C'){
            ACcount[i+1] = ACcount[i] + 1;
        }else{
            ACcount[i+1] = ACcount[i];
        }
    }
    for(int i=0; i<q; i++){
        int l, r;
        cin >> l >> r;
        cout << ACcount[r-1] - ACcount[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
N, M, C = (int(x) for x in input().split())
b=list(map(int,input().split()))
ans=0

for i in range(N):
    sum=C
    a=list(map(int,input().split()))
    for j in range(M):
        sum+=a[j]*b[j]
    
    if sum>0: ans+=1

print(ans)

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
    string str;
    cin>>str;
    if(str[0]=='7'||str[1]=='7'||str[2]=='7')
        cout<<"Yes";
    else
        cout<<"No";
	return 0;
}

//Total solved problems:- 13


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int maN = 1e6+5;
bool isPrime[maN];
int gcd(int a, int b)
{
    if(b == 0 )
        return a;
        
    return gcd(b, a%b);
}
bool visited[maN];
int main() {
    int n;
    // sieve();
    cin >> n ;
    vector<int> a;
    for(int i = 0; i < n; ++i)
    {
        int x ;
        cin >> x;
        a.push_back(x);
    }
    int pw = 1,  sw = 1, ncp = 1;
    // int cnt = 0;
    
    for(int i = 0; i < n; ++i)
    {
        for(int j = 1; (ll)j*j <= a[i]; j++)
        {
            if(a[i]%j==0 && j!=0)
            {
                if(visited[a[i]/j] && a[i]/j != 1)
                {
                    pw = 0;
                    break;
                }
                if(visited[j] && j!= 1)
                {
                    pw = 0;
                    break;
                }
                else
                {
                    visited[a[i]/j] = true;
                    visited[j] = true;
                }
            }
        }
    }
    
    // for(int i = 0; i < n; ++i)
    // {
    //     if(!isPrime[a[i]])
    //         cnt++;
    // }
    // if(cnt < n-2)
    //     pw = 0;
    if(pw)
    {
        cout << "pairwise coprime";
        return 0;
    }
    int gcds = gcd(a[0], a[1]);

    for(int i = 2; i < n; ++i)
    {
        gcds = gcd(gcds, a[i]);
    }

    if(gcds != 1)
        sw = 0;
        
    if(sw)
        cout << "setwise coprime";
    else
        cout << "not coprime";
    
	return 0;
}


Measured memory_bytes: 8180
#include<stdio.h>
#define max 2000000
int n,A[max+1];
void maxheapfiy(int A[],int i){
  int r,l,largest,change;
  l=2*i;
  r=2*i+1;
  if(l<=n && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=n && A[r]>A[largest])largest =r;
  if(largest!=i){
    change = A[i];
    A[i]=A[largest];
    A[largest]= change;
    maxheapfiy(A,largest);
  }
}
    int main(){
      int i;
      scanf("%d",&n);
      for(i=1;i<=n;i++)scanf("%d",&A[i]);
      for(i=n/2;i>=1;i--)maxheapfiy(A,i);
      for(i=1;i<=n;i++)printf(" %d",A[i]);
      printf("\n");
      return 0;
    }



Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

lint par[100500];
lint ufsize[100050];

void init(lint x){
  rep(i,x) par[i]=i,ufsize[i]=1;
}

lint root(lint x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(lint x,lint y){
  return root(x)==root(y);
}

void unite(lint x,lint y){
  x=root(x);
  y=root(y);
  if(x==y) return;
  lint s=ufsize[x]+ufsize[y];
  ufsize[x]=s,ufsize[y]=s;
  par[x]=y;
}

lint size(lint x){
  return ufsize[root(x)];
}

int main(void){
    lint N,M,K;
    cin >> N >> M >> K;
    init(N);
    lint ans[N]={};
    rep(i,M){
        lint a,b;
        cin >> a >> b;
        a--,b--;
        ans[a]--,ans[b]--;
        unite(a,b);
    }
    rep(i,K){
        lint c,d;
        cin >> c >> d;
        c--,d--;
        if(same(c,d)) ans[c]--,ans[d]--;
    }
    rep(i,N) ans[i]+=size(i)-1;
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3584
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if a % b == 0 else gcd(b, a%b)

MAX_NUM = 10**6
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
primes = []
for i in range(2, MAX_NUM):
    if is_prime[i]:
        primes.append(i)
        for j in range(2*i, MAX_NUM, i):
            is_prime[j] = False

def f(x):
    res = {}
    for p in primes:
        if x % p == 0:
            res[p] = 0
            while x % p == 0:
                res[p] += 1
                x //= p
    if x > 1:
        res[x] = 1
    return res

def solve(a, b):
    p = f(gcd(a, b))
    return len(p) + 1

a, b = map(int, input().split())
print(solve(a, b))

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

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

  bool ans = false;

  if (a == 5 && b == 5 && c == 7) ans = true;
  if (a == 5 && b == 7 && c == 5) ans = true;
  if (a == 7 && b == 5 && c == 5) ans = true;
  
   if (ans) {
     cout << "YES" << endl;
   }
   else{
     cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    long double r;
    cin >> r;

    cout << r * 2 * pi << endl;

    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#define Lens 105
#define Nil -1
using namespace std;
struct work
{
	string s;
	int key;
};

int N, limit;
queue<work> Q;

int main()
{
	cin >> N >> limit;
	for (int i = 0; i < N; i++)
	{
		work w;
		cin >> w.s >> w.key;
		Q.push(w);
	}
	int sum = 0;
	while (!Q.empty())
	{
		work k = Q.front();
		Q.pop();
		if (k.key - limit > 0)
		{
			k.key -= limit;
			sum += limit;
			Q.push(k);
		}
		else
		{
			
			sum += k.key;
			cout << k.s << ' ' << sum << endl;
		}
	}
	return 0;

}


Measured memory_bytes: 6220