akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190810
{
    class ProblemA
    {
        static List<long> ab = new List<long>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            ab = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long a = ab[0];
            long b = ab[1];
            answer = Math.Max(Math.Max(a + b, a - b), a * b);
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair< P , string > PP;
#define MAX 200005
 
int bit[MAX];
void add(int i,int x){
  while(i<MAX){
    bit[i]+=x;
    i+=(i&-i);
  }
}
int sum(int i){
  int res=0;
  while(i>0){
    res+=bit[i];
    i-=(i&-i);
  }
  return res;
}
 
map<string,bool> mp;
int n,m;
 
PP t[MAX];
vector< PP > u;
 
char a[MAX];
string b[MAX];
int c[MAX];
 
map<string,int> X;
 
void queryA(int x){
  PP key=PP( P(-c[x],-n-x) ,b[x]);
  int id=lower_bound( u.begin(), u.end(), key ) - u.begin();
  add(id,1);
  X[ b[x] ] = id;
  
  int size=sum(MAX-1);
  size/=5;
 
  if(size==0){
    cout<<b[x]<<" is not working now."<<endl;
    return;
  }
 
  
  if(sum(id)<=size){
    mp[ b[x] ]=true;
    cout<<b[x]<<" is working hard now."<<endl;
  }else{
    mp[ b[x] ]=false;
    cout<<b[x]<<" is not working now."<<endl;
  }
  
  int L=1,R=MAX-2,M;
  while(L<R){
    M=(L+R)/2;
    if(sum(M)<=size)L=M+1;
    else R=M;
  }
 
  string name=u[L].second;
 
 
  if(mp[name]&&name!=b[x]){
    mp[name]=false;
    cout<<name<<" is not working now."<<endl;
  }
 
  L=1,R=MAX-2;
  while(L<R){
    M=(L+R)/2;
    if(sum(M)<size)L=M+1;
    else R=M;
  }
  name=u[L].second;
  
  if(!mp[name]&&name!=b[x]){
    mp[name]=true;
    cout<<name<<" is working hard now."<<endl;
  }
}
 
void queryB(int x){
  int id=X[ b[x] ];
  mp[b[x]]=false;
  add(id,-1);
  
  int cnt=sum(MAX-1);
 
  int size=cnt/5;
 
  
  int L=1,R=MAX-2,M;
  while(L<R){
    M=(L+R)/2;
    if(sum(M)<size)L=M+1;
    else R=M;
  }
 
  string name=u[L].second;
  if(cnt>=5 && !mp[name]){
    mp[name]=true;
    cout<<name<<" is working hard now."<<endl;
  }  
 
  L=1,R=MAX-2;
  while(L<R){
    M=(L+R)/2;
    if(sum(M)<=size)L=M+1;
    else R=M;
  }
 
  name=u[L].second;
  
  if(cnt+1>=5 && mp[name]){
    mp[name]=false;
    cout<<name<<" is not working now."<<endl;
  }
 
}
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i].second>>t[i].first.first;
    t[i].first.second=-i;
    t[i].first.first*=-1;
    u.push_back(t[i]);
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a[i];
 
        
    if(a[i]=='+'){
      cin>>b[i]>>c[i];
      u.push_back(PP(P( -c[i], -n-i ) ,b[i]));
    }else{
      cin>>b[i];
    }
  }
 
  u.push_back(PP( P(-1e9,-1e9) , "" ) );
  
  sort(u.begin(),u.end());
  
  for(int i=0;i<n;i++){
    int id=lower_bound( u.begin(), u.end(), t[i])-u.begin();
    add(id,1);
    X[ t[i].second ] = id;
  }
  
  for(int i=0;i<n;i++){
    int id=lower_bound( u.begin(), u.end(), t[i])-u.begin();
    if(sum(id)<=n/5)mp[t[i].second]=true;
  }
 
  for(int i=0;i<m;i++){
    if(a[i]=='+'){
 
      
      queryA(i);
    }else{
      queryB(i);
    }
 
    //    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 17480
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll N = 4e5+1;
ll n,k,a[N],s[N],ans,stack[N];

ll w[N],size[N];
ll num[N],fa[N],son[N][2];
ll tot,root;
void update(ll x){size[x]=size[son[x][0]]+size[son[x][1]]+num[x];}
void rotate(ll x)
{
    ll y=fa[x],z=fa[y],t=(son[y][0]==x);
    fa[y]=x;fa[x]=z;
    if(z) son[z][son[z][1]==y]=x;
    son[y][!t]=son[x][t];fa[son[x][t]]=y;
    son[x][t]=y;
    update(x);update(y);
}
void splay(ll x,ll f)
{
    while(fa[x]!=f)
    {
        ll y=fa[x],z=fa[y];
        if(z!=f)
        {
            if(son[y][0]==x^son[z][0]==y)rotate(x);
            else                        rotate(y);
        }
        rotate(x);
    }
    if(!f)root=x;
}
void insert(ll &x,ll val,ll f)
{
    if(!x)
    {
        x=++tot;
        fa[x]=f;
        son[x][0]=son[x][1]=0;
        w[x]=val;
        size[x]=num[x]=1;
        splay(x,0);
        return;
    }
    if(val==w[x]){size[x]++;num[x]++;splay(x,0);return;}
    insert(son[x][val>w[x]],val,x);
    update(x);
}
ll get(ll val)
{
    ll x=root;
    while(x&&w[x]!=val)x=son[x][val>w[x]];
    return x;
}
void delet(ll w)
{
    ll x=get(w);if(!x)return;
    splay(x,0);
    if(num[x]>1){num[x]--;size[x]--;return;}
    if(!son[x][0]||!son[x][1])root=son[x][0]+son[x][1];
    else
    {
        ll y=son[x][1];while(son[y][0])y=son[y][0];
        splay(y,x);
        fa[son[x][0]]=y;
        son[y][0]=son[x][0];
        root=y;
        son[x][0]=son[x][1]=0;
    }
    fa[root]=0;
    update(root);
}
ll getrank(ll val)
{
    insert(root,val,0);
    ll ans=size[son[root][0]]+num[root]-1;
    delet(val);
    return ans;
}
ll kth(ll k)
{
    ll x=root;
    while(k<=size[son[x][0]]||k>size[son[x][0]]+num[x])
    {
        if(k<=size[son[x][0]]) x=son[x][0];
        else                   k-=size[son[x][0]]+num[x],x=son[x][1];
    }
    return w[x];
}
ll getpre(ll val)
{
    insert(root,val,0);
    ll y=son[root][0];
    while(son[y][1])y=son[y][1];
    delet(val);
    return w[y];
}
ll getne(ll val)
{
    insert(root,val,0);
    ll y=son[root][1];
    while(son[y][0])y=son[y][0];
    delet(val);
    return w[y];
}

int main()
{
	cin>>n>>k;
	for(ll i=1;i<=n;++i)cin>>a[i],a[i]-=k;
	for(ll i=1;i<=n;++i)s[i]=s[i-1]+a[i];
	for(ll i=1;i<=n;++i)
	{
		insert(root,s[i],0);
		ans+=getrank(s[i])-1;
	}
	for(ll i=1;i<=n;++i)if(s[i]>=0)ans++;
	cout<<ans;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int N, x, cnt = 0;
    cin >> N >> x;
    vector<int> stf(N);
    for (int i = 0; i < N; i++) {
        cin >> stf.at(i);
    }
    sort(stf.begin(), stf.end());
    for (int i = 0; i < N; i++) {
        x -= stf.at(i);
        if (x < 0) {
            break;
        }
        cnt++;
    }
    if (x > 0) cout << cnt - 1 << endl;
    else cout << cnt << endl;
}

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

signed main() {
    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(a[i] == 0 or i == n - 1){
            ans += sum / 2;
            sum = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define s^i pow(s,i)

void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

 int main(){
     speed();
   int n,m;
   cin>>n>>m;
   int ans=0;
     if(n>1&&m>1){
         ans=((n*(n-1))/2)+((m*(m-1))/2);
         cout<<ans;
     }
     else{
         if(n>1){
             cout<<(((n*(n-1))/2));
         }
         else{
             cout<<((m*(m-1))/2);
         }
     }
     
    return 0;
}


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

using namespace std;

#define EPS (1e-6)


void calc(double x1,double y1,double x2,double y2,double *c_x1,double *c_y1,double *c_x2,double *c_y2){
  double midx,midy,hox,hoy,dx,dy,dis;
  midx = (x1+x2) / 2.0 , midy = (y1+y2) / 2.0;
  dx = x1-x2 , dy = y1-y2;
  dis = sqrt(1 - pow(x1-midx,2.0) - pow(y1-midy,2.0));
  hox = sqrt(pow(dy,2.0) / (pow(dy,2.0) + pow(dx,2.0)));
  hoy = hox * (-1.0) * (dx / dy);
  *c_x1 = midx + hox*dis,*c_y1 = midy + hoy*dis;
  *c_x2 = midx - hox*dis,*c_y2 = midy - hoy*dis;
}

int main(){
  int N;

  while(cin >> N){
    double x[300],y[300],c_x1,c_y1,c_x2,c_y2;
    int count,m;
    m = 1;
    if(!(N)) break;
    for(int i=0;i<N;i++) cin >> x[i] >> y[i];
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(i == j) continue;
        if(sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) > 2.0 + EPS  ) continue;
        count = 2;
        calc(x[i],y[i],x[j],y[j],&c_x1,&c_y1,&c_x2,&c_y2);
        for(int k=0;k<N;k++){
          if(k == i || k == j) continue;
          if((x[k] - c_x1)*(x[k] - c_x1) + (y[k] - c_y1)*(y[k] - c_y1) < 1.0 + EPS  ) count++;
        }
        if(m < count) m = count;
        count = 2;
        for(int k=0;k<N;k++){
          if(k == i || k == j) continue;
          if((x[k] - c_x2)*(x[k] - c_x2) + (y[k] - c_y2)*(y[k] - c_y2) < 1.0 + EPS) count++;
        }
        if(m < count) m = count;
      }
    }

    printf("%d\n",m);
  }

  return 0;
}    

