akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <sstream>
#include <stdlib.h>
#include <cstdio>
#include <typeinfo>

typedef long long int ll;
using namespace std;

int main()
{
    stack<int> S;
    string word;

    while (cin >> word)
    {
        int front, back, num;
        string result;

        if (word == "+")
        {
            back = S.top();
            S.pop();
            front = S.top();
            S.pop();
            S.push(front + back);
        }
        else if (word == "-")
        {
            back = S.top();
            S.pop();
            front = S.top();
            S.pop();
            S.push(front - back);
        }
        else if (word == "*")
        {
            back = S.top();
            S.pop();
            front = S.top();
            S.pop();
            S.push(front * back);
        }
        else
        {
            num = atoi(word.c_str());
            S.push(num);
        }
    }
    cout << S.top() << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int cnt[100001] = {};

int main() {
    scanf("%d", &n);
    forn(i, n) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    int sum = 0;
    forn(i, 100001) {
        sum += max(cnt[i] - 1, 0);
    }
    sum = (sum + 1) / 2;
    n -= 2 * sum;
    cout << n << endl;
    return 0;
}


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

ll res(ll x){
  if(x%4==0) return x;
  if(x%4==1) return 1;
  if(x%4==2) return x+1;
  if(x%4==3) return 0;
}
int main() {
  ll a,b;
  cin >> a >> b;
  ll ansa=0,ansb=0;;
  ll now=1;
  a--;
  ansa=res(a);
  ansb=res(b);
  ll ans=ansa^ansb;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
typedef long long ll;

int main(){
	ll K;
	cin>>K;
	ll N;
	cin>>N;
	vector<ll> A(N);
	for(ll i=0; i<N; i++){
		cin>>A[i];
	}
	ll max=0;
	vector<ll> B(N);
	for(ll i=0; i<N-1; i++){
		B[i] = A[i+1] - A[i];
	}
	B[N-1] = K - A[N-1] + A[0];
	for(int i=1; i<B.size(); i++){
		if(max<B[i]) max = B[i];
	}

	ll ans = K - max;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3328
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    S = [input() for _ in range(n)]
    print(len(set(S)))



if __name__ == '__main__':
  main()


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

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> p(N, 0);
    vector<int> n(N, 0);
    long double sump = 0;
    for(int i=0; i<N; i++) {
        p[i] += i+1;
        while(p[i] < K) {
            p[i] *= 2;
            n[i] ++;
        }
        sump += (1.000000000/N) * powl(1.000000000/2, n[i]);
    }
    
    cout << fixed << setprecision(9) << sump << endl;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;

  int cum[200000] = {};
  for ( int i = 0; i < M; i++ ) {
    int l, r;
    cin >> l >> r;
    cum[l]++;
    cum[r+1]--;
  }

  for ( int i = 1; i < 200000; i++ ) {
    cum[i] += cum[i-1];
  }

  int ans = 0;
  for ( int i = 0; i < 200000; i++ ) {
    if ( cum[i] == M ) ans++;
  }

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


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


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

  cout << max({a + b,  a- b,  a* b}) << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

const inf = 1 << 60

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
	}

	ct := 0
	mn := inf
	for _, p := range ps {
		if chmin(&mn, p) {
			ct++
		}
	}
	fmt.Println(ct)
}


Measured memory_bytes: 4992
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		String t=s.next();
		System.out.println(
				REPS(getInt())
				.mapToObj(i->s.next())
				.map(o->o+o)
				.filter(o->o.matches("^.*"+t+".*$"))
				.count());
	}
}

Measured memory_bytes: 32184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  set <ll> s;
  ll count = 1;
  bool flag = 1;
  ll i = 0;
  while (v.at(i) != 2) {
    if (s.count(i+1)) {
      flag = 0;
      break;
    } else {
      s.insert(i+1);
      count++;
      i = v.at(i)-1;
    }
  }
  if (flag) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
}

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

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

