akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
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(){
string s;
cin >> s;
for(int i=0;i<s.size();i++){
    cout << "x";
}
cout << endl;
}





Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  if(s[n-1] == '3') cout << "bon" << endl;
  else if(s[n-1] == '0' || s[n-1] == '1' || s[n-1] == '6' || s[n-1] == '8') cout << "pon" << endl;
  else cout << "hon" << endl;
}


Measured memory_bytes: 3552
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N, int Q, string S) {
  vector<int> t(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      t[i] = 1;
    }
  }
  vector<int> tt(N + 1, 0);
  for (int i = 0; i < N; i++) {
    tt[i + 1] = tt[i] + t[i];
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    scanf("%d %d", &l, &r);
    printf("%d\n", tt[r - 1] - tt[l - 1]);
  }
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  solve(N, Q, S);
  return 0;
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  100012101;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
 


int main(){
ll N,min_num=INF2;
cin>>N;
string S,T;
for(ll i=1;i*i<=N;i++){
    if(N%i==0){
        S=to_string(i);
        T=to_string(N/i);

        min_num=min(min_num,(ll)max(S.size(),T.size()));

    }
}
cout<<min_num<<endl;


return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<iomanip>
using namespace std;

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

    vector<double> v(N);
    for (int i = 0; i < N; i++)
        cin >> v[i];

    sort(v.begin(), v.end());

    for (int i = 0; i < N - 1; i++)
        v[i + 1] = (v[i] + v[i + 1]) / 2.0;

    cout << fixed << setprecision(20) << v[N - 1] << endl;
    

    return 0;
}


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

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;
    array<int, 100000> a;
    array<bool, 100000> b;

    b.fill(false);

    gc(N);

    for (int i = 0; i < N; i++)
    {
        gc(a[i]);
    }

    int x = 1;
    int cnt = 1;

    int nxt;
    while (true)
    {
        nxt = a[x - 1];
        if (nxt == 2) break;

        if (b[nxt - 1]) break;
        b[nxt - 1] = true;

        x = nxt;
        cnt++;
    }

    printf("%d\n", nxt == 2 ? cnt : -1);
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
bool divid[1000006];
int freq[1000006];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i],freq[v[i]]++;
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    for(int i=0;i<v.size();i++)
        for(int j=v[i]+v[i];j<=1000000;j+=v[i])
            divid[j]=1;
    for(int i=0;i<v.size();i++)
        ans+=(freq[v[i]]==1&&divid[v[i]]==0);
    cout<<ans;
    return 0;
}


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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    long long n;
    cin >>n;
    
    
    cout << (2000000014+modpow(10, n, 1000000007)+modpow(8, n, 1000000007)-(modpow(9, n, 1000000007)*2)%1000000007)%1000000007 << endl;
}

Measured memory_bytes: 3620
using System;
public class Hello{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        
        if(n < k){
            Console.WriteLine(x * n);
        }else{
            Console.WriteLine(x * k + y * (n - k));
        }
    }
}


