akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int n;
            cin>>n;
            if(360%n==0) cout<<360/n;
            else{
              REP(i,1,1000){
                REP(j,1,1000){
                  if(i*360==j*n){
                    cout<<j; return 0;
                  }
                }
              }
              //cout<<(((360%n))*360)%n;
            }
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define pb push_back

int main(){

	int N, A, B;
	cin >> N >> A >> B;
	if(N == 1)cout << "Hello World" << endl;
	else cout << A + B << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int cnt = 0, H[10000], W[10000];
	int i, j, k;
	
	do{
		scanf("%d %d", &H[cnt], &W[cnt]);
		cnt++;
	} while(H[cnt-1] != 0 && W[cnt-1] != 0);
	
	for(i = 0; i < cnt-1; i++) {
		for(j = 0; j < H[i]; j++){
			for(k = 0; k < W[i]; k++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
n = int(input())
a_list = list(map(int,input().split()))

divs = [a%4 for a in a_list]
mp_of_four = divs.count(0)
mp_of_two  = divs.count(2) 

if mp_of_four+mp_of_two//2 >= n//2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
//
// ローリングハッシュ
//
// verified:
//   ABC 141 E - Who Says a Pun?
//     https://atcoder.jp/contests/abc141/tasks/abc141_e
//


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};


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

    // ロリハ
    RollingHash rh(S);

    // 求める
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int lcp = rh.getLCP(i, j);
            lcp = min(lcp, j-i);
            res = max(res, lcp);
        }
    }   
        
    cout << res << endl;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	w, a, b := nextInt(), nextInt(), nextInt()
	ans := 0
	if a+w < b {
		ans = b - (a + w)
	} else if b+w < a {
		ans = a - (b + w)
	}
	fmt.Println(ans)
}


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

