akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,X,D,A;
	while(cin>>N>>D>>X) {
		VI m(D+1);
		REP(i, N) {
			cin>>A;
			REP(i, 1000) {
				ll ni=1+A*i;
				if(ni<D+1) m[ni]++; else break;
			}
		}
		ll ans=accumulate(ALL(m),0LL)+X;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	string S;
	cin>>N;
	cin>>S;
	int reader;
	int leftNumE=0;
	int leftNumW=0;
	int minChange=N+1;
	reader=0;
	if (S[reader]=='E'){
		leftNumE++;
	}else{
		leftNumW++;
	}
	int rightNumE=0;
	int rightNumW=0;
	for (reader=1;reader<N;reader++){
		if (S[reader]=='E'){
			rightNumE++;
		}else{
			rightNumW++;
		}
	}
	minChange=leftNumW+rightNumE-1;
	for (reader=1;reader<N;reader++){
		if (S[reader]=='E'){
			rightNumE--;
			leftNumE++;
		}else{
			rightNumW--;
			leftNumW++;
		}
		if (minChange>leftNumW+rightNumE){
			minChange=leftNumW+rightNumE;
		}
	}
	cout<<minChange<<endl;
	return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	string s; cin >> s;
	reverse(s.begin(), s.end());
	int n_s = s.size();
	string t; cin >> t;
	reverse(t.begin(), t.end());
	int n_t = t.size();

	bool ok = false;
	int n = n_s - n_t;
	REP(i, n + 1) {
		int cnt = 0;
		string sub = s.substr(i, n_t);
		REP(j, n_t) {
			if (sub[j] == '?' || sub[j] == t[j])
				cnt++;
		}
		if (cnt == n_t) {
			ok = true;
			s.replace(i, n_t, t);
			break ;
		}
	}

	if (ok) {
		REP(i, n_s)
			if (s[i] == '?')
				s[i] = 'a';
		reverse(s.begin(), s.end());
		cout << s << '\n';
	} else
		cout << "UNRESTORABLE" << '\n';
    return 0;
}


Measured memory_bytes: 3556
class UF():
  def __init__(self, N):
    self.parents = [-1] * N

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

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p]

n,m = map(int,input().split())
edges = []
for _ in range(m):
  u,v = map(int,input().split())
  edges.append((u,v))
edges.reverse()

uf = UF(n+1)

ans = [n*(n-1)//2]
for i in range(m-1):
  if ans[-1] == 0:
    ans.append(0)
  else:
    u,v = edges[i]
    if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v)

for a in ans[::-1]:
  print(a)

Measured memory_bytes: 92976
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7


ll N, K;
ll dp[105][500000];

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

	set<ll> numset;
	for(ll i = 1; i * i <= N; i++) {
		numset.insert(i);
		numset.insert(N/i);
	}

	vector<ll> nums;
	for(ll num: numset) {
		nums.push_back(num);
	}
	sort(nums.begin(), nums.end());


	rep(i, nums.size()) {
		if(i == 0) {
			dp[0][i] = 1;
		} else {
			dp[0][i] = (nums[i] - nums[i-1]) % DIV;
		}
	}

	for(ll i = 1; i < K; i++) {
		rep(j, nums.size()) {
			dp[i-1][j+1] += dp[i-1][j];
			dp[i-1][j+1] %= DIV;
		}
		rep(j, nums.size()) {
			//numsのj番目は numsのいくつ以下からもらえる？
			ll prev = lower_bound(nums.begin(), nums.end(), N/nums[j]) - nums.begin();
			ll add;
			if(j == 0) {
				add = 1;
			} else {
				add = nums[j] - nums[j-1];
				add %= DIV;
			}
			dp[i][j] += dp[i - 1][prev] * add;
			dp[i][j]  %= DIV;
		}
	}


	ll ans = 0;
	rep(i, nums.size()) {
		ans += dp[K - 1][i];
		ans %= DIV;
	}
	cout << ans << endl;
}


Measured memory_bytes: 56556
N = int(input())
*A, = map(int, input().split())

