akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	/**
	 * @param args 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
//			String ss = br.readLine();
//			String tt = br.readLine();
			String ss = sc.next();
			String tt = sc.next();
			int[]s = new int[ss.length()];
			int[]t = new int[tt.length()];
			for(int i=0;i<s.length;i++){
				s[i] = ss.charAt(i);
			}
			for(int i=0;i<t.length;i++){
				t[i] = tt.charAt(i);
			}
			SuffixArray sa = new SuffixArray(s);
			int left=-1,right=t.length+1;
			while(left<right-1){
				int len= (left+right)/2;
				boolean f = false;
				int[] sub = new int[len];
				for(int i=0;i<t.length;i++){
					if(i+len>t.length)break;
					for(int k=i;k<i+len;k++){
						sub[k-i]=t[k];
					}
					if(sa.contain(sub)){
						f=true;
						break;
					}
				}
				if(f){
					left=len;
				}
				else{
					right=len;
				}

			}
			System.out.println(left);
		}
	}

	static class SuffixArray {

		int n,k=1;
		Integer[] sa,rank,tmp;
		int[] s;

		SuffixArray(int[] _s) {
			s=_s;
			n = s.length;
			rank=new Integer[n+1];
			sa=new Integer[n+1];
			tmp=new Integer[n+1];
			for(int i=0;i<n;i++){
				sa[i]=i;
				rank[i]=s[i];
			}
			sa[n]=n;
			rank[n]=-1;

			for(k=1;k<=n;k<<=1){
				Arrays.sort(sa,new Comparator<Integer>(){
					@Override
					public int compare(Integer o1, Integer o2) {
						int r1=rank[o1];
						int r2=rank[o2];
						if(r1!=r2)return r1-r2;
						int r11=o1+k <= n ? rank[o1+k] : -1;
						int r22=o2+k <= n ? rank[o2+k] : -1;

						return r11-r22;
					}
				});
				tmp[sa[0]]=0;
				for(int i=1;i<=n;i++){
					tmp[sa[i]]=tmp[sa[i-1]]+ (compare(sa[i-1],sa[i])!=0?1:0);
				}
				for(int i=0;i<=n;i++){
					rank[i]=tmp[i];
				}
			}
		}

		/*
		 * s.contains(t)的な
		 */
		boolean contain(int[] t){
			return contain(s,sa,t);
		}

		private boolean contain(int[]s,Integer[] sa,int[] t){
			int a=0,b=s.length;
			while(b-a>1){
				int c = (a+b)/2;
				//			String sub = s.substring(sa[c], Math.min(sa[c]+t.length, s.length));
				if(compare(s,sa[c],Math.min(sa[c]+t.length, s.length),t)<0){
					a=c;
				}
				else{
					b=c;
				}
			}
			return compare(s,sa[b], Math.min(sa[b]+t.length, s.length),t)==0;
		}

		/*
		 * s.substring(i1,i2).compareTo(t) 的な
		 */
		private int compare(int[]s,int i1,int i2,int[] t){
			for(int i=i1;i<i2;i++){
				if(i-i1>=t.length){
					return 1;
				}
				if(s[i]!=t[i-i1]){
					return s[i]-t[i-i1];
				}
			}
			return (i2-i1)-t.length;
		}

		private int compare(Integer o1, Integer o2) {
			int r1=rank[o1];
			int r2=rank[o2];
			if(r1!=r2)return (r1-r2);
			int r11=o1+k <= n ? rank[o1+k] : -1;
			int r22=o2+k <= n ? rank[o2+k] : -1;

			return (r11-r22);
		}
	}
}

Measured memory_bytes: 72228
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

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

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

string s;

void init()
{
}

void solve()
{
    ll ans = 0;
    int nums[10];
    int len = s.size();
    REP(i, len){
        nums[i] = s[i] - '0';
    }
    REP(i, 1<<(len-1)){
        ll sum = 0;
        ll n = nums[0];
        REP(j, len-1){
            if((i>>j) & 1){
                sum += n;
                n = nums[j+1];
            }else{
                n *= 10;
                n += nums[j+1];
            }
        }
        sum += n;
        ans += sum;
    }
    cout << ans << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N;
	double PI = 3.141592653589793;
	cin >> N;

	cout << showpoint;
	cout << fixed;
	cout << setprecision(20);
	cout << 2.0*PI*(double)N << endl;


    biday;
}
 
