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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  string s, t;
  cin >> s >> t;
  int dp[s.size() + 1][t.size() + 1];
  memset(dp, 0, sizeof dp);
  for(int i = 1; i <= s.size(); ++i) {
    for(int j = 1; j <= t.size(); ++j) {
      if(s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1; 
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int i = s.size(), j = t.size();
  string ans = "";
  while(i >= 1 && j >= 1) {
    if(s[i - 1] == t[j - 1]) {
      ans += s[i - 1];
      --i; --j;
    } else if(dp[i - 1][j] > dp[i][j - 1]) --i;
    else --j;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
}

Measured memory_bytes: 35456
#include <stdio.h>
int binarySearch(int *, int, int);

int main(){
  int N[100000]; int Q[50000];
  int nnum, qnum;
  int i, j, count = 0;
  
  scanf("%d", &nnum);
  for(i = 0; i < nnum; i++){
    scanf("%d", &N[i]);
  }
  scanf("%d", &qnum);
  for(i = 0; i < qnum; i++){
    scanf("%d", &Q[i]);
  }
  
  for(i = 0; i < qnum; i++){
    if(binarySearch(N, nnum, Q[i]) == 1){
      count++;
    }
  }
  
  printf("%d\n", count);
  return 0;
}

int binarySearch(int *A, int length, int key){
  int left, right, mid;
  
  left = 0;
  right = length;
  
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]){
      return 1;
    }
    
    if(key < A[mid]){
      right = mid;
    }
    else {
      left = mid+1;
    }
  }
  
  return 0;
}



Measured memory_bytes: 2272
S = str(input())
N = len(S)

num = [0] * 2019
num[0] = 1
prev = 0
result = 0
_10 = 1
for i in range(N-1, -1, -1):
    prev = (prev + int(S[i]) * _10) % 2019
    _10 *= 10
    _10 %= 2019
    result += num[prev]
    num[prev] += 1

print(result)

Measured memory_bytes: 9308
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;

#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

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


struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

const int nax = 2e3 + 5;
int fib[nax], inv[nax];

int nCk(int n, int k){
    if(k > n){
        return 0;
    }
    int temp = fib[n];
    temp *= inv[k];
    temp %= mod;
    temp *= inv[n-k];
    temp %= mod;
    return temp;
}

int32_t main(){
    IOS
    fib[0] = inv[0] = 1;
    fib[1] = inv[1] = 1;
    for(int i = 2; i < nax; i++){
        fib[i] = fib[i-1]*i;
        fib[i] %= mod;
        inv[i] = modexpo(fib[i], mod-2);
    }
    int n,k;
    cin >> n >> k;
    int slots = n-k+1;
    // debug3(p,q, slots);
    for(int i = 1; i <= k; i++){
        int x = nCk(k-1,i-1);
        // cout << x << endl;
        int y = nCk(slots,i);
        x *= y;
        x %= mod;
        cout << x << endl;
    }
} 

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

const int N = 1e5 + 5;
int tab[N];
int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> tab[i];
    sort( tab + 1, tab + n + 1 );
    cout << tab[ n / 2 + 1 ] - tab[ n / 2 ] << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
typedef long long lo;
 
template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

const int N = 5e5 + 233;
int H, W, n;
set <int> pos[N];

int main(void) {
	read(H); read(W); read(n);
	rep (i, n) {
		int x, y; read(x); read(y);
		pos[y].insert(x);
	}
	rep (i, W) pos[i].insert(H + 1);
	int ans = 1e9, y = 1;
	for (int x = 1; x <= H; x++) {
		// cout << x << " " << y << " " << *pos[y].lower_bound(x) - 1 << "\n";
		ans = min(ans, *pos[y].lower_bound(x) - 1);
		if (y < W && !pos[y + 1].count(x + 1)) ++y;
	}
	cout << ans << "\n";
}


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

int main(){
  int n;
  cin >> n;
  map<int,int> d; 
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    d[a]++;
  }
  int m;
  cin >> m;
  map<int,int> t;
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    t[a]++;
  }
  int flag = 0;
  for (auto p : t) {
  auto k = p.first;
  auto v = p.second;
  if(d[k]<v) flag = 1;
  }
  if(flag) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

typedef long long ll;
const int N = 1e5 + 5;
ll x;

int solve() {
    int k = (int)sqrt((double)x*2.0) + 5;
    for (; (ll)(1+k)*k/2 >= x; --k) {
        if ((ll)(1+k)*k/2 == x) return k;
    }
    return k + 1;
}

int main() {
    cin >> x;
    cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);

    while(true){
      int n = s.nextInt();
      int min = s.nextInt();
      int max = s.nextInt();

      if(n==0 && min==0 && max==0){
        break;
      }
      int[] a = new int[n];
      for(int i=0; i<n; i++){
        a[i] = s.nextInt();
      }

      int ans = 0;
      int m = 0;

      for(int i=min; i<=max; i++){
        int l = a[i-1] - a[i];
        if(m <= l){
          ans = i;
          m = l;
        }
      }

      System.out.println(ans);
    }

  }
}