from collections import Counter
C = 0
mycounter = Counter(A)
for i, v in mycounter.items():
  if int(i) < int (v):
    C += int (v) - int(i)
  elif int(i) > int(v):
    C += int(v)

print(C)

Measured memory_bytes: 70952
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    long N = sc.nextLong();
	    long K = sc.nextLong();
	     
	    long min = 0;
	    long max = 0;
	    for(int i = 0; i < K; i++) {
	        min += i;
	        max += N - i;
	    }
	    long sum = max - min + 1;
	    
	    for(long i = K; i <= N; i++) {
	        min += i;
	        max += N - i;
	        sum += max - min + 1;
	    }
	    System.out.println(sum % 1000000007);
	    
	    
	}
	
	
}

Measured memory_bytes: 35764
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
vector<int> con[100111];
int dp[100111];
void dfs(int x)
{
	vector<int>v;
	for(int i=0;i<con[x].size();i++)dfs(con[x][i]),v.PB(dp[con[x][i]]);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)dp[x]=max(dp[x],v[i]+int(v.size())-i);
}
int main()
{
	geti(n);
	for(int i=2;i<=n;i++)
	{
		int x;
		geti(x);
		con[x].PB(i);
	}
	dfs(1);
	cout<<dp[1]<<endl;
	return 0;
}


Measured memory_bytes: 13952
c,i,p,P,f;main(n){float x[100],y[100],d,t,T;for(;scanf("%d",&n)*n;printf("%d\n",c)){for(T=2e3,i=n;i--;y[i]>T||(T=y[p=f=i]))scanf("%f,%f",x+i,y+i);c=n;d=0;do{T=9;for(i=n;i--;)i-p?t=atan2f(y[i]-y[p],x[i]-x[p]),t+=8*atan(t<d),t<T?T=t,P=i:0:0;p=P,d=T,c--;}while(p-f);}}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                if (s.charAt(0) == 'Y') {
                    out.println("Four");
                    return;
                }
            }
            out.println("Three");
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

typedef pair<int, int> ii;
typedef long long ll;

int main()
{
	int h, w, m, r, c, mr = 0, mc = 0;
	set<ii> s, s2;
	scanf("%d%d%d", &h, &w, &m);
	int R[h], C[w];
	memset(R, 0, sizeof R);
	memset(C, 0, sizeof C);
	while (m--) {
		scanf("%d%d", &r, &c);
		mr = max(mr, ++R[r-1]);
		mc = max(mc, ++C[c-1]);
		s.insert(ii(r-1, c-1));
	}
	vector<bool> br(h, 0), bc(w, 0);
	ll vr = 0, vc = 0;
	for (int i = 0; i < h; ++i) if (R[i] == mr) br[i] = 1, vr++;
	for (int i = 0; i < w; ++i) if (C[i] == mc) bc[i] = 1, vc++;
	for (ii e : s) {
		if (br[e.first] && bc[e.second]) s2.insert(e);
	}
	printf("%d\n", mr+mc-(vr*vc==ll(s2.size())));
}

Measured memory_bytes: 34244
n = int(input())
t,a = map(int, input().split())
l = list(map(int, input().split()))
min=2000
ans = 0
for j in range(n):
    if abs(a-t+0.006*l[j]) < min:
        min = abs(a-t+0.006*l[j])
        ans=j+1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
int main(void)
{
	int	N=0;
	int out1[101]={0};int out2[101]={0};int out3[101]={0};
	int a[660]={0};int a1[660]={0};int a2[660]={0};
	int all[220]={0};
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d %d %d",&a[i],&a1[i],&a2[i]);
		if(out1[a[i]]<0){
			out1[a[i]]=-2;
			}
		else{
			out1[a[i]]=-1;
			}
		if(out2[a1[i]]<0){
			out2[a1[i]]=-2;
			}
		else{
			out2[a1[i]]=-1;
			}
		if(out3[a2[i]]<0){
			out3[a2[i]]=-2;
			}
		else{
			out3[a2[i]]=-1;
			}
	}
	for(int i=1;i<=N;i++)
	{
		if(out1[a[i]]!=-2)
		{
			all[i]+=a[i];
		}
		if(out2[a1[i]]!=-2)
		{
			all[i]+=a1[i];
		}
		if(out3[a2[i]]!=-2)
		{
			all[i]+=a2[i];
		}
		printf("%d\n",all[i]);
	}
	return 0;
}
//26:00クリア


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

