akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <sstream>
#include <iostream>
#include <stack>
using namespace std;
typedef pair<int,int> P;
int n,m;
map<string,P> data;
string str[101];
struct var{
	string str;
	bool a[257];
};

bool check(){
	stack<var> s;
	for(int i=0;i<n;i++){
		if(data.find(str[i])!=data.end()){
			var da;
			da.str="";
			memset(da.a,false,sizeof(da.a));
			for(int j=data[str[i]].first;j<=data[str[i]].second;j++){
				da.a[j]=true;
			}
			s.push(da);
		}else{
			if(str[i][0]>='0' && str[i][0]<='9'){
				var da;
				da.str="";
				memset(da.a,false,sizeof(da.a));
				int num=0;
				for(int j=0;j<str[i].size();j++){
					num=(num*10+str[i][j]-'0')%256;
				}
				da.a[num]=true;
				s.push(da);
			}else if(str[i]=="+"){
				if(s.size()==0)return false;
				var b=s.top();
				s.pop();
				if(s.size()==0)return false;
				var a=s.top();
				s.pop();
				var next;
				memset(next.a,false,sizeof(next.a));
				for(int j=0;j<256;j++){
					if(!b.a[j])continue;
					for(int k=0;k<256;k++){
						if(!a.a[k])continue;
						next.a[(j+k)%256]=true;
					}
				}
				s.push(next);

			}else if(str[i]=="-"){
				if(s.size()==0)return false;
				var b=s.top();
				s.pop();
				if(s.size()==0)return false;
				var a=s.top();
				s.pop();
				var next;
				memset(next.a,false,sizeof(next.a));
				for(int j=0;j<256;j++){
					if(!b.a[j])continue;
					for(int k=0;k<256;k++){
						if(!a.a[k])continue;
						next.a[(k-j+256)%256]=true;
					}
				}
				s.push(next);

			}else if(str[i]=="*"){
				if(s.size()==0)return false;
				var b=s.top();
				s.pop();
				if(s.size()==0)return false;
				var a=s.top();
				s.pop();
				var next;
				memset(next.a,false,sizeof(next.a));
				for(int j=0;j<256;j++){
					if(!b.a[j])continue;
					for(int k=0;k<256;k++){
						if(!a.a[k])continue;
						next.a[(k*j+256)%256]=true;
					}
				}
				s.push(next);

			}else if(str[i]=="/"){
				if(s.size()==0)return false;
				var b=s.top();
				s.pop();
				if(s.size()==0)return false;
				var a=s.top();
				s.pop();
				var next;
				memset(next.a,false,sizeof(next.a));
				for(int j=0;j<256;j++){
					if(!b.a[j])continue;
					for(int k=0;k<256;k++){
						if(!a.a[k])continue;
						if(j==0)return false;
						next.a[(k/j)%256]=true;
					}
				}
				s.push(next);
			}
		}
	}
	return true;
}

int main(void){
	scanf("%d%*c",&m);
	for(int i=0;i<m;i++){
		string inp;
		int l=0,r=0;
		cin >> inp >> l >> r;
		data[inp]=P(l,r);
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> str[i];
	}
	printf("%s\n",check()?"correct":"error");
	return 0;
}

Measured memory_bytes: 1292
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
 
using namespace std;
 
using ll = long long int; 
 
void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;
 
    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}
 
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}
 
ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}
 