int main(){
	int t,n;
	while(cin >> t,t){
		int sum = 0;
		cin >> n;
		for(int i = 0;i < n;i++){
			int a,b;
			cin >> a >> b;
			sum += b - a;
		}
		if(sum >= t) cout << "OK" << endl;
		else cout << t - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
int main(void){
  int i,bt[4]={0},t;
  char l[5],z;
  while(scanf("%d %c %s",&t,&z,l)!=EOF){
    switch(l[0]-'A'){
    case 0:
      if(l[1]=='B')bt[2]++;
      else bt[0]++;
      break;
    case 1:bt[1]++;break;
    case 14:bt[3]++;break;
    }
  }
  for(i=0;i<3;i++)
    printf("%d\n",bt[i]);
  printf("%d\n",bt[3]);
  return 0;
}

Measured memory_bytes: 596
import math
a, b, h, m = map(int, input().split())
lk = 6 * m
sk = 30 * h + 0.5 * m
theta = max(lk, sk) - min(lk, sk)
if theta > 180:
  theta = 360 - theta
ans = math.sqrt(a*a + b*b - 2 * a * b * math.cos(math.radians(theta)))
print(ans)

Measured memory_bytes: 9508
N = int(input())
K = int(input())
ball_list = list(map(int, input().split()))

ans = 0

for ball in ball_list:
    if abs(ball - 0) <= abs(ball - K):
        ans += abs(ball - 0) * 2
    else:
        ans += abs(ball - K) * 2

print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std; 
#define LIM 1000003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";




ll n, k;
int main() {
	int i, j, t;
	scl2(n, k) ;
	double tempK = (double)k, tempN = (double)n ;
	double dd = 1/ tempN, answer = 0.00;
	for(i=1; i<=n; i++) {
		ll em = i ;
		double xx = 1 ;
		while(em < k) {
			em *= 2LL ;
			xx /= 2.0 ;
		}

		answer += xx ;
	}
	answer = answer * dd ;
	printf("%0.12lf\n", answer) ;
	return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
void disp(vector<int> v){
  for(int i=0;i<v.size();i++){
    cout << v[i] << " ";
  }
  cout<<endl;
}
 
template <typename T>
class undigraph {
public:
  struct edge{
    int from;
    int to;
    T cost;
  };
  
  vector< vector<int> > v;
  vector<edge> edges;
 
  int n;
 
  undigraph(int n){
    v.resize(n);
  }
 
  void add(int from,int to,T cost = 1){
    v[from].push_back(edges.size());
    v[to].push_back(edges.size());
    edges.push_back({from, to, cost});
  }
};
 
template <typename T>
vector <T> dijkstra(const undigraph<T> &g, int start) {
  vector<T> dist(g.n, numeric_limits<T>::max());
  priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > > s;
  dist[start] = 0;
  s.emplace(dist[start], start);
 
  while(!s.empty()){
    int expected = s.top().first;
    int base = s.top().second;
    if(expected != dist[base]){
      continue;
    }
    s.pop();
    for(int id:g.v[base]){
      auto &e = g.edges[id];
      int to = base ^ e.from ^ e.to;
      if(dist[base] + e.cost < dist[to]){
	dist[to] = dist[base] + e.cost;
	s.emplace(dist[to],to);
      }
    }
  }
  return dist;
}
 
int i,j;
 
int main(){
  int n,m,a,b;
  cin>>n>>m;
  undigraph<int> g(n);
  g.n=n;
  for(i=0;i<m;i++){
    cin>>a>>b;
    g.add(a-1,b-1);
  }
  vector<int> dist = dijkstra(g,0);
 
  for(auto &e:g.edges){
    if(dist[e.from]%2 == dist[e.to]%2){
      cout<<(long long)n* (long long)(n-1) /2-m<<endl;
      return 0;
    }
  }
  int c=0;
  for(int i=0;i<n;i++){
    c+=dist[i]%2?1:0;
  }
  cout<<(long long)c* (long long)(n-c)-m<<endl;
  return 0;
}

Measured memory_bytes: 8116
A,B,K = input().split()
A=int(A)
B=int(B)
K=int(K)

if K==1:
    if A % 2 ==1:
        A =A-1
    A =A/2
    B=B+A

if K==2:
    if A % 2 ==1:
        A =A-1
    A =A/2
    B=B+A
    if B % 2==1:
        B=B-1
    B=B/2
    A=A+B

if K>=3:
    for i in range(1,K,2):
        if A % 2 ==1:
            A =A-1
        A =A/2
        B=B+A
        if B % 2==1:
            B=B-1
        B=B/2
        A=A+B

    if K%2==1:
        if A % 2 ==1:
            A =A-1
        A =A/2
        B=B+A


print (int(A),int(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[11];
    int m1=0,m2=0,m3=0;
    for(i=0;i<10;i++)
    {
        cin>>a[i];
    }
   sort(a,a+10);

   cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
    return 0;
}

Measured memory_bytes: 3120
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
read = sys.stdin.read

N, M, *abc = map(int, read().split())
a, b, c = zip(*zip(*[iter(abc)] * 3))

graph = csr_matrix((c, (a, b)), shape=(N + 1, N + 1))
distance = dijkstra(graph, directed=False)

answer = 0

for i, j, k in zip(a, b, c):
    k = float(k)
    if k == distance[i][j]:
        continue

    for s in range(1, N + 1):
        if i == s or j == s:
            continue

        if k + distance[j][s] == distance[i][s]:
            break

        if k + distance[i][s] == distance[j][s]:
            break

    else:
        answer += 1

print(answer)

Measured memory_bytes: 26568
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define TERMING { if(sign==0) term=term*x; else term=term/x; }

int n,pp;
char exp[150];

int culc(){
	int x=0,term=1,sum=0,sign=0;
	while(1){
		switch(exp[pp]){
			case '*':
				TERMING
				sign=0;
				x=0;
			break;
			case '/':
				TERMING
				sign=1;
				x=0;
			break;
			case '+':
				TERMING
				sum+=term;
				term=1;
				sign=0;
				x=0;
			break;
			case '-':
				TERMING
				sum+=term;
				term=-1;
				sign=0;
				x=0;
			break;
			case '(':
				pp++;
				x=culc();
			break;
			case ')':
			case'=':
				TERMING
				sum+=term;
				return sum;
			break;
			default:
				x=x*10+exp[pp]-'0';
			break;
		}
		pp++;
	}
}

int main(){
	for(scanf("%d",&n);n>0;n--){
		scanf("%s",exp);
		pp=0;
		printf("%d\n",culc());
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;

ll v[3005][3005];
ll dp[4][3005][3005];

int main() {
  ll r,c,k;
  cin>>r>>c>>k;
  rep(j,3005)rep(q,3005)v[j][q]=0;
  rep(i,k){
    ll r1,c1,k1;
    cin>>r1>>c1>>k1;
    r1--;c1--;
    v[r1][c1]=k1;
  }

  rep(i,4)rep(j,3005)rep(q,3005){
    dp[i][j][q]=0;
  }
dp[0][0][0]=0;
dp[1][0][0]=v[0][0];
  rep(i,r)rep(j,c)rep(q,4){
  //  cout<<"q"<<q<<endl;
    dp[0][i+1][j]=max(dp[0][i+1][j],dp[q][i][j]);
    dp[1][i+1][j]=max(dp[1][i+1][j],dp[q][i][j]+v[i+1][j]);
  //  cout<<'i'<<i+1<<'j'<<j<<dp[1][i+1][j]<<' '<<dp[2][i][j]<<' '<<dp[2][i][j]<<endl;
    dp[q][i][j+1]=max(dp[q][i][j+1],dp[q][i][j]);
    if(q<3 and v[i][j+1]!=0)    {
      dp[q+1][i][j+1]=max(dp[q+1][i][j+1],dp[q][i][j]+v[i][j+1]);
    }
//cout<<'i'<<i<<'j'<<j<<dp[1][i][j]<<' '<<dp[2][i][j]<<' '<<dp[2][i][j]<<endl;
  }
ll ans=0;
rep(i,4)ans=max(ans,dp[i][r-1][c-1]);
cout<<ans;

}


Measured memory_bytes: 356376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

string str_int(long long int num){
	string str = "";
	bool minus = false;
	if(num < 0){
		minus = true;
		num = -num;
	}else if(num == 0){
		str = "0";
		return str;
	}
	while(true){
		if(num == 0){
			break;
		}
		string d = "D";
		d[0] = '0' + (num % 10);
		str = d + str;
		num /= 10;
	}
	if(minus){
		str = "-" + str;
	}
	return str;
}

long long int int_str(string str){
	long long int num = 0;
	bool minus = false;
	if(str[0] == '-'){
		str = str.substr(1);
		minus = true;
	}
	for(int i = 0; i < str.size(); i++){
		num *= 10;
		num += (str[i] - '0');
	}
	if(minus){
		num = -num;
	}
	return num;
}

int main(){
	
	int N;
	
	cin >> N;
	
	vector<long long int> v, v2;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		v.push_back(num);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < v.size(); i++){
		if(i > 10){
			break;
		}
		for(int j = i + 1; j < v.size(); j++){
			if(j > 10){
				break;
			}
			v2.push_back(int_str(str_int(v[i]) + str_int(v[j])));
			v2.push_back(int_str(str_int(v[j]) + str_int(v[i])));
		}
	}
	
	sort(v2.begin(), v2.end());
	
	cout << v2[2] << endl;
	
	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int cnt=0,n,m,a,b,ans[1005][1005];
int main()
{
	cin>>n>>m>>a>>b;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout<<((i<b)^(j<a));
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 3*a+b;
		out.print(ans/2);
		out.close();
	}
	
	
}

Measured memory_bytes: 21460
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    	int r = sc.nextInt();
    	int g = sc.nextInt();
    	int b = sc.nextInt();
    		r = r*100;
			g = g*10;
    		if((r+g+b)%4 == 0){
              System.out.println("YES");
            }else{
              System.out.println("NO");
            }
  }
} 

Measured memory_bytes: 20688
#include<iostream>
#include<queue>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

double dp[1001][1001];

double solve(int i,int j){
  if (i <= j)return 0;
  if (i == 1)return 0;
  
  double &ret=dp[i][j];
  if (ret == -1){
    double a=(2*i-j),b=(2*i-(j+1));
    if(j == 0){
      ret=0;
      ret+=2*i/(a*b)*solve(i-1,0);
      ret+=(a*b-2*i)/(a*b)*(1+solve(i,2));
    }else {
      ret=0;
      ret+=(2*i-2*j)*(i-(j+1))*2/(a*b)*(1+solve(i,j+2));
      ret+=(2*i-2*j)*(j)/(a*b)*(1+solve(i-1,j));
      ret+=j/(a)*solve(i-1,j-1);
      ret+=(2*i-2*j)/(a*b)*solve(i-1,j);
    }
  }
  return ret;
}

main(){
  rep(i,1001)rep(j,1001)dp[i][j]=-1;
  int n;
  while(cin>>n && n){
    printf("%.10lf\n",solve(n/2,0));
  }
}

Measured memory_bytes: 0
s = int(input())
a = [s]

for i in range(1, 1000001):
    if(a[i-1]%2 == 0):
        a.append(a[i-1]//2)
    else:
        a.append(3*a[i-1] + 1)
    if(a.count(a[i])) == 2:
        break
        
print(len(a))

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void) {
    int i,j;
    int H, W;
    
    while(1){
        scanf("%d %d",&H,&W);
        //???????????其
        if(H==0&&W==0) break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if((i+j)%2==0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
         
        return 0;
}

Measured memory_bytes: 572
import java.util.*;
public class Main {

	static int[] dist,visit;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		List<List<Integer>> ls=new ArrayList<>();

		int n=in.nextInt();
		dist=new int[n]; visit=new int[n];
		for(int i=0;i<n;i++) {
			ls.add(new ArrayList<>());
			dist[i]=-1;
		}
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()),k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++)ls.get(u-1).add(Integer.parseInt(in.next())-1);
		}

		solve(ls);
		for(int i=0;i<n;i++) System.out.println(i+1+" "+dist[i]);
	}
	
	static void solve(List<List<Integer>> ls) {
		Queue<Integer> que=new ArrayDeque<>();
		que.add(0);
		visit[0]=1;
		dist[0]=0;
		while(!que.isEmpty()) {
			int p=que.remove();
			for(int i=0;i<ls.get(p).size();i++) {
				int next=ls.get(p).get(i);
				if(visit[next]==0) {
					visit[next]=1;
					dist[next]=dist[p]+1;
					que.add(next);
				}
			}
		}
	}
}



Measured memory_bytes: 27992
x = input().split()

a = int(x[0])
b = int(x[1])

c = 1
outlet = a
if(b==1):
  print(0)
  exit()

while True:
  if(outlet >= b):
    print(c)
    break
  elif(outlet < b):
    c = c + 1
    outlet = outlet + a - 1
 
    

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	ll mi = 10000000000;
	ll ma = -10000000000;
	for (int i = 0; i < n; i++) {
		ll m;
		cin >> m;
		ma = max(m - mi, ma);
		mi = min(m, mi);
	}
	cout << ma << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int a=in();
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
long long lcm(long long a, long long b)
{
    return a * (b / __gcd(a, b));
}

long long lcma(vector<long long> input)
{
    long long result = input[0];
    for(int i = 1; i < input.size(); i++) result = lcm(result, input[i]);
    return result;
}
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector<long long> num(n);
    long long numGcd = 0;
    for(int i = 0;i < n;i++)
        cin >> num[i];
    cout << lcma(num);
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn nCr(mut k: i64, n: i64) -> i64 {
    if k > n {
        return 0;
    }
    if k * 2 > n {
        k = n - k
    }
    let mut res = 1;
    for i in 1..k + 1 {
        res *= n - k + i;
        res /= i;
    }
    res
}

fn main() {
    let n: i64 = read();
    let m: i64 = read();
    let nn = nCr(2, n);
    let mm = nCr(2, m);
    println!("{}", nn + mm);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
	public static void main(String[] args){
		int i,x,rst,oneCount;
		boolean flg;
		Scanner scan = new Scanner(System.in);

		while(true){
			String[] s = scan.nextLine().split(" ");
			rst = oneCount = 0;
			flg = true;

			if(s[0].equals("0")) break;

			for(i=0;i<s.length;i++){
				x = Integer.parseInt(s[i]);

				if(x==1) oneCount++;

				else if(x>=10){
					if(rst+10<22) rst += 10;
					else{
						rst = 0;
						flg = false;
						break;
					}
				}

				else{
					if(rst+x<22) rst += x;
					else{
						rst = 0;
						flg = false;
						break;
					}
				}
			}

			if(flg && oneCount>=1){
				if(rst+11+(oneCount-1) < 22)
					rst += 11 + (oneCount-1);
				else if(rst+oneCount < 22)
					rst += oneCount;
				else
					rst = 0;
			}
			System.out.println(rst);
		}
	}
}

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

int main(){
    long long n=0,i=0,j=0;
    cin >> n;
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)j +=i;
    }
    cout << j << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#define F(i) for(int i=0;i<100;i++)