int main() {
	int A,B,T;
  	cin >> A >> B >> T;
  
  	int num = 0;
  
  	while(T - A >= 0) {
    	num++;
      	T -= A;
    }
  
  	cout << B * num << endl;
}
  

Measured memory_bytes: 256
a=int(input())
cards = []
for c in ['S', 'H', 'C', 'D']:
  for n in range(1, 14):
    cards.append(f'{c} {n}')

for i in range(a):
    x=input()
    if x in cards:
        cards.remove(x)
for i in range(len(cards)):
    print(cards[i])


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

int collatz(int);
int count(int);

int main(void){
  int num;

  while(1){

    cin >> num;
    if( num == 0 ) break;

    cout << collatz(num) << endl;

  }

  return 0;
}

int collatz(int num){
  int cnt = 0;
  
  while( num != 1 ){
    
    switch(num%2){
      
    case 0:
      num /= 2;
      break;
      
    case 1:
      num = num*3 + 1;
      break;      
    }
    cnt++;
  }  
  return cnt;
}

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

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

  for (int i=0;i<n;i++){
    if(a[i] != i+1)cnt++;
  }
  if (cnt ==0 ||cnt ==2){
    cout <<"YES"<<endl;
  }else{
    cout <<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,num,maxn,ans=1,minn,a[100001];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    minn=a[1],maxn=a[n];
    if(minn<maxn-1||maxn>=n)ans=0;
    if(maxn==minn)
    {
        if(minn+1!=n&&minn*2>n)ans=0;
    }
    else
    {
        for(int i=1;i<=n;i++)if(a[i]==minn)num++;
        n-=num;maxn-=num;
        if(minn<num)ans=0;
        else if(maxn*2>n)ans=0;    
    }
    if(ans)cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b) {
			if(b != c) {
				System.out.println("Yes");
				return;
			}
		}else {
			if(a == c) {
				System.out.println("Yes");
				return;
			}
			if(b == c) {
				System.out.println("Yes");
				return;
			}
		}



		System.out.println("No");
	}

}

Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
# C

'''
5 100
1 0 0 1 0
'''

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
A = list(map(int, input().split()))
prev = A

for k in range(K):
    B = [0] * N
    for i in range(N):
        l = max(0, i-prev[i])
        r = min(N-1, i+prev[i])
        # print(i, l, r)
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    if prev == B:
        break
    prev = B

for b in B:
    print(b, end=' ')
print()

Measured memory_bytes: 144728
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;
string s;
INT ans, n, cnt[26][200020];

INT solve(INT l, INT r)
{
    if( l >= r ) return 0;
    INT m = (l+r)/2, val = 0;
    for(int i = m+1 ; i <= r ; i++ ) for(int j = 0 ; j < 26 ; j++ )
        if( j != (s[i]-'a') ) val += cnt[j][m] - cnt[j][l-1];
    return solve(l, m) + solve(m+1, r) + val;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>s; n = s.size();
    s = " "+s;
    for(int i = 1 ; i <= n ; i++ )
    {
        for(int j = 0 ; j < 26 ; j++)
        {
            if( j == (s[i]-'a') ) cnt[j][i] = cnt[j][i-1] + 1;
            else cnt[j][i] = cnt[j][i-1];
        }
    }
    cout<<solve(1, n)+1<<endl;
    return 0;
}


Measured memory_bytes: 41168
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let m1d1 = readn::<usize>(" ");
    let m1 = m1d1[0];
    let m2d2 = readn::<usize>(" ");
    let m2 = m2d2[0];

    if m1 == m2 {
        println!("0");
    } else {
        println!("1");
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int* leap_year_array, int start_year, int final_year);
int main()
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int* leap_year_array, int start_year, int final_year)
{
    int count = 0;
    for(int i = start_year; i <= final_year; i++){
        if(is_leap_year(i)){
            leap_year_array[count] = i;
            count++;
        }    
    }
    return count;
}
            

