akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
const int N = five;
ll ans[N];
int main()
{
       ll n,k;
       cin>>n>>k;
       for(int curr = k ; curr >= 1 ; curr--)
       {
              ans[curr] = power((k/curr),n,mod);
              for(int j = 2*curr ; j <= k ; j += curr)
              {
                     ans[curr] += (mod-ans[j])%mod;
                     ans[curr] %= mod;
              }
       }
       ll sum = 0;
       fri(i,1,k+1){
              sum += (i*ans[i])%mod;
              sum %= mod;
       }
       cout<<sum<<endl;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
const int maxn = 1e5 + 10;
vector<int> E[maxn];
int n, s, t, ans; 
bool inq[maxn], vis[maxn];
int fa[maxn];
vector<int> path;
void bfs()
{
	queue<int> Q;
	Q.push(t);
	inq[t] = 1;
	while(!Q.empty())
	{
		 int x = Q.front(); Q.pop();
		 if(x == s) break;
		 for(auto v : E[x])
		 	if(!inq[v])
		 	{
		 		inq[v] = 1;
		 		fa[v] = x;
		 		Q.push(v);
		 	}
	}
	int u = s;
	while(u)
	{
		path.push_back(u);
		u = fa[u];
	}
}
int dfs(int x)
{
	vis[x] = 1;
	int ret = 0;
	for(auto v : E[x])
		if(!vis[v])
			ret = max(ret, dfs(v) + 1);
	return ret;
}
int solve(int s, int t, int d)
{
	if(d == 0) return 0;
	int dis = dfs(s);
	dis += d - 1;
	return dis;
}
void force()
{
	for(auto v : path) vis[v] = 1;
	for(int i = 0, j = path.size() - 1; i <= j; ++i, --j)
	{
		//cout << ' ' << i << ' ' << j << ' ' << path[i] << ' ' << path[j] << endl;
		ans = max(ans, solve(path[i], path[j], j - i) + i);
	}
}
int main()
{
	scanf("%d%d%d", &n, &s, &t);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	bfs();
	force();
	printf("%d\n", ans);
	return 0;
}
	

Measured memory_bytes: 8448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] range = new int[m][2];
    for (int i = 0; i < m; i++) {
      range[i][0] = sc.nextInt() - 1;
      range[i][1] = sc.nextInt() - 1;
    }
    Arrays.sort(range, (int[] a, int[] b) -> a[1] != b[1] ? a[1] - b[1] : a[0] - b[0]);
    int result = 0;
    int[] last = range[0];
    for (int i = 1; i < m; i++) {
      if (last[1] <= range[i][0]) {
        result++;
        last = range[i];
      } else {
        last[0] = Math.max(last[0], range[i][0]);
        last[1] = Math.min(last[1], range[i][1]);
      }
    }
    System.out.println(result + 1);
  }
}

Measured memory_bytes: 58232
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	int ans=1,n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)ans+=min(ans,k);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int count_senbei(int senbei, int R) {
    int res=0;

    for(int i=0; i<R; ++i) {
        res+=senbei%2;
        senbei>>=1;
    }

    return max(res,R-res);
}

int main()
{
    int R,C;
    cin >> R >> C;

    while(R!=0 && C!=0) {
        int s[C]={0};
        int MAXR=0;

        for(int i=0; i<R; ++i) {
            for(int j=0; j<C; ++j) {
                int temp;
                cin >> temp;
                s[j]<<=1;
                s[j]+=temp;
            }

            MAXR<<=1;
            MAXR+=1;
        }

        int ans=0;

        for(int i=0; i<=MAXR; ++i) {
            int res=0;
            for(int j=0; j<C; ++j) {
                res+=count_senbei(s[j]^i,R);
            }
            ans=max(ans,res);
        }

        cout << ans << endl;

        cin >> R >> C;
    }

    return 0;
}