Measured memory_bytes: 57456
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
string s[50050];

int menor (string a, string b){
    string na = a+b, nb = b+a;
    if (na == nb) {
        if (a < b) return -1;
        else if (a == b) return 0;
        else return 1;
    }
    else if(na < nb) return -1;
    else return 1;
}

void ordena(int l, int m, int r){
    int i = l, j = m+1, cnt = r-l+1;
    vector<string> ans;
    while (cnt--){
        if ((i <= m and menor(s[i], s[j]) != 1) || j > r){
            ans.push_back(s[i]);
            i++;
        }
        else{
            ans.push_back(s[j]);
            j++;
        }
    }
    for (i=l; i<=r; i++){
        s[i] = ans[i - l];
    }
}

void merge(int l, int r){
    if (l == r) return;
    int mid = (l+r)/2;

    merge(l, mid);
    merge(mid+1, r);

    ordena(l, mid, r);
}

int main (){
    long double a, b;
    cin >> a >> b;

    cout << ll(a*b) << endl;
    return 0;
}

Measured memory_bytes: 5384
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		int[] b=new int[n];
		for(int i=0; i<n; i++){
			b[i]=sc.nextInt();
		}
		int ans=Integer.MAX_VALUE;
		for(int i=0; i<1<<n; i++){
			ArrayList<State> even=new ArrayList<>();
			ArrayList<State> odd=new ArrayList<>();
			for(int j=0; j<n; j++){
				if((i>>j & 1)==1){
					if(j%2==0){
						odd.add(new State(b[j],j));
					}else{
						even.add(new State(b[j],j));
					}
				}else{
					if(j%2==0){
						even.add(new State(a[j],j));
					}else{
						odd.add(new State(a[j],j));
					}
				}
			}
			if(n%2==0){
				if(even.size()!=odd.size()){
					continue;
				}
			}else{
				if(even.size()!=odd.size()+1){
					continue;
				}
			}
			Collections.sort(odd,(x,y)->(x.num-y.num));
			Collections.sort(even,(x,y)->(x.num-y.num));
			ArrayList<State> tmp=new ArrayList<>();
			for(int k=0; k<n/2; k++){
				tmp.add(even.get(k));
				tmp.add(odd.get(k));
			}
			if(even.size()>odd.size()){
				tmp.add(even.get(n/2));
			}
			if(!check(tmp)){
				continue;
			}
			ArrayList<Integer> index=new ArrayList<>();
			for(State s:tmp){
				index.add(s.index);
			}
			ans=Math.min(ans,bubble(index));
		}
		if(ans==Integer.MAX_VALUE){
			System.out.println(-1);
		}else{
			System.out.println(ans);
		}
	}
	static class State{
		int num,index;
		State(int num,int index){
			this.num=num;
			this.index=index;
		}
	}
	static int bubble(ArrayList<Integer> list){
		int count=0;
		for(int i=0; i<list.size(); i++){
			for(int j=list.size()-2; j>=0; j--){
				if(list.get(j)>list.get(j+1)){
					count++;
					Collections.swap(list,j,j+1);
				}
			}
		}
		return count;
	}
	static boolean check(ArrayList<State> list){
		for(int i=0; i<list.size()-1; i++){
			if(list.get(i).num>list.get(i+1).num){
				return false;
			}
		}
		return true;
	}
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 3e3 + 7;

int dp[N], dp2[N];