void insertSort(int p[], int n)
{
	int i, j,k;

	for (i = 1; i < n; i++)
	{
		j = i;
		while (j >= 1 && (p[j] < p[j - 1]))
		{
			swap(&p[j], &p[j - 1]);
			j--;
		}

		for (k = 0; k < n-1; k++)
			printf("%d ", p[k]);

		printf("%d\n",p[n-1]);
	}
}

int GCD(int x, int y)
{
	if (x < y)
		swap(&x, &y);

	if (y == 0)
		return x;

	return GCD(y, x % y);
}

int not_prime_count(int p[], int n)
{
	int count = 0;
	int i, j;
	int num;

	for (i = 0; i < n; i++)
	{
		for (j = 2; j < (int)(sqrt(p[i])+1); j++)
		{
			if (p[i] % j == 0)
			{
				count++;
				break;
			}
		}
	}
	return count;
}

typedef struct T
{
	char mark;
	int num;
}T;

int bubble_sort(T p[], int n)
{
	int i, j;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n - 1 - i; j++)
		{
			if (p[j].num > p[j + 1].num)
			{
				swap(&p[j].num, &p[j + 1].num);
				temp = p[j].mark;
				p[j].mark = p[j + 1].mark;
				p[j + 1].mark = temp;

				count++;
			}
		}
	}
	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark,p[i].num);
	printf("%c%d\n", p[n-1].mark,p[n - 1].num);

	return count;
}

int selection_sort(T p[],int n)
{
	int i, j, min;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		min = i;
		for (j = i; j < n; j++)
		{
			if (p[j].num < p[min].num)
				min = j;
		}

		if (i != min)
		{
			swap(&p[i].num, &p[min].num);
			temp = p[i].mark;
			p[i].mark = p[min].mark;
			p[min].mark = temp;
			count++;
		}
	}

	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark, p[i].num);
	printf("%c%d\n", p[n - 1].mark, p[n - 1].num);

	return count;
}

T card[100];
T card2[100];

int main()
{
	int n;
	int temp;


	scanf("%d", &n);

	int i;
	char t;

	scanf("%c", &t);

	for (i = 0; i < n; i++)
	{
		scanf("%c%d", &card[i].mark, &card[i].num);
		//printf("%c%d\n", card[i].mark, card[i].num);

		scanf("%c", &t);
	}

	memcpy(card2, card, sizeof(T) * n);

	bubble_sort(card, n);
	printf("Stable\n");
	selection_sort(card2,n);

	for (i = 0; i < n; i++)
	{
		if ((card[i].num == card2[i].num) && (card[i].mark != card2[i].mark))
		{
			printf("Not stable\n");
			return 0;
		}
	}
	printf("Stable\n");
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;
// 約数列挙
template <class T>
set<T> dividers(T n) {

    set<T> ret;
    for (T x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            ret.insert(x);
            ret.insert(n / x);
        }
    }
    return ret;
}
int main() {
    lint N;
    cin >> N;
    lint ans = 0;
    // 約数じゃないもの
    // dump(dividers(9));
    ans += dividers(N - 1).size() - 1;
    // cout << ans << endl;
    // dump(dividers(N - 1));
    // 約数であるもの
    for (auto div : dividers(N)) {
        if (div == 1) continue;
        lint n = N;
        while (n % div == 0) {
            n /= div;
        }

        if (n % div == 1) { ans++; }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//大きい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return bNum - aNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",_lcm(a,b));
    
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int comp(const int *a, const int *b){
    return *a-*b;
}

int main(void){
    int n, t, *v;
    long ans=0;
    scanf("%d", &n);
    v = (int*)malloc(sizeof(int)*n);
    for(int i=0; i<n; i++){
        scanf("%d", &t);
        v[i] = t-(i+1);
    }
    qsort(v, n, sizeof(int), (int(*)(const void*,const void*))comp);
    for(int i=0; i<n; i++){
        ans += labs(v[i]-v[n/2]);
    }
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1788
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {

  static final int MOD = 1000000007;

  public static void main(String [] args) {
    InputReader scanner = new InputReader(System.in);
    int N = scanner.nextInt();
    int [] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
    }
    Arrays.sort(A);
    int res = 1;
    if (N % 2 == 1) {
      if (A[0] != 0) {
        System.out.println(0);
        return;
      }
    }
    int cnt = (N % 2 == 1) ? 2 : 1;
    int start = (N % 2 == 1) ? 1 : 0;
    for (int i = start; i < N; i += 2) {
      if (A[i] != cnt || A[i + 1] != cnt) {
        System.out.println(0);
        return;
      }
      res *= 2;
      res %= MOD;
      cnt += 2;
    }
    System.out.println(res);
  }

  static class Interval implements Comparable<Interval> {
    int a, b;
    public Interval(int a, int b) {
      this.a = a;
      this.b = b;
    }

    public int compareTo(Interval rhs) {
      if (b < rhs.b) return -1;
      if (b == rhs.b) {
        return a - rhs.a;
      }
      return 1;
    }
  }

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

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

    public String nextLine() {
      try {
        return reader.readLine();
      } catch (IOException e) {
        return null;
      }
    }

    public boolean hasNext() {
      if (tokenizer == null) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
        }
      }
      return tokenizer.hasMoreTokens();
    }

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

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

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


Measured memory_bytes: 22772
#include <cstdio>
#include <cmath>
#include <random>
#define REP(i,n) for (int i=0;i<(n);i++)
int main(){
	int N,M;
	int a[52],b[52],c[52],d[52];
	int check[52],max[52]={};
	scanf("%d %d",&N,&M);
	REP(i,N){scanf("%d %d",&a[i],&b[i]);check[i]=2147483647;}
	REP(j,M){scanf("%d %d",&c[j],&d[j]);}
	REP(i,N){
		REP(j,M){
			if(abs(c[j]-a[i])+abs(d[j]-b[i])<check[i]){
				check[i]=abs(c[j]-a[i])+abs(d[j]-b[i]);
				max[i]=j+1;
			}
		}
	}
	REP(i,N){printf("%d\n",max[i]);}
	scanf("%d");
	return 0;
}


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

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;
    ll x = min(B - 1, N);
    cout << (A * x) / B - A * (x / B) << endl;
    return 0;
}