Measured memory_bytes: 968
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
ostream& operator << (ostream& out, vector<int>& v) {
	for (auto& x: v) out << x << ' ';
	return out;
}

ostream& operator << (ostream& out, pii& v) {
	out << v.fi << ", " << v.se;
	return out;
}

istream& operator >> (istream& in, pii& a) {
	in >> a.fi >> a.se;
	return in;
}

const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int l[maxn], r[maxn];

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<int> goo (n);
	cinv (goo);
	stack <int> a;
	fr (i, n) {
		while (!a.empty () && goo[a.top ()] > goo[i]) a.pop ();
		if (!a.empty ()) l[i] = a.top ();
		else l[i] = -1;
		a.push (i);
	}
	while (!a.empty ()) a.pop ();
	for (int i = n - 1; i >= 0; --i) {
		while (!a.empty () && goo[a.top ()] > goo[i]) a.pop ();
		if (!a.empty ()) r[i] = a.top ();
		else r[i] = n;
		a.push (i);
	}
	int ans = 0;
	fr (i, n) {
		ans += (i - l[i]) * (r[i] - i) * goo[i];
	}
	cout << ans << '\n';






}

Measured memory_bytes: 9516
from sys import exit

S = input()

ans = 0
temp_ans = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        temp_ans += 1
    else:
        if temp_ans > ans:
            ans = temp_ans
            temp_ans = 0