int main()
{
    _upgrade
    int a, b, c, d, f; int e;
    cin >> a >> b >> c >> d >> e >> f;
    //e = e * (100.0 / (100.0 + e));
    dp[0] = dp2[0] = 1;
    for(int i = 0; i + 100 * a <= f; i++) if(dp[i]) dp[i + 100 * a] = 1;
    for(int i = 0; i + 100 * b <= f; i++) if(dp[i]) dp[i + 100 * b] = 1;
    for(int i = 0; i + c <= f; i++) if(dp2[i]) dp2[i + c] = 1;
    for(int i = 0; i + d <= f; i++) if(dp2[i]) dp2[i + d] = 1;
    int r1 = 100 * a, r2 = 0;
    for(int i = 100; i <= f; i++)
    {
        for(int j = 0; j <= f; j++)
        {
            if(i + j <= f && dp[i] && dp2[j])
            {
                if(100 * j * (100 + e) <= (i + j) * 100 * e)
                {
                    if(100 * j * (r1 + r2) > (i + j) * 100 * r2)
                        r1 = i, r2 = j;
                }
            }
        }
    }
    cout << r1 + r2 << " " << r2 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int par[200100];
int ranks[200100];
int sizes[200100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ranks[i]=0;
    sizes[i]=1;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

int size(int x){
  return sizes[find(x)];
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y){
    return ;
  }
  if(ranks[x]<ranks[y]){
    par[x]=y;
    sizes[y]+=sizes[x];
  }
  else{
    par[y]=x;
    sizes[x]+=sizes[y];
  }
  if(ranks[x]==ranks[y]){
    ranks[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}



int main(){
  int N,M;
  cin>>N>>M;
  long long a,b;
  long long A[100100];
  long long B[100100];
  long long ans[100100];
  for(int i=0;i<M;++i){
    cin>>a>>b;
    A[i]=a-1;
    B[i]=b-1;}
    //union findを初期化
    init(N);
  int placeA,placeB;
  long long tmp;
  for(int i=M-1;i>=0;i--){
    //新しく行き来できるようになる場所を計算
    placeA=A[i];
    placeB=B[i];
    if(same(placeA,placeB)){
      tmp=0;
    }
    else{
    tmp=size(placeA)*size(placeB);
    ans[i]=tmp;
    unite(placeA,placeB);}
  }
  tmp=0;
  for(int i=0;i<M;++i){
    tmp+=ans[i];
    cout<<tmp<<"\n";
  }
return 0;
}

Measured memory_bytes: 4864
n, m = map(int, input().split())
a = list(map(int ,input().split()))
sa = sum(a)
val = 1 / (4*m)
cnt = 0
for i in range(n):
    if a[i] >= sa * val:
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

using ll = long long int;
const int mod = 1e9+7;
const int inf = 1e9+5;


int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	//dp[i] is mininum cast till i
	//base case dp[0] = 0;
	vector<int>dp(n);
	dp[1] = abs(arr[1]-arr[0]);
	if(n > 2){
		dp[2] = abs(arr[2]-arr[0]);
	}
	for(int i = 3; i < n; i++){
		dp[i] = min(abs(arr[i]-arr[i-1]) + dp[i-1], abs(arr[i]-arr[i-2]) + dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int l,a,b,c,d;
  cin>>l>>a>>b>>c>>d;
  int ko = (a/c) + (int)(a%c!=0);
  int ei = (b/d) + (int)(b%d!=0);
  int r = max(ko,ei);
  cout<<(l-r)<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int x,int y){
    if(x<y) swap(x,y);
    int r = x%y;
    while(r!=0){
      x=y;
      y=r;
      r=x%y;
    }
  return y;
}
int main(){
  int x,y;
  cin >>x>>y;
  cout <<gcd(x,y)<<'\n';
  return(0);
}


Measured memory_bytes: 3084
package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	h := nextInt()
	a := make([]int, 1, h+1)
	for i := 0; i < h; i++ {
		a = append(a, nextInt())
	}

	buildMaxHeap(a)
	for _, k := range a[1:] {
		fmt.Fprintf(w, " %d", k)
	}
	fmt.Fprintln(w)

	w.Flush()
}

func buildMaxHeap(a []int) {
	for i := len(a) / 2; i > 0; i-- {
		maxHeapify(a, i)
	}
}

func maxHeapify(a []int, i int) {
	l := i * 2
	r := l + 1
	var largest int
	if l < len(a) && a[l] > a[i] {
		largest = l
	} else {
		largest = i
	}
	if r < len(a) && a[r] > a[largest] {
		largest = r
	}

	if largest != i {
		a[i], a[largest] = a[largest], a[i]
		maxHeapify(a, largest)
	}
}



Measured memory_bytes: 10040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,v,i,hi,lo;
  long sum;
  cin>>n;
  cin>>v;
  hi=lo=sum=v;
  for(i=1;i<n;i++){
    cin>>v;
    if(lo>v)lo=v;
    else if(hi<v)hi=v;
    sum+=v;
  }
  cout<<lo<<" "<<hi<<" "<<sum<<endl;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

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

void isLand(int i,int j){
    if(land[i][j]==1){
    	land[i][j] = 0;
		REP(k,8){
			int newy=i+dy[k];
			int newx=j+dx[k];
			isLand(newy,newx);
		}
    }
}

signed main(){
	int w,h;
	while( w=read(),h=read(),w||h){
		cnt=0;
		
		REP(i,100){
			REP(j,100){
				land[i][j]=0;
			}
		}
		FOR(i,1,h+1){
			FOR(j,1,w+1){
				land[i][j]=read();
			}
		}
		
		FOR(i,1,h+1){
			FOR(j,1,w+1){
				if(land[i][j]==1){
					cnt++;
					isLand(i,j);
				}
			}
		}
		
		cout << cnt << endl;
	}
	
}

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

typedef pair<int, int> pair_int;

bool comp_sec(pair_int p, pair_int q) {
    return p.second < q.second;
}

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

    int N, M, Q;
    cin >> N >> M >> Q;
    int box[502][502] = {};
    // memset(box, 0, box.size())
    int L, R;
    for (int i = 1; i <= M; ++i) {
        cin >> L >> R;
        box[L][R]++;
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            box[i + 1][j] += box[i][j];
        }
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            box[i][j + 1] += box[i][j];
        }
    }

    int p, q;
    for (int i = 0; i < Q; ++i) {
        cin >> p >> q;
        cout << box[q][q] - box[q][p - 1] - box[p - 1][q] + box[p - 1][p - 1] << '\n';
    }


    return 0;
}