const int MAX = 50;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
int main(void){
 
    string s;
    int n;

    cin>>n>>s;
    int sum = 0;

    for(int i=0;i<n-2;i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'&&s[i+2]=='C'){
                sum++;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
int main (void)
{
	int n,i,min,a,count=0;
scanf("%d",&n);
for(i=0;i<n;i++){

  scanf("%d",&a);
    if(i==0){
   min=a; 
  }
      if(a<=min){
      min=a;
      count++;
    }

  
}  
  printf("%d",count);
return 0;
}


Measured memory_bytes: 1724
n=int(input())
p=list(map(int,input().split()))
k=0
a=[0]*n
for i in range(n):
  a[i]=i+1
  
for i in range(n):
  if a[i]!=p[i]:
    k+=1
    
    
if k<=2:
  print('YES')
else:
  print('NO')
  

Measured memory_bytes: 3060
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int main() {
  FASTIO();

  bool front = 1;
  deque<char> q;
  string s;
  cin >> s;
  for (char c : s) {
    q.emplace_back(c);
  }

  int x;
  cin >> x;
  while (x--) {
    int t;
    cin >> t;
    if (t == 1) {
      front = !front;
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        if (front) {
          q.emplace_front(c);
        } else {
          q.emplace_back(c);
        }
      } else {
        if (front) {
          q.emplace_back(c);
        } else {
          q.emplace_front(c);
        }
      }
    }
  }

  while (q.size()) {
    if (!front) {
      cout << q.back();
      q.pop_back();
    } else {
      cout << q.front();
      q.pop_front();
    }
  }
}

Measured memory_bytes: 960
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;

map< pair<int,int>, vector<int> > lns;

pair<int,int> f(int x,int y){
	int g = __gcd(x,y);
	x /= g;
	y /= g;
	if( x < 0 ) x *= -1, y *= -1;
	return make_pair(x,y);
}

int main(){
	int m;
	cin >> m;
	vector< pair<int,int> > ps;
	for(int i = 0 ; i < m ; i++){
		int x,y;
		cin >> x >> y;
		ps.push_back({x,y});
	}
	for(int i = 0 ; i < m ; i++){
		for(int j = 0 ; j < i ; j++){
			lns[f(ps[i].first-ps[j].first,ps[i].second-ps[j].second)].push_back((1<<i) + (1<<j));
		}
	}
	
	
	int dp[2][1<<16][9];
	int cur = 0;
	int nex = 1;
	memset(dp[cur],0xf0,sizeof(dp[cur]));			
	dp[cur][0][0] = 0;
	for( auto ls : lns ){
		for(auto v : ls.second ){
			memcpy(dp[nex],dp[cur],sizeof(dp[nex]));			
			for(int i = 0 ; i < (1<<16) ; i++){
				if( v & i ) continue;
				for(int j = 0 ; j < 8 ; j++){
					dp[nex][i|v][j+1] = max(dp[nex][i|v][j+1], dp[cur][i][j] + j);
				}
			}
			swap(dp[cur],dp[nex]);
		}
		memset(dp[nex],0xf0,sizeof(dp[nex]));	
		for(int i = 0 ; i < (1<<16) ; i++){
			for(int j = 0 ; j < 9 ; j++){
				dp[nex][i][0] = max(dp[nex][i][0], dp[cur][i][j]);
			}
		}
		swap(cur,nex);
	}
	int ans = 0;
	for(int i = 0 ; i < (1<<16) ; i++)
		ans = max(ans,dp[cur][i][0]);
	cout << ans << endl;
	
}

Measured memory_bytes: 7764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

	for (int i = 0; i < ty - sy; i++) {

		cout << "U";

	}
	for (int i = 0; i < tx - sx; i++) {

		cout << "R";

	}
	for (int i = 0; i < ty - sy; i++) {

		cout << "D";

	}
	for (int i = 0; i < tx - sx; i++) {

		cout << "L";

	}
	cout << "L";
	for (int i = 0; i < ty - sy + 1; i++) {

		cout << "U";

	}
	for (int i = 0; i < tx - sx + 1; i++) {

		cout << "R";

	}
	cout << "D";
	cout << "R";
	for (int i = 0; i < ty - sy + 1; i++) {

		cout << "D";

	}
	for (int i = 0; i < tx - sx + 1; i++) {

		cout << "L";

	}
	cout << "U" << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
if s[0] != s[len(s)-1]:
  count = 0
  cur = '*'
  for i in range(len(s)):
    if cur == s[i]:
      count += 1
      cur = '*'
    else:
      cur = s[i]
  print(count*k)
else:
  flag = True
  for i in range(len(s)-1):
    if s[i] != s[i+1]:
      flag = False
      break
  if flag:
    print(len(s)*k//2)
  else:
    ans = 0
    t = s[0]
    mae = 0
    ushiro = len(s)-1
    for i in range(len(s)-2,-1,-1):
      if s[i] == t:
        ushiro = i
      else:
        break
    for j in range(1,len(s)):
      if s[j] == t:
        mae = j
      else:
        break
    count = 0
    cur = s[mae]
    for i in range(mae+1,ushiro):
      if cur == s[i]:
        count += 1
        cur = '*'
      else:
        cur = s[i]
    ans = count*k
    ans += ((len(s)-ushiro+mae+1)//2)*(k-1)+(mae+1)//2+(len(s)-ushiro)//2
    print(ans)

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

int main(){
    char a,b;
    cin >> a >> b;
    if((a=='H'&&b=='H')||(a=='D'&&b=='D')){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
}

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

int main(){
	int n ,k; cin>>n;
    if( n == 0 ){
    	cout << "0" << endl;
        return 0;
    }
    vector<vector<int > > dp( n , vector<int> (3) );
    for(int i=0;i<n;i++){
        cin>> dp[i][0] >> dp[i][1] >> dp[i][2] ;
    }
    for(int i=1;i<n;i++){
        dp[i][0] = dp[i][0] + max( dp[i-1][1] , dp[i-1][2] );
        dp[i][2] = dp[i][2] + max( dp[i-1][0] , dp[i-1][1] );
        dp[i][1] = dp[i][1] + max( dp[i-1][0] , dp[i-1][2] );
    }
    cout << max ( dp[n-1][0] , max( dp[n-1][1] , dp[n-1][2] ))<< endl;
    return 0;
	
}

Measured memory_bytes: 5760
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B = input().split()

A = int(A)
B = int(B.replace(".", ""))

print(A * B // 100)


Measured memory_bytes: 9608
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,last,len,ans;
char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i=last+1){
		int j=1;
		if(len==1){
			for(;j<=len;j++){
				if(s[i+j-1]!=s[last-len+j]){
					break;
				}
			}
		}
		if(i+j-1<=n){
			ans++;
		}
		len=j;
		last+=len;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
def main():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A: 
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1) 
            return
    print(prod) 

main()


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

using ll=int64_t;
#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)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

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

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

struct SegTree{
	vi buf;
	int s;
	SegTree(int n){
		s=1;
		while(s<n)s*=2;
		buf.resize(s*2,inf);
	}
	void Update(int b,int e,int v,int l,int r,int i){
		if(e<=l||r<=b)return;
		if(b<=l&&r<=e)return void(chmin(buf[i],v));
		Update(b,e,v,l,(l+r)/2,i*2);
		Update(b,e,v,(l+r)/2,r,i*2+1);
	}
	void Update(int b,int e,int v){
		Update(b,e,v,0,s,1);
	}
	int Get(int i){
		i+=s;
		int res=inf;
		while(i){
			chmin(res,buf[i]);
			i>>=1;
		}
		return res;
	}
};

struct Query{
	int l,r,t;
	bool operator<(const Query&rhs)const{
		return r!=rhs.r?r<rhs.r:t<rhs.t;
	}
};

signed main(){
	int n=read(),base=0;
	vi b(n);REP(i,n)base+=1-(b[i]=read());
	SegTree seg(n+1);
	seg.Update(0,1,base);
	vector<Query> qs;
	REP(i,n)qs.PB(Query{i,i+1,0});
	int q=read();
	REP(i,q){
		int l=read()-1,r=read();
		qs.PB(Query{l,r,1});
	}
	sort(ALL(qs));
	for(auto w:qs){
		int l=w.l,r=w.r,t=w.t;
		int a=seg.Get(l);
		if(t==0)
			seg.Update(r,r+1,a+(b[l]==0?-1:1));
		else
			seg.Update(l+1,r+1,a);
	}
	cout<<seg.Get(n)<<endl;
}

Measured memory_bytes: 20332
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
}
int n,sum,cnt,a[10010];
int main()
{
	while(n=scan())
	{
		sum=0;
		cnt=0;
		for(int i=1;i<=n;++i)
		{
			a[i]=scan();
			sum+=a[i];
		}
		for(int i=1;i<=n;++i)
			if(a[i]*n<=sum)
				++cnt;
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
namespace P_TEMPLATE{
	#define endl '\n'
	#define rgi register int
	typedef long long ll;
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL),setbuf(stdin,NULL);
	#endif
}}using namespace P_TEMPLATE;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1201201201;

int pos[maxn];
ll sum[maxn];
signed main()
{P_INIT();
	ll n,m,x,p,ans;
	fin>>n>>x>>m;
	pos[x]=1,sum[1]=x;
	for(p=2;p<=std::min(n,m+10);++p) {
		x=(x*x)%m;
		sum[p]=sum[p-1]+x;
		if(pos[x]) break;
		pos[x]=p;
	}
	if(p>n) fout<<sum[n];
	else {
		ans=sum[pos[x]],n-=pos[x];
		ans+=(sum[p]-sum[pos[x]])*(n/(p-pos[x]));
		n%=p-pos[x];
		ans+=sum[pos[x]+n]-sum[pos[x]];
		fout<<ans;
	}
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 4320
package main

import (
	"fmt"
	"strconv"
)

type op bool

func (o op) String() string {
	if o {
		return "+"
	} else {
		return "-"
	}
}

func main() {
	var n string
	fmt.Scan(&n)
	a, _ := strconv.Atoi(string(n[0]))
	b, _ := strconv.Atoi(string(n[1]))
	c, _ := strconv.Atoi(string(n[2]))
	d, _ := strconv.Atoi(string(n[3]))

	options := [][]op{
		{true, false, false},
		{true, true, false},
		{true, true, true},
		{true, false, true},
		{false, true, true},
		{false, false, true},
		{false, true, false},
		{false, false, false},
	}

	for _, op := range options {
		total := a
		if op[0] {
			total += b
		} else {
			total -= b
		}
		if op[1] {
			total += c
		} else {
			total -= c
		}
		if op[2] {
			total += d
		} else {
			total -= d
		}
		if total == 7 {
			fmt.Println(fmt.Sprintf("%d%s%d%s%d%s%d=7", a, op[0], b, op[1], c, op[2], d))
			return
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll a, p;
    cin >> a >> p;

    cout << ((a * 3 + p) >> 1) << endl;

    return 0;
}


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

using namespace std;

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

	for (int i = 0; i < k; i++)
	{
		if(i % 2 == 0)
		{
			if(a % 2 != 0){
				a--;
			}
			b += a/2;
			a = a/2;
		}else{
			if(b % 2 != 0){
				b--;
			}
			a += b/2;
			b = b/2;
		}
	}
	cout << a << " " << b << endl;

	return 0;
}

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

void setd(vector<long> &a, long n){
  for(int i=0; i<n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
}

int main(){
  long n, ans = 0;  cin >> n;
  vector<long> a(n), b(n), c(n);
  setd(a, n);  setd(b, n);  setd(c, n);
  
  for(int i=0; i<n; i++){
    long anum = max(0L, min(n, (long)(lower_bound(a.begin(), a.end(), b[i]) - a.begin())));
    long cnum = max(0L, min(n, (long)(c.end() - upper_bound(c.begin(), c.end(), b[i]))));
    ans += anum * cnum;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5580
#include<cstdio>

using namespace std;

int main(){
	for(int n,m,p;scanf("%d%d%d",&n,&m,&p),n;){
		int x[100],sum=0;
		for(int i=0;i<n;i++)	scanf("%d",x+i),sum+=x[i];
		if(x[m-1]==0)	puts("0");
		else{
			int ans=100*sum*(100-p)/(100*x[m-1]);
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,k,ans=0,cnt=0;
  scanf("%d %d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  FOR(n-1){
    if(s[i]==s[i+1]){
      ans++;
    }else{
      cnt++;
    }
  }
  PRN(ans+min(2*k,cnt));
  return 0;
}


Measured memory_bytes: 256
from math import acos, tan, hypot

def getRad1(s12, s13, s23):
    return acos((s12*s12 + s13*s13 - s23*s23) / (2*s12*s13))

def getMaxR(s12, rad1, rad2):
    tan1 = tan(rad1 / 2)
    tan2 = tan(rad2 / 2)
    h = s12 * (tan1*tan2) / (tan1+tan2)

    def isOK(mid):
        return s12 - mid/tan1 - mid/tan2 <= 2*mid

    ng, ok = 0, h
    while abs(ok-ng) > 10**-12:
        mid = (ng+ok) / 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    return ok

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

s12 = hypot(x1-x2, y1-y2)
s23 = hypot(x2-x3, y2-y3)
s31 = hypot(x3-x1, y3-y1)

rad1 = getRad1(s12, s31, s23)
rad2 = getRad1(s23, s12, s31)
rad3 = getRad1(s31, s23, s12)

maxRs = [
    getMaxR(s12, rad1, rad2), 
    getMaxR(s23, rad2, rad3),
    getMaxR(s31, rad3, rad1)
]
print(max(maxRs))


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<char> ans(2*N+1);
    cout << '?';
    for (int i=1;i<=N;++i) cout << ' ' << i;
    cout << endl;
    string left,S; cin >> left;
    int lb=1,ub=N+1;
    while(ub-lb>1){
        int mid=(ub+lb)>>1;
        cout << '?';
        for (int i=0;i<N;++i) cout << ' ' << mid+i;
        cout << endl; cin >> S;
        (S==left?lb:ub)=mid;
    }
    ans[lb]=left[0],ans[lb+N]=(left[0]=='R'?'B':'R');
    vector<int> half,rest;
    for (int i=1;i<N;++i) half.emplace_back(lb+i);
    for (int i=1;i<lb;++i){
        cout << "? " << i;
        for (int i=0;i<N-1;++i) cout << ' ' << half[i];
        cout << endl; cin >> S;
        ans[i]=S[0]; rest.emplace_back(i);
    }
    for (int i=lb+N+1;i<=2*N;++i){
        cout << "? " << i;
        for (int i=0;i<N-1;++i) cout << ' ' << half[i];
        cout << endl; cin >> S;
        ans[i]=S[0]; rest.emplace_back(i);
    }
    for (int i=ub;i<lb+N;++i){
        cout << "? " << i;
        for (int i=0;i<N-1;++i) cout << ' ' << rest[i];
        cout << endl; cin >> S;
        ans[i]=S[0];
    }
    cout << "! ";
    for (int i=1;i<=2*N;++i) cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 724
for e in iter(input,'0'):
 a=[list(map(int,input().split())) for _ in range(int(e))]
 s,t=a[0]
 b=[list(map(int,input().split())) for _ in range(int(input()))]
 for x,y in b:
  flag = True
  for u,v in a[1:]:
   if [x + u - s, y + v - t] not in b:
    flag = False
    break
  if flag == True:
   print(x - s, y - t)
   break


Measured memory_bytes: 5896
tolower 'A' = 'a'
tolower 'B' = 'b'
tolower 'C' = 'c'

main = do
  [n, k] <- map read . words <$> getLine
  s <- getLine
  putStr $ take (k-1) s
  putChar $ tolower $ s !! (k-1)
  putStrLn $ drop k s

Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Array.Sort(nums, (a, b) => b - a);

            for (int i = 0; i < 4; i++) Console.Write(nums[i] + " ");
            Console.WriteLine(nums[4]);
        }
    }
}

Measured memory_bytes: 9184
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)



 
int main()
{ 
  ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif 

  int i,n; 
   cin >> n;
    vector<ll>a(n);
    rep(i, n)  
   cin >> a[i];
    ll s = 0;
    rep(i, n)  
   s ^= a[i];
   
    rep(i, n)
    {
        ll ans = s^a[i];
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N),ABdif(N);
    ll sumA=0,sumB=0;
    rep(i,N) {
        cin >> A[i];
        sumA+=A[i];
        ABdif[i] = A[i];
    }
    rep(i,N){
        cin >> B[i];
        sumB += B[i];
        ABdif[i]-=B[i];
    }
    if(sumA<sumB){
        cout << -1 << endl;
        return 0;
    }
    sort(ABdif.rbegin(),ABdif.rend());
    ll d = 0;
    ll ans = 0;
    rep(i,N){
        if(B[i]>A[i]){
            d += B[i]-A[i];
            ans++;
        }
    }
    if(d==0){
        cout << 0 << endl;
        return 0;
    }
    ll s = 0;
    rep(i,N){
        s+=ABdif[i];
        ans++;
        if(d<=s){
            cout << ans << endl;
            return 0; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int l,n,hit[100],blow[100];
bool use[100][10];
char tmp[11],in[100][11],ans[11];

int main()
{
	while(scanf("%d%d",&l,&n),l)
	{
		rep(i,n)
		{
			scanf("%s%d%d",in[i],hit+i,blow+i);
			rep(j,10)use[i][j]=0;
			rep(j,l)use[i][in[i][j]-'0']=1;
		}
		
		int cand=0,cbit=0;
		rep(i,1<<10)
		{
			rep(j,n)
			{
				int cnt=0;
				rep(k,10)if((i&1<<k)&&use[j][k])cnt++;
				if(cnt!=hit[j]+blow[j])goto NI;
			}
			cand|=i;
			NI:;
		}
		ans[0]=0;
		rep(i,10)if(cand&1<<i)tmp[cbit++]=i+'0';
		do
		{
			rep(i,n)
			{
				int h=0,b=0;
				rep(j,l)
				{
					if(tmp[j]==in[i][j])h++;
					else if(use[i][tmp[j]-'0'])b++;
				}
				if(h!=hit[i]||b!=blow[i])goto NEXT;
			}
			if(ans[0]!=0)
			{
				ans[0]=0; goto END;
			}
			rep(i,l)ans[i]=tmp[i];
			
			NEXT:;
			reverse(tmp+l,tmp+cbit);
		}while(next_permutation(tmp,tmp+cbit));
		
		END:
		ans[l]=0;
		if(ans[0])printf("%s\n",ans);
		else puts("NO");
	}
	
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<long long> ryuka;
  ryuka.push_back(2);
  ryuka.push_back(1);
  for(int i=2;i<=n;++i){
    long long temp=ryuka[i-1]+ryuka[i-2];
    ryuka.push_back(temp);
  }
  cout<<ryuka[n]<<endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int x, a, b; cin >> x >> a >> b;

    string ans = abs(x - a) <= abs(x - b) ? "A" : "B";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int result=0;
		for(int i=0;i<n;i++) {
			int hight=sc.nextInt();
			result+=k>hight?0:1;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 48612
#include<stdio.h>

long ryuka(int i){
  if(i == 0)
    return 2;
  else if(i == 1)
    return 1;
  else
    return ryuka(i-1)+ryuka(i-2);
}

int main(){
  long ans=0;
  int i,j,k;
  scanf("%d",&k);
  long L[k+1];
  for(i=0;i<=k;i++){
    if(i==0){
      L[0] = 2;}
    else if(i==1){
      L[1] = 1;}
    else
      L[i] = L[i-1]+L[i-2];
    ans=L[i];
  }
  
  printf("%ld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
int f[1100000];
int n;
int main()
{
	cin >> n;
	f[1] = f[2] = 0;
	f[3] = f[4] = f[5] = 1;
	f[6] = 2;
	for(int i=7; i<=n; i++)
		f[i] = (f[i - 1] % N + f[i - 3] % N) % N;
	cout << f[n] % N << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<vector<int> > to(MAXV);
int id[MAXN][MAXN];
int toId(int i, int j) {
    if (i > j) swap(i, j);
    return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int v) {
    if (visited[v]) {
        if (!calculated[v]) return -1; //ループ検出
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for (int u : to[v]) {
        int res = dfs(u);
        if (res == -1) return -1;
        chmax(dp[v], res+1);
    }
    calculated[v] = true;
    return dp[v];
}

int main() {
    int n; cin >> n;
    vector<vector<int> > a(n, vector<int>(n-1));
    rep(i, n)rep(j, n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }
    int V = 0;
    rep(i, n)rep(j, n) {
        if (i < j) id[i][j] = V++;
    }
    rep(i, n) {
        rep(j, n-1) {
            a[i][j] = toId(i, a[i][j]); //選手iとjが戦う試合を順に格納
        }
        rep(j, n-2) {
            to[a[i][j+1]].push_back(a[i][j]); //次戦う選手のとこにその前に戦う選手格納
        }
    }
    int ans = 0;
    rep(i, V) {
        int res = dfs(i);
        if (res == -1) {
            puts("-1");
            return 0;
        }
        chmax(ans, res);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 38528
#include <cstdio>
#include <cstdlib>

int N;
int xs[200008];
int ys[200008];
int event[200008];
long long lf=0;
long long rg=0;
long long up=0;
int ind[200008];
int cmp(const void *ka,const void *kb) {
	int a=*(int *)ka;
	int b=*(int *)kb;
	if(xs[a]!=xs[b]) return xs[b]-xs[a];
	return a-b;
}
int main() {
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		scanf("%d%d",&xs[i],&ys[i]);
		if(xs[i]<ys[i]) {
			int temp=xs[i];
			xs[i]=ys[i];
			ys[i]=temp;
		}
	}
	int ymin_ind=0;
	for(int i=0;i<N;i++) if(ys[i]<ys[ymin_ind]) ymin_ind=i;
	int ind_list=0;
	for(int i=0;i<N;i++) {
		if(xs[i]>xs[ymin_ind]) {
			//add to ind
			ind[ind_list++]=i;
		} else {
			//it is optimal
			if(lf<xs[ymin_ind]-xs[i]) lf=xs[ymin_ind]-xs[i];
		}
		if(up<ys[i]-ys[ymin_ind]) up=ys[i]-ys[ymin_ind];
	}
	qsort(ind,ind_list,sizeof(int),cmp);
	long long sol=1000000007;
	sol*=sol;
	for(int i=0;i<ind_list;i++) {
		int now=ind[i];
		long long rg_now=rg;
		if(rg_now<xs[now]-xs[ymin_ind]) rg_now=xs[now]-xs[ymin_ind];
		if(sol>(lf+rg_now)*up) sol=(lf+rg_now)*up;
		//reverse
		if(up<xs[now]-ys[ymin_ind]) up=xs[now]-ys[ymin_ind];
		if(ys[now]>xs[ymin_ind]) {
			if(rg<ys[now]-xs[ymin_ind]) rg=ys[now]-xs[ymin_ind];
		} else {
			if(lf<xs[ymin_ind]-ys[now]) lf=xs[ymin_ind]-ys[now];
		}
	}
	if(sol>(lf+rg)*up) sol=(lf+rg)*up;
	printf("%lld\n",sol);
	return 0;
}


Measured memory_bytes: 3324
#include<stdio.h>
int main(void){
    int n, i, k, h[100000], s=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++) scanf("%d",&h[i]);
    for(i=0;i<n;i++){
        if(h[i]>=k) s+=1;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int n,L,a[100005],x;
inline int read(){
	int ret=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return f?-ret:ret;
}
int main(){
	n=read(),L=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<n;i++)
	if(a[i]+a[i+1]>=L) x=i;
	puts(x?"Possible":"Impossible");
	if(x){
		for (int i=1;i<x;i++) printf("%d\n",i);
		for (int i=n-1;i>x;i--) printf("%d\n",i);
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t;
	scanf("%d",&n);
	int MAX=0,MIN=1000;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t);
		if(t>MAX) MAX=t;
		if(t<MIN) MIN=t;
	}
	printf("%d\n",MAX-MIN);
	return 0;
 } 

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

int main() {
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice =0;
  int bob =0;
  for(int j=0;j<N;j+=2){
    alice+=a.at(j);
  }
  for(int k=1;k<N;k+=2){
    bob+=a.at(k);
  }
  cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    bool[] state;
    int[] p;
    int n, m;
    int res = 0;
    List<List<int>> map;
    void Run()
    {
        var sc = new Scanner();
        n = sc.NextInt();
        m = sc.NextInt();
        state = new bool[n];
        map = new List<List<int>>();
        for (int i = 0; i < m; i++)
        {
            int k = sc.NextInt();
            map.Add(new List<int>());
            for (int j = 0; j < k; j++)
            {
                map[i].Add(sc.NextInt() - 1);
            }
        }
        p = new int[m];
        for (int i = 0; i < m; i++)
        {
            p[i] = sc.NextInt();
        }
        Dfs(0);
        Console.WriteLine(res);
    }

    void Dfs(int l)
    {
        if (l < n)
        {
            state[l] = false;
            Dfs(l + 1);
            state[l] = true;
            Dfs(l + 1);
        }
        else
        {
            for (int i = 0; i < m; i++)
            {
                int sum = 0;
                for (int j = 0; j < map[i].Count; j++)
                    if (state[map[i][j]]) sum++;
                if (sum % 2 != p[i]) return;
            }
            res++;
        }
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13268
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	P[] a, b, c, d;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			n+=2;
			a=new P[n];
			b=new P[n];
			c=new P[n];
			d=new P[n];
			a[0]=new P(0, 0);
			b[0]=new P(0, 1);
			c[0]=new P(0, 0);
			d[0]=new P(1, 0);
			for(int i=1; i<n-1; i++)
				a[i]=new P(sc.nextDouble(), 0);
			for(int i=1; i<n-1; i++)
				b[i]=new P(sc.nextDouble(), 1);
			for(int i=1; i<n-1; i++)
				c[i]=new P(0, sc.nextDouble());
			for(int i=1; i<n-1; i++)
				d[i]=new P(1, sc.nextDouble());
			a[n-1]=new P(1, 0);
			b[n-1]=new P(1, 1);
			c[n-1]=new P(0, 1);
			d[n-1]=new P(1, 1);
			solve();
		}
	}

	void solve(){
		double ans=0;
		for(int j=0; j<n-1; j++){
			for(int i=0; i<n-1; i++){
				P p1=isLL(a[i], b[i], c[j], d[j]);
				P p2=isLL(a[i+1], b[i+1], c[j], d[j]);
				P p3=isLL(a[i+1], b[i+1], c[j+1], d[j+1]);
				P p4=isLL(a[i], b[i], c[j+1], d[j+1]);
				ans=max(ans, area(p1, p2, p3)+area(p3, p4, p1));
				// debug(j, i, area(p1, p2, p3)+area(p3, p4, p1));
				// debug(p1, p2, p3, p4);
			}
		}
		// debug(ans);
		println(String.format("%.6f", ans+EPS));
	}

	double area(P p1, P p2, P p3){
		double a=p1.sub(p2).abs();
		double b=p2.sub(p3).abs();
		double c=p3.sub(p1).abs();
		double s=(a+b+c)/2;
		return Math.sqrt(s*(s-a)*(s-b)*(s-c));
	}

	// ツ陳シツ静シツづ陳シツ静シツづ個古ーツ点
	P isLL(P p1, P p2, P q1, P q2){
		double d=q2.sub(q1).det(p2.sub(p1));
		if(abs(d)<EPS)
			return null;
		return p1.add(p2.sub(p1).mul(q2.sub(q1).det(q1.sub(p1))/d));
	}

	class P{
		double x, y;

		P(){
			this(0, 0);
		}

		P(double x, double y){
			this.x=x;
			this.y=y;
		}

		P add(P p){
			return new P(x+p.x, y+p.y);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y);
		}

		P mul(double m){
			return new P(x*m, y*m);
		}

		P div(double d){
			return new P(x/d, y/d);
		}

		double abs(){
			return Math.sqrt(abs2());
		}

		double abs2(){
			return x*x+y*y;
		}

		double arg(){
			return Math.atan2(y, x);
		}

		// inner product
		double dot(P p){
			return x*p.x+y*p.y;
		}

		// outer product
		double det(P p){
			return x*p.y-y*p.x;
		}

		P rot90(){
			return new P(-y, x);
		}

		// conjugation
		P conj(){
			return new P(x, -y);
		}

		@Override
		public String toString(){
			return "("+x+", "+y+")";
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main(){
    int n , k;
    cin >> n >> k;
    vector<long long> mon(n);
    for (int i = 0; i < n; i++){
        cin >> mon.at(i);
    }
    sort(mon.begin(),mon.end());
    k = min(k, n);
    for (int j = 0; j < k; j++){
        mon.pop_back();
    }
    long long ans = 0;
    for (long long m : mon){
        ans += m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=0
    crr[1]=abs(arr[1]-arr[0])
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr[-1])

b=input()
cr=list(map(int,input().split()))
func(cr)
    

Measured memory_bytes: 13928
#include <iostream>
#include <map>
using namespace std;
int main(){
    int n; cin >> n;
    map<int, int> mp;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        sum += a;
        mp[a]++;
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int b,c;
        cin >> b >> c;
        mp[c] += mp[b];
        sum += mp[b]*(c-b);
        mp[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

const long long MOD = 1000000007;

int main() {
    long long N, K;

    cin >> N >> K;

    long long p;
    for (int i = 0; i < 99; i++) {
        p = (p * 10) % MOD;
    }

    long long sum = 0;

    for (long long k = K; k <= N + 1; k++) {
        long long min = (0 + k - 1) * k / 2;
        long long max = (N + N - k + 1) * k / 2;

        // min %= MOD;
        // max %= MOD;

        sum += (max - min + 1);
    }

    cout << sum % MOD << endl;
}


Measured memory_bytes: 3636
unittest
{
	assert( [ "3 2", "1 2", "2 3" ].parse.expand.solve == 2 );
	assert( [ "3 3", "1 2", "2 3", "2 3" ].parse.expand.solve == 1 );
	assert( [ "4 4", "1 2", "2 3", "4 1", "3 4" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto xys = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
		xy[] -= 1;
	}
	return tuple( nm[ 0 ], xys );
}

auto solve( long n, long[ 2 ][] xys )
{
	auto cs = new long[ n ];
	auto bs = new bool[ n ];
	cs[] = 1;
	bs[ 0 ] = true;
	foreach( xy; xys )
	{
		cs[ xy[ 1 ] ]++;
		cs[ xy[ 0 ] ]--;
		if( bs[ xy[ 0 ] ]      ) bs[ xy[ 1 ] ] = true;
		if( cs[ xy[ 0 ] ] <= 0 ) bs[ xy[ 0 ] ] = false;
	}
	return bs.count( true );
}


Measured memory_bytes: 4988
# include <stdio.h>
     
    int main (void){
        char first, second, third, forth;
        scanf("%s" "%s" "%s" "%s", &first, &second, &third, &forth);
        if(first != second && second != third && third != forth){
            printf("Good\n");
        }
        else{
            printf("Bad\n");
        }
    }
    

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b,c) make_pair(make_pair(a,b),c)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

int c[10001];
int main(){
	
	int n = in();
	for(int i = 0 ; i < n ; i++){
		int t = in();
		c[t]++;
	}
	vector<int> v;
	for(int i = 0 ; i <= 10000 ; i++){
		while( v.size() < 10 && c[i] ){
			v.push_back(i);
			c[i]--;
		}
	}
	vector<int> w;
	for(int i = 0 ; i < v.size() ; i++){
		for(int j = 0 ; j < v.size() ; j++){
			if( i != j ){
				stringstream ss;
				ss << v[i] << v[j];
				w.push_back(atoi(ss.str().c_str()));
			}
		}
	}
	sort(w.begin(),w.end());
	cout << w[2] << endl;
	
}

Measured memory_bytes: 1264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		sc.close();
		switch(b) {
		case "A":
			System.out.println("T");
			break;
		case "T":
			System.out.println("A");
			break;
		case "G":
			System.out.println("C");
			break;
		case "C":
			System.out.println("G");
			break;

		}

	}

}

Measured memory_bytes: 21716
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	double n;
	while(cin>>n,n>=0.0){
		int a=n;
		n-=a;
		// cout<<a<<" "<<n<<endl;
		bool f1=false;
		bool f2=false;
		if(a<(1<<8)) f1=true;
		if(n==0.0) f2=true;
		stringstream ss;
		rep(i,4){
			n*=2.0;
			if(n==1.0){
				ss<<'1';
				n=0.0;
				f2=true;
			}
			else if(n>1.0){
				n-=1.0;
				ss<<'1';
			}
			else{
				ss<<'0';
			}
		}
		stringstream ss1;
		if(f1&&f2){
			string s1;
			ss>>s1;
			rep(i,8){
				if(a&1){
					ss1<<'1';
					// cout<<1;
				}
				else{
					ss1<<'0';
					// cout<<0;
				}
				a>>=1;
			}
			string s2;
			ss1>>s2;
			// cout<<s2<<endl;
			reverse(ALL(s2));
			cout<<s2<<"."<<s1<<endl;
		}
		else{
			cout<<"NA"<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1252
# https://atcoder.jp/contests/abc146/tasks/abc146_b

N = int(input())
S = input()
max_val = ord('Z')
N_mod = N % 26

ans = ''

for i in range(len(S)):
    a = ord(S[i]) + N_mod
    if a > max_val:
        a = a - 26

    ans += chr(a)

print(ans)



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

int main() {
    long N,A,B;
  	long c,d,ans;
    cin >> N >> A >> B;
   	c = N/(A+B);
  	d = N%(A+B);
  	if(d<A)ans = c*A + d;
  	else ans = c*A + A;
    cout << ans << endl;
}

Measured memory_bytes: 256
@prv=map$-=$_-2,@nxt=1..<>+2;--$nxt[-1];
$_[$_]=++$%for glob<>;
$\+=$_*=(($nxt[$nxt[$i=$_[$_]]]-$nxt[$i])*($i-$prv[$i])+($prv[$i]-$prv[$prv[$i]])*($nxt[$i]-$i)),$nxt[$prv[$nxt[$i]]=$prv[$i]]=$nxt[$i]for 1..$%;
print

Measured memory_bytes: 40868