//...............BYE BYE................

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

int main(){
    ll N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    ll tmpcnt = 0;
    ll cnt = 0;

    rep(i, N-1){
        if(S[i] == S[i+1]){
            tmpcnt++;
        }else{
            cnt += tmpcnt;
            tmpcnt = 0;
        }
    }
    cnt += tmpcnt; tmpcnt = 0;

    cnt += 2 * K;
    if(cnt > N-1) cnt = N - 1;
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define Len 100005


typedef struct pp{
char name[100];
int t;
}P;

P Q[Len];
int head ,tail,n;

void enqueue(P x){
Q[tail]=x;
tail=(tail+1)%Len;

}

P dequeue(){
	P x=Q[head];
	head=(head+1)%Len;
	return x;
}

int min(int a,int b){return a<b?a:b;}

int main(){

int elaps=0,c;
int i,q;
P u;
scanf("%d %d",&n,&q);
for(i=1;i<=n;i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head=1;tail=n+1;

while(head!=tail){
u=dequeue();
c=min(q,u.t);
u.t-=c;
elaps+=c;
if(u.t>0)enqueue(u);
else{
printf("%s %d\n",u.name,elaps);
}
}
return 0;
}

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

vector<pair<int, int>> adj[100005];
int col[100005], sol[100005];
int n, r;

void dfs(int x, int p)
{
    int ci = 1;
    int y, k;
    for (auto par : adj[x])
    {
        tie(y, k) = par;
        if (y != p)
        {
            if (ci == col[x])
                ci++;

            r = max(r, ci);
            sol[k] = col[y] = ci++;
            dfs(y, x);
        }
    }
}

int main()
{
    cin >> n;
    for (int i = 1; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].emplace_back(b, i);
        adj[b].emplace_back(a, i);
    }
    dfs(1, -1);
    cout << r << '\n';
    for (int i = 1; i < n; ++i)
        cout << sol[i] << '\n';
}


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

long long N, L[1000009];

int main() {
	cin >> N;
	for (long long i = 0; i < N * 3; i++) cin >> L[i];

	sort(L + 0, L + N * 3);

	long long ret = 0;
	for (int i = 0; i < N; i++) ret += L[N * 3 - 1 - 1 - 2 * i];
	cout << ret;

	return 0;
}

Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int main () {
  ll N , K ;
  cin >> N >> K ;
  ll a[N] ;
  for(int i =0 ;i < N;i++) 
    cin >> a[i] ;
  sort(a,a+N) ;
  ll min_val = a[K-1] - a[0] ;
  for(int i =1;i <= N - K;i++)
    min_val = min(min_val , a[i+K-1] - a[i]) ;
  cout<<min_val<<endl;
  return 0 ;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  int count = 1;
  
  for (int i = 0; i < N - 1; i++) {
    if (a.at(i) != a.at(i + 1)) count++;
  }
  cout << count << endl;
}

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

int main()
{
    int d, t, s;
    cin >> d >> t >> s;

    cout << (t * s >= d ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    long double al, Mal, PI=3.1415926535;
    cin >> n;
    int X[n], Y[n];
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i];
    }
    if (n == 2)
    {
        cout << 0.5 << endl;
        cout << 0.5;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        vector <long double> V;
        for (int y = 0; y < n; y++)
        {
            if (i != y)
            {
                al = atan2(Y[y]-Y[i], X[y]-X[i]);
                V.push_back(al);
            }
        }
        Mal = 0;
        sort(V.begin(), V.end());
        for (int y = 1; y < V.size(); y++)
        {
            Mal = max(Mal, V[y] - V[y-1]);
        }
        Mal = max(Mal, 2*PI+V[0]-V[V.size()-1]);
        al = (Mal-PI) / (2*PI);
        if (al < 0)
        {
            cout << 0 << "\n";
        }
        else
        {
            cout << fixed << setprecision(7) << al << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s[3] = {};
    cin >> s[0] >> s[1] >> s[2];
    if (s[0].back() == s[1][0] && s[1].back() == s[2][0]) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
	cin >> N;
	ll ans = (N > 2 ? 2 : 1);
	for (ll i = 2; i * i <= N; ++i) {
		if (N % i == 0) {
			ll n = N;
			while (n % i == 0) { n /= i; }
			ans += (n % i == 1);
		}
		if (N % i == 1) {
			++ans;
			ans += (i != (N - 1) / i);
		}
	}
	cout << ans << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( s.size() > K )
    {
        rep(i,K) cout << s[i];
        cout << "..." << endl;
    }
    else cout << s << endl;
}


Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

const int mod = 1000000007;

int main() {
  string s; cin >> s;
  int n = s.length();
  vector<vector<long long>> dp(n+10, vector<long long>(13, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int now = (s[i] == '?' ? -1 : s[i]-'0');
    for (int j = 0; j < 10; j++) {
      if (now != -1 && now != j) { continue; }
      for (int k = 0; k < 13; k++) {
        dp[i+1][(k*10+j)%13] += dp[i][k];
      }
    }
    for (int j = 0; j < 13; j++) {
      dp[i+1][j] %= mod;
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}

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

int f(int x,int y,int z){
    return pow(x,2)+pow(y,2)+pow(z,2)+x*y+y*z+z*x;
}

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

    for(int n=1;n<=N;n++){
        int ans=0;
        int intn=(int)sqrt(n)+1;
        for(int x=1;x<=intn;x++){
            for(int y=1;y<=x && f(x,y,1)<=n ;y++){
                for(int z=1; z<=y && f(x,y,z)<=n ;z++){
                    if(f(x,y,z)==n){
                        //cout<<"x "<<x<<" y "<<y<<" z "<<z<<endl;
                        if(x==y && y==z) ans++;
                        else if((x==y)||(y==z)) ans+=3;
                        else ans+=6;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 3480
map${-$`}{-$&}=${-$&}{-$`}=$'*<>=~/ .* /,2..<>;@s=<>!~$"-$';map$$_//=$u+$u{$s[@s]=$_},keys%{*u=$_}for@s;//,print${-$`}+${-$'},$/for<>


Measured memory_bytes: 93568
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  int h = 0, w = 0;

  cin >> h >> w;

  char a[10][10] = {0};

  int tot = 0, ans = 0, k = 0;

  cin >> k;

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> a[i][j];
      tot += a[i][j] == '#';
    }
  }

  for(int i = 0; i < (1 << h); i++)
    for(int j = 0; j < (1 << w); j++) {
      bitset<10> rc(i);
      bitset<10> cc(j);
      int del = 0;
      bool u[10][10] = {false};
      for(int ii = 0; ii < h; ii++) {
        if(!rc[ii]) continue;
        for(int jj = 0; jj < w; jj++) {
          if(!u[ii][jj] && a[ii][jj] == '#') del++;
          u[ii][jj] = true;
        }
      }
      for(int jj = 0; jj < w; jj++) {
        if(!cc[jj]) continue;
        for(int ii = 0; ii < h; ii++) {
          if(!u[ii][jj] && a[ii][jj] == '#') del++;
          u[ii][jj] = true;
        }
      }
      ans += (tot - del) == k;
    }

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
     
int main(void){
	int n,total,i;
	int d[3];
	int *a;
    
	scanf("%d",&n);
	a=(int *)malloc(sizeof(int)*n);
	d[0]=0;
	scanf("%d",&d[1]);
	a[0]=abs(d[1]);
   	total=a[0];
	for(i=0;i<n-1;i++){
		scanf("%d",&d[2]);
		a[i+1]=abs(d[1]-d[2]);
		total+=a[i+1];
		a[i]+=a[i+1]-abs(d[0]-d[2]);
		d[0]=d[1];
		d[1]=d[2];
	}
	a[n-1]+=abs(d[1])-abs(d[0]);
	total+=abs(d[1]);
	for(i=0;i<n;i++){
		printf("%d\n",total-a[i]);
	}
     
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    
    public void Slove()
    {
        var n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var oddArray = 
            array.Where((x, i) => (i & 1) == 1).ToArray();
        var oddCount =
            oddArray
            .GroupBy(x => x)
            .OrderByDescending(x => x.Count())
            .ToArray();
        var evenArray = 
            array.Where((x, i) => (i & 1) == 0).ToArray();
        var evenCount =
            evenArray
            .GroupBy(x => x)
            .OrderByDescending(x => x.Count())
            .ToArray();
        //System.Console.WriteLine(oddCount);
        //System.Console.WriteLine(evenCount);
        if(evenCount.First().Key != oddCount.First().Key)
            System.Console.WriteLine(n - (oddCount.First().Count() + evenCount.First().Count()));
        else
        {
            System.Console.WriteLine(
                Math.Min(
                n - (oddCount.First().Count() + (evenCount.Skip(1).Any() ? evenCount.Skip(1).First().Count() : 0)),
                n - ((oddCount.Skip(1).Any() ? oddCount.Skip(1).First().Count() : 0) + evenCount.First().Count()))
                );
        }
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 38604
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
// #define int long long int

int t[600][600];

void solve() {
  int H, W;
  cin >> H >> W;
  for (int h = 1; h <= H; h++) {
    for (int w = 1; w <= W; w++) {
      cin >> t[h][w];
    }
  }

  vector<pair<int, int>> v;
  for (int h = 1; h <= H; h++) {
    if (h % 2 == 1) {
      for (int w = 1; w <= W; w++) {
        v.emplace_back(h, w);
      }
    } else {
      for (int w = W; w >= 1; w--) {
        v.emplace_back(h, w);
      }
    }
  }

  vector<tuple<int, int, int, int>> ans;
  for (int i = 0; i < v.size() - 1; i++) {
    auto p = v[i];
    int h = p.first;
    int w = p.second;

    auto pn = v[i + 1];
    int hn = pn.first;
    int wn = pn.second;

    if (t[h][w] % 2 == 1) {
      t[h][w]--;
      t[hn][wn]++;
      ans.emplace_back(h, w, hn, wn);
    }
  }

  printf("%ld\n", ans.size());
  for (auto &t : ans) {
    printf("%d %d %d %d\n", get<0>(t), get<1>(t), get<2>(t), get<3>(t));
  }
}

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


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL n;
LL f(LL x)
{
    LL cnt=0;
    for(LL i=0; i<n; i++)
    {
        if(x&(1<<i))
            cnt++;
    }
    return cnt;
}
int main()
{
    cin>>n;
    vector<pLL>v[n];
    for(LL i=0; i<n; i++)
    {
        LL sz;
        cin>>sz;
        for(LL j=0; j<sz; j++)
        {
            LL x,y;
            cin>>x>>y;
            x--;
            v[i].pb({x,y});
        }

    }
    LL mx=0;
//    cout<<"her\n";
    for(LL i=0; i<(1<<n); i++)
    {
//        cout<<i<<" ..1\n";

        LL fg=0;
        for(LL j=0; j<n; j++)
        {
            if(i&(1<<j))
            {
                for(LL k=0; k<v[j].size(); k++)
                {
                    LL p=1<<v[j][k].ff;
                    if(v[j][k].ss==0 and (i&p))
                        fg=1;
                    if(v[j][k].ss==1 and (i&p)==0)
                        fg=1;
                }
            }
        }
//        cout<<i<<" .. 2\n";
        if(fg==0)
            mx=max(mx,f(i));
    }
    cout<<mx;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    
    cin >> A >> B >> C >> D;
    bool turn = true;
    while(A > 0 && C > 0){
        if(turn){
            C -= B;
            //cout << "taro:"<< C << endl;
            turn = false;
        }else{
            A -= D;
            //cout <<"sato:"<< A << endl;
            turn = true;
        }
    }
    
    if(A > C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		String a = scanner.next();
		String b = scanner.next();
		
		if (a.equals("H") && b.equals("H")) {
			System.out.println("H");
		}else if (a.equals("H") && b.equals("D")){
			System.out.println("D");
		}else if (a.equals("D") && b.equals("H")) {
			System.out.println("D");
		}else if (a.equals("D") && b.equals("D")){
			System.out.println("H");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 1000000
#define LL long long
#define MOD 998244353
int n,a[MAXN+5],cnt[MAXN+5],ans;
int mx,inv[MAXN+5],f[MAXN+5];
inline LL read(){
   	LL x=0,F=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
   	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*F;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		cnt[a[i]]++;
		mx=max(mx,a[i]);
	}
	inv[1]=1;
	for(int i=2;i<=mx;i++)
	inv[i]=1LL*(MOD-MOD/i)*inv[MOD%i]%MOD;
	for(int i=mx;i>=1;i--){
		int res=0,sum=0,pw=0;
		for(int j=i;j<=mx;j+=i){
			res=(res+f[j])%MOD;
			sum=(sum+1LL*cnt[j]*j)%MOD;
			pw=(pw+1LL*cnt[j]*j*j)%MOD;
		}
		f[i]=(1LL*(1LL*sum*sum-pw+MOD)%MOD*inv[2]%MOD-res+MOD)%MOD;
		ans=(ans+1LL*f[i]*inv[i])%MOD;
	}
	printf("%d",ans);
}

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

using ll = long long;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;
  std::string A, B, C;
  std::cin >> A >> B >> C;

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    if (A[i] == B[i] && B[i] == C[i]) {
      continue;
    }
    if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
      ans++;
      continue;
    }
    ans += 2;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 998244353;


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

  int32_t N, K;
  cin >> N >> K;
  vector<int64_t> dp(N,0);
  dp[0] = 1;
  dp[1] = -1;
  vector<pair<int32_t,int32_t>> S(K);
  for (auto& p : S) {
    cin >> p.first >> p.second;
  }

  int64_t cur = 0;
  for (int i = 0; i < N - 1; i++) {
    cur += dp[i];
    cur %= MOD;
    if (cur == 0) continue;
    for (int k = 0; k < K; k++) {
      auto p = S[k];
      if (i + p.first < N) {
        dp[i+p.first] += cur;
        dp[i+p.first] %= MOD;
      }
      if (i + p.second + 1 < N) {
        dp[i+p.second+1] -= cur;
        dp[i+p.second+1] %= MOD;
        if (dp[i+p.second+1] < 0) {
          dp[i+p.second+1] += MOD;
        }
      }
    }
  }
  cur += dp[N-1];
  cur %= MOD;
  cout << cur << endl;
  

  return 0;
}


Measured memory_bytes: 4724
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<math.h>
#include<utility>
#include<iomanip>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<string> v(n);
	vector<int> u(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	int most = 1;
	int current = 1;
	string s = v[0];
	int it = 0;
	u[it]++;
	for (int i = 1; i < n; i++) {
		if (s == v[i]) {
			current++;
			most = max(most, current);
		}
		else {
			s = v[i];
			current = 1;
			it = i;
		}
		u[it]++;
	}

	for (int i = 0; i < n; i++) {
		if (u[i] == most) {
			cout << v[i] << " ";
		}
	}

}

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

long long extGCD(long long a, long long b, long long *px, long long *py){
    if(b == 0){
        *px = 1;
        *py = 0;
        return a;
    }
    long long d = extGCD(b, a%b, py, px);
    *py -= a/b * (*px);
    return d;
}

int main(){
    //input
    long long N;
    cin >> N;
    long long T[N];
    long long i;
    for(i=0; i<N; i++){
        cin >> T[i];
    }

    //calc
    long long x, y;
    long long val=T[0];
    for(i=1; i<N; i++){
        val=val*(T[i]/extGCD(val,T[i],&x,&y));
    }

    //output
    cout << val << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3652
n=gets.chop.to_i
array=gets.chomp.split(" ").map(&:to_i)
a='Yes'
x=0

if array[0]>array[n-1]
a='No'
end
for i in 0...n-1 do
  if array[i+1]-array[i]<-1
  a='No'
  end
  if array[i+1]-array[i]==-1
  if array[i+1]<x
  a='No'
  end
x=array[i+1]


end
end

if n==1
    a='Yes'
end

puts a


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

int main(){
	int i, j, k ,n,m,l,f;
	set<int> a;
	rep(i, 3){
		int b;
		cin >> b;
		a.insert(b);
	}
	cout << a.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll num[4];
  for(int i=0;i<4;i++){
    char c;
    cin>>c;
    num[i]=(int)(c-'0');
  }
  for(int i=0;i<8;i++){
    ll kans=num[0];
    string ans;
    ans.push_back((char)(num[0]+'0'));
    for(int j=0;j<3;j++){
      if(((i>>j)&1)==1){
        kans+=num[j+1];
        ans.push_back('+');
      }
      else{
        kans-=num[j+1];
        ans.push_back('-');
      }
      ans.push_back((char)(num[j+1]+'0'));
    }
    ans+="=7\n";
    if(kans==7) {
      cout<<ans;
      return 0;
    }
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

unsigned GetDigit(ull num) {
    return log10(num);
}

void nextPernutationPrint(const vector<int>& v) {
    for_each(v.begin(), v.end(), [](int x) { cout << x << " "; });
    cout << endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> T(N), P(N), Q(N);

    rep(i, N) {
        T[i] = i + 1;
    }
    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) {
        cin >> Q[i];
    }

    int cnt = 1, pValue = 0, qValue = 0;
    do {
        bool pFlag = true;
        for (int i = 0; i < N; i++) {
            if (T[i] != P[i]) {
                pFlag = false;
            }
        }
        if (pFlag) {
            pValue = cnt;
        }

        bool qFlag = true;
        for (int i = 0; i < N; i++) {
            if (T[i] != Q[i]) {
                qFlag = false;
            }
        }
        if (qFlag) {
            qValue = cnt;
        }

        cnt++;
    } while (next_permutation(T.begin(), T.end()));

    cout << abs(pValue - qValue) << endl;
}


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

#define N 200005
int a[N],b[N];
using namespace std;
int main(){
    int c,d,e,f;
    cin>>e>>f;
    for(int i=0;i<f;i++){
        cin>>c>>d;
        if(c==1) a[d]=1;
        if(d==e) b[c]=1;
    }
    for(int j=1;j<e;j++){
        if(a[j]==1&&b[j]==1){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }   
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[]) {
	int N, K; cin >> N >> K;
	vector<int> x(N);
	rep(i, N) cin >> x[i];

	ll ans = INF;
	vector<ll> sec(N - K + 1, 0);
	rep(i, N - K + 1) {
		int s = i, e = i + K - 1;
		sec[i] = abs(x[s] - x[e]);
		if (x[s] < 0 && x[e] <= 0) sec[i] += abs(x[e]);
		else if (x[s] <= 0 && x[e] > 0) sec[i] += min(abs(x[s]), x[e]);
		else sec[i] += x[s];
		// cout << sec[i] << endl;
		ans = min(ans, sec[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int k;
struct node
{
	int i,j;
	bool p;
	ll v;
	friend bool operator<(node m,node n){
		return m.v<n.v;
	}
};
vector<ll> sol(vector<ll> a,vector<ll> b){
	priority_queue<node> Q;
	vector<ll> ans;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	Q.push({(int)a.size(),(int)b.size(),false,a[a.size()-1]+b[b.size()-1]});
	while(!Q.empty()){
		node c=Q.top();
		Q.pop();
		ans.push_back(c.v);
		//cout<<c.p<<' '<<c.i<<' '<<c.j<<endl;
		if(ans.size()==k)break;
		if(!c.p&&c.i-1>0)Q.push({c.i-1,c.j,false,a[c.i-2]+b[c.j-1]});
		if(c.j-1>0)Q.push({c.i,c.j-1,true,a[c.i-1]+b[c.j-2]});
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	vector<ll> a,b,c;
	int x,y,z;
	cin>>x>>y>>z>>k;
	k=min(k,x*y*z);
	ll h;
	for(int i=1;i<=x;i++){
		cin>>h;
		a.push_back(h);
	}
	for(int i=1;i<=y;i++){
		cin>>h;
		b.push_back(h);
	}
	for(int i=1;i<=z;i++){
		cin>>h;
		c.push_back(h);
	}
	vector<ll> ans;
	vector<ll> ans1=sol(a,b);
	ans=sol(ans1,c);
	for(int i=0;i<k;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 512
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var n = long.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = input[0];
        var b = input[1];
        var p = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var count = 0L;
        var first = 0L;
        var second = 0L;
        var third = 0L;
        for(var i = 0;i < n;i++){
            if(p[i] <= a){
                first++;
            }else if(a < p[i] && p[i] <= b){
                second++;
            }else{
                third++;
            }
        }
        
        Console.WriteLine(Math.Min(first,Math.Min(second,third)));
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    cout << (t.compare(s) > 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 10007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b, t; cin >> a >> b >> t;
    auto times = t / a;
    cout << b * times << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long int n,count=1,a=7;
  cin>>n;
  if(n%2==0||n%5==0)
    cout<<"-1";
  else
    while(true)
    {
      if(a%n==0)
      {
        cout<<count;
        break;
      }  
      if(count>n)
      {
        cout<<"-1";
      	break;
      }
      a=(a%n)*10+7;
      count++;
    } 
    return 0;
} 

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN

const int N=1e5+5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll dp[N][2];
ll n;
string s;
ll fun(ll pos,ll f)
{
    //cout<<pos<<" "<<f<<endl;
    //cout<<dp[pos][f]<<endl;
    if(pos==n)
        return 1;
    if(dp[pos][f] != -1)    return dp[pos][f];
    ll res = 0;
    if(f==0)
    {
        if(s[pos]-'0'==1)
        {
            res = (res + fun(pos+1,1)) % mod;
            res = (res + (2*fun(pos+1,0))) % mod;
        }
        else
            res = (res + fun(pos+1,f)) % mod;
    }
    else
    {
        res = (res + (3*fun(pos+1,f))%mod)%mod;
    }
    return dp[pos][f] = res;    
}
int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    n=s.length();
    memset(dp, -1, sizeof(dp));
    cout<<fun(0,0);
    return 0;
}  

Measured memory_bytes: 6736
import qualified Data.IntMap as M
import qualified Data.ByteString.Char8 as B
import Data.Maybe
 
main = B.getContents >>= print . calc . count . tail . map readB . B.words

readB = fst . fromJust . B.readInt
 
count [] = M.empty
count (a:as) = M.insertWith (+) a 1 $ count as
 
calc = M.foldrWithKey' op 0
 
op k v s
  | k <= v = s + v - k
  | otherwise = s + v


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

int main() {
  int n;
  cin >> n;
  
  int i = 1;
  while(1) {
    if(i*i>n) break;
    i++;
  }
  cout << (i-1)*(i-1) << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

int main(void)
{
    int X;
    cin >> X;
    if (X >= 30){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3604
n, m = map(int, input().split())
a = list(map(int, input().split()))

amax = max(a)
s = sum(a)

mm = s / (4 * m)
a.sort(reverse=True)

y = True
for i in range(m):
    if a[i] < mm:
        print('No')
        y = False
        break

if y:
    print('Yes')

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const double PI = acos(-1);
struct CP {
	double x, y;
	CP(double x = 0, double y = 0) : x(x), y(y) {}
	CP operator+(const CP &a) { return CP(x + a.x, y + a.y); }
	CP operator-(const CP &a) { return CP(x - a.x, y - a.y); }
	CP operator*(const CP &a) { return CP(x * a.x - y * a.y, x * a.y + y * a.x); }
};
void FFTMakeG(int n, CP g[]) {
	for (int i = 0; i < n; ++i) { double th = PI * 2.0 * i / n; g[i] = CP(cos(th), sin(th)); }
}
void FFT(int n, CP g[], CP z[]) {
	int i, j, k, l, m;
	for (i = 1, j = 0; i < n; ++i) {
		for (k = n >> 1; (j ^= k) < k; k >>= 1);
		if (i < j) swap(z[i], z[j]);
	}
	for (l = k = 1, m = __builtin_ctz(n); m--; l |= k <<= 1) {
		for (i = 0; i < n; ++i) if (i < (j = i ^ k)) {
			CP t = z[j] * g[(i & l) << m];
			z[j] = z[i] - t;
			z[i] = z[i] + t;
		}
	}
}

const int P = 200003;
int N, A[202020];
i64 pows[202020];
map<i64, int> ord;
int cnt[202020];

CP g[1 << 19], xhi[1 << 19], xlo[1 << 19], y[1 << 19];
const int K = 330;
i64 ans[202020];

i64 naive()
{
	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) ret += (A[i] * (i64)A[j]) % P;
	}
	return ret;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);

	i64 v = 1;
	for (int i = 0; i < P - 1; ++i) {
		ord[v] = i;
		pows[i] = v;
		v = v * 2 % P;
	}
	for (int i = 0; i < N; ++i) {
		int ai = A[i];
		if (ai == 0) continue;
		++cnt[ord[ai]];
	}
	FFTMakeG(1 << 19, g);
	for (int i = 0; i < P - 1; ++i) {
		xhi[i] = cnt[i] / K;
		xlo[i] = cnt[i] % K;
	}
	FFT(1 << 19, g, xhi);
	FFT(1 << 19, g, xlo);

	for (int i = 0; i < 3; ++i) {
		if (i == 0) {
			for (int j = 0; j < (1 << 19); ++j) y[j] = xhi[j] * xhi[j];
		} else if (i == 1) {
			for (int j = 0; j < (1 << 19); ++j) y[j] = xhi[j] * xlo[j];
		} else {
			for (int j = 0; j < (1 << 19); ++j) y[j] = xlo[j] * xlo[j];
		}
		reverse(g + 1, g + (1 << 19));
		FFT(1 << 19, g, y);
		reverse(g + 1, g + (1 << 19));

		i64 waffle = 1;
		if (i == 0) waffle = K * K;
		else if (i == 1) waffle = K * 2;

		for (int j = 0; j < (1 << 19); ++j) {
			i64 v = (i64)(y[j].x / (1 << 19) + 0.5);
			ans[j % (P - 1)] += v * waffle;
		}
	}
	i64 ret = 0;
	for (int i = 0; i < P - 1; ++i) {
		ret += ans[i] * pows[i];
		ret -= cnt[i] * pows[(i * 2) % (P - 1)];
	}
	ret /= 2;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 53664
N,X = map(int,input().split())
L =[int(i) for i in input().split()]
now_L = 0
ans = 0
for i in range(N):
    if X >= now_L:
        ans += 1
        now_L += L[i]
    else:
        break
if X >= now_L:
    ans = N+1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define PI 3.141592653

int main(){
    double h[100000]={0};
    int n;
    
    for(int i=0;EOF!=scanf("%lf",&h[i]);i++) n++;
    
    sort(h,h+n);
    
    printf("%lf\n",h[n-1]-h[0]);
    
    return 0;
}

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

long long N;

long long zeronum;
long long onenum;
long long twonum;


int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		if(tmp%4 == 0){
			twonum++;
		}else if(tmp%2 == 0){
			onenum++;
		}else{
			zeronum++;
		}
	}
	if(zeronum > twonum){
		if(zeronum == twonum + 1 && onenum == 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 384
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#include <iomanip>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }


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



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int x, y, z, k;
vector<ll> a;
vector<ll> b;
vector<ll> c;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x>>y>>z>>k;
    for(int i=0;i<x;i++) {
        ll temp;
        cin>>temp;
        a.push_back(temp);
    }
    for(int i=0;i<y;i++) {
        ll temp1;
        cin>>temp1;
        b.push_back(temp1);
    }
    for(int i=0;i<z;i++) {
        ll temp2;
        cin>>temp2;
        c.push_back(temp2);
    }
    vector<ll> s;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ll tmp=a[i]+b[j];
            s.push_back(tmp);
        }
    }
    vector<ll> ans;
    sort(s.begin(), s.end(), greater<ll>() );
    sort(c.begin(), c.end(), greater<ll>() );
    int k1=min(x*y,k);
    for(int i=0;i<k1;i++){
        for(int j=0;j<z;j++){
            ll tmp1=s[i]+c[j];
            ans.push_back(tmp1);
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    for (int i=0;i<k;i++){
        cout<<ans[i]<<"\n";
    }
}

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

typedef long long LL;

LL A, B, C, D;
map<LL, LL> memo;

LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    
	if (memo.count(N)) return memo[N];     //¼ÇÒä»¯ËÑË÷ 
    
	LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}

Measured memory_bytes: 4340
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    s = readline().rstrip().decode()
    print(s[:3])



if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
long long int a[200010];
long long int aa[200010];
int main()
{
    long long int n,ans=20000000100,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        aa[i]=sum;
    }
    for(int i=0;i<n-1;i++)
    {
        ans=min(abs((sum-aa[i])-aa[i]),ans);
    }
    cout<<ans;
    return 0;
}


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

void test2(){
    long long a,b,x;
    cin>>a>>b>>x;
        long long t1=a%x,t2=b%x;
        long long k1=a/x,k2=b/x;
        if(t1==0)cout<<(k2-k1+1)<<endl;
        else cout<< k2-k1<<endl;
    return;
}

int main()
{
    test2();
    return 0;
}


Measured memory_bytes: 256