Measured memory_bytes: 3608
//In the name of Allah
//In the name of the compassionate of the merciful
//Ya Ali!
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename Type>
using ordered_multiset = tree<Type, null_type, less_equal<Type>, rb_tree_tag, tree_order_statistics_node_update> ;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 2e5 + 10  ;
const ll INF = 3e18 ;

#define f first
#define s second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define endll "\n"
#define sortt(v) sort(v.begin() , v.end())
#define reversee(v) reverse(v.begin() , v.end())

// for sqrt on interval and array , always sq = maxn/80 ;
// cout << *ss.find_by_order(index) ; -> return the value that indexed in index position
// cout << ss.order_of_key(value) ; -> lower_bound in ordered_set
//ifstream fin("input.txt");
//ofstream fout("output.txt");
// fflush(stdout);
ll mod = 1e9 + 7 , p1 = 999999929 , p2 = 999999937 ;

ll n , mark[maxn] , sub[maxn] , ans = 0 ;
vector<ll> g[maxn] ;

ll poww(ll a , ll b)
{
 if(b==0)return 1;
 ll x = poww(a , b/2)%mod ;
 x %= mod ;
 if(b&1)return (((x*x)%mod)*a)%mod ;
 else return (x*x)%mod ;
}

void dfs(ll v)
{
  mark[v] = 1;
  ll sum = 0 , x = 0 ;
  for(auto u : g[v]){
    if(!mark[u]){
        dfs(u) ;
        sub[v] += sub[u] ;
        sum += poww(2 , sub[u])%mod ;
        x ++ ;
    }
  }
  sum += poww(2 , n-sub[v])%mod ;
  //ll x = (ll)g[v].size() ;
  sum = (sum-x+mod)%mod ;
  ll inv = poww(2 , n)%mod ;
  inv = poww(inv , mod-2)%mod ;
  ll xx = poww(2 , n-1)%mod ;
  ll va = (((xx-sum+mod)%mod)*inv)%mod ;

  //cout << sum << " " << v << endl ;

  //va = (1-va+mod)%mod ;
  ans = (ans+va)%mod ;
}

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