if temp_ans > ans:
    ans = temp_ans

print(ans)


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

using namespace std;

int main(){
    int n, k, num;
    bool valid = true;
    vector<int> numbers(10,0);

    cin >> n >> k;

    for(int i=0; i<k; i++){
        cin >> num;
        numbers[num] = 1;
    }

    for(int i=n; i<100005; i++){
        num = i;

        while(num > 0){
            if(numbers[num % 10]){
                valid = false;
                break;
            }
            else
                num /= 10;
        }

        if(valid){
            cout << i << endl;
            break;
        }
        else
            valid = true;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define mod (ll)1e9+7
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
#define X first
#define Y second
#define up upper_bound
#define lo lower_bound
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b) 
{
    if(a>b)
        return b;
    return a;
}
ll maxx2( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll maxx(ll a,ll b,ll c)
{
  return maxx2(a,maxx2(b,c));
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
ll dsum(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
ll poww(ll a,ll b)
{
    if(b<=0)
        return 1;
    if(b==1)
        return a;
    if(b==2)
        return (a*a);
    else
        return poww(poww(a,b/2),2)*(poww(a,b%2));
}
ll sumsq(ll x,ll y,ll z)
{
    return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);
} 
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    IOS;
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll x=0;
    f(i,0,n)
    {
        if(s[i]!=t[i])
            x++;
    }
    cout<<x<<endl;

    return 0;
}

Measured memory_bytes: 3888
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll num=1e9+7;
ll mod(ll n)
{
    return (n%num+num)%num;
}
ll add(ll x,ll y)
{
    return mod(mod(x)+mod(y));
}
ll mult(ll x,ll y)
{
    return mod(mod(x)*mod(y));
}
ll sub(ll x,ll y)
 {
     return mod(mod(x)-mod(y));
 }
 ll pt(ll n,ll p)
 {
      if(p==0)
       return 1;
       if(p==1)
        return n%num;
        ll t=pt(n,p/2);
        if(p%2==0)
         return mult(t,t);
         else
          return mult(n,mult(t,t));
 }
 void solve()
 {
    ll k;
    cin>>k;
    string str="ACL",ans;
    for(ll i=0;i<k;i++)
    ans+=str;
    cout<<ans<<endl;
      
 }
int main(){
   ll t;
   t=1;
   while(t--)
   {
       solve();
   }
    
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define N 1000000
#define ar array
#define inf 1e18
#define mod 998244353
#define ld long double
#define pb push_back
#define f first
#define s second
typedef long long int ll;
using namespace std;
/*

ll d[N];
set<pair<ll,ll>>s;
ll par[N];
vector<pair<ll,ll>>adj[N];
void Dijkstra(ll v){
	d[v]=0;
	s.insert({d[v],v});
	par[v]=v;
	while(!s.empty()){
		ll u=s.begin()->second;
		s.erase(s.begin());
		for(auto x:adj[u]){
			if(d[x.first]>d[u]+x.second){
				s.erase({d[x.first],x.first});
				d[x.first]=d[u]+x.second;
				s.insert({d[x.first],x.first});
				par[x.first]=u;
			}
		}
	}
}*/
int main(void){
	fast;
	int n;
	cin>>n;
	int p=(n+999)/1000;
	int r=p*1000-n;
	cout<<r;
	
}


Measured memory_bytes: 3608
N, K = map(int, input().split())

rlt = 0
for b in range(K+1, N+1):
  if K > 0:
    rlt += (N//b)*(b-K) + max(0, N%b - K +1)  
  else:
    rlt += (N//b)*(b-K) + max(0, N%b)  
print(rlt)

Measured memory_bytes: 64772
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		
		int ans = 1;
		int size = d[0];
		for (int i = 1; i < d.length; i++) {
			if (d[i]>size) {
				ans++;
				size = d[i];
			}
		}
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



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

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while (n--) {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size() - 6; i++) {
      if (s.size() < 7) break;
      string t = s.substr(i, 7);
      if (t == "Hoshino") {
	s[i] = 'H';
	s[i + 1] = 'o';
	s[i + 2] = 's';
	s[i + 3] = 'h';
	s[i + 4] = 'i';
	s[i + 5] = 'n';
	s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }
  return 0;
}

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


int main()

{
    int a[3],s;//,b,c,s=0;
    cin>>a[0]>>a[1]>>a[2];
    s=a[0]+a[1]+a[2];
    if(s>=22)
        cout<<"bust"<<endl;

      else
        cout<<"win"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, t;
  scanf("%lld%lld", &n, &k);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(a[i] > a[j]) t = a[i], a[i] = a[j], a[j] = t;
  for(i = 0; i < k; ++i) ans += a[i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
int n;
int dp[3][100005];
int al[3][100005];
int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n ;
    for(int i = 1; i <= n;  i++){
        for(int k = 0 ; k < 3 ; k++)
            cin >>al[k][i];
    }
    for(int i = n; i > 0 ; i--){
        for(int j = 0 ;  j < 3 ; j++)
        for(int k = 0 ; k < 3 ; k++){
            if(k!=j){
            if(dp[j][i] < dp[k][i+1] + al[j][i]){
                dp[j][i] = dp[k][i+1] + al[j][i];
            }
            }
        }
    }
    cout << max(dp[0][1],max(dp[1][1],dp[2][1]));

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  ll a=T1*(A1-B1),b=T2*(A2-B2);
  if(a<0){a*=-1;b*=-1;}
  if(a+b>0){cout<<"0"<<endl;return 0;}
  if(a+b==0){cout<<"infinity"<<endl;return 0;}
  ll dp=a,ans=0;
  if(a%(a+b)==0){cout<<-2*(a/(a+b))<<endl;return 0;}
  if(a%(a+b)!=0){cout<<-2*(a/(a+b))+1<<endl;return 0;}
}

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

int main() {
  long n, k;
  cin >> n >> k;
  vector<double> kitai(n), ave(n - k + 1);
  for (int i = 0; i < n; i++) {
    double x;
    cin >> x;
    kitai.at(i) = (x + 1.0) / 2.0;
  }
  double avezero = 0;
  for (int i = 0; i < k; i++) {
    avezero += kitai.at(i);
  }
  ave.at(0) = avezero;
  for (int i = 1; i < ave.size(); i++) {
    ave.at(i) = ave.at(i - 1) + kitai.at(k + i - 1) - kitai.at(i - 1);
  }
  sort(ave.begin(), ave.end());
  cout << fixed << setprecision(10);
  cout << ave.at(ave.size() - 1);
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;

	if (K > (N - 1) * (N - 2) / 2)
	{
		cout << -1 << endl;
	}
	else
	{
		vector<pair<int, int>> result;
		for (auto i = 2; i <= N; ++i)
		{
			result.push_back(make_pair(1, i));
		}
		auto num = (N - 1) * (N - 2) / 2;
		for (auto i = 2; i < N && num > K; ++i)
		{
			for (auto j = i + 1; j <= N && num > K; ++j)
			{
				result.push_back(make_pair(i, j));
				--num;
			}
		}

		cout << result.size() << endl;
		for (auto i = 0; i < result.size(); ++i)
		{
			cout << result[i].first << " " << result[i].second << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
	int n = 0;
	while (cin >> n) {
		int a[4], b[4];
		int hit = 0, blow = 0;
		a[0] = n;
		cin >> a[1] >> a[2] >> a[3];
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (i == j && a[i] == b[i]) {
					++hit;
				}
				else if (a[j] == b[i]) {
					++blow;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
let rec take_while pred = function
    [] -> []
  | x::xs -> if pred x then x :: take_while pred xs else []

let rec scan_n n f v = if n <= 0 then [] else v :: scan_n (n-1) f (f v)

let arr = Array.init 101010 (fun i -> i)
let () = Scanf.scanf "%d" (fun n ->
  scan_n n succ 1 |> List.iter (fun i ->
    [6; 9] |> List.iter (fun m ->
      scan_n 10 (( * ) m) 1 |> take_while ((>=) i) |> List.iter (fun j ->
        arr.(i) <- min arr.(i) (arr.(i - j) + 1))));
  Printf.printf "%d\n" arr.(n))


Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    int Max=0;
    int Sum=0;
    rep(i,n){
        cin>>p.at(i);
        Sum+=p.at(i);
        Max=max(Max,p.at(i));
    }
    Sum-=Max;
    Sum+=Max/2;
    cout<<Sum<<endl;
}

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

#define int long long

using namespace std;

//int a[100001];

void no () {
	cout << 0;
	exit (0);
}

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int n, a, b;	
	cin >> n >> a >> b;
	if (n == 1 && a != b) no ();
	if (a > b) no ();
	if (n == 1) {
		cout << 1;
		return 0;
	}
	int len = n - 2;
	int mn = a * len;
	int mx = b * len;
	cout << mx - mn + 1;
	return 0;
}


Measured memory_bytes: 256
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let k = get!();
    let blue = k;
    let red = n - k;
    let md = 1e9 as i64 + 7;
    let mb = ModBinomial::new(n, md);
    for i in 1 .. k+1 {
        if red == 0 {
            if i == 1 {
                println!("1");
            } else {
                println!("0");
            }
            continue;
        }
        if blue < i {
            println!("0");
            continue;
        }
        let x = mb.bin(blue-1, i-1);
        let mut y = 0;
        if i-2 >= 0 && red-1 >= i-2 {
            y = mb.bin(red-1, i-2);
        }
        if i-1 >= 0 && red-1 >= i-1 {
            y += mb.bin(red-1, i-1) * 2 % md;
            y %= md;
        }
        if i >= 0 && red-1 >= i {
            y += mb.bin(red-1, i);
            y %= md;
        }
        let ans = x * y % md;
        println!("{}", ans);
    }
}


fn modpow(x: i64, p: i64, m: i64) -> i64 {
    if p == 0 {
        1
    } else if p % 2 == 0 {
        modpow((x * x) % m, p / 2, m)
    } else {
        (x * modpow(x, p - 1, m)) % m 
    }
}
struct ModBinomial { m: i64, f: Vec<i64>, p: Vec<i64> }
impl ModBinomial {
    fn new(n: i64, m: i64) -> ModBinomial {
        let mut f = vec![1; n as usize + 1];
        let mut p = vec![1; f.len()];
        for i in 2..f.len() {
            f[i] = (i as i64 * f[i - 1]) % m;
            p[i] = modpow(f[i], m - 2, m);
        }
        ModBinomial { m: m, f: f, p: p }
    }
    fn bin(&self, n: i64, k: i64) -> i64 {
        (((self.f[n as usize] * self.p[k as usize])
            % self.m) * self.p[(n - k) as usize]) % self.m
    }
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	string lhs;
	string rhs;
	int power;
	Data(string _l,string _r, int _p){
		lhs = _l;
		rhs = _r;
		power = _p;
	}
};

map<string,int> gUnit;
int gCount = 0;

int dp[101][101];

int unit2num(string str){
	if(gUnit.find(str) == gUnit.end()){
		gUnit[str]=gCount++;
	}

	return gUnit[str];
}

int main(){
	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;
		gCount = 0;
		gUnit.clear();
		memset(dp,0x3f,sizeof(dp));

		vector<Data> relations;
		for(int i=0;i<n;i++){
			int num;
			string lhs;
			string eq;
			string rhs;
			string tmp;

			cin >> num >> lhs >> eq >> tmp >> rhs;
			int base,pow;
			sscanf(tmp.c_str(),"%d^%d",&base,&pow);
			relations.push_back(Data(lhs,rhs,pow));
		}

		for(int i=0;i<relations.size();i++){
			dp[unit2num(relations[i].lhs)][unit2num(relations[i].rhs)] = -relations[i].power;
			dp[unit2num(relations[i].rhs)][unit2num(relations[i].lhs)] = relations[i].power;
		}

		for(int k=0;k<gCount;k++){
			for(int i=0;i<gCount;i++){
				for(int j=0;j<gCount;j++){
					dp[i][j] = min(dp[i][k] + dp[k][j],dp[i][j]);
				}
			}
		}

		bool isok = true;
		for(int i=0;i<gCount;i++){
			if(dp[i][i] != 0) isok = false;
		}

		printf("%s\n",isok ? "Yes" : "No");
	}
}

Measured memory_bytes: 1332
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
vl v,dp;
ll f(int x,int k){
    if(x==0){
        return 0;
    }
    if(x<0){
        return intlimit;
    }
    if(dp[x]!=-1){
        return dp[x];
    }
     ll zg = intlimit;
     rep(i,1,k+1){
         zg = min(zg,f(x-i,k)+abs(v[x-i]-v[x]));
         if(!(x-i)){
             break;
         }
     }
     dp[x] = zg;
     return zg;
}
int main()
{
    int n,k;
    cin >> n >> k;
    v.resize(n);
    dp.resize(n,-1);
    rep(i,0,n){
        cin >> v[i];
    }
    dp[n-1] = f(n-1,k);
    cout << dp[n-1];
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <algorithm>
 
using namespace std;
 
int N, M, Q;
int st[200005];
 
int ele(pair<int,int>p)
{
  return p.second - p.first + 1;
}
 
int main()
{
  memset(st, 0, sizeof(st));
  scanf("%d%d%d", &N, &M, &Q);
  deque<pair<int,int> >b;
  b.push_back(make_pair(0, N-1));
 
  int pos = 0, now = 0;
  for(int i=0;i<M;i++){
    int a;
    scanf("%d", &a);
    if(a%2){
      while(a > ele(b.back())){
    a -= ele(b.back());
    b.push_front(b.back());
    b.pop_back();
      }
      pair<int, int>tmp = b.back();
      b.pop_back();
      now = tmp.second - (a-1);
      if(now == tmp.first){
    tmp.first++;
    b.push_front(tmp);
      }else if(now == tmp.second){
    tmp.second--;
    b.push_back(tmp);
      }else{
    b.push_front(make_pair(tmp.second - (a-1) + 1, tmp.second));
    b.push_back(make_pair(tmp.first, tmp.second -  (a-1) - 1 ));    
      }
    }else{
      while(a >= ele(b.front())){
    a -= ele(b.front());
    b.push_back(b.front());
    b.pop_front();
      }
      pair<int,int>tmp = b.front();
      b.pop_front();
      now = tmp.first + a;
      if(now == tmp.first){
    tmp.first++;
    b.push_front(tmp);
      }else if(now == tmp.second){
    tmp.second--;
    b.push_back(tmp);
      }else{
    b.push_back(make_pair(tmp.first, tmp.first + a - 1));
    b.push_front(make_pair(tmp.first + a + 1, tmp.second));
      }
    }
    st[now] = 1;
    now = b.front().first;
    //    for(int j=0;j<b.size();j++) printf("%d:%d ", b[j].first, b[j].second); puts("");
  }
  for(int i=0;i<Q;i++){
    int q;
    scanf("%d", &q);
    printf("%d\n", !st[q]);
  }
  return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n, k;
    cin >> n >> k;
    vi arr(n);
    garr(arr);
    sort(all(arr));
    int sum = 0;
    rlt(i, 0, k)
        sum += arr[i];
    cnl(sum);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3424
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

long long int f(long long int n, long long int b)
{
	if(n < b) return n;
	return f(n / b, b) + n % b;
}

int main()
{
	long long int n, s;
	cin >> n >> s;
	if(n == s){
		cout << n + 1 << endl;
		return 0;
	}
	if(n < s){
		cout << -1 << endl;
		return 0;
	}

	long long int ans = -1;
	for (long long int i = 2; i * i <= n; i++){
		if(f(n, i) == s){
			if(ans == -1) ans = i;
			else ans = min(ans, i);
		}
	}

	// i * i > nを満たすiは、n = p * i + q となる(1 <= p < i, 0 <= q < i)
	// p * i + q >= p * i > p * p
	// よって n > p * p
	// pとして1 ~ sqrt(n)を試せばよい
	// また p + q = s より q = s - p よって i = (n - q) / p = (n - s + p) / p
	for(long long int p = 1; p * p <= n; p++){
		long long int i = (n - s) / p + 1;
		if(i >= 2 && f(n, i) == s){
			if(ans == -1) ans = i;
			else ans = min(ans, i);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <deque>
#include <map>
using namespace std;


#define lli long long
#define ii pair <lli, lli>
#define pll pair <lli, lli>
#define iii pair <lli, pll>
#define pb push_back
#define X first
#define Y second

const lli Mod = 1E9 + 7;
const lli Inf = 1E9 + 7;
const lli N = 2E5 + 10;

lli n;
lli X, D;
iii Seg[N];

void Input()
{
    cin >> n >> X >> D;
}

void Solve()
{
    if (D == 0) {
        if (X == 0) cout << 1;
        else cout << n + 1;
        return ;
    }
    /// k * X + D * Sum k tk i
    /// 0 + 1 + 2 + ... + (k - 1) <= Sum k tk i <= (N - k) + (N - k + 1) + ... + (N - 1)
    if (D < 0) {
        X = - X;
        D = - D;
    }
    for (lli k = 0; k <= n; k++) {
        lli L = (lli) (k * X) + D * (k - 1) * k / 2;
        lli R = (lli) (k * X) + D * (k * n - k * (k + 1) / 2);
        Seg[k].X = (k * X % D + D);
        Seg[k].Y = {(L - Seg[k].X) / D, (R - Seg[k].X) / D};
        //cout << Seg[k].X << " " << L << " " << R << " " << (R - L) / D + 1 << "\n";
    }
    //cout << endl;

    sort(Seg , Seg + 1 + n);
    //for (int i = 0; i <= n; i++)
     //   cout << Seg[i].X << " " << Seg[i].Y.X << " " << Seg[i].Y.Y << endl;
    Seg[n + 1].X = -1;
    lli res = 0;
    lli Rem = Seg[0].X ,L = Seg[0].Y.X, R = Seg[0].Y.Y;
    for (lli i = 1; i <= n + 1; i++) {
        if (Rem != Seg[i].X) {
            res += R - L + 1;
            L = Seg[i].Y.X;
            R = Seg[i].Y.Y;
            Rem = Seg[i].X;
            continue;
        }
        if (Seg[i].Y.X <= R) R = max(R, Seg[i].Y.Y);
        else {
            res += (lli) R - L + 1;
            L = Seg[i].Y.X;
            R = Seg[i].Y.Y;
        }
    }
    cout << res;
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    lli testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




Measured memory_bytes: 7868
program main
  implicit none
  integer i, N, ans
  character(100) S
  read(*, *) S
  ans = 1
  !read(*, *) (L(i), i = 1,N)
  N = len(trim(S))
  do i = 1,N
    if (mod(i,2) == 1 .and. S(i:i) == 'L') then
      ans = 0
    else if (mod(i,2) == 0 .and. S(i:i) == 'R') then
      ans = 0
    endif
  end do
  if (ans == 0) then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  end if
end program main


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

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

    if (a >= 13) {
        cout << b << endl;
    }else if(a >= 6 && a < 13) {
        cout << b / 2 << endl;
    }else {
        cout << 0 << endl;
    }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double pi = 3.14;
int main() {
	// your code goes here
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n; 
	cin >> n;
	float ans = 2*pi*n;

	cout << fixed << setprecision(14) << ans << "\n";

	return 0;
	} 

Measured memory_bytes: 3788
def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    N = int(input())
    ans = float('INF')
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans = min(ans, f(i, N // i))
    print(ans)


main()


Measured memory_bytes: 3060
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

V<string> a;
ll N;

void dfs(ll max, ll len, string cur) {
  if (len == 0) {
    a.push_back(cur);
    return;
  }

  rep(i, max + 1) {
    string t = "" + cur + "";
    t += 'a' + i;

    if (i == max) {
      dfs(max + 1, len - 1, t);
    } else {
      dfs(max, len - 1, t);
    }
  }
}

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

  cin >> N;

  a = V<string>(0);
  dfs(0, N, "");

  sort(all(a));

  for (auto st : a) {
    cout << st << endl;
  }

  return 0;
}


Measured memory_bytes: 9716
function main(input) {
  input=input.trim();
  const N = parseInt(input.split(" ")[0], 10);
  var arrd=[]
  for(var i=0; i<N; i++){
    arrd.push(parseInt(input.split("\n")[1+i], 10))
  }

  var set=new Set(arrd)
  console.log(set.size);

}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
n=int(input()) 
pf={}
for i in range(2,int(n**0.5)+1):
    while n%i==0:
        pf[i]=pf.get(i,0)+1
        n//=i
if n>1:pf[n]=1
#print(pf)

cnt = 1
ans = 0
for i in pf.values():
    tmp = i
    while tmp >= cnt: 
        ans += 1
        tmp = tmp - cnt
        cnt += 1
    cnt = 1
print(ans)

Measured memory_bytes: 9460
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
        ret.push_back(i);
        if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll N; cin >> N;
    vll A(N+1);
    rep(i, 1, N+1){
        cin >> A[i];
    }
    vb ald(1000000, false);
    vll count(1000000, 0);
    ll c = 0;
    rep(i, 1, N+1){
        ald[A[i]] = true;
        count[A[i]]++;
    }
    rep(i, 1, N+1){
        vll t = divisor(A[i]);
        bool f = true;
        for(auto x: t){
            if(x == A[i]){
                continue;
            }
            if(ald[x]){
                f = false;
            }
        }
        if(f){
            if(count[A[i]] < 2){
                c++;
            }
        }
    }
    prt(c);
}

Measured memory_bytes: 12744
package main

import (
	"fmt"
)

func main() {
	var n, m, a int

	fmt.Scan(&n)
	fmt.Scan(&m)

	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		n -= a
	}

	if n < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(n)
	}
}


Measured memory_bytes: 2428
n,q = map(int, input().split())
s = input()
lst = []
num = 0
for i in range(n):
    if i == 0:
        lst.append(num)
        continue
    ss = s[i-1:i+1]
    if ss == 'AC':
        num += 1
    lst.append(num)
for _ in range(q):
    l,r = map(int,input().split())
    ans = lst[r-1] - lst[l-1]
    print(ans)

Measured memory_bytes: 6156
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fid(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define TTT "Stones"
#define maxn 105
#define maxk 100005
using namespace std;
int n, k, a[maxn];
int f[maxk][2], cl[maxk][2];
int cal(int x, int tt)
{
    if(x < a[1]) return 0;
    if(cl[x][tt]) return f[x][tt];
    cl[x][tt] = 1;
    f[x][tt] = 0;
    fi(i, 1, n)
    if(x - a[i] >= 0 && cal(x - a[i], 3 - tt) == 0)
    {
        f[x][tt] = 1;
        return 1;
    }
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(TTT".inp", "r", stdin);
    freopen(TTT".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    fi(i, 1, n) cin >> a[i];
    if(cal(k, 1)) cout << "First"; else cout << "Second";
}


Measured memory_bytes: 13028
import sys
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD=10**9+7
n,m=map(int,input().split())
a=set([int(input()) for _ in range(m)])
if n==1:
  print(1)
  exit()
if 1 in a and 2 in a:
  print(0)
  exit()
elif 1 in a:
  ans=[0,0,1]
elif 2 in a:
  ans=[0,1,0]
else:
  ans=[0,1,2]

@lru_cache(maxsize=None)
def cnt(x):
  if x<3:
    return ans[x]
  if x in a:
    return 0
  else:
    return (cnt(x-1)+cnt(x-2))%MOD

print(cnt(n))

Measured memory_bytes: 128784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll path; vl D;
//***********//
int main() {
	ll H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	ll T = 0;
	if (H1 == H2) {
		T = M2 - M1;
	}
	else {
		if (H1 < H2) {
			H1++;
			T += 60 - M1;
		}
		while (H1 < H2) {
			H1++;
			T += 60;
		}
		T += M2;
	}
	cout << T - K;
}

Measured memory_bytes: 3600
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=nii()
uf=UnionFind(n)
for i in range(m):
  a,b=nii()
  a-=1
  b-=1
  uf.union(a,b)

root=uf.roots()
ans=0
for i in root:
  ans=max(ans,uf.size(i))

print(ans)

Measured memory_bytes: 18488
# https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_3_A
# P426の解説がわかりやすい。なるほどなぁという感じ。

from itertools import product, chain

# load data
H, W = list(map(int, input().split()))
C = []
for i in range(H):
    C.append(list(map(int, input().split())))

# dp (H,W) ... dp[i][j]においてはC[i][j]から左上に向かってできる最大の正方形の辺の長さを記録していく

# dpテーブルの作成
dp = [[-1] * W for _ in range(H)]  # (H,W)

# dpテーブルの初期化
# 今回は0行目と0列目が即座にわかる
for j in range(W):
    if C[0][j] == 1:
        dp[0][j] = 0
    else:
        dp[0][j] = 1

for i in range(H):
    if C[i][0] == 1:
        dp[i][0] = 0
    else:
        dp[i][0] = 1


# dpテーブルの更新
for i, j in product(range(1, H), range(1, W)):
    if C[i][j] == 1:
        dp[i][j] = 0
    else:
        dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1

side_length = max(chain.from_iterable(dp))  # flatten
print(side_length**2)



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


int main(){
  int n;
  cin >> n;
  vector<int> ans(4,0);
  for(int i=0;i<n;++i){
    string s;
    cin >> s;
    if(s=="AC") ans[0]++;
    else if(s=="WA") ans[1]++;
    else if(s=="TLE") ans[2]++;
    else ans[3]++;
  }
  cout << "AC" << " " << "x" << " " << ans[0] << endl;
  cout << "WA" << " " << "x" << " " << ans[1] << endl;
  cout << "TLE" << " " << "x" << " " << ans[2] << endl;
  cout << "RE" << " " << "x" << " " << ans[3] << endl;
  return 0;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
        

Measured memory_bytes: 80856