using namespace std;
int main(void){
int n,m,g[100][100],h[100][100],a,b,c,ans=0,t;
cin>>n>>m;
F(i)F(j)g[i][j]=1e9;
for(t=0;t<m;t++){
cin>>a>>b>>c;
g[a-1][b-1]=c;
g[b-1][a-1]=c;
}
F(i)F(j)h[i][j]=g[i][j];
F(k)F(i)F(j)g[i][j]=min(g[i][k]+g[k][j],g[i][j]);
F(i)F(j)if(h[i][j]!=1e9&&g[i][j]!=h[i][j])ans++;
cout<<ans/2;
}


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

int main() {
  int n, i, j;
  cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1), t(n, 0);
  for (i = 0; i < n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }
  for (i = 0; i < n - 1; i++) {
    t[i] = 0;
    for (j = i; j < n - 1; j++) {
      if (t[i] < s[j]) {
        t[i] += s[j] - t[i];
      } else if (t[i] % f[j] != 0) {
        t[i] += f[j] - t[i] % f[j];
      }
      t[i] += c[j];
    }
    cout << t[i] << "\n";
  }
  t[n - 1] = 0;
  cout << t[n - 1] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N;cin>>N;
  string s;
  int a=0,b=0;cin>>s;
  for(char p:s)if(p=='R')a++;
  b=N-a;
  if(a>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;
typedef pair<int,int> P;
vector<P> g[100005];
int ans[100005];


void dfs(int v, int prev, bool WorB) {
  if(WorB) ans[v] = 1;
  else ans[v] = 0;

  for(int i = 0; i < g[v].size(); i++) {
    if(g[v][i].first == prev) continue;
    if(g[v][i].second % 2) {
      dfs(g[v][i].first,v,!WorB);
    }
    else dfs(g[v][i].first,v,WorB);
  }
  return;
}
    
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int u,v,w;
    cin >> u >> v >> w;
    u--,v--;
    g[u].push_back(P(v,w));
    g[v].push_back(P(u,w));
  }

  bool exist = false;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < g[i].size(); j++) {
      dfs(i,-1,true);
      exist = true;
      break;
    }
    if(exist) break;
  }

  for(int i = 0; i < n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 9984
from collections import deque
import math
n, h = map(int, input().split())
a_list = []
b_list = []
time = 0
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list.sort()
b_list.sort(reverse=True)
b_stack = deque(b_list)
while h > 0:
    if len(b_stack) > 0:
        if a_list[-1] < b_stack[0]:
            h -= b_stack.popleft()
            time += 1
        else:
            
            time += math.ceil(h / a_list[-1])
            h = 0
    else:        
        time += math.ceil(h / a_list[-1])
        h = 0
    
print(time)

Measured memory_bytes: 12056
INF = 10**10

N,T = map(int, input().split())
t = list(map(int, input().split()))
t.append(INF)

res = 0
for i in range(1,len(t)):
	if t[i] - t[i-1] < T:
		res +=  t[i] - t[i-1]
	else:
		res += T

print(res)

Measured memory_bytes: 26832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  char s[50];
  int i, l;
  scanf("%s",s);
  l = strlen(s);
  for(i=0;i<l-8;i++) printf("%c",s[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int F(ll n){
    ll ans=0;
    if(n%2==0)
        ans++;
    while(n%2==0){
        n=n/2;
    }
    for(ll i=3;i<=sqrt(n);i=i+2){
        if(n%i==0)
        ans++;
        while(n%i==0){
            n=n/i;
        }
    }
    if(n>2)
    ans++;
    return ans+1;
}
int main(){
    ll n,a,b;
cin>>b>>a;
n=__gcd(a,b);
cout<<F(n);
    return 0;
}


Measured memory_bytes: 256
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int N=1e5+10;


int main(){
	jaldibazi;

    int n; cin>>n;
    int a[n];

    for (int i= 0; i <n; ++i) cin >> a[i];

    int xr=0;
    for(int i: a) xr^=i;

    int ans[n]={};
	for(int i=0; i<n;++i){
		ans[i]=xr^a[i];
	}

	for(int i=0;i<n;++i) cout << ans[i]<< " ";
	cout << endl;

    return 0;
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int n, m;
int a[305][305];

bool usedAll(vector<bool> u){
	rep(i,u.size()){
		if(not u[i]) return false;
	}
	return true;
}

bool C(int mid){
	vector<int> p(n,0);
	vector<bool> u(m,0);
	rep(i,m){
		vector<int> cnt(m,0);
		//rep(i,m){ cout << u[i] << ' '; } cout << endl;
		if(usedAll(u)){
			return false;
		}

		rep(j,n){
			while(u[ a[j][ p[j] ] ]){
				p[j]++;
				if(p[j] >= m) return false;
			}
			cnt[ a[j][ p[j] ] ]++;
		}

		bool f = true;
		vector<int> tmp;
		rep(j,n){
			if(cnt[a[j][ p[j] ]] > mid){
				f = false;
				u[ a[j][p[j]] ] = true;
			}
		}
		if(f) return true;
	}
	return false;
}

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

	rep(i,n){
		rep(j,m){
			cin >> a[i][j];
			a[i][j]--;
		}
	}

	int right = n, left = 1;
	rep(i,100){
		int mid = (right + left ) / 2;
		if(C(mid)) right = mid;
		else left = mid;
	}
	cout << right << endl;
}


Measured memory_bytes: 640
use io::*;
use std::*;

fn gcd(mut m: i64, mut n: i64) -> i64 {
    if m == 0 || n == 0 {
        return (m | n).abs();
    }

    // find common factors of 2
    let shift = (m | n).trailing_zeros();

    // The algorithm needs positive numbers, but the minimum value
    // can't be represented as a positive one.
    // It's also a power of two, so the gcd can be
    // calculated by bitshifting in that case

    // Assuming two's complement, the number created by the shift
    // is positive for all numbers except gcd = abs(min value)
    // The call to .abs() causes a panic in debug mode
    if m == i64::min_value() || n == i64::min_value() {
        return ((1 << shift) as i64).abs();
    }

    // guaranteed to be positive now, rest like unsigned algorithm
    m = m.abs();
    n = n.abs();

    // divide n and m by 2 until odd
    // m inside loop
    n >>= n.trailing_zeros();

    while m != 0 {
        m >>= m.trailing_zeros();
        if n > m {
            ::std::mem::swap(&mut n, &mut m)
        }
        m -= n;
    }

    n << shift
}

fn solve(K: i64) {
    println!(
        "{}",
        (1..=K)
            .map(|x| {
                (1..=K)
                    .map(|y| (1..=K).map(|z| gcd(gcd(x, y), z)).sum::<i64>())
                    .sum::<i64>()
            })
            .sum::<i64>()
    );
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut K: i64;
    K = scanner.next();
    solve(K);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


Measured memory_bytes: 2148
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

let main _ =
    let N = read int
    let A = reada int |> Array.map (fun x -> x - 1)
    let B = A |> Array.indexed

    B
    |> Array.filter (fun (i, a) -> i = A.[a] && a = A.[i])
    |> Array.length
    |> fun x -> x / 2
    |> printfn "%d"
    0 // return an integer exit code

main()


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

int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int e;
        cin >> e;
        sum += e;
    }
    if (h - sum > 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[200000];
		int[] t = new int[200000];
		int color = 1;
		a[0] = sc.nextInt();
		t[0] = a[0];
		int stackablenum = 0;


		for(int i = 1 ; i < n ; i++){
			a[i] = sc.nextInt();
			stackablenum = color-1;
			while(stackablenum >= 0 && a[i] > t[stackablenum]){
				stackablenum--;
			}
			t[stackablenum+1] = a[i];
			if(stackablenum == color-1){
				color++;
			}
		}

		System.out.println(color);
	}
}

Measured memory_bytes: 61016
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
const double pi=acos(-1.0);
char ch[10001];
int main()
{
    int n,m,len;
    while(cin>>n)
    {
        printf("%d\n",n*n);
    }
    return 0;
}

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

using namespace std;

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

    vector<int> x(N+1);
    vector<int> y(N+1);
    for (int i=1;i<=N;i++) cin>>x[i]>>y[i];

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

    do {
        for (int i=0;i<N-1;i++) {
            double dx = x[v[i]] - x[v[i+1]];
            double dy = y[v[i]] - y[v[i+1]];
            sum += pow(dx * dx + dy * dy, 0.5);
        }
    } while (next_permutation(v.begin(), v.end()));

    int f = 1;
    for (int i=2;i<=N;i++) f *= i;

    cout << fixed << setprecision(10) << sum / f << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(void){

  ll a,b;
  cin>>a>>b;

  ll target=gcd(a,b);
  /*
  vector<ll> yaku;
  for(ll i=1;i<=sqrt(target);i++ ){
    if( target%i==0 ){
      yaku.push_back(i);
      yaku.push_back( target/i );
    }
  }
  sort(begin(yaku),end(yaku));
  */
  //for(auto x:yaku) cout << x << endl;
  //ll ans=0;
  auto v=prime_factor(target);
  //for(auto x:v) cout << x.first << "," << x.second << endl;

  cout << v.size()+1 << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

typedef long long LL;
const int MAXN=1e6+10;
const int mod=1e9+7;
const double eps=1e-8;

int n,m;
int f[55][55][55*55];

void Add(int &a,LL b){
    LL c=(a+b)%mod;
    a=c;
}

int main(){
    scanf("%d%d",&n,&m);
    memset(f,0,sizeof(f));
    f[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=n*n;k++){
                Add(f[i+1][j][k+j],f[i][j][k]);
                if (k+j+1<=n*n) Add(f[i+1][j+1][k+j+1],f[i][j][k]);
                if (j+k<=n*n) Add(f[i+1][j][k+j],2LL*f[i][j][k]*j);
                if (j>=1 && k+j-1<=n*n) Add(f[i+1][j-1][k+j-1],(LL)f[i][j][k]*j*j);
            }
        }
    }
    if (m%2==1) puts("0");
    else printf("%d\n",f[n][0][m/2]);
}

/*
1
8 3
0 0101010 1
0 0101011 2
1 0101010 1
0 1100000 3
0 0101011 -1
0 1111111 4
1 0101011 -1
1 0101010 0
*/

Measured memory_bytes: 35968
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N; cin>>N;
    ll ans=0;
    string s; cin>>s;
    vector<ll> stock[10];
    rep(i,sz(s)){
        ll tmp=s[i]-'0';
        stock[tmp].pb(i);
    }
    rep(i,10)rep(j,10)rep(k,10){
        //(i,j,k)
        if(lower_bound(all(stock[i]),0)==stock[i].ed){
            continue;
        }
        else{
            ll tmpi=*(lower_bound(all(stock[i]),0));
            if(upper_bound(all(stock[j]),tmpi)==stock[j].ed){
                continue;
            }
            else{
                ll tmpj=*(upper_bound(all(stock[j]),tmpi));
                if(upper_bound(all(stock[k]),tmpj)!=stock[k].ed){
                    //cout<<i<<j<<k<<endl;
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3856
#include<iostream>
#include<string.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll count = 0;
    count += n/(a+b) * a;
    ll mod = n%(a+b);
    if(mod > 0){
        if(a > mod) count += mod;
        else count += a;
    }
    cout << count << endl;
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
#define rep(i, n) for(int i=0;i<(int)(n);i++)

int L[MAX/2+2], R[MAX/2+2];

llong merge(int A[], int n, int left, int mid, int right){
    int i, j, k;
    llong cnt=0;
    int n1=mid-left;
    int n2=right-mid;
    rep(i, n1) L[i]=A[left+i];
    rep(i, n2) R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
            cnt+=n1-i;
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
    int mid;
    llong v1, v2, v3;
    if(left+1<right){
        mid=(left+right)/2;
        v1=mergeSort(A, n, left,mid);
        v2=mergeSort(A,n,mid,right);
        v3=merge(A,n,left,mid,right);
        return v1+v2+v3;
    }else return 0;
}

int main(){
    int A[MAX], n, i;

    cin>>n;
    rep(i,n){
        cin>>A[i];
    }

    llong ans=mergeSort(A,n,0,n);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4652
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
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 f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
void umin(ll& a,ll t){if(t<a)a=t;}
const ll INF=1ll<<58;
#define MAXN 200011
struct one
{
	ll val,type,dex;
	bool operator <(const one& t)const{return val<t.val;}
}a[MAXN];
ll posa[MAXN],posb[MAXN],s[MAXN];
int main()
{
	ll n=read(),suma=0,sumb=0 ,cnt=0;
	for(ll i=1;i<=n;++i)
	{
		ll x=read(),y=read();
		a[++cnt]=one{x,0,i},a[++cnt]=one{y,1,i};
		suma+=x,sumb+=y;
	}
	ll ans=min(suma,sumb);
	std::sort(a+1,a+cnt+1);
	for(ll i=1;i<=cnt;s[i]=s[i-1]+a[i].val,++i)
		if(!a[i].type)posa[a[i].dex]=i;
		else posb[a[i].dex]=i;
	for(ll i=1;i<=n;++i)
	{
		ll tmp=s[n-2],cur=n-2;
		if(posa[i]>posb[i])std::swap(posa[i],posb[i]);
		if(posa[i]<=cur)tmp+=a[++cur].val;
		else tmp+=a[posa[i]].val;
		if(posb[i]<=cur)tmp+=a[++cur].val;
		else tmp+=a[posb[i]].val;
		umin(ans,tmp);
	}
	std::cout<<ans;
	return 0;
}

Measured memory_bytes: 10940
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;


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

	string S, T;
	cin >> S >> T;

	string a;
	rep(i, N)
	{
		a += S[i];
		a += T[i];
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
//ABC137A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans;
	ans = max({a+b,a-b,a*b});
	cout << ans << endl;
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int n, m, s[100], t[100];
typedef map<string, int> mp;
int main(void){
    // Your code here!
    mp blue, red;
    string str;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> str;
        blue[str]++;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> str;
        blue[str]--;
    }
    int res = 0;
    for (auto it = blue.begin(); it != blue.end(); it++) {
        res = max(res, it->second);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
P = [int(x) for x in input().split()]

L = 2*N+100

A = [None] + [L*i for i in range(1,N+1)]
B = [None] + [L*(N+1-i) for i in range(1,N+1)]

for i,p in enumerate(P,1):
    A[p] += i

print(' '.join(map(str,A[1:])))
print(' '.join(map(str,B[1:])))

Measured memory_bytes: 7352
N, M = map(int, input().split())
load = []
for i in range(M):
    load.append(input().split())

num = [0] * N
for j in range(N):
    for k in range(M):
        if str(j+1) == load[k][0] or str(j+1) == load[k][1]:
            num[j] += 1
    print(num[j])


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

using namespace std;
int a[1005][1005],n;
int r[1005],d[1005];
bool v[1005];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        for(int j=0;j<n-1;++j) scanf("%d",a[i]+j);
    }
    int day = 1;bool update=true;
    for(int i=1;i<=n;++i)
        {r[i] = a[i][0];a[i][n-1]=-1;}

    int ans = 0;
    while(true)
    {
        update= false;
        for(int i=1;i<=n;++i){
            if(r[i]==-1) continue;
            if(v[i]){
                v[i] = false;continue;
            }
            if(r[i]>i&&!v[r[i]]&&i==r[r[i]]){

                update=true;
                v[r[i]] = true;
                if(d[i]+1<n)
                {
                    int rr = r[i];
                    r[i] = a[i][++d[i]];
                    r[rr] = a[rr][++d[rr]];
                }
            }
        }
        if(!update) break;
        ++ans;
    }
    for(int i=1;i<=n;++i){
        if(r[i]!=-1){
            ans = -1;break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main(){
	int n,i,j,k,l,now=0;
	long long ans=0;
	string s;
	cin>>s;
	n=s.size();
	s=" "+s;
	for(i=1;i<=n;i++){
		if(s[i]=='A'){
			now++;
		}
		if(s[i]=='B'){
			if(i==n||s[i+1]!='C'){
				now=0;
			}
			else{
				ans+=now;
			}
		}
		if(s[i]=='C'){
			if(i==1||s[i-1]!='B'){
				now=0;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 772
n, m = gets.split.map(&:to_i)
ary = (n + 1).times.map { Array.new(n + 1) }
m.times {
  a, b = gets.split.map(&:to_i)
  ary[a][b] = ary[b][a] = true
}

puts [*2..n].permutation.count { |a| ([1] + a).each_cons(2).all? { |b| ary.dig(*b) } }

Measured memory_bytes: 14356
s = gets.chomp.split('').map(&:to_i)
hoge = 0
count1 = 0
s.each do |tile|
  count1 += 1 if (tile != hoge)
  hoge = hoge==0 ? 1 : 0
end

hoge = 1
count2 = 0
s.each do |tile|
  count2 += 1 if (tile != hoge)
  hoge = hoge==0 ? 1 : 0
end

puts [count1,count2].min

Measured memory_bytes: 7804
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int max = a + b;
	if (max > a + c) {
		max = a + c;
	}
	if (max > b + c) {
		max = b + c;
	}
	cout << max << endl;
}

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

double ex(int n) {
    double total = 0.0;
    for(int i = 1; i <= n; i++) total += i;
    return (double)total / n;
}

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

    vector<int> p(n, 0);
    vector<double> q(n, 0.0);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        q[i] = ex(p[i]);
    }
    
    vector< pair<double, int> > adj(n - k + 1, {0.0, 0});
    for(int i = 0; i < k; i++) adj[0].first += q[i];
    for(int i = 1; i < n - k + 1; i++) {
        adj[i].first = adj[i - 1].first - q[i - 1] + q[i + k - 1];
        adj[i].second = i;
    }
    sort(adj.rbegin(), adj.rend());

    printf("%.10f\n", adj[0].first);

    return 0;
}

Measured memory_bytes: 5704