Measured memory_bytes: 1920
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut ans = "Yes";

    if s.contains('N') ^ s.contains('S') {
        ans = "No";
    }
    if s.contains('E') ^ s.contains('W') {
        ans = "No";
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int a, b;

int read() {
  if (scanf("%d%d", &a, &b) < 2) {
    return 0;
  }
  return 1;
}

void solve() {
  int res = 2 * inf;
  for (int it = 0; it < 2; a = -a, ++it) {
  for (int jt = 0; jt < 2; b = -b, ++jt) {
    if (a <= b) {
      res = min(res, it + jt + b - a);
    }
  }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}

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

    ll r = 0;
    vector<int> a(k + 1);
    for (int i = k; i > 0; i--) {
        ll t = powmod(k / i, n);
        for (int j = i * 2; j <= k; j += i) {
            t -= a[j];
        }
        t %= P;
        if (t < 0) t += P;
        r += t * i % P;
        a[i] = t;
    }
    r %= P;

    cout << r << endl;

    //N=9のとき2の余裕を5個の区間で分け合う仕切り4個 4+2から2個選ぶ
    //区間は最大3個に分かれる（区間内では1つおきになってる）

    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  string s;

  cin>>s;

  for(int i=0;i<s.size();i++){
    cout<<"x";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n, k;

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

  scan(n>>k);

//  vint s(n);
//  REP(i, n) scan(s[i]);

 if(k>1)  cout << n-k << endl;
 else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int c[10][10];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int j = i;
    int lst = j %10;
    int fst = lst;
    while(j){
      fst = j %10;
      j/=10;
    }
    c[fst][lst]++;
  }
  ll ret = 0;
  for(int i=1;i<=n;i++){
    int j = i;
    int lst = j %10;
    int fst = lst;
    while(j){
      fst = j %10;
      j/=10;
    }
    ret += c[lst][fst];
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
import itertools

def solve():
    N, M, _ = list(map(int, input().split()))
    R = list(map(int, input().split()))
    R = map(lambda x: x-1, R)
    G = [[] for i in range(N)]

    for i in range(M):
        A, B, C = list(map(int, input().split()))
        A -= 1
        B -= 1
        G[A].append((C, B))
        G[B].append((C, A))


    def dijkstra(d):
        que = []

        tar = -1
        count = set()
        for i in range(len(d)):
            if d[i] == 1e+16:
                break
            if d[i] == 0:
                tar = i
            heapq.heappush(que, (d[i], i))
            count.add(i)

        checked = [False for i in range(N)]

        while len(que) != 0:
            dist, node = heapq.heappop(que)
            if checked[node]:
                continue
            count.add(node)
            if len(count) == N:
                break

            for (cost, to) in G[node]:
                if d[to] > d[node] + cost:
                    d[to] = d[node] + cost
                    heapq.heappush(que, (dist + cost, to))

            checked[node] = True

        return d


    ds = [[1e16 for i in range(N)] for j in range(N)]

    for i in range(N):
        ds[i][i] = 0

    for i in range(N):
        ds[i] = dijkstra(ds[i])
        for j in range(N):
            ds[j][i] = ds[i][j]

    res = 1e16
    for r in list(itertools.permutations(R)):
        d = 0
        for i in range(len(r)-1):
            d += ds[r[i]][r[i+1]]
        res = min(res, d)

    return res

print(solve())

Measured memory_bytes: 12620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, m; cin >> n >> m;
	VI a(n); REP(i, n)cin >> a[i];
	sort(ALL(a));
	ll l = 0, r = 200001;
	while (r - l > 1) {
		ll x = l + (r - l) / 2;
		ll p = 0;
		REP(i, n)p += n - (lower_bound(ALL(a), x - a[i]) - a.begin());
		if (p < m)r = x;
		else l = x;
	}
	VI rs(n + 1, 0);
	REP(i, n)rs[i + 1] = rs[i] + a[n - i - 1];
	ll ans = 0, c = 0;
	REP(i, n) {
		ll s = n - (lower_bound(ALL(a), r - a[i]) - a.begin());
		ans += a[i] * s + rs[s];
		c += s;
	}
	ans += (m - c) * l;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#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 X,Y;
	while(cin>>X>>Y) {
		ll ans=0;
		REP(i, X+1) {
			ll c = 2*i+4*(X-i);
			if(c==Y) ans=1;
		}
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    int p[n+2],cost=0;
    p[0]=p[n+1]=0;
    for (i=1;i<=n;i++)
    {
        cin>>p[i];
        cost+=abs(p[i]-p[i-1]);
    }
    cost+=abs(p[n+1]-p[n]);
    for (i=1;i<=n;i++)
        cout<<cost-abs(p[i]-p[i-1])-abs(p[i+1]-p[i])+abs(p[i+1]-p[i-1])<<endl;
}

Measured memory_bytes: 1664
<?php
  $n = str_split(trim(fgets(STDIN)));
  $total = count($n);
  $half = ceil($total / 2);

  $ans = 0;
  for ($i = 0; $i < $half; $i++) {
    $back = $total - $i - 1;
    if ($i == $back) {
      break;
    }

    if ($n[$i] != $n[$back]) {
      $ans++;
      continue;
    }
  }
  echo $ans . PHP_EOL;


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N;
string S;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> S;

  ll tbr = 0;
  for (ll i = 1; i < N; i++) {
    if (S.at(i) == 'E') tbr++;
  }
  ll ans = tbr;
  for (ll i = 1; i < N; i++) {
    if (S.at(i-1) == 'W') tbr++;
    if (S.at(i) == 'E') tbr--;
    ans = min(ans, tbr);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<vector<int>> root(N);
	vector<int> depth(N, -1);
	int current;
	queue<int> next;

	for (int i = 0; i < N - 1; i++)
	{
		int from, to;
		cin >> from >> to;
		root[from - 1].push_back(to - 1);
		root[to - 1].push_back(from - 1);
	}

	depth[N - 1] = 0;
	next.push(N - 1);
	for (; !next.empty();)
	{
		current = next.front();
		next.pop();

		for (auto to : root[current])
		{
			if (depth[to] == -1)
			{
				depth[to] = depth[current] + 1;
				next.push(to);
			}
		}
	}
	vector<int> shortest_root;
	shortest_root.push_back(0);

	current = 0;

	for (; current != N - 1;)
	{
		for (auto to : root[current])
		{
			if (depth[to] == depth[current] - 1)
			{
				shortest_root.push_back(to);
				current = to;
				break;
			}
		}
	}

	depth.assign(N, -1);
	reverse(all(shortest_root));

	for (int i = 0; i < shortest_root.size() / 2; i++)
	{
		depth[shortest_root[i]] = -2;
	}

	depth[0] = 0;
	next.push(0);
	int count = 1;
	for (; !next.empty();)
	{
		current = next.front();
		next.pop();

		for (auto to : root[current])
		{
			if (depth[to] == -1)
			{
				count++;
				depth[to] = depth[current] + 1;
				next.push(to);
			}
		}
	}

	if (N - count < count)
	{
		cout << "Fennec" << endl;
	}
	else
	{
		cout << "Snuke" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main() {
    int K, X;
    cin >> K >> X;
    int l = X - (K-1);
    int r = X + (K-1);
    rep(i, r-l+1) {
        cout << l+i << " ";
    }
    cout << endl;
    return 0;
}

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

int main()
{
    // 入力 (1-based indexing)
    long long N;
    long long W;
    std::cin >> N >> W;
    std::vector<long long> w(N+1, 0);
    std::vector<long long> v(N+1, 0);
    for (int i = 0; i < N; i++) std::cin >> w[i+1] >> v[i+1];

    // 問題を解く
    std::vector<std::vector<long long>> dp(N+1, std::vector<long long>(W+1, 0));

    // i = 0 のアイテムを選択していないときは既に 0 で初期化されているので飛ばす
    for (int i = 1; i <= N; i++)
    {
        // 各アイテムに対して部分和毎に計算
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            // 選ぶとき（部分和が足りるときのみ）
            if (sum_w - w[i] >= 0) dp[i][sum_w] = std::max(dp[i][sum_w], dp[i-1][sum_w - w[i]] + v[i]);
            // 選ばないとき
            dp[i][sum_w] = std::max(dp[i][sum_w], dp[i-1][sum_w]);
        }
    }

    long long ans = dp[N][W];
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 80256
S = gets.chomp

if S == "SUN"
  print("7")
elsif S == "MON"
  print("6")
elsif S == "TUE"
  print("5")
elsif S == "WED"
  print("4")
elsif S == "THU"
  print("3")
elsif S == "FRI"
  print("2")
elsif S == "SAT"
  print("1")
end

Measured memory_bytes: 14232
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] count = new int[10001];

        for(int x=1;x<101;x++){
            for(int y=1;y<101;y++){
                for(int z=1;z<101;z++){
                    int calc = x*x + y*y + z*z + x*y + y*z + z*x;
                    if(calc <= 10000){
                        count[calc]++;
                    }else{
                        break;
                    }
                }
            }
        }

        for (int i=1;i<=n;i++){
            System.out.println(count[i]);
        }

    }
}


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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(m);
  for (int i = 0; i < m; i++) cin >> v[i];
  sort(v.begin(), v.end());
  auto h = lower_bound(v.begin(), v.end(), x);
  cout << min(h - v.begin(), v.end() - h) << endl;
}


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

int main() {
	string s;
	cin >> s;
	set<char> st;
	rep(i, (int)s.size()) st.insert(s[i]);
	int ans = 100;
	for (auto a : st) {
		int cnt = 0;
		string t = s;
		rep(i, (int)t.size()) {
			bool ok = true;
			for (auto c : t) {
				if (c != a) ok = false;
			}
			if (ok) break;
			string u;
			rep(j, (int)t.size() - 1) {
				if (t[j] == a || t[j + 1] == a) {
					u.push_back(a);
				}
				else {
					u.push_back(t[j]);
				}
			}
			cnt++;
			t = u;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
n,k = map(int,input().split()) # n人、k個のお菓子

people = [1] * n

for i in range(k): #お菓子i
  x = int(input()) #お菓子iを持っている人数
  y = list(map(int,input().split()))
  for j in y:
    people[j-1] = 0

print(sum(people))


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
   for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }
  
  int c = 0;
  int x = 1;
  
  for (int i = 0; i < N; i++) {
//    cout << x << endl;
    x = vec.at(x-1);
//    cout << x << endl;
    c++;
    if (x == 2) {
      cout << c << endl;
      break;
    }
    if (i == N-1) {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 640
n = int(input())
s = 0
for i in range(1, n + 1, 2):
    c = 0
    sq = int(i ** 0.5)
    for j in range(1, sq + 1):
        if i % j == 0:
            c += 1
    if c == 4:
        s += 1

print(s)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b)
{
	if(a>b)
		swap(a,b);
	if(a==0)
		return b;
	return gcd(b%a,a);
}
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//   fl();
	long long a,b;
	scanf("%lld%lld",&a,&b);
	long long ans=a*b/gcd(a,b);
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
    int N ,K;
    cin >> N >> K;
    
    int ans = 1;
    int wei = 1;
    N--;
    while(N > 0){
        int n = ceil((double)wei / (double)K);
        if(N >= n) ans++;
        wei += n;
        N -= n;
    }

    cout << ans << endl;
}


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




const int N = 2e5 + 5;





int n, h[N], a[N];
long long t[N], ans;

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur = max(cur, t[i]);
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] = max(t[i], val);
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        long long val = get(h[i] - 1) + a[i];
        upd(h[i], val);
        ans = max(ans, val);
    }
    cout << ans;
}