Measured memory_bytes: 3032
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
template<typename Monoid, typename OperatorMonoid=Monoid>
struct LazySegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	using G=function<Monoid(Monoid, OperatorMonoid, int)>;
	using H=function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
	int sz;
	vector<Monoid> data;
	vector<OperatorMonoid> lazy;
	const F f;
	const G g;
	const H h;
	const Monoid e1;
	const OperatorMonoid e0;

	LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){
		sz=1;
		while(sz<n) sz<<=1;
		data.resize(2*sz-1, e1);
		lazy.resize(2*sz-1, e0);
	}

	void build(vector<Monoid> v){
		for(int i=0; i<v.size(); i++) data[i+sz-1]=v[i];
		for(int i=sz-2; i>=0; i--) data[i]=f(data[2*i+1], data[2*i+2]);
	}

	void eval(int k, int l, int r){
		if(lazy[k]!=e0){
			data[k]=g(data[k], lazy[k], r-l);
			if(k<sz-1){
				lazy[2*k+1]=h(lazy[2*k+1], lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2], lazy[k]);
			}
		}
		lazy[k]=e0;
	}

	void update(int a, int b, const OperatorMonoid &x, int k, int l, int r){
		eval(k, l, r);
		if(r<=a || b<=l) return;
		if(a<=l && r<=b){
			lazy[k]=h(lazy[k], x);
			eval(k, l, r);
		}else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			data[k]=f(data[2*k+1], data[2*k+2]);
		}
	}
	void update(int a, int b, const OperatorMonoid &x){
		return update(a, b, x, 0, 0, sz);
	}

	Monoid find(int a, int b, int k, int l, int r){
		eval(k, l, r);
		if(b<=l || r<=a) return e1;
		if(a<=l && r<=b) return data[k];
		else return f(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
	}
	Monoid find(int a, int b){
		return find(a, b, 0, 0, sz);
	}
	Monoid operator[](const int &k){
		return find(k, k+1);
	}
};
int main()
{
    int n, q; cin>>n>>q;
    using mint=modint998244353;
    mint p10[200020];
    p10[0]=1;
    for(int i=1; i<=n; i++) p10[i]=p10[i-1]*10;
    mint inv9=mint(1)/mint(9);
    using pm=pair<mint, int>;
    auto f=[&](pm a, pm b){
        return pm(a.first*p10[b.second]+b.first, a.second+b.second);
    };
    auto g=[&](pm a, mint x, int len){
        return pm((p10[len]-1)*inv9*x, len);
    };
    auto h=[&](mint x, mint y){
        return y;
    };
    LazySegmentTree<pm, mint> seg(n, f, g, h, pm(0, 0), 0);
    vector<pm> v(n, pm(1, 1));
    seg.build(v);
    for(int i=0; i<q; i++){
        int l, r, d; cin>>l>>r>>d;
        l--;
        seg.update(l, r, mint(d));
        cout<<seg.find(0, n).first.val()<<endl;
    }
    return 0;
}

Measured memory_bytes: 13340
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
Z = 2000

for i in range( 2, Z + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int,input().split())

for i in range(1,K+1):
    c1 = cmb(K-1,i-1,mod)
    c2 = cmb(N-K+1,i,mod)
    print(int((c1*c2)%(1000000000+7)))



Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll X,Y,Z;
  cin>>X>>Y>>Z;
  
  cout<<Z<<" "<<X<<" "<<Y<<endl;
}


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