cin >> n ;
for(int i = 1 ; i < n ; i ++){
    ll v , u ;
    cin >> v >> u ;
    g[v].pub(u) ;
    g[u].pub(v) ;
}

for(int i = 1 ; i <= n ; i ++)sub[i] = 1;
dfs(1) ;

cout << ans%mod ;

 return 0;
}
/*
                  _     _   __
            /_\  (_    (_)  __)
           /   \  _) . (_) (__
*/


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b,ll p){if(b==0)return 1;ll res=1;a=a%p;while(b>0){if(b&1){res=(res*a)%p;b--;}a=(a*a)%p;b>>=(ll)1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f,cnt;
	cin>>n;
	string s;c=0;
	ll num1=0,num2=0,num;
	cin>>s;
	for(i=0;i<n;i++)
	    if(s[i]=='1')
	        c++;
	k=c;
	ll t1=1,t2=1;
	   for(j=n-1;j>=0;j--)
	   {
	       if(s[j]=='1'){
	       num1+=t1;
           num2+=t2;
	       num1%=k+1;
             if(k==1)
           num2%=1;
             else
               	num2%=k-1;
           }
	       t1*=2;t2*=2;
	       t1%=k+1;
         if(k>1)
           t2%=k-1;
         else
           	t2%=1;
	   }
	for(i=0;i<n;i++)
	{
	    cnt=1;k=c;
	    if(s[i]=='0')
	       num=(num1+power((ll)2,(n-1-i),++k))%k;
	    else{
	        if(k==1){
	            cout<<0<<"\n";continue;}
	        num=(num2-power((ll)2,(n-1-i),--k)+k)%k;
	    }
	   while(num>0)
	   {
	       cnt++;
	       num%=(__builtin_popcount(num));
	   }
	   cout<<cnt<<"\n";
	   
	}
	return 0;
}


Measured memory_bytes: 3776
# ABC159_D
from collections import defaultdict as dd
n=int(input())
a=list(map(int,input().split()))
d=dd(int)
for aa in a:
    d[aa]+=1
a_sum=0
for k,v in d.items():
    # if v>=2:
    a_sum+=v*(v-1)//2

for i,aa in enumerate(a):
    s=a_sum
    t=d[a[i]]
    s-=t*(t-1)//2
    t-=1
    s+=t*(t-1)//2
    print(s)
# for k,v in d.items()


Measured memory_bytes: 26780
import fractions
 
a,b,c,d=map(int, input().split())
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
x =(b//c)-(((a-1)//c))
y =(b//d)-(((a-1)//d))
n =lcm(c,d)
xy=(b//n)-(((a-1)//n))
 
ans = (b-a+1) - (x+y-xy)
print(ans)

Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n;

int main(){
	while(cin>>n&&n){
		int a,b,c,d,e,m=500,M=0;
		rep(i,n){
			cin>>a>>b>>c>>d>>e;
			int s=a+b+c+d+e;
			m=min(m,s);M=max(M,s);
		}
		cout<<M<<" "<<m<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define N 100

int main() {
    long long a,b,c;
    cin>>a>>b>>c;
    if(a!=7 && a!=5){
        cout<<"NO"<<endl;
        return 0;
    }
     if(b!=7 && b!=5){
        cout<<"NO"<<endl;
        return 0;
    }
     if(c!=7 && c!=5){
        cout<<"NO"<<endl;
        return 0;
    }

    if(a+b+c==17){
        cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    return 0;
    }

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

print('R' * dx + 'U' * dy + 'L' * dx + 'D' * dy, end='')
print('D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L', end='')
print('U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R')


Measured memory_bytes: 3060
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int main()
{
    long long X;
    cin >> X;
    ll now = 100;
    ll y = 0;
    while (now < X) {
        now *= 1.01;
        y++;
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3632
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  if(n ==1) 
    cout << "Hello World";
  else
  {
    int a,b;
    cin >> a >> b;
    cout << a + b;
  }
  
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
#define ll long long int
#define endl '\n'
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,a;
	double s;
	cin>>n;
	while(n--)
	{
		cin>>a;
		s += 1.0/a;
	}
	double s1 = 1.0/s;
	cout<<s1<<endl;
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  	char AtCoder[4];
  
  	scanf("%s", AtCoder);
  
  	if(strcmp(AtCoder, "ARC") == 0){
      printf("ABC\n");
    }else{
    	printf("ARC\n");
    }

	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int n; // n:element count
	std::cin >> n;

	std::vector<int> figure; // figure:column of figures
	figure.resize(n);
	
	// input figure
	int tmp;
	for(int i = 0; i < n; ++i){
		std::cin >> tmp;
		figure[i] = tmp;
	}

	std::vector<long int> ans; // ans:combination number
	ans.resize(21); // ans is divided in solution

	ans[figure[0]] = 1; // first input

	for(int i = 1; i < (n - 1); ++i){
		std::vector<long int> buf_ans; // buf_ans:recoad the following ans
		buf_ans.resize(21);

		for(int j = 0; j < 21; ++j){
			if(ans[j] != 0){ // omit calculaton of the non-existent colution
				// minus
				if((j - figure[i]) >= 0){
					buf_ans[j - figure[i]] += ans[j];
				}
				// plus
				if((j + figure[i]) <= 20){
					buf_ans[j + figure[i]] += ans[j];
				}
			}
		}

		// copy buf_ans to ans
		ans.assign(buf_ans.begin(), buf_ans.end());
	}
	
	std::cout << ans[figure[n - 1]] << std::endl; // output

	return 0;
}

Measured memory_bytes: 1212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws IOException {
		TreeSet<String> input = new TreeSet<String>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		Collections.addAll(input, br.readLine().split(" "));
		System.out.println(input.size() != num ? "NO" : "YES");
	}

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main( int argc, char *argv[] ) {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	cout << min(a,b) + min(c,d) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
	ios;
	int a,b,c=0;
	cin>>a>>b;
	int x=1;
	while(x<b)
	{
		x=x-1+a;
		c++;
	}
	cout<<c;
	
	return 0;
}
 

Measured memory_bytes: 256
// AOJ 1026 Hedro's Hexahedron
// 2018.2.2 bal4u@uu

#include <stdio.h>
#include <math.h>

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

int main()
{
	long long n, k, ans;
	int i, m;

	while(n = in()){
        ans = n >> 1, m = (int)sqrt((double)ans);
		if ((long long)m*m == ans) m--;
        for(i = 1, k = 2; i <= m; i++, k+=2) ans += (n+k-1)/k;
        ans <<= 1, ans -= (long long)i*i; if (n & 1) ans++;
        printf("%lld\n", (ans + n) << 3);
	}
	return 0;
}


Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
int my_max(int a,int b)
{
	return a>b ?a:b; 
}
int my_min(int a,int b)
{
	return a<b? a:b;
}
int main()
{
	int n,m,x,y;
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(int i=0;i<n;i++)
	{
		int num;
		scanf("%d",&num);
		x=my_max(x,num);
	}for(int i=0;i<m;i++)
	{
		int num;
		scanf("%d",&num);
		y=my_min(y,num);
	}
	if(x<y)
		printf("No War");
	else
		printf("War");
	return 0;
 } 

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

using namespace std;

int main(void){
  int n, m = 1;
  cin >> n;
  
  vector<int> p(n), q(n), a(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }

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

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

  int i = 0;
  int ans = 0;
  do{
    int j;
    for(j= 0; j < n; j++){
      if(p[j] != a[j]) break;
    }
    if(j == n) ans += i;

    for(j = 0; j < n; j++){
      if(q[j] != a[j]) break;
    }
    if(j == n) ans -= i;
    i++;
  }while(next_permutation(a.begin(), a.end()));

  cout << abs(ans) << endl;


}

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

int main()
{
    string a[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string in;
    cin >> in;

    for(int i = 0; i < 7; i++) {
        if(in == a[i]) cout << 7-i;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
CD = []
for _ in range(M):
    c, d = map(int, input().split())
    CD.append((c, d))
for a, b in AB:
    i = min(range(M), key=lambda i: abs(a - CD[i][0]) + abs(b - CD[i][1]))
    print(i + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000000000
int n;

int main(){
    int a,b;
	cin >> a >> b;
	
	int insert = 0;
	int  hole = 1;
	while(hole < b){
		hole+=(a-1);
		insert++;
    }
	
	cout << insert <<endl;
	
    
    return 0;	
}

Measured memory_bytes: 256
N,K = map(int,input().split())
S = list(input())

List = []
ans = 0
now,count = 1,0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        List.append(count)
        now = 1-now
        count = 1
if count != 0:
    List.append(count)

if len(List)%2 == 0:
    List.append(0)

Ruisekiwa = [0]*(len(List)+1)
for i in range(len(List)):
    Ruisekiwa[i+1] = Ruisekiwa[i]+List[i]

add = 2*K+1
for i in range(0,len(List),2):
    left = i
    right = min(i+add,len(List))
    tmp = Ruisekiwa[right] - Ruisekiwa[left]

    ans = max(tmp,ans)


print(ans)


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

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

  if(n % 500 > a){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	string s;
	cin>>n>>s;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'A';
		now+=n;
		if(now>=26){
			now-=26;
		}
		cout << char(now+'A');
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        var nmk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nmk[0], m = nmk[1], k = nmk[2];
        bool judge = false;
        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; j <= m; j++)
            {
                if ((n - i) * (m - j) + i * j == k) judge = true;
            }
        }
        Console.WriteLine(judge ? "Yes" : "No");
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

vector<string> s;
int x, y;

void gotoend()
{
	y = s[x].size();
}

void gotohome()
{
	y = 0;
}

int check()
{
	if (s[x].size() == 0 || y == s[x].size()) return 1;
	else return 0;
}


int main()
{
	x = 0; y = 0;
	string tmp;
	string buf = "";
	while (1)
	{
		getline(cin, tmp);
		if (tmp == "END_OF_TEXT") break;
		s.push_back(tmp);
	}
	char com;
	while (cin >> com)
	{
		if (com == '-') break;
		else if (com == 'a') gotohome();
		else if (com == 'e') gotoend();
		else if (com == 'p')
		{
			if (x == 0) gotohome();
			else
			{
				x--;
				gotohome();
			}
		}
		else if (com == 'n')
		{
			if (x < s.size() - 1) x++;
			gotohome();
		}
		else if (com == 'f')
		{
			if (check() == 0) y++;
			else if (check() == 1 && x < s.size() - 1)
			{
				x++;
				gotohome();
			}
		}
		else if (com == 'b')
		{
			if (y > 0) y--;
			else if (y == 0 && x > 0)
			{
				x--;
				gotoend();
			}
		}
		else if (com == 'd')
		{
			if (check() == 0) s[x].erase(y, 1);
			else if (check() == 1 && x < s.size() - 1)
			{
				s[x] += s[x + 1];
				s.erase(begin(s) + x + 1);
			}
		}
		else if (com == 'k')
		{
			if (check() == 1 && x < s.size() - 1)
			{
				s[x] += s[x + 1];
				s.erase(begin(s) + x + 1);
				buf = "\n";
			}

			else if (check() == 0)
			{
				buf = s[x].substr(y);
				s[x].erase(y);
			}
		}
		else if (com == 'y')
		{
			if (buf == "\n")
			{
				string tmp = s[x].substr(y);
				s.insert(begin(s) + x + 1, tmp);
				s[x].erase(y);
				x++;
				gotohome();
			}
			else if (buf != "")
			{
				s[x].insert(y, buf);
				y += buf.size();
			}
		}


	}
	REP(i, s.size())
	{
		cout << s[i] << endl;
	}
	return 0;

}

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

using namespace std;

const int maxn=1e4+5;

typedef long long ll;

const ll mod=1e9+7;

int a[maxn];
int b[maxn];
int dp[2*maxn];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	if(n*500>=k) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 * Created by Harry on 5/10/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        long[] nums = new long[n];
        long[] sum = new long[n+1];
        int mod = (int)(1e9+7);
        for(int i=0; i<n; i++){
            nums[i] = scanner.nextLong();
            sum[i+1] = sum[i]+nums[i];
        }
        long res = 0;
        for(int i=0; i<n; i++){
            res = (res + nums[i]*((sum[n]-sum[i+1]+mod)%mod)%mod )%mod;
        }
        System.out.println(res%mod);
    }
}


Measured memory_bytes: 62340
n=input()
l=[None]*7
for i in range(4):
    l[i*2]=n[i]
for i in range(2**3):
    for j in range(3):
        if (i>>j)&1:
            l[j*2+1]="+"
        else:
            l[j*2+1]="-"
    a="".join(l)
    if eval(a)==7:
        print(a+"=7")
        exit()

Measured memory_bytes: 3064
import math

def main():
    a,b,c = map(int, input().split())
    
    if c > 2 * (a+b):
        print("Yes")
    elif c - a - b <= 0:
        print("No")
    elif (c - a - b)**2 > 4*a*b:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    main()




Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> Odd[100010],Even[100010];
int color[100010];

bool dfs(int v,int c){
  color[v]=c;
  for(int i=0;i<Odd[v].size();i++){
    if(color[Odd[v][i]]==0)dfs(Odd[v][i],-c);
  }
  for(int i=0;i<Even[v].size();i++){
    if(color[Even[v][i]]==0)dfs(Even[v][i],c);
  }
}

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  rep(i,s.size()){
    if(i==k-1){
      char c=s[i]-('A'-'a');
      cout << c ;
    }
    else cout << s[i] ;
  }
  cout << endl;
return 0;}


Measured memory_bytes: 4992
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin >> x; cout << (1 - x) << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b;
    cin>>a>>b;
    if(a>8||b>8)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(M)]

contact = defaultdict(list)

for a, b in ab:
	contact[a-1].append(b-1)
	contact[b-1].append(a-1)

#print(contact)

for x in contact[0]:
	if N-1 in contact[x]:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")


Measured memory_bytes: 97636
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

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

int a[200010], b[200010], c[200010];
int bit[200010], n;

//0からi-1番目までの和
int sum(int i) {
  i++;
  int s = 0;
  while(i > 0) {
    s += bit[i];
    i -= i&-i;
  }
  return s;
}

//i番目(0-index)にxを加える
void add(int i, int x) {
  i++;
  while(i <= n) {
    bit[i] += x;
    i += i&-i;
  }
}

signed main(void)
{
	int k;
	cin >> n >> k;
	REP(i, n) cin >> a[i];
	FOR(i, 1, n) {
		a[i] += a[i-1];
		b[i] = a[i] - (i+1)*k;
	}
	b[0] = a[0] - k;
	//REP(i, n) cout << b[i] << " "; cout << endl;
	//座圧するパート
	map<ll, ll> mp;
	vector<ll> d(n);
	REP(i, n) {
		mp[b[i]] = 0;
		d[i] = b[i];
	}
	int rank = 0, cnt = 0;
	for(auto& i: mp) i.second = rank++;
	for(auto& i: d) {
		c[cnt] = mp[i];
		cnt++;
	}
	//REP(i, n) cout << c[i] << " "; cout << endl;

	ll ret = 0;
	REP(i, n) {
		//c_i以下の値の個数を
		ret += sum(c[i]);
		if(b[i] >= 0) ret++;
		//BITにc_iを追加
		add(c[i], 1);
		//REP(j, n) cout << bit[j] << " "; cout << endl;
		//cout << "ret:" << ret << endl;
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 20608
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
ans = [(i%26)+1 for i in range(D)]
manzoku_down = [0]*26
for i in range(D):
    tmp = -float('inf')
    for j in range(26):
        last = 0
        for l in range(0,i+1):
            if ans[l] == j+1:
                last = j+1
        manzoku_down[j] = C[j]*((i+1)-last)
    for k in range(26):
        if S[i][k]-sum(manzoku_down)+manzoku_down[k] >= tmp:
            tmp = S[i][k]-sum(manzoku_down)+manzoku_down[k]
            ans[i] = k+1
for i in ans:
    print(i)

Measured memory_bytes: 68928
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int t = 10;

    int n;
    cin >> n;

    vector<vector<int>> f(n, vector<int>(t));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            cin >> f[i][j];
        }
    }

    vector<vector<long long>> p(n, vector<long long>(t + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= t; j++) {
            cin >> p[i][j];
        }
    }

    long long res = -(1LL << 48);
    for (int i = 1; i < (1 << t); i++) {
        long long r = 0;
        for (int j = 0; j < n; j++) {
            int c = 0;
            for (int k = 0; k < t; k++) {
                if ((i & (1 << k)) > 0 && f[j][k] > 0) {
                    c++;
                }
            }

            r += p[j][c];
        }

        res = max(res, r);
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 100005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int P[MAX];
int Find(int x)
{
    if(P[x]==x) return x;
    else
    {
        P[x]=Find(P[x]);
        return P[x];
    }
}
bool Join(int x,int y)
{
    int PoX=Find(x),PoY=Find(y);
    if(PoX==PoY) return false;
    else if(PoX<PoY)
    {
        P[PoY]=PoX;
    }
    else
    {
        P[PoX]=PoY;
    }
    return true;
}
int main()
{
    int n,m,i,u,v;
    scanf("%d %d",&n,&m);
    int com=n-1;
    for(i=1;i<=n;i++)
    {
        P[i]=i;
    }
    for(i=0;i<m;i++)
    {
        scanf("%d %d",&u,&v);
        if(Join(u,v)) com--;
    }
    printf("%d",com);
    return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
vector<int> v[1010];
vector<pair<int,int>> u;
int main(){
	int i,j,h,w;
	cin >> h >> w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			char c; cin >> c;
			if(c=='B'){
				v[i].push_back(j);
			}
		}
	}
	for(i=0;i<h;i++){
		sort(v[i].begin(),v[i].end());
	}
	for(i=0;i<h;i++){
		if(v[i].size()>=1){
			u.push_back({i,v[i][0]});
			u.push_back({i,v[i].back()});
		}
	}
	int mx = 0;
	for(i=0;i<u.size();i++){
		for(j=0;j<u.size();j++){
			mx = max(mx,abs(u[i].first - u[j].first) + abs(u[i].second - u[j].second));
		}
	}
	cout << mx << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll a,b,c;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> a >> b >> c;
    cout << min(c,b/a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>

using namespace std;

int main () {
    int N, M;
    cin>>N>>M;
    vector<pair<int,int>> ds;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin>>a>>b;
        ds.push_back(make_pair(a,b));
    }
    sort(begin(ds), end(ds));
    int mn = N;
    int count = 0;
    for (auto&& d : ds) {
        if (mn < d.first) {
            count++;
            mn = d.second-1;
        } else if (d.second-1 < mn) mn = d.second-1;
    }
    count++;
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll N, K;
    cin >> N >> K;
    vll data(N);
    for (ll i = 0; i < N; i++) {
        cin >> data[i];
    }
    for (ll i = 0; i < N - K; i++) {
        if (data[i] < data[i + K]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

int main(){
   int W,H,x,y,r;
   cin >> W >> H >> x >> y >> r;
   if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
    cout << "Yes" <<endl; 
   }else{
    cout << "No" <<endl; 
   }
   return 0;
}

Measured memory_bytes: 3040
s = input()
ans = "AC"
if s[0] != 'A':
    ans = "WA"
cnt = 0
for i in range(1,len(s)):
    if s[i].isupper():
        if i == 1 or s[i]!= "C" or i==len(s)-1:
            ans = "WA"
        cnt+=1
if cnt!=1:
    ans="WA"
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <list>
#include <sstream>
#include <numeric>

#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;

const ld PI = acosl(-1.0);
const ll mod = 1000000007;
const ll inf = 9223372036854775803;
const int maxN = 6;//1000000;

int main() {
    cout.precision(10);
    cout << fixed;
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int k;
    string s;
    cin >> k >> s;
    if (s.length() > k) {
        s = s.substr(0, k) + "...";
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3616