Measured memory_bytes: 3328
def solve(x, y):
    if x < 0:
        x, y = solve(-x, y)
        return -x, y
    if y < 0:
        x, y = solve(x, -y)
        return x, -y
    if x > y:
        x, y = solve(y, x)
        return y, x

    if x + y >= 2 * K:
        return x, y - K
    if x + y == K:
        return 0, 0

    r = K - (x + y) // 2
    return -r, (x + y + r - K)



K, X, Y = map(int, open(0).read().split())

if K % 2 == 0 and (X + Y) % 2 == 1:
    print(-1)
    quit()

A = []
while X or Y:
    A.append((X, Y))
    X, Y = solve(X, Y)

print(len(A))
for a in reversed(A):
    print(*a)

Measured memory_bytes: 26340
s = gets.chomp.chars
alp = ('a'..'z').to_a
non_appeared = []

alp.each do |str|
  unless s.include?(str)
    non_appeared.push(str)
  end
end

if non_appeared.length == 0
  puts 'None'
else
  puts non_appeared.sort[0]  
end


Measured memory_bytes: 6908
from math import pi, sin, cos, sqrt

A, B, H, M = map(int, input().split())

y1 = A * cos(2 * pi * (H + M / 60) / 12)
x1 = A * sin(2 * pi * (H + M / 60) / 12)
y2 = B * cos(2 * pi * M / 60)
x2 = B * sin(2 * pi * M / 60)