int main(){
    int A, B, C, X, ans = 0;
    cin >> A >> B >> C >> X;
    for(int a = 0; a <= A; ++a){
        for(int b = 0; b <= B; ++b){
            for(int c = 0; c <= C; ++c){
                if(500*a + 100*b + 50*c == X) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin>>n;
    ll a[n];
    ll max1=0;
    ll max2=0;
    for(int i=0;i<n;i++){
        ll num;
        cin>>num;
        a[i]=num;
        if(num>=max1){
            max2=max1;
            max1=num;
        }else if(num>=max2){
            max2=num;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==max1){
            ans=max2;
        }else ans=max1;
        cout <<ans<<endl;
    }



    return 0;

}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
string add(string s1,string s2)
{
    int i,a,b,n,m,k;
    string ans;
    n=s1.size(),m=s2.size();
    rep(k,26)
    {
        a=0;
        rep(i,n)
            if(s1[i]-'a'==k)a++;
        b=0;
        rep(i,m)
            if(s2[i]-'a'==k)b++;
        rep(i,min(a,b))
            ans.push_back('a'+k);
    }
    return ans;
}
int main()
{
    int i,n;
    string str;
    in(n);
    string ans;
    rep(i,n)
    {
        llin(str);
        sort(all(str));
        if(i==0)
            ans=str;
        else
            ans=add(ans,str);
    }
    llout(ans);
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, k, s;
    cin >> n >> k >> s;
    bool f = 0;
    for (int i = 0; i < n; i++) {
        if (i < k) {
            cout << s;
        }
        else {
            if (s == 1000000000) {
                cout << 1;
            }
            else {
                cout << s+1;
            }
        }
        if (i != n-1) {
            cout << " ";
        }
        else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N;
    int values[4] = {10, 50, 100, 500};
    
    bool flag = true;
    while(cin>>N, N){
        int coin[4];
        int sum = 0;
        for(int i=0; i<4; i++){
            cin >> coin[i];
            sum += coin[i] * values[i];
        }
        sum -= N;
        for(int i=0; i<4; i++){
            int d = sum/values[3-i];
            coin[3-i] -= min(d, coin[3-i]);
            sum -= d*values[3-i];
        }
        if(flag)
            flag = false;
        else
            cout << endl;
        for(int i=0; i<4; i++){
            if(coin[i])
                cout << values[i] << " " << coin[i] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (s.equals(u)) {
            System.out.println(a-1 + " " +b);
        }else {
            System.out.println(a + " " + (b-1));
        }
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;


public class Main {
	static Scanner sc;
	static int C1,C2,C3,count;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		new Main();
	}
	
	Main(){
		while (sc.hasNext()) {
			C1 = sc.nextInt();
			C2 = sc.nextInt();
			C3 = sc.nextInt();
			count =0;
			
			for(int i=1; i<=10; i++){
				if(!(i==C1 || i==C2 || i==C3)){
					if(i+C1+C2<=20) count++;
				}
			}
			Print();
		}
	}
	
	void Print(){
		if(count>=4)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 17192
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

std::string s;

int main(){
    std::cin >> s;
    if(s == "RRR"){
        printf("3\n");
    }else if(s == "SSS"){
        printf("0\n");
    }else if(s == "RRS" || s == "SRR"){
        printf("2\n");
    }else{
        printf("1\n");
    }
}


Measured memory_bytes: 3560
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::f64::consts::PI;

fn main() {
    input! {
        (a, b, h, m): (f64, f64, f64, f64)
    }
    // println!("{}, {}, {}, {}", a, b, h, m);

    // hとmから角度を求める
    // 12時からの角度で行くか
    let h_angle: f64 = f64::from(h * 30.0) + f64::from(m) * 0.5;
    let m_angle: f64 = f64::from(m * 6.0);

    // println!("{}, {}", h_angle, m_angle);

    // 短い方の角度を求める
    let mut hm_diff = (h_angle - m_angle).abs();
    if hm_diff > 180.0 {
        hm_diff = 360.0 - hm_diff;
    }

    // println!("{}, {}", hm_diff, ((hm_diff / 180.0) * PI).cos());

    let c = a * a + b * b - 2.0 * a * b * ((hm_diff / 180.0) * PI).cos();
    println!("{:.20}", c.sqrt());
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define pii tuple<ll,ll,ll>
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const ll N=1005;
const ll INF=LLONG_MAX;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
int a;
cin>>a;
int sol=a+a*a+a*a*a;
cout<<sol;

}


Measured memory_bytes: 3644
#include<map>
#include<queue>
#include<cstdio>
#include<vector>

#define	pb	push_back

using namespace std;

typedef	vector<int>	vi;

vi mv[13];
long long pow12[13];

void findEmptyPos(long long stat,int *z){
	for(int i=0,j=0;i<13;i++){
		if(stat%12==0)	z[j++]=12-i;
		stat/=12;
	}
}

long long sw(long long stat,int i,int j){
	long long powi=pow12[12-i],powj=pow12[12-j];
	int pi=(stat/powi)%12,pj=(stat/powj)%12;
	return stat+(pj-pi)*powi+(pi-pj)*powj;
}

void bfs(map<long long,int> &f,long long inistat,int stop){
	f[inistat]=0;
	queue<long long> qu;	qu.push(inistat);
	while(!qu.empty()){
		long long stat=qu.front();	qu.pop();
		int cnt=f[stat];
		if(cnt==stop)	break;

		int z[2];	findEmptyPos(stat,z);
		for(int i=0;i<2;i++){
			for(int j=0;j<mv[z[i]].size();j++){
				long long nextstat=sw(stat,z[i],mv[z[i]][j]);
				if(f.count(nextstat)==0){
					qu.push(nextstat);
					f[nextstat]=cnt+1;
				}
			}
		}
	}
}

int main(){
	long long a=1;
	for(int i=0;i<13;i++)	pow12[i]=a,a*=12;

	mv[0].pb(2);
	mv[1].pb(2);	mv[1].pb(5);
	mv[2].pb(0);	mv[2].pb(1);	mv[2].pb(3);	mv[2].pb(6);
	mv[3].pb(2);	mv[3].pb(7);
	mv[4].pb(5);
	mv[5].pb(1);	mv[5].pb(4);	mv[5].pb(6);	mv[5].pb(9);
	mv[6].pb(2);	mv[6].pb(5);	mv[6].pb(7);	mv[6].pb(10);
	mv[7].pb(3);	mv[7].pb(6);	mv[7].pb(8);	mv[7].pb(11);
	mv[8].pb(7);
	mv[9].pb(5);	mv[9].pb(10);
	mv[10].pb(6);	mv[10].pb(9);	mv[10].pb(11);	mv[10].pb(12);
	mv[11].pb(7);	mv[11].pb(10);
	mv[12].pb(10);

	int ans[]={0,1,2,3,4,5,6,7,8,9,10,11,0};
	long long ansstat=0;
	for(int i=0;i<13;i++)	ansstat=ansstat*12+ans[i];

	map<long long,int> f;
	bfs(f,ansstat,13);

	for(long long inistat;scanf("%lld",&inistat),~inistat;){
		for(int i=1,p;i<13;i++)	scanf("%d",&p),inistat=inistat*12+p;
		map<long long,int> g;
		bfs(g,inistat,7);

		int cmin=21;
		map<long long,int>::iterator it;
		for(it=g.begin();it!=g.end();it++){
			long long stat=it->first;
			int cnt=it->second;
			if(f.count(stat))	cmin=min(cmin,cnt+f[stat]);
		}
		if(cmin<=20)	printf("%d\n",cmin);
		else	puts("NA");
	}

	return 0;
}

Measured memory_bytes: 3340
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 2000
 
bool flag;
int n,k,u,v,ans;
int cnt[MAXN+3];
vector<int>G[MAXN+3];
 
int Dfs(int u,int fa,int d) {
    if(d>k) {
    	cnt[u]=0;
		return 1;
	}
    int ret=0; cnt[u]=1;
    for(int i=0;i<G[u].size();i++) {
        int v=G[u][i];
        if(v==fa)
            continue;
        ret+=Dfs(v,u,d+1);
        cnt[u]+=cnt[v];
    }
    return ret;
}
int main() {
    scanf("%d %d",&n,&k);
    if(k%2==0)
        flag=true;
    else flag=false;
    k/=2;
    for(int i=1;i<n;i++) {
        scanf("%d %d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1;i<=n;i++) {
        int tot=0; cnt[i]=1;
        for(int j=0;j<G[i].size();j++) {
            tot=max(tot,Dfs(G[i][j],i,1));
            cnt[i]+=cnt[G[i][j]];
        }
        if(flag) tot=0;
        tot+=cnt[i];
        ans=max(ans,tot);
    }
    printf("%d\n",n-ans);
    return 0;
}

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

using namespace std;

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

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int res = 0;
    for (int i = 0, r = 0; i < n - 1; i++) {
        if (h[i] >= h[i + 1]) {
            r++;
        } else {
            r = 0;
        }

        if (res < r) {
            res = r;
        }
    }

    cout << res << endl;
}


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

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

    if (s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else if(s=="Rainy"){
        cout << "Sunny" << endl;
    }
}

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

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll b=0, a=0;
    ll cnt=0;
    vector<string> V(N);
    for(int i = 0; i < N; i++){
        string S; cin >> S;
        for(int j = 0; j < S.size()-1; j++){
            if(S[j] == 'A' && S[j+1] == 'B') ans++;
        }
        
        if(S[0] == 'B' && S[(int)S.size()-1] == 'A') cnt++;
        else if(S[0] == 'B') b++;
        else if(S[(int)S.size()-1] == 'A') a++;

    }
    ll c;
    if(cnt == 0) c = min(a, b);
    else {
        if(a+b>0) c = cnt+min(a, b);
        else{
            c = cnt-1;
        }
    }
    cout << ans + c << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n,r;
cin >> n >> r;
ll ans = max(r,(10-n)*100+r);
cout << ans << endl;
}



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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



const int MOD = 1E9 + 7;

ll exp(int a, int n) {
        if (n == 0) return 1;
        ll b = exp(a, n / 2);
        (b *= b) %= MOD;
        if (n & 1) (b *= a) %= MOD;
        return b;
}

void _main() {
        int n; cin >> n;
        vector<ll> a(n); cin >> a;
        ll ans = 0;
        for (int bit = 60; bit >= 0; bit--) {
                ll cnt[2]{};
                for (int i = 0; i < n; i++) {
                        cnt[!!(1LL << bit & a[i])]++;
                }

                ans += cnt[0] * cnt[1] % MOD * exp(2, bit) % MOD;
                ans %= MOD;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(i % 2 == 0) cout << char(s[i]);

    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 592
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll vi[20][20];
ll vii[20][20];

int main(){
  for(ll i=0; i<20; i++) {
    for(ll j=0; j<20; j++) {
      vi[i][j] = 0;
      vii[i][j] = 0;
    }
  }
  ll h, w;
  cin>>h>>w;
  vector<string> v;
  for(ll i=0; i<h; i++) {
    string s;
    cin>>s;
    v.push_back(s);
  }
  ll sx, sy;
  bool f = true;
  for(ll i=0; i<h; i++) {
    for(ll j=0; j<w; j++) {
      if(v[i][j]=='.') {
	sx = j;
	sy = i;
	break;
      } 
    }
  }
  for(ll i=0; i<h; i++) {
    for(ll j=0; j<w; j++) {
      if(v[i][j]!='.')
	f = false;
    }
  }
  if(f) {
    std::cout << (h-1)+(w-1) << std::endl;
    return 0;
  }
  ll m = 0;
  ll mx, my;
  queue<pair<pair<ll, ll>, ll>> q;
  set<pair<ll, ll>> visited;
  ll d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  q.push(make_pair(make_pair(sx, sy), 0));
  while(!q.empty()) {
    ll x = q.front().first.first;
    ll y = q.front().first.second;
    ll cost = q.front().second;
    vi[y][x] = 1;
    //visited.insert(make_pair(x, y));
    if(cost > m) {
      mx = x;
      my = y;
      m = cost;
    }
    q.pop();
    for(ll i=0; i<4; i++) {
      ll nx = x+d[i][0];
      ll ny = y+d[i][1];
      if(0 <= nx and nx < w and 0 <= ny and ny < h and v[ny][nx]=='.' and vi[ny][nx]==0) {
	q.push(make_pair(make_pair(nx, ny), cost+1));
      }
    }
  }
  m = 0;
  q.push(make_pair(make_pair(mx, my), 0));
  set<pair<ll, ll>> vis;
  while(!q.empty()) {
    ll x = q.front().first.first;
    ll y = q.front().first.second;
    ll cost = q.front().second;
    vii[y][x] = 1;
    //vis.insert(make_pair(x, y));
    if(cost > m) {
      mx = x;
      my = y;
      m = cost;
    }
    q.pop();
    for(ll i=0; i<4; i++) {
      ll nx = x+d[i][0];
      ll ny = y+d[i][1];
      if(0 <= nx and nx < w and 0 <= ny and ny < h and v[ny][nx]=='.' and vii[ny][nx]==0) {
	q.push(make_pair(make_pair(nx, ny), cost+1));
      }
    }
  }
  std::cout << m << std::endl;
  // std::cout << sx << " " << sy << std::endl;
  // std::cout << mx << " " << my << " "<< m << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n, a[50];

int solve(int i, int m) {
    if(m == 0) {
        return 1;
    }
    if(i >= n) {
        return 0;
    }
    int res = solve(i+1, m) || solve(i+1, m-a[i]);
    return res;
}

int main() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    int q;
    cin >> q;

    int M;
    rep(i, q) {
        cin >> M;
        if(solve(0, M)) {
            cout << "yes" << "\n";
        }
        else {
            cout << "no" << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3056
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define M 1000000007

 int main()
 {
    int m,d,ans=0;
    cin>>m>>d;
    for(int i=22;i<=d;i++)
    {
        int d1=i%10;
        int d2=i/10;
        if((d1*d2)<=m && d1>1 && d2>1)
            //cout<<i<<endl;
            ans++;
    }
    cout<<ans;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<bitset>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 2010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn];
std::bitset<maxn*maxn>f;
int n;
int main()
{
	n=read();
	int sum=0;
	for(int i=1;i<=n;i++)
		a[i]=read(),sum+=a[i];
	f.set(0);
	for(int i=1;i<=n;i++)
		f|=f<<a[i];
	int ans=(sum+1)/2;
	while(!f[ans])++ans;
	writeln(ans);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M, K;
    cin >> N >> M >> K;
    bool ok = false;
    rep(i, N + 1) {
        rep(j, M + 1) {
            if (i * (M - j) + (N - i) * j == K) ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import sys
 
day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
num = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
 
for s in sys.stdin:
    M, D = map(int, s.strip().split())
    if M == 0:
        break
    totalDay = D
    M -= 1
 
    while M > 0:
        totalDay += num[M-1]
        M -= 1
 
    print(day[(totalDay+2)%7])


Measured memory_bytes: 5600
import sys
input = sys.stdin.readline

def main():
    input_line = list(map(int, input().split()))
    a = input_line[0]
    b = input_line[1]
    
    if((a + b) % 2 == 0):
    	print(int((a + b) / 2))
    else:
      print("IMPOSSIBLE")





if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#define ll long long
#define M 1010
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int sum[M];
bool vis[M];
int n, m;
int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; i++) {
		int x = read();
		for(int j = 1; j <= x; j++) {
			sum[read()]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= m; i++) {
		if(sum[i] == n) ans++;
	}
	cout << ans << "\n";


	return 0;
}




Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
else:
    s[k-1] = "c"
for i in range(n):
    if i != n-1:
        print(s[i],end="")
    else:
        print(s[i])

Measured memory_bytes: 3060
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
 
 
N = int(input())
An = list(map(int, sys.stdin.readline().rstrip().split()))
 
ans = 0
mn = 10**9
minus = 0
for a in An:
  mn = min(mn, abs(a))
  ans += abs(a)
  if a < 0:
    minus += 1
 
if minus%2 == 0:
  print(ans)
else:
  print(ans-mn*2)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S == "MON"){
    cout << 6 << endl;
  }else if(S == "TUE"){
    cout << 5 << endl;
  }else if(S == "WED"){
    cout << 4 << endl;
  }else if(S == "THU"){
    cout << 3 << endl;
  }else if(S == "FRI"){
    cout << 2 << endl;
  }else if(S == "SAT"){
    cout << 1 << endl;
  }else if(S == "SUN"){
    cout << 7 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (int)(n); i++)
int main(){
    int N;
    cin >> N;
    vector<int> Acount(1000001);
    vector<int> A(N);
    vector<bool> ans(1000001,false);
    rep(i,N){
        cin >> A.at(i);
        Acount.at(A.at(i))++;
        ans.at(A.at(i))=true;
    }
    sort(A.begin(),A.end());
    rep(i,N){
        if(ans.at(A.at(i))){
            int j=2;
            while(A.at(i)*j<=A.at(N-1)){
                ans.at(A.at(i)*j)=false;
                j++;
            }
        }
    }
    rep(i,1000001){
        if(Acount.at(i)>1) ans.at(i)=false;
    }
    int ANS=0;
    rep(i,1000001){
        if(ans.at(i)) ANS++;
    }
    cout << ANS << endl;
}

Measured memory_bytes: 8012
import os

N = int(input())
S = [0] * N

for i in range(0, N):
    S[i] = input()

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == "AC":
        AC+=1
    elif i == "WA":
        WA+=1
    elif i == "TLE":
        TLE+=1
    elif i == "RE":
        RE+=1

print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

        

Measured memory_bytes: 15992
a,b,c = map(int,input().split())
if a==b:
    if a==c:
        print('No')
        exit()
    else:
        print('Yes')
        exit()
if b==c:
    if b==a:
        print('No')
        exit()
    else:
        print('Yes')
        exit()
if c==a:
    if c==b:
        print('No')
        exit()
    else:
        print('Yes')
        exit()
else:
    print('No')
    exit()

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		long len = 0;
		char[] c = s.toCharArray();
		for(int i = 0; i < c.length; i++) {
			long temp = c[i]-'0';
			k -= (long) Math.pow(temp, 5*Math.pow(10, 15));
			if(k <=0) {
				System.out.println(temp);
				break;
			}
		}
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

#define MOD 1000000007

long long totient(long long a) {
	ll ret = a;
	for(int i = 2;i * i <= a;i++){
		if(a % i == 0){
			ret = ret * (i - 1) / i;
			while(a % i == 0)a /= i;
		}
	}
	if(a > 1)ret = ret * (a - 1) / a;
	return ret;
}

// a / b (mod p) b と p は互いに素
// O(sqrt(p))かかるので注意
long long totient_div(long long a, long long b, long long p) {
	long long ret = a;
	long long tp = totient(p) - 1;
	long long c = b;
	for(int i = 0;i <= 60;i++){
		if(tp & (1LL << i))ret = (ret * c) % p;
		c = (c * c) % p;
	}
	return ret;
}

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 3333333
vector<long long> fact(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
    long long ret = fact[n];
	long long tmp = (fact[r] * fact[n-r]) % MOD;
    return mod_div(ret,tmp);
}

ll seica(ll a, ll b){
	return combination(a+b, a);
}

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

	ll r1, r2, c1, c2;cin >> r1 >> c1 >> r2 >> c2;
	ll ans = seica(r1, c1);
	for(ll i = r1+1;i <= r2;i++){
		ans = (ans + seica(i, c2)) % MOD;
	}
	for(ll i = c1+1;i <= c2;i++){
		ans = (ans + seica(r2, i)) % MOD;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 2e5 + 5;

vector < int > p (N), sz (N);

int find (int u) {
  if (p[u] == u) return u;
  return p[u] = find (p[u]);
}

void merge (int u, int v) {
  u = find (u);
  v = find (v);
  if (u == v) return;
  if (sz[u] > sz[v]) swap (u, v);
  p[u] = v;
  sz[v] += sz[u];
}

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

  for (int i = 0; i < N; i++) {
    sz[i] = 1;
    p[i] = i;
  }

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    merge (u, v);
  }

  int mx = 0;
  for (int i = 1; i <= n; i++) {
    mx = max (mx, sz[i]);
  }

  cout << mx << '\n';
}


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

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


	 long long result = 1;


	string S1, S2;
	cin >> S1 >> S2;

	int prev = 0;

	for (int a = 0; a < N; a++) {
		if (a == 0) {
			if (S1[a] == S2[a]) {
				result *= 3;
				prev = 1;
			}
			else {
				result *= 6;
				prev = 2;
			}
		}
		else {
			if (S1[a - 1] == S2[a - 1]) {
				result *= 2;
			}
			else {
				if (S1[a] == S2[a]) {
					result *= 1;
				}
				else {
					result *= 3;
				}
			}
		}
		if (S1[a] != S2[a])a++;
		

		result %= 1000000007;
		
	}


	

	cout << result << endl;
	
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <bits/stdc++.h>
using namespace std;

// rep (i, 回数) { // 0~回数-1
// 処理
//}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main ()
{
    int k,s;
    cin >> k >> s;

    int count = 0 ;
    for( int x=0; x <=k; ++x){
        for( int y = 0; y<=k; ++y){
            const int zz = s-x-y;
            if( zz >=0  && zz <= k) {
                ++ count ;
            }
        }
    }


    cout << count;
    cout << endl;
    return 0;
}                       

Measured memory_bytes: 3524
N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
dict = {}
for i in A_lst:
    if not i in dict.keys():
        dict[i] = 1
    else:
        dict[i] += 1

val_lst = list(dict.values())
val_lst.sort()
k = len(val_lst)
cnt = 0

for i in val_lst:
    if k <= K:
        break
    else:
        k -= 1
        cnt += i

print(cnt)


Measured memory_bytes: 34172
//Saurabhsahab
#include<bits/stdc++.h>
#define ll long long 
#define mod 1000000007
#define pb push_back
#define  V vector<ll>
#define lcm(x,y) boost::math::lcm(x,y)
#define f(i,s,n) for(ll i=s;i<n;i++)
#define f1(i,s,n) for(ll i=s;i>n;i--)
#define T ll t ; cin>>t; while(t--)
using namespace std ;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   ll k,a,b,x,m,s=0;
   cin>>k>>a>>b;
   if((a==b&&a%k==0)||a%k==0||b%k==0){
       cout<<"OK";
       return 0;
   }
   else{
       if(a==b&&a%k!=0){
       cout<<"NG";
       return 0;
       }
   }
   x=a/k;
   f(i,x,1000){
      m=k*i;
      if(m>=a&&m<=b){
          s=1;
          break;
      }
   }
   if(s==1)
   cout<<"OK";
   else
   cout<<"NG";
   
}

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

vector<bool> prime_sieve; //Á¥†Êï∞„Åã„Å©„ÅÜ„Åã
vector<ll> prime_numbers; //Á¥†Êï∞„ÅÆ„É™„Çπ„Éà
void init_prime(ll n){
  prime_sieve.resize(n+1, true);
  prime_sieve[0] = prime_sieve[1] = false;
  for(ll i = 2; i <= n; i++){
    if(prime_sieve[i] == true){
      prime_numbers.push_back(i);
      for(ll j = 2; i * j <= n; j++){
	prime_sieve[i * j] = false;
      }
    }
  }
}

//Á¥†Êï∞„ÅãÂà§ÂÆö O(sqrt(N))
bool is_prime(ll N){
  if(N <= 1) return false;
  for(ll i = 2; i * i <= N; i++){
    if(N % i == 0){
      return false;
    }
  }
  return true;
}

//N!„Å´‰ΩïÂÄãÁ¥†Êï∞p„ÅåÂ≠òÂú®„Åô„Çã„Åã
int count_prime(int N, int p){ 
  int res = 0;
  int tmp = p;
  while(N >= tmp){
     res += N/tmp;
    tmp *= p;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  init_prime(N);
  int cnt75 = 0;
  int cnt24 = 0;
  int cnt14 = 0;
  int cnt4 = 0;
  int cnt2 = 0;
  int cnt5 = 0;
  for(auto x: prime_numbers){
    int tmp = count_prime(N,x);
    if(tmp >= 74){
      cnt75++; cnt24++; cnt14++; cnt4++; cnt2++; cnt5++;
    }else if(tmp >= 24){
      cnt24++; cnt14++; cnt4++; cnt2++; cnt5++;
    }else if(tmp >= 14){
      cnt14++; cnt4++; cnt2++; cnt5++;
    }else if(tmp >= 5){
      cnt4++; cnt2++; cnt5++;
    }else if(tmp >= 4){
      cnt4++; cnt2++;
    }else if(tmp >= 2){
      cnt2++;
    }
  }
   int res = 0;
  res += cnt75;
  res = res +  cnt24 * (cnt2 - 1);
  res = res + cnt14 * (cnt4 - 1);
  res += (cnt4 * (cnt4-1)) / 2  * (cnt2-2);
  cout << res << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (ll i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll F(ll A, ll B) {
    return max(log10(A)+1, log10(B)+1);
}

int main() {

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

    ll N; cin >> N;

    ll res = INF;
    FOR(i, 1, N+1) {
        if (i*i > N) break;

        if (N%i == 0) {
            res = min(res, F(i, N/i));
        }
    }

    cout << res << "\n";
}


Measured memory_bytes: 256
# ABC124 A

def main():
    AB = list(map(int, input().split()))

    result = 0

    for i in range(2):
        max_num = max(AB)
        result += max_num
        AB[AB.index(max_num)] = max_num - 1
    
    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
# C - 755

def dfs(n,s):
    if int(s)>n:
        return 0
    res=0
    if s.count('7')>0 and s.count('5')>0 and s.count('3')>0:
        res=1
    
    for i in '753':
        res+=dfs(n,s+i)
    return res

n=int(input())
print(dfs(n,'0'))

Measured memory_bytes: 3060