Measured memory_bytes: 1048
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int n,m;
main(){
	int i,j,k;
	string s;
	map<string, bitset<256> > var;
	cin >> m;
	for(i=0;i<m;i++){
		string c;
		int lb, ub;
		cin >> s >> lb >> ub;
		var[s] = 0;
		for(j=lb;j<=ub;j++) var[s][j] = 1;
	}
	stack<bitset<256> > st;
	for(cin>>n;n--;){
		cin >> s;
		if(isdigit(s[0])){
			bitset<256> ret(0);
			ret[atoi(s.c_str())] = 1;
			st.push(ret);
		}else if(s[0] == '+' || s[0] == '-' || s[0] == '*' || s[0] == '/'){
			bitset<256> b=st.top();st.pop();
			bitset<256> a=st.top();st.pop();
			bitset<256> ans(0);
			for(i=0;i<256;i++){
				if(!a[i]) continue;
				for(j=0;j<256;j++){
					if(!b[j]) continue;
					if(s[0] == '+') ans[(i+j)%256] = 1;
					if(s[0] == '-') ans[(i-j+256)%256] = 1;
					if(s[0] == '*') ans[(i*j)%256] = 1;
					if(s[0] == '/'){
						if(!j){
							cout << "error" << endl;
							return 0;
						}
						ans[(i/j)%256] = 1;
					}
				}
			}
			st.push(ans);
		}else{
			st.push(var[s]);
		}
	}
	cout << "correct" << endl;
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>

int main(void){
    
    int n, a, b, c, d;
    
    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    
    int p1, p2;
    
    p1 = b * (1 + (n-1) / a); 
    p2 = d * (1 + (n-1) / c);
    
    if (p1 < p2) printf("%d\n",p1);
    else printf("%d\n",p2);
    
    return 0;
    
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  vector<ll> save(N+1);


  for (ll i=1; i<N+1; i++){
    cin >> A[i];
  }

  ll save_sum =0;
  for (ll i=N; i >1; i--){
    save_sum += A[i];
    save_sum = save_sum % 1000000007;
    save[i] = save_sum;
    //cout << "save_sum:" << save_sum << endl;
  }

  ll sum = 0;

  for(ll i=1; i< N; i++){    
    sum += (A[i] * save[i+1]) % 1000000007;
    sum = sum % 1000000007;
    //cout << "add:"<< A[i] * save[i+1] << endl;
  }
  
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin >> n >> s;
  for(int i = 0;i<s.size();i++){
    s.at(i) = s.at(i) + n;
    if(s.at(i)>90){
      s.at(i) -= 26;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  ll a, b;
  in, a, b;
  ll ans = 0;
  if (b < 0) {
    if (b <= a) {
      ans = min(abs(-a + b) + 1, abs(a + b));
    } else {
      ans = abs(a - b) - 1;
    }
    ans++;
  } else {
    if (a < b) {
      ans = min(abs(a - b), abs(-a - b) + 1);
    } else {
      ans = min(abs(-a - b) + 1, abs(a - b) + 2);
    }
  }
  cout << (ans) << endl;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  multiset<int> st;
  int ans = 0;
  // 証明できます，できるので
  for(int i = 0; i < n; i++) {
    auto ite = st.lower_bound(a[i]);
    if(ite != st.begin()) {
      st.erase(prev(ite));
    } else ans++;
    st.insert(a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5376
#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
# INF = 1<<32

def solve(N: "List[int]"):
    # N=36を考える
    # l = list(map(int, list(str(N))))
    dp = 0,1
    for i in N:
        # a = f(3), f(36)
        a = min(dp[0]+i, dp[1]+10-i)
        # b = f(4), f(40)
        b = min(dp[0]+i+1, dp[1]+10-(i+1))
        dp = a, b

    print(dp[0])
    return



def main():
    stdin = open(0)
    N = [int(x) for x in stdin.read().rstrip()]
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13644
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 27;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 6);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    cands.reserve(26);
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    let w = if l > 1 { 2 } else { 1 };
    for &(_, j) in cands.iter().take(w) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


Measured memory_bytes: 2348
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         998244353
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}

const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

int tree[4*maxn],n,dp1[maxn],dp2[maxn];
vector<pii>v(maxn);

void build(int no, int st, int la)
{
    if(st == la){
        tree[no] = st;
        return ;
    }
    int mid = (st+la)/2;
    build(2*no,st,mid);
    build(2*no+1,mid+1,la);
    if(v[tree[2*no]].se >= v[tree[2*no+1]].se){
        tree[no] = tree[2*no];
    }
    else tree[no] = tree[2*no+1]; 
}

int query(int no,int st,int la,int l,int r){

    if(l <= st && r >= la)return tree[no];
    if(l > la || r < st)return 0;
    int mid = (st+la)/2;
    int l1 = query(2*no,st,mid,l,r);
    int l2 = query(2*no+1,mid+1,la,l,r);
    if(v[l1].se >= v[l2].se)return l1;
    return l2;
}   

void solve(){
    cin >> n;
    FOR(i,1,n+1){cin >> v[i].f >> v[i].se;v[i].se += v[i].f-1;}
    sort(v.begin()+1,v.begin()+n+1);
    build(1,1,n);
    v[0].se = -inf;
    dp1[n+1] = 1;
    RFOR(i,n,0){
        pii p = {v[i].se+1,-inf};
        int j = lower_bound(v.begin()+i,v.begin()+n+1,p)-v.begin()-1;
        int max_in = query(1,1,n,i,j);
        if(v[max_in].se <= v[i].se)dp2[i] = dp1[j+1]%mod;
        else dp2[i] = dp2[max_in]%mod;
        dp1[i] = (dp1[i+1]+dp2[i])%mod;
    }
    cout << dp1[1] << "\n";
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
       solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
vector<int> adjlist[100005];
bool visited[100005];
vector<ll> indegree(100005);
vector<ll> dist(100005);

void dfs(int a){
   assert(!visited[a]);
   visited[a] = true;
   for(auto b:adjlist[a]){
      dist[b] = max(dist[b],dist[a]+1);   
      --indegree[b];
      if(indegree[b]==0){
         dfs(b);
      }   
   }
}

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

   int n , m ; cin>>n>>m;
   rep(i,m){
      int a, b; cin>>a>>b;
      adjlist[a].pb(b);
      indegree[b]++;
   }
   repA(i,1,n){
      if(visited[i]==false&&indegree[i]==0){
         dfs(i);
      }
   }
   ll ans = 0;
   repA(i,1,n){
      ans = max(ans, dist[i]);
   }
   cout<<ans;
    return 0;
}  

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

using namespace std;

int main(){
    int64_t a, b, x;
    cin >> a >> b;
    if(a > b) swap(a,b);
    x = ((b-1)/a+1)*a;
    if(x/a + x%a < x/b + x%b){
        cout << x << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define in insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007

int p[1000001]; 

int main()
{
FIO

    memset(p,0,sizeof(p));
    int n; cin >> n;
    int num; vi a(n); For(n) { cin >> a[i]; p[a[i]]++; }
    if(p[1])
    {
        if(p[1] == 1)
            cout << 1 << endl;
        else
            cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    For(n)
    {
        num = a[i];
        bool ok = 1;
        for(int j = 2; j * j <= num; j++)
        {
            if((p[j] || p[num/j] ) && num % j == 0)
            {
                ok = 0;
                break;
            }
        }
        if(p[num] > 1)
            ok = 0;
        if(ok)
        {
            // cout << num << endl;
            ans++;
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

int main(void) {
	int h, w;
	char field[100][100], tate[100] = {0}, yoko[100] = {0};
	
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", field[i]);
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (field[i][j] == '#') yoko[i] = 1;
		}
	}
	
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (field[j][i] == '#') tate[i] = 1;
		}
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (tate[j] == 1 && yoko[i] == 1) printf("%c", field[i][j]);
		}
		if (yoko[i] == 1) printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
N = int(input())
lm = [float("INF")]*3
rm = [-float("INF")]*3
um = [-float("INF")]*3
dm = [float("INF")]*3

for i in range(N):
    x,y,d = input().split()
    x = int(x)
    y = int(y)
    if d == "L":
        um[1] = max(um[1],y)
        dm[1] = min(dm[1],y)
        lm[2] = min(lm[2],x)
        rm[0] = max(rm[0],x)
    if d == "R":
        um[1] = max(um[1],y)
        dm[1] = min(dm[1],y)
        lm[0] = min(lm[0],x)
        rm[2] = max(rm[2],x)
    if d == "U":
        um[2] = max(um[2],y)
        dm[0] = min(dm[0],y)
        lm[1] = min(lm[1],x)
        rm[1] = max(rm[1],x)
    if d == "D":
        um[0] = max(um[0],y)
        dm[2] = min(dm[2],y)
        lm[1] = min(lm[1],x)
        rm[1] = max(rm[1],x)

time = [0]

def calc(t):
    x = max(rm[1],rm[0]-t,rm[2]+t) -min(lm[1],lm[0]+t,lm[2]-t)
    y = max(um[1],um[0]-t,um[2]+t) -min(dm[1],dm[0]+t,dm[2]-t)
    return x*y

for i in range(3):
    for j in range(i):
        t = (lm[i]-lm[j])/(i-j)
        if t > 0:
            time.append(t)
        t = (dm[i]-dm[j])/(i-j)
        if t > 0:
            time.append(t)
        t = (rm[j]-rm[i])/(i-j)
        if t > 0:
            time.append(t)
        t = (um[j]-um[i])/(i-j)
        if t > 0:
            time.append(t)

ans = float("INF")
for t in time:
    ans = min(ans,calc(t))
print(ans)

Measured memory_bytes: 9364
import sys

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print("-1")
    sys.exit()

x = 1
for i in range(1, 1000000):
    if (x * 7) % K == 0:
        print(i)
        sys.exit()
    x = (x + pow(10,i,K))%K

print("-1")
sys.exit()


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << endl;

int main() {
  int A, B;

  CIN(A >> B);



  int c = 0;
  int T = 1;
  while(true)
  {
    if (B <= T) {
      COUT(c);
      return 0;
    }

    T += A - 1;
    c++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  int cnt = 0;
  for(int i = 1; i < N; i++) {
    if (h[i] <= h[i-1]) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin >> n;
    int edge[n][n];
    pair<int, pair<int, int>> sort_you_edge[n*n];
    int warshall_floyd[n][n];

    rep(i,n) rep(j,n)
    {
        int tmpnum;
        cin >> tmpnum;
        edge[i][j] = tmpnum;
        warshall_floyd[i][j] = tmpnum;
        sort_you_edge[i*n+j].first = tmpnum;
        sort_you_edge[i*n+j].second = make_pair(i,j);
    }
    sort(sort_you_edge, sort_you_edge+n*n);

    rep(i,n) rep(j,n)
    {
        rep(w, n)
        {
            warshall_floyd[i][j] = min(warshall_floyd[i][j], warshall_floyd[i][w]+warshall_floyd[w][j]);
        }
    }
    bool flag = true;

    rep(i,n) rep(j,n)
    {
        if (edge[i][j]!=warshall_floyd[i][j])
        {
            flag = false;
        }
    }
    // syori
    ll distance = 0;
    rep(i,n-1) REP(j,i+1, n)
    {
        bool tmp_flag = true;
        rep(w,n)
        {
            if (edge[i][j] == edge[i][w] + edge[w][j] && i != w && j != w)
            {
                tmp_flag = false;
            }
        }
        if (tmp_flag)
        {
            distance += edge[i][j];
        }
    }

    if (!flag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << distance << endl;
    }
    
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double f(double x){
    return x * x;
}

int main(void){
    double x[101], y[101], n, ans;
    cout << fixed << setprecision(6);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }
    
    ans = 0;
    // p = 1
    for(int i = 0; i < n; i++){
        ans += fabs(x[i] - y[i]);
    }
    cout << ans << endl;
    
    //p = 2
    ans = 0;
    for(int i = 0; i < n; i++){
        ans += f(fabs(x[i] - y[i]));
    }
    cout << sqrt(ans) << endl;
    
    //p = 3
    ans = 0;
    for(int i = 0; i < n; i++){
        ans += pow((fabs(x[i] - y[i])), 3.0);
    }
    cout << pow(ans, 1.0 / 3.0) << endl;
    
    
    //p = inf
    ans = 0;
    for(int i = 0; i < n; i++){
        if(ans <= fabs(x[i] - y[i]))
            ans = fabs(x[i] - y[i]);    
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(ll i = 0;i<n;++i)
#define repc(bit,k,n) for (ll bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;

template <typename T>
struct RAQBIT {
  ll n;             // 要素数
  vector<T> bit[2];  // データの格納先
  RAQBIT(ll n_) { init(n_); }
  void init(ll n_) {
    n = n_ + 1;
    for (ll p = 0; p < 2; p++) bit[p].assign(n, 0);
  }
  void add_sub(ll p, ll i, T x) {
    for (ll idx = i; idx < n; idx += (idx & -idx)) {
      bit[p][idx] += x;
    }
  }
  void add(ll l, ll r, T x) {  // [l,r) に加算
    add_sub(0, l, -x * (l - 1));
    add_sub(0, r, x * (r - 1));
    add_sub(1, l, x);
    add_sub(1, r, -x);
  }
  T sum_sub(ll p, ll i) {
    T s(0);
    for (ll idx = i; idx > 0; idx -= (idx & -idx)) {
      s += bit[p][idx];
    }
    return s;
  }
  T sum(ll i) { return sum_sub(0, i) + sum_sub(1, i) * i; }
  T sum_range(ll a, ll b) { return sum(b)-sum(a-1);}
};
struct EN{
  ll x,h;
  EN(ll x, ll h):x(x),h(h){};
  bool operator<(const EN &other)const{
    return x < other.x;
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,d,a;cin>>n>>d>>a;
  RAQBIT<ll> bit(n+1);
  vector<EN> enemy;
  rep(i,n){
    ll x,h;cin>>x>>h;
    enemy.push_back(EN(x,h));
  }
  sort(ALL(enemy));
  rep(i,n){
    bit.add(i+1,i+2,enemy[i].h);
  }
  vector<ll> enemy_pos(n);
  rep(i,n)enemy_pos[i] = -enemy[i].x;
  vector<ll> range(n);
  rep(i,n){
    range[i] = upper_bound(ALL(enemy_pos), enemy_pos[i]-2*d, greater<ll>())-enemy_pos.begin();
  }
  ll ans = 0;
  rep(i,n){
    ll s = bit.sum_range(i+1,i+1);
    if(s<=0)continue;
    ll temp = (s+a-1)/a;
    bit.add(i+1,range[i]+1,-temp*a);
    ans+=temp;
  }

  cout<<ans<<endl;

  return 0;
}

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

char buf[114514];

int main() {
  while (1) {
    scanf(" %s", buf);
    if (buf[0] == '#') return 0;

    string s(buf);
    int cnt = 0;
    while (1) {
      int n = s.size();
      if (n == 0) break;

      if (s.substr(n-4) == "west") s = s.substr(0, n-4);
      else s = s.substr(0, n-5);
      cnt++;
    }

    int denom = 1 << (cnt-1);
    int mul = denom;
    int ans = 0;
    s = buf;
    while (1) {
      int n = s.size();
      if (n == 0) break;

      if (s.substr(n-4) == "west") {
        ans += 90 * mul;
        s = s.substr(0, n-4);
      } else {
        if (mul == denom) ans = 0;
        else ans -= 90 * mul;
        s = s.substr(0, n-5);
      }

      mul >>= 1;
    }

    while (ans%2 == 0 && denom%2 == 0) {
      ans /= 2;
      denom /= 2;
    }

    if (denom == 1) printf("%d\n", ans);
    else printf("%d/%d\n", ans, denom);
  }
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

char c[55][55];
int h, w, cnt;

int main () {
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> c[i][j];
  rep(i,h) {
    rep(j,w) {
      if (!(0 <= i && i <= h-1 && 0 <= j && j <= w-1)) continue;
      if (c[i][j]=='#' && c[i][j-1]!='#' && c[i-1][j]!='#' && c[i][j+1]!='#' && c[i+1][j]!='#') {
        cnt++;
      }
    }
  }
  cout << (cnt==0?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ 1611: Daruma Otoshi
// 2018.1.30 bal4u

#include <stdio.h>
#include <string.h>

int w[301];
char d[301][301];
int dp[301][301];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, j, k, m, t;

	while (n = in()) {
		for (i = 0; i < n; i++) w[i] = in();
		memset(d, 0, sizeof(d));
		for (i = 0; i < n; i++) {
			d[i][i] = 1;
			for (j = i+1; j < n; j++) {
				t = w[i] - w[j];
				if (-1 <= t && t <= 1) d[j][i] = d[i][j] = 1;
			}
		}

		memset(dp, 0, sizeof(dp));
		for (m = 1; m < n; m++) for (i = 0; i < n - m; i++) {
			j = i+m;
			if (d[i][j] && dp[i+1][j-1] == m-1) dp[i][j] = m+1;
			else {
				for (k = i; k < j; k++) {
					t = dp[i][k] + dp[k+1][j];
					if (t > dp[i][j]) dp[i][j] = t;
				}
			}
		}
		printf("%d\n", dp[0][n-1]);
	}
	return 0;
}


Measured memory_bytes: 2140
def gcd(a,b):
    while b:a,b=b,a%b
    return a
def lcm(c,d):return c*d//gcd(c,d)
def div(x):
    num=x
    num-=x//C
    num-=x//D
    num+=x//lcm(C,D)
    return num
A,B,C,D=map(int,input().split())
print(div(B)-div(A-1))

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

int main() {
        long long N;
        vector<long long> v(4);
        for(int i = 0; i < 4; i++) {
                cin >> v[i];
                if(i > 0) {
                        v[i] = min(v[i], v[i - 1] * 2);
                }
        }
        
        cin >> N;
        N *= 4;
        long long res = 0;
        for(int i = 3; i >= 0; --i) {
        		int t = (1 << i);
        		res += N / t * v[i];
                N -= N / t * t;
        }
        cout << res << endl;
        return 0;
}


Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
t = 0
for i in range(N):
  A = list(map(int,input().split()))
  k = C
  for j in range(M):
    k += A[j]*B[j]
  if k > 0:
    t += 1
print(t)



Measured memory_bytes: 3060
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] spText = input.Split(' ');
            ulong a = ulong.Parse(spText[0]);
            ulong b = ulong.Parse(spText[1]);
            ulong x = ulong.Parse(spText[2]);
            ulong ret = (b / x) - (a / x);
            if (a % x == 0) { ret +=1 ; }
            Console.WriteLine(ret.ToString("##################0"));
            //Console.ReadKey();
        }
    }
}




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

using namespace std;

int main(){
	int  n;
	int ta1,ans=0;
	cin>>n;
	int arr[2*n];
	
	for(int i = 0; i < 2*n; i++){
		cin>>arr[i];
	}
	sort(arr,arr+2*n);
	
	for(int i=n*2-1;i>0;i-=2){
		int m=0;
		m=min(arr[i],arr[i-1]);
		ans+=m;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define F(I,J,N) for(int I=J;I<N;I++)

int n,ans;

bool r(int p,int c){
	if(p<0) return false;
	if(n-p>c*9) return true;
	if(c==0){if(p==n)ans++;return true;}
	F(i,0,10){
		if(!r(p+i,c-1)) break;
	}
	return true;
}

int main(){
	while(cin>>n){
		ans=0;
		r(0,4);
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    int count = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    for (int i = 0; i <= n; i++) {
       if (sum <= x) {
           count++;
       } 
       sum += l[i];
    }
    cout << count << endl;
}


Measured memory_bytes: 256