print(sqrt((y1 - y2) * (y1 - y2) + (x1 - x2) * (x1 - x2)))


Measured memory_bytes: 9564
#include<iostream>
#include<stdbool.h>
#include<math.h>
using namespace std;
void swap(int num1, int num2, int a[100000]){
   int temp = a[num1];
   a[num1] = a[num2];
   a[num2] = temp;
}
int partition(int left, int right, int pivot, int a[100000]){
   int leftPointer = left -1;
   int rightPointer = right;

   while(true){
	
      while(a[++leftPointer] < pivot){
         //khong lam gi
      }
	  while(rightPointer > 0 && a[--rightPointer] > pivot){
         //khong lam gi
      }
      if(leftPointer >= rightPointer){
         break;
      }else{
         swap(leftPointer,rightPointer,a);
      }	
   }
   swap(leftPointer,right,a);
   return leftPointer;
}
// ham sap xep
void quickSort(int left, int right, int a[100000]){        
   if(right-left <= 0){
      return;   
   }else {
      int pivot = a[right];
      int partitionPoint = partition(left, right, pivot,a);
      quickSort(left,partitionPoint-1,a);
      quickSort(partitionPoint+1,right,a);
   }        
} 
int main()
{
  int i,n,a[100000],achuan[100000],nut=0;
  long long sum=0,x1=0,x2=0,x3=0;
  cin >> n;
  for (i=0; i<n; i++) cin >> a[i];
  quickSort(0, n-1, a);
  if (a[0]<=0 && a[n-1]>=0)
    {
      for (i=0; i<n; i++) sum += abs(a[i]);
      cout << sum << endl;
      for (i=0; i<n; i++) achuan[i]=a[i];
    }
  if (a[n-1]<0)
    {
      sum += a[n-1]-a[0];
      for (i=1; i<n-1; i++) sum += abs(a[i]);
      cout << sum << endl;
      cout << a[n-1] << " " << a[0] << endl;
      achuan[n-2] = a[n-1]-a[0];
      for (i=0; i<n-2; i++) achuan[i]=a[i+1];
      n--;
    }
  if (a[0]>0)
    {
      sum += a[n-1]-a[0];
      for (i=1; i<n-1; i++) sum += a[i];
      cout << sum << endl;
      cout << a[0] << " " << a[n-1] << endl;
      achuan[0] = a[0]-a[n-1];
	  for (i=1; i<n-1; i++) achuan[i]=a[i];	
	  n--;
    }
  for (i=0; i<n; i++)
    {
      if (achuan[i]>=0) 
        { 
          nut=i; break;
        }
    }
    //cout << nut << endl;
  if (n==2)
    {
      if (!nut) cout << achuan[1] << " " << achuan[0];
       else cout << achuan[0] << " " << achuan[1];
       return 0;
    }
  if (!nut)
    {
      x1 = achuan[nut];
      for (i=1; i<n-1; i++)
        {
          cout << x1 << " " << achuan[i] << endl;
          x2 = x1-achuan[i];
          x1 = x2;
        }
      cout << a[n-1] << " " << x1 << endl;
      return 0;
    }
  x1 = achuan[0];
  for (i=nut+1; i<n; i++) 
    {
    	cout << x1 << " " << achuan[i] << endl;
    	x2 = x1-achuan[i];
    	x1 = x2;
    }
  x3 = achuan[nut];
  cout << x3 << " " << x1 << endl;
  x3 -= x1;
  for (i=1; i<nut; i++)
    {
    	cout << x3 << " " << achuan[i] << endl;
        x2 = x3-achuan[i];
		x3 = x2;	
    }
  return 0;
}