Measured memory_bytes: 11092
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  
  if(n>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long a[200001], b[200001];
int main(void){
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    for(int i=1;i<=n;i++){ cin >> a[i]; a[i] += a[i-1];}
    for(int i=1;i<=m;i++){ cin >> b[i]; b[i] += b[i-1];}
    for(int i=0;i<=n;i++){
        if(a[i] > k) break;
        int ok = 0, ng = m+1;
        while(ok + 1 < ng){
            int mid = (ok+ng)/2;
            if(a[i]+b[mid] <= k) ok = mid;
            else ng = mid;
        }
        ans = max(ans, i+ok);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6312
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int x1=sc.nextInt();
		int y1=sc.nextInt();
		int x2=sc.nextInt();
		int y2=sc.nextInt();
		boolean neg=false;
		if((Math.min(x1, x2)==x1) !=(Math.min(y1, y2)==y1))
			neg=true;
		if(neg){
			x1*=(-1);
			x2*=(-1);
		}
		
		int minX=Math.min(x1, x2);
		int maxX=Math.max(x1, x2);
		int minY=Math.min(y1, y2);
		int maxY=Math.max(y1, y2);
		
		
		
		int n=sc.nextInt();
		int [] x=new int [n];
		int [] y=new int [n];
		TreeMap<Integer, Integer> mapX=new TreeMap<Integer, Integer>();
		TreeMap<Integer, Integer> mapY=new TreeMap<Integer, Integer>();
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
			if(neg)
				x[i]*=(-1);
			y[i]=sc.nextInt();
			mapX.put(x[i], y[i]);
			mapY.put(y[i], x[i]);
		}
		double circ=Math.PI*20;
		double init=100.0*(maxX-minX+maxY-minY);
		double op1=init,op2=init;
		if(mapX.containsKey(minX)){
			int tmp=mapX.get(minX);
			if(tmp>minY && tmp<maxY)
				op1+=(circ/2-20);
			if(tmp==maxY)
				op1+=(circ/4-20);
		}
		if(mapY.containsKey(maxY)){
			int tmp=mapY.get(maxY);
			if(tmp>minX && tmp<maxX)
				op1+=(circ/2-20);
		}
		if(mapX.containsKey(maxX)){
			int tmp=mapX.get(maxX);
			if(tmp>minY && tmp<maxY)
				op2+=(circ/2-20);
			if(tmp==minY)
				op2+=(circ/4-20);
		}
		if(mapY.containsKey(minY)){
			int tmp=mapY.get(minY);
			if(tmp>minX && tmp<maxX)
				op2+=(circ/2-20);
		}
		double dis=Math.min(op1, op2);
		ArrayList<pair> arr=new ArrayList<pair>();
		for(int i=0;i<n;i++)
			if(x[i]>=minX && x[i]<=maxX && y[i]>=minY && y[i]<=maxY){
				arr.add(new pair(x[i], y[i]));
			}
		Collections.sort(arr);
		int [] a=new int [arr.size()];
		for(int i=0;i<a.length;i++)
			a[i]=arr.get(i).y;
		int l=lis(a, a.length);
		if(minX!=maxX && minY!=maxY){	
			if(l==maxY-minY+1 || l==maxX-minX+1)
				dis=Math.min(dis, init-l*(20-circ/4)+circ/4);
			else
				dis=Math.min(dis, init-l*(20-circ/4));
		}
		pw.println(dis);
		pw.flush();
		pw.close();
	}
	
	static class pair implements Comparable<pair>{
		int x,y;
		pair(int a,int b){
			x=a;
			y=b;
		}
		public int compareTo(pair o) {
			return x-o.x;
		}
	}
	
	public static int lis(int [] a,int n){
		ArrayList<Integer> l=new ArrayList<Integer>();
		for(int i=0;i<n;i++){
			int pos=Collections.binarySearch(l, a[i]);
			if(pos<0)
				pos=-(pos+1);
			if(pos>=l.size())
				l.add(a[i]);
			else
				l.set(pos, a[i]);
		}
		return l.size();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

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

using namespace std;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        
        bool r = false;
        bool l = false;
        bool b = false;
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            if (s[0] == 'l') {
                if (s[1] == 'u') l = true; else l = false;
            } else {
                if (s[1] == 'u') r = true; else r = false;
            }
            if (l == r) {
                if (b == l) continue;
                b = l;
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int MAX_N = 1e5 + 5;
int longest_path[MAX_N];
vector <int> graph[MAX_N];

int dfs(int v)
{
    if(longest_path[v] != -1)
    {
        return longest_path[v] ;
    }

    int longest_child_path = 0;

    for(int i = 0; i < graph[v].size(); i++)
    {
        int child = graph[v][i];

        longest_child_path = max(longest_child_path, dfs(child));
    }

    longest_path[v] = 1 + longest_child_path;

    return longest_path[v] ;
}

int main()
{
    int no_of_vertices, no_of_edges;
    cin >> no_of_vertices >> no_of_edges;

    for(int i = 1; i <= no_of_edges; i++)
    {
        int x, y;
        cin >> x >> y;

        graph[x].push_back(y);
    }

    memset(longest_path, -1, sizeof(longest_path));

    int vertices_on_longest_path = 0;

    for(int i = 1; i <= no_of_vertices; i++)
        vertices_on_longest_path = max(vertices_on_longest_path, dfs(i));

    int edges_on_longest_path = vertices_on_longest_path - 1;

    cout << edges_on_longest_path;

    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int l,r,d,ans=0;
    cin>>l>>r>>d;
    for(int i=1;i<=100;i++)
    {
        if(i*d <= r && i*d >= l)
            ans++;
    }
    cout<<ans;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
    go();
    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

int main(void)
{
	ll n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	vector<vector<ll>> g(n,vector<ll>(n, INF));
	rep(i, n) {
		rep(j, n) {
			if (i == j) {
				g[i][j] = 0;
			}
			ll a = abs(i - j);
			g[i][j] = a;
			ll b = abs(i - x) + abs(j - y) + 1;
			ll c = abs(j - x) + abs(i - y) + 1;
			g[i][j] = min(b, g[i][j]);
			g[i][j] = min(c, g[i][j]);
		}
	}
	unordered_map<ll, ll> mm;
	for (int i = 0; i < n - 1;i++) {
		for (int j = i + 1; j < n; j++) {
			mm[g[i][j]]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << mm[i] << endl;
	}
	return 0;
}


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

using namespace std;


int main(){

    //freopen("input.txt","r",stdin);
    string str;

    cin >> str;

    for(int i=0; i<str.length();){

        string temp = "";

        //cout << str[i] << endl;

        if(str[i] == 'd'){ // dream

         temp += str[i] ;
         temp += str[i+1];
         temp += str[i+2];
         temp += str[i+3];
         temp += str[i+4];

        //cout << temp << endl;

         if(temp == "dream"){


            if(str[i+5] == 'e' && str[i+6] == 'r' && str[i+7] != 'a'){
                i = i + 7;
                continue;
            }else{
                i = i + 5;
                continue;
            }
         }else{
            cout << "NO" <<endl;
            return 0;
         }

        }else if(str[i] == 'e'){

         temp += str[i] ;
         temp += str[i+1];
         temp += str[i+2];
         temp += str[i+3];
         temp += str[i+4]; // erase

        if(temp == "erase"){

            if(str[i+5] == 'r'){
                i = i + 6;
                continue;
            }else{
                i = i + 5;
                continue;
            }
         }else{
            cout << "NO" <<endl;
            return 0;
         }

        }else{
            cout << "NO" <<endl;
            return 0;
        }

    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())

sp = []
he = []
di = []
cl = []
for i in range(13):
    sp.append(i+1)
    he.append(i+1)
    di.append(i+1)
    cl.append(i+1)
#print(sp)

for i in range(n):
    s, n = map(str,input().split())
    n = int(n)
    if s == "S":
        sp.remove(n)
    elif s == "H":
        he.remove(n)
    elif s == "D":
        di.remove(n)
    elif s == "C":
        cl.remove(n)
for i in range(len(sp)):
    print("S "+ str(sp[i]))
for i in range(len(he)):
    print("H "+ str(he[i]))
for i in range(len(cl)):
    print("C "+ str(cl[i]))
for i in range(len(di)):
    print("D "+ str(di[i]))



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   
	ll n;cin>>n;
	ll a[n],b[n],c[n],dp[n+1][3];
	for(int i=0;i<n;++i)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(int i=1;i<=n;++i)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i-1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i-1];
	}
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<"\n";

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9+10;
const double eps=1e-9;
const int maxn=2e3+10;
ll a[maxn],pre[maxn],Ans[maxn],dp[maxn];
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	ll i,j,k,m,n;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	for(i=1;i<=n;i++)dp[i]=a[i];
	for(i=3;i<=n;i++){
		for(j=i-2;j>=1;j-=2)
			if(dp[i]<dp[j]+a[i]){
				dp[i]=dp[j]+a[i];
				pre[i]=j;
			}
	}
	ll ans=-INF,pos=0;
	for(i=1;i<=n;i++)if(dp[i]>ans)ans=dp[i],pos=i;
	printf("%lld\n",ans);
	int cnt=0,lpos=n;
	if(ans<0){
		for(i=1;i<=n;i++)
			if(a[i]==ans){
				printf("%lld\n",n-1);
				for(j=1;j<i;j++)printf("%lld\n",1);
				for(j=i+1;j<=n;j++)printf("%lld\n",n-j+2);
				return 0;
			}
	}
	else{
		while(pos){
			for(i=lpos;i>=pos+1;i--)Ans[++cnt]=i;
			for(i=pos-2;i>pre[pos];i-=2)Ans[++cnt]=i;
			Ans[++cnt]=pre[pos]+1;
			pos=pre[pos];lpos=pos;
			if(pos==1)break;
		}
	}
	printf("%d\n",cnt);
	for(i=1;i<=cnt;i++)printf("%lld\n",Ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s;
  cin>>s;
  long long a=0,b=0,carry=0;
  for(int i=s.length()-1;i>=0;i--){
  	int p=s[i]-'0'+carry;
    carry=0;
    if(p>5){
    	b+=10-p;
  		carry=1;
    }
    else if(p==5){
    	if(s[i-1]-'0'>=5){
			b+=p;
			carry=1;
		}
		else{
			a+=p;
		}
	}
    else{
      a+=p;
    }
  }
  long long ans=a+b+carry;
  cout<<ans<<endl;
}

Measured memory_bytes: 1412
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		int[] A = nextIntArray(N);


		int cnt = 0;
		for(int i=0;i<N;i++) {
			cnt += A[i]==cnt+1?1:0;
		}

		int res = -1;
		if(cnt > 0)res = N - cnt;
		out.println(res);
	}

	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 int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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


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

    int ar[n+10],ans[n+10];

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

    ans[0]=0;
    ans[1]=abs(ar[1]-ar[0]);

    for(int i=2;i<n;i++)
    {
       int r1,r2;

       r1=abs(ar[i]-ar[i-1])+ans[i-1];
       r2=abs(ar[i]-ar[i-2])+ans[i-2];

       ans[i]=min(r1,r2);

    }

    cout<<ans[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
# 2019-11-15 14:12:24(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, d = [int(x) for x in sys.stdin.readline().split()]
    ran = 1 + d * 2
    number = math.ceil(n / ran)
    print(number)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import collections
N = int(input())
A = list(map(int, input().split()))

ans = 2**(N//2)
table = collections.defaultdict(int)
flag = True
for x in A:
    table[x] += 1

for x in table:
    if x % 2 == N % 2:
        flag = False
        break
    if x == 0 and table[x] > 1:
        flag = False
        break
    if x >= 1 and table[x] != 2:
        flag = False
        break
    if x > N - 1:
        flag = False
        break
mod = 10**9 + 7
if flag:
    print(ans % mod)
else:
    print(0)


Measured memory_bytes: 14820
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn $ solve n


solve :: Int -> String
solve n = show n ++ ": "
          ++ unwords (map show $ factrization n
                      (takeWhile ((<= n) . (^ 2)) primes))
  where
    primes = 2 : 3 : 5 : filter f [7, 9..]
      where
        f n = all ((/= 0) . (mod n)) $
              takeWhile ((<= n) . (^ 2)) primes
    factrization :: Int -> [Int] -> [Int]
    factrization n [] = [n]
    factrization n pss@(p:ps)
      | n == 1 = []
      | n `mod` p == 0 = p : factrization (n `div` p)  pss
      | otherwise = factrization n ps

Measured memory_bytes: 4244
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	d := intSliceScanner(n)
	time := make([]int, 13)
	time[0] = 1
	for _, v := range d {
		time[v]++
	}
	f := false
	for _, v := range time {
		if v > 2 {
			f = true
		}
	}
	if time[12] > 1 || time[0] > 1 {
		f = true
	}
	if f {
		fmt.Println(0)
	} else {
		x := make([]int, 0, 24)
		y := make([]int, 0, 13)
		for i, v := range time {
			if i == 0 || i == 12 {
				if v == 1 {
					x = append(x, i)
				}
			} else if v == 2 {
				x = append(x, i)
				x = append(x, 24-i)
			} else if v == 1 {
				y = append(y, i)
			}
		}
		m := uint(len(y))
		ans := 0
		for i := 0; i < (1 << m); i++ {
			z := make([]int, len(x), 24)
			copy(z, x)
			for j := 0; j < len(y); j++ {
				if (i>>uint(j))&1 == 0 {
					z = append(z, y[j])
				} else {
					z = append(z, 24-y[j])
				}
			}
			ans = larger(ans, dist(z))
		}
		fmt.Println(ans)
	}
}
func dist(x []int) int {
	ret := mod
	for i := 0; i < len(x); i++ {
		for j := i + 1; j < len(x); j++ {
			d := abs(x[i] - x[j])
			d = smaller(d, 24-d)
			ret = smaller(ret, d)
		}
	}
	return ret
}


Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
	if (s[0] == s[1]) {
		if (s[0] == s[2]) {
			cout << "No" << endl;
		} else {
			if (s[2] == s[3]) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	} else {
		if (s[0] == s[2]) {
			if (s[1] == s[3]) cout << "Yes" << endl;
			else cout << "No" << endl;
		} else {
			if (s[1] == s[2]) {
				if (s[0] == s[3]) cout << "Yes" << endl;
				else cout << "No" << endl;
			} else {
				cout << "No" << endl;
			}
		}
	}
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC136C
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    vector<int>h(n);
    rep(i,n) cin>>h.at(i);
    for(int i=n-2;i>=0;i--){
        if(h.at(i)>h.at(i+1)){
            h.at(i)--;
            if(h.at(i)>h.at(i+1)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3148
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def N(self):
        save = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = save

    def E(self):
        save = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = save

    def S(self):
        save = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = save

    def W(self):
        save = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = save

    def display(self):
        print(self.top)

nums = list(map(int, input().split()))
dice = Dice(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5])
s = input()
for c in s:
    if c == 'N':
        dice.N()
    elif c == 'E':
        dice.E()
    elif c == 'S':
        dice.S()
    elif c == 'W':
        dice.W()
dice.display()


Measured memory_bytes: 5608
#include<iostream>

using namespace std;


int main()
{

	int N;
	int A;
	int B;

	int nokori5;
	int nokori4;
	int nokori3;
	int nokori2;
	int nokori1;

	int keta5;
	int keta4;
	int keta3;
	int keta2;
	int keta1;

	int ANS[10000];
	int counter=0;

	int i;


	cin >> N;
	cin >> A;
	cin >> B;

	for (i = 1;i <= N;i++) {

		keta1 = i % 10;
		nokori1 = i / 10;

		keta2 = nokori1 % 10;
		nokori2 = nokori1 / 10;

		keta3 = nokori2 % 10;
		nokori3 = nokori2 / 10;

		keta4 = nokori3 % 10;
		nokori4 = nokori3 / 10;

		keta5 = nokori4 % 10;
		nokori5 = nokori4 / 10;


		ANS[i] = keta5+keta4+keta3+keta2+keta1 ;

		if (A <= ANS[i] && ANS[i] <= B) {
			counter= counter+i;
		}
	}

	cout << counter;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstring>
#include<vector>
#include<algorithm> 
#include<queue>
#define PII pair<int,int>
#define INF 0x3f3f3f3f

typedef long long ll;

using namespace std;
int n,m;
const int N=2e5+10; 
int head[N],ne[N<<1],e[N<<1];
int cnt;
bool st[N];
int pre[N];//存放路径 
int dis[N];
priority_queue<PII,vector<PII>,greater<PII> > heap;

void add(int u,int v){
	e[cnt]=v,ne[cnt]=head[u],head[u]=cnt++;
}
void dijkstra(){
	heap.push({0,1});
	dis[1]=0;
	while(heap.size()){
		auto t=heap.top();
		heap.pop();
		int ver=t.second,distance=t.first;
		if(st[ver]) continue;
		st[ver]=1;
		for(int i=head[ver];i!=-1;i=ne[i]){
			int v=e[i];
			if(dis[v]>distance+1){
				pre[v]=ver;
				dis[v]=distance+1;
				heap.push({dis[v],v});
			}
		}
	}
}
int main()
{
	memset(dis,INF,sizeof(dis));
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	int u,v;
	while(m--){
		cin>>u>>v;
		add(u,v);
		add(v,u);
	}
	dijkstra();
	for(int i=1;i<=n;i++){
		if(dis[i]==INF){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++){
		cout<<pre[i]<<endl;
	}
}

Measured memory_bytes: 9384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;

int n, m;
void solve() {
	vector<vector<bool>> b(n);
	rep(i, n) {
		b[i].resize(m, false);
		rep(j, m) {
			char t; cin >> t;
			b[i][j] = (t == '1');
		}
	}
	//cout << "ans is ";
	if (n <= 21) {
		int ans = 0;
		rep(i, (1 << n)) {
			vector<int> c(m, 0);
			int cnt = 0;
			rep(j, n) {
				if (i&(1 << j)) {
					cnt++;
					rep(k, m)if (b[j][k])c[k] ^= 1;
				}
			}
			bool f = true;
			rep(k, m)if (c[k])f = false;
			if(f)ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	else {
		vector<int> dp(1 << m,-mod),cop(1<<m);
		dp[0] = 0;
		rep(i, n) {
			fill(cop.begin(), cop.end(), -mod);
			int z = 0;
			rep(k, m)if (b[i][k])z += (1 << k);
			rep(j, (1 << m)) {
				cop[j^z] = max(cop[j^z], dp[j] + 1);
			}
			rep(j, (1 << m)) {
				dp[j] = max(dp[j], cop[j]);
			}
		}
		cout << dp[0] << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	while (cin >> n>>m,n)solve();
	//solve();
	//stop
	return 0;
}



Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l;
	cin>>l;
	//long double x=(double)(l/(double)3.0*(l/(double)3.0+(l%3)/2)*(l/(double)3.0+(l%3-(l%3)/2)));
	cout <<fixed<<setprecision(6)<<l/3.0*l/3.0*l/3.0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int num,A[999],v,j,i,c;

  scanf("%d",&num);
  for(i = 0;i < num;i++){
    scanf("%d",&A[i]);
  }
  
 for(i = 0;i < num-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d",A[num-1]);
    printf("\n");

  for(i = 1;i <= num-1;i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
      A[j+1] = v;
    for(c = 0;c < num-1;c++){
      printf("%d ",A[c]);
    }
    printf("%d",A[num-1]);
    printf("\n");

  }

  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
typedef long long ll;
int dp[maxn];
int main()
{
    for(int i=0;i<maxn;i++){
        dp[i]=1e9;
    }
    dp[0]=0;
    for(ll i=0;i<=maxn;i++){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(ll j=6;i+j<=maxn;j*=6){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
        for(ll j=9;i+j<=maxn;j*=9){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
    }
    int n;
    cin>>n;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 4096
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = collections.deque()
odd = True
for c in s:
    if odd:
        ans.append(c)
    odd = not odd
print(''.join(ans))

Measured memory_bytes: 75792
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int ceil(int a, int b) {
    return (a+b-1) / b;
}

int main() {
    int k, q;
    cin >> k >> q;
    vector<ll> d(k);
    rep(i, k) cin >> d[i];

    ll n, x, m;
    ll last, count_equal, count_di;
    rep(i, q) {
        cin >> n >> x >> m;
        last = x;
        count_equal = 0;
        rep(j, k) {
            count_di = ceil(n-1-j, k);
            last += (d[j] % m) * count_di;
            if(d[j] % m == 0) count_equal += count_di;
        }
        cout << (n-1) - (last/m - x/m) - count_equal << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007
using namespace std;

int main() {
   int ans = 0, pos = 0;
   int n;
   cin >> n;

   while (pos < n) {
      ans++;
      pos += ans;
   }

   cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int mod = 1000000007;

ll dp[100050][4];

int main(){
    string s; cin >> s;
    int size = s.size();
    s = '0' + s;

    dp[0][0] = 1;

    for(int i=1; i<=size; i++){
        if(s[i] != '?') for(int j=0; j<4; j++) dp[i][j] += dp[i-1][j], dp[i][j] %= mod;
        else for(int j=0; j<4; j++) dp[i][j] += 3*dp[i-1][j], dp[i][j] %= mod;

        if(s[i] == 'A' || s[i] == '?') dp[i][1] += dp[i-1][0], dp[i][1] %= mod;
        if(s[i] == 'B' || s[i] == '?') dp[i][2] += dp[i-1][1], dp[i][2] %= mod;
        if(s[i] == 'C' || s[i] == '?') dp[i][3] += dp[i-1][2], dp[i][3] %= mod;
    }

    cout << dp[size][3] << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	int n;
	cin>>n;
	int h[n];
	f(i,0,n)
	cin>>h[i];
	int fg=0;
	h[0]-=1;
	f(i,1,n)
	{
		if(h[i]==h[i-1])
			continue;
		else if(h[i]>h[i-1])
			h[i]-=1;
		else
			fg=1;
	}
	f(i,1,n)
	{
		if(h[i]<h[i-1])
			fg=1;
	}
	if(fg==1)
		cout<<"No";
	else
		cout<<"Yes";
}

Measured memory_bytes: 1024
//Heaplax
#include<bits/stdc++.h>
#define N 405
#define M 100005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
bitset<N> gg[N];
int n,m,x[M],y[M],d[N];
bool ggg[N];
int main()
{
	re(n),re(m);
	for(int i=1;i<=m;++i)
		re(x[i]),re(y[i]);
	for(int a=1;a<=n;++a)
	{
		gg[a][a]=1;
		for(int i=m;i;--i)
			if(gg[a][x[i]] && gg[a][y[i]])
			{
				ggg[a]=1;
				break;
			}
			else if(gg[a][x[i]])gg[a][y[i]]=1;
			else if(gg[a][y[i]])gg[a][x[i]]=1;
	}
	int ans=0;
	for(int a=1;a<=n;++a)if(!ggg[a])
		for(int b=a+1;b<=n;++b)if(!ggg[b])
			if((gg[a]&gg[b]).count()==0)
				++ans;
	printf("%d\n",ans);
}


Measured memory_bytes: 1024
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

#include<bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void sync() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void timeTaken() {
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

int32_t main() {
	sync();
	dip(string, s);
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += s[i] - 48;
	}
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3748
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a<*(int *)b)return 1;
    return -1;
}
typedef struct{
    int x;
    int y;
} move;
int main()
{   int n;
    scanf("%d",&n);
    int x[n],y[n];
    for(int i=0;i<n;i++){
        scanf("%d%d",&x[i],&y[i]);    
    }
    move a[n*n+1];
    int k=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            a[k].x=x[i]-x[j];
            a[k].y=y[i]-y[j];
            k++;
        }
    }
    int counter[2501]={0};
    for(int l=0;l<k;l++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(x[i]-x[j]==a[l].x&&y[i]-y[j]==a[l].y){
                    counter[l]++;
                }
            }
        }
    }
    qsort(counter,k,sizeof(int),compare);
    
    printf("%d",n-counter[0]);
    
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if n>=2 or m>=2:
  if m<2:
    print(n*(n-1)//2)
    
  elif n<2:
    print(m*(m-1)//2)
    
  else:
    print(n*(n-1)//2+m*(m-1)//2)
    
else:
  print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

struct Gift {
  double amount;
  string currency;
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<Gift> gift(n);
  rep(i, n) {
    cin >> gift[i].amount; 
    cin >> gift[i].currency; 
  }

  double ans = 0;
  rep(i, n) {
    if (gift[i].currency == "JPY") {
      ans += gift[i].amount;
    } else {
      ans += gift[i].amount * 380000.0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  map<ll,ll>mp;
  rep(i,0,w)mp[i]=0;
  multiset<ll>st;
  rep(i,0,w)st.insert(0);
  mp[w]=0;
  vector<ll>p(h),q(h);rep(i,0,h)cin>>p[i]>>q[i];
  rep(i,0,h){
    ll a=p[i]-1,b=q[i];
    auto itr=mp.lower_bound(a);
    ll to=b;
    while(itr->fi<b){
      ll val=itr->se+(to-itr->fi);
      st.erase(st.find(itr->se));
      itr=mp.erase(itr);
      if(to!=w){
        if(!mp.count(to)){
          mp[to]=val;
          st.insert(val);
        }
        else if(val<mp[to]){
          st.erase(st.find(mp[to]));
          mp[to]=val;
          st.insert(val);
        }
      }
    }
    //for(auto z:mp)cout<<z<<"|";cout<<endl;
    if(st.empty())cout<<-1<<endl;
    else cout<<*st.begin()+i+1<<endl;
  }
  return 0;
}

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

string s,t;

bool match(int k){
  for(int i=0;i<t.size();++i){
    if(s[i+k]!=t[i] && s[i+k]!='?'){
      return false;
    }
  }
  return true;
}

int main(){
  int i,j,k,kk;
  kk=0;
  cin >> s;
  cin >> t;
  bool ha=false;
  k=0;
  if(s.size()-t.size()<0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  while(k<=s.size()-t.size()+1){
    ha=match(k);
    k++;
    if(ha==true){
      kk=k;
      ha=false;
    }
    }
  string ans=s;
  kk--;
    for(i=0;i<t.size();++i){
      ans[kk+i]=t[i];
    }
    for(i=0;i<s.size();++i){
      if(ans[i]=='?'){
        ans[i]='a';
      }
    }
  if(ans.find(t)!=string::npos){
    cout << ans << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }
  return 0;

}


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

int main (){
    int n;
    cin>>n;
    int a, b, c, d;
    a=n/1000;
    d=n%10;
    b=(n/100)%10;
    c=(n/10)%10;
    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }
    else if(b==c&&c==d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let max_b = 4 in
  let max_f = 3 in
  let max_r = 10 in
  let ary = Array.make_matrix max_b (max_f * max_r) 0 in
  let n = read_int () in
  for _ = 1 to n do
    let l = read_line () in
    match List.map int_of_string (split l ' ') with
    | [] | [_] | _::_::[] | _::_::_::[] -> exit 1
    | b :: f :: r :: v :: _ ->
        ary.(b - 1).(max_r * (f - 1) + r - 1) <- ary.(b - 1).(max_r * (f - 1) + r - 1) + v
  done;
  for i = 1 to max_b do
    for j = 1 to (max_f * max_r) do
      if j mod max_r = 0 then Printf.printf " %d\n" ary.(i - 1).(j - 1)
      else Printf.printf " %d" ary.(i - 1).(j - 1)
    done;
    if i <> max_b then Printf.printf "####################\n"
  done

Measured memory_bytes: 2348
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

ll m,n;
const ll mxn=1e5;
vector<ll> adj[mxn],ans;
bool vis[mxn];

void dfs(ll u){
	vis[u]=1;
	for(auto v:adj[u]){
		if(!vis[v])
			dfs(v);
	}
}

void solve(){
	//code
	cin>>n>>m;
	
	for(ll i=0,a,b;i<m;i++){
		cin>>a>>b;
		--a;
		--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	for(ll i=0;i<n;i++){
		if(!vis[i]){
			ans.push_back(i);
			dfs(i);
		}
	}
	
	cout<<ans.size()-1<<"\n";
	//for(int i=1;i<ans.size();i++)
	//	cout<<ans[0]+1<<" "<<ans[i]+1<<"\n";
}

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


Measured memory_bytes: 10552
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 13016
from math import ceil


def solve(string):
    n, *csf = map(int, string.split())
    f_list = []
    for c, s, f in zip(csf[::3], csf[1::3], csf[2::3]):
        f_list = [c + ceil((max(_f, s)) / f) * f for _f in f_list]
        f_list.append(c + s)
    f_list.append(0)
    return "\n".join([str(_f) for _f in f_list])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n - 1)])))


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var len = S.Length;
            var ans = new int[len];
            
            foreach (var _ in Enumerable.Range(0, 2))
            {
                var count = 0;
                for (var i = 0; i < len; i++)
                {
                    if (S[i] == 'R') count++;
                    else
                    {
                        ans[i] += count / 2;
                        ans[i - 1] += (count + 1) / 2;
                        count = 0;
                    }
                }

                Array.Reverse(ans);
                Array.Reverse(S);
                
                for (var i = 0; i < len; i++)
                {
                    if (S[i] == 'L') S[i] = 'R';
                    else S[i] = 'L';
                }
            }
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


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

int main()
{
    long long X, Y;
    cin >> X >> Y;
    long long cnt = 1LL;
    while (X <= Y)
    {
        X *= 2LL;
        if (X > Y)
            break;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256