Measured memory_bytes: 2688
from collections import Counter
N = int(input())
A = []
cnt = 0
for i in range(N):
    a = str(input())
    A.append(a)
c = Counter(A)
set_A = list(set(A))
for i in set_A:
    if int(c[str(i)]) < 2:
        cnt += 1
    else:
        cnt += int(c[str(i)]) % 2
print(cnt)

Measured memory_bytes: 23420
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N = 1e5 + 10;

int n, k;
int a[N];
int ans;
int pos;

int main() {
	cin>>n>>k;
	REP(i, 1, n) {
		cin>>a[i];
		if (a[i]==1) {
			pos=i;
			break;
		}
	}

	k--;
	int L=pos-1;
	int t=(L+k-1)/k;
	int R=n-t*k-1;
	int t2=(R+k-1)/k;
	cout<<t+t2<<endl;
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll cfmod = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f;
const int MAXN = 1e5+5;

string s;
int k;

int dp[MAXN][105][5];

int solve(int i, int mod, bool flag) {

	int &ans = dp[i][mod][flag];
	// debug3(i, mod ,flag);
	if(i == s.size())
		return ans = !mod;
	if(ans != -1)
		return ans;

	int limit = flag ? 9 : s[i];
	
	int aux = 0;
	for(int x = 0; x <= limit; x++) {
		aux = (aux + solve(i+1, (mod + x)%k, flag | (x < s[i])))%cfmod;
	//	if(i == 1 && mod == 0) debug2(x, aux);
	}
	
	return ans = aux;
	
}

int32_t main() {

	memset(dp, -1, sizeof dp);
	cin >> s >> k;
	for(char &i : s)
		i -= '0';

	solve(0, 0, 0);
	int ans = dp[0][0][0] - 1;
	cout << (ans < 0 ? ans + cfmod : ans) << endl;
}

Measured memory_bytes: 411264
N = int(input())
S = input()
 
r = S.count('R')
g = S.count('G')
b = S.count('B')
max = r * g * b 
 
count = 0
for i in range(N-2):
	for j in range(i+1, N-1):
		k = 2 * j - i
		if k > N - 1:
			break
	
		if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
			count += 1
		
		
 
print(max - count)

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

int main(){
    int N,K;
    cin >> N >> K;
    long long int H[N],sum=0;
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    if(N <= K) cout << "0";
    else{
        sort(H,H+N);
        long long int result;
        result = accumulate(H,H + N - K,0.0);
        cout << result;
    }
}

Measured memory_bytes: 1792
#include <algorithm>
#include <utility>
#include <cstring>
#include <cstdio>
typedef std::pair<int, int> data; 
data arr[100005]; 
int lst[100005], to[1000005], pre[1000005], tot; 
int lson[100005], rson[100005], pos[100005], rt, t_cnt; 
int low[100005], dfn[100005], st[100005], comp[100005]; 
int x[100005], y[100005], n, tp, clk, comp_cnt; 
bool in[100005]; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
}
void build(int &u, int l, int r)
{
	if (l == r)
	{
		u = arr[l].second < n ? arr[l].second + n : arr[l].second - n; 
		pos[arr[l].second] = l;
		return; 
	}
	u = ++t_cnt;
	int m = l + r >> 1; 
	build(lson[u], l, m); 
	build(rson[u], m + 1, r); 
	add_edge(u, lson[u]); 
	add_edge(u, rson[u]); 
}
void modify(int u, int l, int r, int L, int R, int from)
{
	if (L > R)
		return; 
	if (L <= l && r <= R)
	{
		add_edge(from, u); 
		return; 
	}
	int m = l + r >> 1; 
	if (L <= m)
		modify(lson[u], l, m, L, R, from); 
	if (m < R)
		modify(rson[u], m + 1, r, L, R, from); 
}
void tarjan(int u)
{
	dfn[u] = low[u] = clk++; 
	st[tp++] = u; 
	in[u] = true; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (-1 == dfn[to[i]])
		{
			tarjan(to[i]); 
			low[u] = std::min(low[u], low[to[i]]); 
		}
		else if (in[to[i]])
			low[u] = std::min(low[u], dfn[to[i]]); 
	}
	if (low[u] == dfn[u])
	{
		do
		{
			comp[st[--tp]] = comp_cnt; 
			in[st[tp]] = false; 
		}
		while (st[tp] != u); 
		comp_cnt++; 
	}
}
inline bool chk(int mid)
{
	for (int i = 0; i < n << 1; i++)
		lst[i] = -1; 
	for (int i = 0; i < n; i++)
	{
		int l = std::lower_bound(arr, arr + (n << 1), (data){x[i] - mid + 1, -1}) - arr; 
		int r = std::upper_bound(arr, arr + (n << 1), (data){x[i] + mid - 1, 1e9}) - arr - 1; 
		if (l <= r)
		{
			modify(rt, 0, (n << 1) - 1, l, pos[i] - 1, i); 
			modify(rt, 0, (n << 1) - 1, pos[i] + 1, r, i); 
		}
		l = std::lower_bound(arr, arr + (n << 1), (data){y[i] - mid + 1, -1}) - arr; 
		r = std::upper_bound(arr, arr + (n << 1), (data){y[i] + mid - 1, 1e9}) - arr - 1; 
		if (l <= r)
		{
			modify(rt, 0, (n << 1) - 1, l, pos[i + n] - 1, i + n); 
			modify(rt, 0, (n << 1) - 1, pos[i + n] + 1, r, i + n); 
		}
	}
	memset(dfn, -1, sizeof(dfn)); 
	memset(in, false, sizeof(in)); 
	clk = comp_cnt = tp = 0; 
	for (int i = 0; i < t_cnt; i++)
	{
		if (-1 == dfn[i])
			tarjan(i); 
	}
	for (int i = 0; i < n; i++)
	{
		if (comp[i] == comp[i + n])
			return false; 
	}
	return true;
}
int main()
{
	// freopen("ARC069-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", x + i, y + i); 
		arr[i << 1] = {x[i], i}; 
		arr[i << 1 | 1] = {y[i], i + n}; 
	}
	std::sort(arr, arr + (n << 1)); 
	t_cnt = n << 1; 
	build(rt, 0, (n << 1) - 1); 
	int l = 0, r = 1e9, ans = 0; 
	while (l <= r)
	{
		int m = l + r >> 1, orig = tot; 
		if (chk(m))
		{
			ans = m;
			l = m + 1; 
		}
		else
			r = m - 1; 
		tot = orig; 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 12288
#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int main(){
	int a,b;
	while (scanf("%d %d",&a,&b) != -1){
		int c = a + b;
		int count = 0;
		while (c > 0){
			c /= 10;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX

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

	int x = 0;
	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I') {
			x++;
		}
		if (s[i] == 'D') {
			x--;
		}
		if (res < x) {
			res = x;
		}
	}
	cout << res << endl;

	return (0);
}

Measured memory_bytes: 256
import math
A,B,H,M=list(map(int, input().split()))


def getdegree(n,m):
    degm=m*6
    degn=(n%12)*30 + 0.5*m
    return min(abs(degn-degm), 360-abs(degn-degm))

D=math.radians(getdegree(H,M))
# print(D)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(D)))

Measured memory_bytes: 62412