akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  int r[K],c[K],v[K];
  rep(i,0,K){
    cin>>r[i]>>c[i]>>v[i];
  }
  vector<vector<int>> item(R,vector<int>(C));
  /*int item[R][C];
  rep(i,0,R){
    rep(j,0,C){
      item[i][j]=0;
    }
  }*/
  rep(i,0,K){
    item[r[i]-1][c[i]-1]=v[i];
  }
  vector<vector<vector<ll>>> dp(R,vector<vector<ll>>(C,vector<ll>(4)));
  /*ll dp[R][C][4];
  rep(i,0,R){
    rep(j,0,C){
      rep(k,0,4){
        dp[i][j][k]=0;
      }
    }
  }*/
  if(item[0][0]!=0) dp[0][0][1]=item[0][0];
  rep(i,0,R){
    rep(j,0,C){
      if(i+1<R){
        dp[i+1][j][0]=max(max(max(max(dp[i+1][j][0],dp[i][j][0]),dp[i][j][1]),dp[i][j][2]),dp[i][j][3]);
        if(item[i+1][j]!=0){
          dp[i+1][j][1]=max(max(max(max(dp[i+1][j][1],dp[i][j][0]+item[i+1][j]),dp[i][j][1]+item[i+1][j]),dp[i][j][2]+item[i+1][j]),dp[i][j][3]+item[i+1][j]);
        }
      }
      if(j+1<C){
        dp[i][j+1][0]=max(dp[i][j+1][0],dp[i][j][0]);
        dp[i][j+1][1]=max(dp[i][j+1][1],dp[i][j][1]);
        dp[i][j+1][2]=max(dp[i][j+1][2],dp[i][j][2]);
        dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][3]);
        if(item[i][j+1]!=0){
          dp[i][j+1][1]=max(dp[i][j+1][1],dp[i][j][0]+item[i][j+1]);
          dp[i][j+1][2]=max(dp[i][j+1][2],dp[i][j][1]+item[i][j+1]);
          dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][2]+item[i][j+1]);
        }
      }
    }
  }
  cout<<max(max(max(dp[R-1][C-1][0],dp[R-1][C-1][1]),dp[R-1][C-1][2]),dp[R-1][C-1][3])<<endl;
}

Measured memory_bytes: 673980
n = gets.chomp
s = n.size

ans = true
for i in 0..(s-3)/2
  ans = false if n[i] != n[-i-2]
end
ans = false if n[-1] == "1" || n[0] == "0"

if ans
  l = 1
  for i in 2..s
    puts "#{l} #{i}"
    l = i if n[i-2] == "1"
  end
else
  puts -1
end

Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll m,n,x=1;
    cin >> m >> n;
    ll ans=0;
    while(x<n){
        x+=m;
        x--;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#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>
#include<functional>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin >> s;
  if(s[0]=='S')cout << "Cloudy" << endl;
  else if(s[0]=='C')cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
return 0;}

Measured memory_bytes: 256
/*
题意是求一个序列中"所有子序列的中位数"所组成的序列的中位数 
看题解了，完全不会。https://www.cnblogs.com/quzhizhou/p/9535597.html  

首先我们先二分最后序列的中位数。设tot为中位数 >= mid的区间个数，若中位数序列的中位数 >= mid，
则有tot >= n(n+1)/4。
我们另外构造一个序列b[i], 当a[i]>=mid时b[i]=1, 否则bi=-1. 
那么若区间[l, r]的中位数 >= mid, 则b[l]+...+b[r] >= 0. 
于是我们求出序列b[i]的前缀和序列sum[i]，那么问题就变成了求满足l <= r且sum[r]-sum[l-1]>=0的数对(l,r)数量(0<=l,r<=n)，
这个问题可以用与求逆序对数量相似的方法解决. 树状数组即可. 
*/ 
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int NN = 110000;
int a[NN], l, r, n, mid, ans;
int s[NN * 2];  
//树状数组，注意，[-n-1, n], 为了让每一个存的值都是>0, 都加上n即可（因为树状数组不能从0开始）
//所以开双倍空间给数组 

int lowbit(int x){
	return x & (-x);
} 

void add1(int x, int k){
	while (x <= n * 2){
		s[x] += k;
		x += lowbit(x);
	}
}

int getsum(int x){
	int sum = 0;
	while (x > 0){
		sum += s[x];
		x -= lowbit(x);
	}
	return sum;
}

int check(int mid){
	memset(s, 0, sizeof(s));  //树状数组清0 
	//for(int i=1;i<=2*n;i++)s[i]=0;
	//与求逆序对的方法相同 
	add1(n, 1);  //因为在每个数的基础上都加了n，所以这句话相当于在和等于0的点+1
	ll sum = 0;
	ll tmp = 0;
	for (int i=1; i<=n; i++){
		if (a[i] >= mid) sum++;
		else sum--;
		tmp += getsum(sum + n);
		add1(sum + n, 1);
	} 
	//return tmp>=1ll*n*(n+1)/4;
	/*long long nn = n * (n + 1) / 4; //注意！nn必须给long long */
	if (tmp>=1ll*n*(n+1)/4) return true;
	else return false; 
}

int main(){
	//freopen("atcoderarc101d.in", "r", stdin);
	
	scanf("%d", &n);
	l = 0x7fffffff; r = 0;
	for (int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= r) r = a[i];
		if (a[i] <= l) l = a[i];
	}
	//printf("%d %d\n", l, r);
	while (l <= r){
		mid = (l + r) / 2;
		if (check(mid)){
			ans = mid; 
			l = mid + 1;
		} else r = mid-1;
	}
	printf("%d", ans);
	
	return 0;
} 

Measured memory_bytes: 1536
S=raw_input()
l=len(S)

p1=""
for i in range(l):
	p1+=str(i%2)

p2=""
for i in range(l):
	p2+=str( (i+1)%2 )

a1=0
for x,y in zip(S,p1):
	if x!=y:
		a1+=1

a2=0
for x,y in zip(S,p2):
	if x!=y:
		a2+=1

print min(a1,a2)


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

int main(){
  int x;
  cin >> x;
  
  int n = x / 100;
  x = x % 100;
  
  if(x <= n * 5){
    cout << "1\n";
  }
  else{
    cout << "0\n";
  }
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

ll v[101], w[101];

ll dp[101][100001];

int n;

ll solve(int idx, int sisaV) {
	// printf("idx: %d n: %d\n",idx,n);
	if(idx == n){
		// printf("halo\n");
		if(sisaV == 0){return 0;}
		else{return inf + 100;}
		
	}
	if(dp[idx][sisaV] != -1){return dp[idx][sisaV];}
	if(sisaV < v[idx]){return solve(idx+1, sisaV);}
	return dp[idx][sisaV] = min(solve(idx+1, sisaV), w[idx] + solve(idx+1, sisaV - v[idx]));
}

int main(){
	ll W,i,j;
	scanf("%d %lld",&n,&W);
	// printf("n: %d\n",n);
	int tot = 0;
	for(i=0;i<n;i++){
		scanf("%lld %lld",&w[i],&v[i]);
		tot += v[i];
	}
	
	//brp weight minimal untuk dapet value dari 0 sampe tot
	memset(dp, -1, sizeof dp);
	int jawab = 0;
	for(i=0;i<=tot;i++){
		ll ans = solve(0,i);
		// printf("i: %lld ans: %lld\n",i,ans);
		if(ans <= W){
			jawab = i;
		}
	}
	
	printf("%d\n",jawab);
	return 0;
};

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<string> v(n);
  vector<ll> cnt(5, 0);
  for(int i=0;i<n;i++) {
    cin >> v[i];
    if(v[i][0] == 'M')
      cnt[0]++;
    if(v[i][0] == 'A')
      cnt[1]++;
    if(v[i][0] == 'R')
      cnt[2]++;
    if(v[i][0] == 'C')
      cnt[3]++;
    if(v[i][0] == 'H')
      cnt[4]++;
  }


  ll ans = 0;
  for(int i=0;i<5;i++) {
    for(int j=i+1;j<5;j++) {
      for(int k=j+1;k<5;k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 5760
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
 console.log(Math.abs(a[2]-a[0])<=a[3]
		|| (Math.abs(a[1]-a[0])<=a[3] && Math.abs(a[1]-a[2])<=a[3])?"Yes":"No");

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29536
package main

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

func main() {
	N, W := ReadInt(), ReadInt()
	ws := make([]int, N)
	vs := make([]int, N)
	maxSumV := 0
	for i := 0; i < N; i++ {
		ws[i] = ReadInt()
		vs[i] = ReadInt()
		maxSumV += vs[i]
	}

	dp := make([][]int, N)
	for i := 0; i < N; i++ {
		dp[i] = make([]int, maxSumV+1)
		for sumV := 0; sumV <= maxSumV; sumV++ {
			dp[i][sumV] = W + 1
		}
	}

	dp[0][0] = 0
	dp[0][vs[0]] = ws[0]

	for i := 1; i < N; i++ {
		for sumV := 0; sumV <= maxSumV; sumV++ {
			dp[i][sumV] = dp[i-1][sumV]
			if sumV-vs[i] >= 0 {
				dp[i][sumV] = Min(dp[i][sumV], dp[i-1][sumV-vs[i]]+ws[i])
			}
		}
	}

	for sumV := maxSumV; sumV >= 0; sumV-- {
		w := dp[N-1][sumV]
		if w <= W {
			fmt.Println(sumV)
			return
		}
	}
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 82956
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC150E solver = new ABC150E();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC150E {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      ModInt res = new ModInt(0);
      ArrayList<Integer> c = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        c.add(in.nextInt());
      }
      c.sort(Comparator.comparing(x -> -x));
      if (n == 1) {
        res = new ModInt(c.get(0));
      } else {
        for (int i = 0; i < n; i++) {
          res = res.add(new ModInt(i + 2).mul(new ModInt(2).pow(n - 2)).mul(new ModInt(c.get(i))));
          // out.println(res);
        }
      }
      out.println(res.mul(new ModInt(2).pow(n)));
    }

  }

  static class ModInt {

    private static int MOD = 1000000007;
    long x;

    ModInt(long l) {
      this.x = l % MOD;
    }

    ModInt add(ModInt mi) {
      return new ModInt(this.x + mi.x);
    }

    ModInt mul(ModInt mi) {
      return new ModInt(this.x * mi.x);
    }

    ModInt pow(int p) {
      ModInt res = new ModInt(1);
      ModInt tmp = this;
      while (p > 0) {
        if ((p & 1) == 1) {
          res = res.mul(tmp);
        }
        tmp = tmp.mul(tmp);
        p /= 2;
      }
      return res;
    }

    public String toString() {
      return Integer.toString((int) this.x);
    }

  }
}



Measured memory_bytes: 161620
def cnt(kurai, num, detalist):
    jun_i = (num - 1 - sum(detalist[:(num-1)])) * kaijo[kurai-1]
    return jun_i

n = int(input())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]

kaijo = [1, 1, 2, 6, 24, 120, 720, 5040]
detalist_p = [0] * n
detalist_q = [0] * n

pno = 1
qno = 1
for i in range(n-1):
    pno += cnt(n-i, P[i], detalist_p)
    detalist_p[P[i]-1] = 1

    qno += cnt(n-i, Q[i], detalist_q)
    detalist_q[Q[i]-1] = 1

print(abs(pno - qno))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
const int mod=998244353;
const int INF=0x3f3f3f3f;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll inv(ll a){return quick(a,mod-2);}
map<PII,int> ext;
vector<PII> all;
ll ans[10];
int getcnt(PII cur)
{
	//if(cur.first-2<=0||cur.second-2<=0) return -1;
	int ret=0;
	for(int i=-2;i<=0;i++)
	{
		for(int j=-2;j<=0;j++)
		{
			if(ext.count(make_pair(cur.first+i,cur.second+j)))
				ret++;
		}
	}
	//dbg(cur.first,cur.second,ret);
	return ret;
}
int main()
{
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	ll tot=1LL*(h-2)*(w-2);
	for(int i=0,a,b;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		ext[make_pair(a,b)]=1;
		for(int dx=-2;dx<=2;dx++)
		{
			for(int dy=-2;dy<=2;dy++)
			{
				int x=a+dx,y=b+dy;
				if(x>h||x<=2||y>w||y<=2) continue;
				all.push_back(make_pair(x,y));
			}
		}
	}
	sort(all.begin(),all.end());
	all.erase(unique(all.begin(),all.end()),all.end());
	ll cnt=0;
	for(auto u:all)
	{
		int cc=getcnt(u);
		if(cc==0) continue;
		ans[cc]++;
		cnt++;
	}
	ans[0]=tot-cnt;
	for(int i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
}


Measured memory_bytes: 40292
#include<bits/stdc++.h>
using namespace std;
int main(){
      string s;
      cin>>s;
      int flag=0;
      for(int i=0;i<s.length();i++){
        if(s[i]=='9'){
            flag=1;
            break;
        }
      }
      if(flag==1){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
      return 0;
}


Measured memory_bytes: 3572
#python3

def main():
    n = int(input())
    s = input()
    cnt = 0
    for i in range(10):
        ind_i = s.find(str(i))    
        if ind_i == -1:
            continue
        for j in range(10):
            ind_j = s.find(str(j), ind_i+1)
            if ind_j == -1:
                continue
            for k in range(10):
                ind_k = s.find(str(k), ind_j+1)   
                if ind_k == -1:
                    continue
                cnt += 1
    print(cnt) 
main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <functional>

using namespace std;

bool comp(pair<int, int> l, pair<int, int> r){
    if(l != r) return l.second < r.second;
    return l.first < r.first;
}

int main(){
    int n, c;
    cin >> n >> c;
    vector<vector<pair<int, int>>> ch(c);
    for(int i = 0; i < n; i++){
        int s, t, cnum;
        cin >> s >> t >> cnum;
        cnum--;
        ch[cnum].push_back(make_pair(s, t));
    }
    vector<vector<pair<int, int>>> ch2(c);
    vector<pair<int, int>> rec;
    for(int i = 0; i < c; i++){
        sort(begin(ch[i]), end(ch[i]));
        for(auto&& j : ch[i]){
            if(ch2[i].empty()){
                ch2[i].push_back(j);
                continue;
            }
            if(rbegin(ch2[i])->second == j.first){
                rbegin(ch2[i])->second = j.second;
            }else{
                ch2[i].push_back(j);
            }
        }
        rec.insert(end(rec), begin(ch2[i]), end(ch2[i]));
    }
    sort(begin(rec), end(rec));   
    priority_queue<int, vector<int>, greater<int>> q;
    for(auto&& i : rec){
        if(q.empty()){
            q.push(i.second);
            continue;
        }
        if(q.top() < i.first){
            q.pop();
        }
        q.push(i.second);
    }
    cout << q.size() << "\n";
}

Measured memory_bytes: 3240
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int n, d;
long long dat[200008] = { 0 };
int N;
void segtree(int n) {
	N = 1;
	while (N < n) N *= 2;
}
void update(long long k, long long a) {
	k += N - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
	}
}
long long query(int a, int b ,int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return dat[k];
	int m = (l + r) / 2;
	return query(a, b, k * 2 + 1, l, m)+query(a, b, k * 2 + 2, m, r);
}
signed main()
{
	int n;
	int a, b;
	int ans = 99999999;
	cin >> n;
	for (int z = 1; z < n; z++) {
		a = z;
		b = n - a;
		int tmp = 0;
		while (1) {
			tmp += (a % 10) + (b % 10);
			a /= 10;
			b /= 10;
			if (a == 0 && b == 0)break;
		}
		if (tmp <ans)ans = tmp;
	}
	cout << ans;
}

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

using namespace std;

int main() {
   int s;
   cin >> s;
   int i=1;
   while(1){
      if(s==4 || s==2 || s==1)break;
      if(s%2==0){
         s /= 2;
      }else{
         s = 3*s + 1;
      }
      i++;
   }
   cout << i+3 << endl;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll a,p=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		p += a%2;
	}
	cout << ((p)?"first":"second") << endl;
	return 0;
}


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

int main() {

    int n;
    cin >> n;

    map<string, int> dic;

    for (int i = 0; i < n; i++) {
        string s, key;
        cin >> s >> key;
        if (s[0] == 'i') {
            dic[key] ++;
        } else{
            if (dic[key] > 0) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }

    return 0;
    
}


Measured memory_bytes: 52444
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    ll k, t, sum = 0, mx = 0;
    cin >> k >> t;
    REP(i, t){
        ll a;
        cin >> a;
        sum += a;
        mx = max(mx, a);
    }
    cout << max(0LL, 2 * mx - sum - 1) << endl;
}

Measured memory_bytes: 256
import sys

def main():

    # sys.stdin = open('input149d.txt')

    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()

    score = 0

    for i in range(n):
        score += make_score(t[i], r, s, p)

    flag = []

    for i in range(k):
        flag.append(False)

    for i in range(k, n):
        if t[i] == t[i - k] and not flag[i - k]:
            score -= make_score(t[i], r, s, p)
            flag.append(True)

        else:
            flag.append(False)

    print(score)


def make_score(value, r, s, p):
    if value == 'r':
        return p
    elif value == 's':
        return r
    elif value == 'p':
        return s


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
s = input()
k = len(s)
a = [0]*(k+1)
for i in range(k):
  if s[i] == '<':
    a[i+1] = a[i]+1
for j in range(k-1,-1,-1):
  if s[j] == '>':
    a[j] = max(a[j],a[j+1]+1)
print(sum(a))


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

int N, Q;
int S[10010], T[512];

int main() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", S+i);
  scanf("%d", &Q);
  REP(i, Q) scanf("%d", T+i);

  sort(S, S+N);
  sort(T, T+Q);

  int ans = 0;
  REP(i, Q) {
    auto it = lower_bound(S, S+N, T[i]);
    ans += (it != S+N && T[i] == *it);
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int card[200][2];
	int card2[200][2];
	int n;
	int taro = 0;
	int hanako = 0;
	int taron,hanakon;
	int kari;
	int count = 0;
	int count2 = 0;
	int ta,ha;
	int turn = 1;
	int ba = 0;
	int han;

	while (1) {
		cin >> n;

		if (n == 0) {
			break;
		}
		turn = 1;
		ba = 0;
		count = 0;
		count2 = 0;
		for (int i = 0; i < n; i++) {
			cin >> card[i][0];
			card[i][1] = 1;
			card2[i][1] = 1;
		}
	
		for (int i = n-1; i >= 0; i--) {
			for (int j = 0; j < i; j++) {
				if (card[j][0] > card[j+1][0]) {
					kari = card[j][0];
					card[j][0] = card[j+1][0];
					card[j+1][0] = kari;
				}
			}
		}

	
		for (int i = 1; i <= 2*n; i++) {
			if (card[count][0] == i){
				count++;
			} else {
				card2[count2][0] = i;
				count2++;
			}
		}
			
		taron = n;
		hanakon = n;
		
		while (taron > 0 && hanakon > 0) { 
			if (turn == 1) {
				if (ba == 0) {
					for (int i = 0; i < n; i++) {
						if (card[i][1] == 1) {
							ta = card[i][0];
							card[i][1] = 0;
							taron--;
							turn = 2;
							ba = 1;
							break;
						}
					}
				} else {
					for (int j = 0; j < n; j++) {
						if (card[j][0] > ha && card[j][1] == 1) {
							ta = card[j][0];
							card[j][1] = 0;
							taron--;
							han = 1;
							break;
						}
					}
					if (han == 0) {
						ba = 0;
					}	
					han = 0;
					turn = 2;
				}	
			} else {
				if (ba == 0) {
					for (int i = 0; i < n; i++) {
						if (card2[i][1] == 1) {
							ha = card2[i][0];
							card2[i][1] = 0;
							hanakon--;
							turn = 1;
							ba = 1;
							break;
						}
					}
				} else {
					for (int j = 0; j < n; j++) {
						if (card2[j][0] > ta && card2[j][1] == 1) {
							ha = card2[j][0];
							card2[j][1] = 0;
							hanakon--;
							han = 1;
							break;
						}
					}
					if (han == 0) {
						ba = 0;
					}	
					han = 0;
					turn = 1;
				}
			}
		}
		cout << hanakon << endl << taron << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

int f(int a)
{
    if(a%10 != 0)
    {
      return  10 - a%10;
    }

  return 0;
}

signed main()
{
  ios();
  int a[5];
  rep(i,5) cin >> a[i];
  sort(a,a+5,[](int a,int b){ return f(a) < f(b);});
  int ans = 0;
  rep(i,4)
  {
    if(a[i]%10 != 0)
    {
      a[i] += 10 - a[i]%10;
    }
    ans += a[i];
  }
  ans += a[4];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e5 * 3 + 10;
vector <ll> vec;
ll q;

int main() {
	fastInp;

	ll a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);

	cout << a << " " << b << " " << c;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
      int n;cin>>n;
      auto a = vec(ll,n+1);
      auto b = vec(ll,n);
      rep(i,n+1)cin>>a[i];
      rep(i,n)cin>>b[i];
      ll res = 0;
      rep(i,n){
          ll m = min(a[i],b[i]);
          a[i] -= m;b[i] -= m;
          res += m;
          ll l = min(a[i+1],b[i]);
          if(b[i]<=0)continue;
          a[i+1] -= l;b[i] -= l;
          res += l;
      }
      cout<<res;
    }
    


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

int main() {
    int n;
    int a[110];
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) {
        if (i == n-1) cout << a[i];
        else cout << a[i] << " ";
    }
    cout << endl;
    for (int i=1; i<n; i++) {
        int v = a[i];
        int j = i-1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for (int k=0; k<n; k++) {
            if (k == n-1) cout << a[k];
            else cout << a[k] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int n,m; cin >> n >> m;
 int x[m]; 
  rep(i,m){
    cin >> x[i];
  }
  sort(x,x+m);
  
  int y[m-1];
  rep(j,m-1){
    y[j] = x[j+1] - x[j];
  }
  sort(y,y+m-1);
  int sum = 0;
  rep(k,m-n){
    sum += y[k];
  }
  
  cout << sum;
 return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define PI 3.141592
using namespace std;


int main()
{
	//q1
	/*int r;
	cin >> r;
	double l = (double)r * 2.0 * PI;

	printf("%.6f", l);

	return 0;
*/

	//q2
	int n, m, tmp;
	cin >> n >> m;
	
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		n -= tmp;
	}

	if (n < 0) {
		printf("-1");
	} else {
		printf("%d", n);
	}

	return 0;

}



Measured memory_bytes: 3764
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
using namespace std;
typedef long long ll;
ll q, dp[555555], a[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll idx){
    if(idx == n)return 0;
    if(idx > n)return 1e16;
    ll &r = dp[idx];
    if(r != -1)return r;
    return r = min(abs(a[idx] - a[idx + 1]) + mem(idx + 1) , abs(a[idx] - a[idx + 2]) + mem(idx + 2));
}
int main() {
    memset(dp , -1 , sizeof dp);
    fast , cin >> n;
    for(ll i = 1 ; i <= n ; i++)cin >> a[i];
    cout << mem(1);
}


Measured memory_bytes: 24132
import sys
from collections import deque

K = int(sys.stdin.readline().rstrip())

deq = deque(range(9, 0, -1))
enqueue = deq.appendleft
dequeue = deq.pop

for _ in range(K):
	x = dequeue()
	y = x % 10
	if y != 0:
		enqueue(x * 10 + y - 1)
	enqueue(x * 10 + y)
	if y != 9:
		enqueue(x * 10 + y + 1)
print(x)


Measured memory_bytes: 11976
#include <cassert>
#include <cstdint>
#include <functional>
#include <tuple>
#include <vector>

template <typename Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using reference = value_type &;
  using const_reference = const value_type &;
  using size_type = std::uint_fast32_t;

private:
  using F = std::function<value_type(const_reference, const_reference)>;
  using G = std::function<value_type(const_reference)>;
  const F f;
  const G g;
  const value_type neutral_;
  std::vector<std::tuple<bool, size_type, value_type>> tree;

public:
  PotentializedUnionFind(const size_type size,
                         const_reference neutral = value_type(),
                         const F &f = std::plus<value_type>(),
                         const G &g = std::negate<value_type>())
      : f(f), g(g), neutral_(neutral),
        tree(size, std::forward_as_tuple(1, 1, neutral_)) {}
  size_type find(const size_type x) {
    assert(x < tree.size());
    if (std::get<0>(tree[x]))
      return x;
    const size_type t = std::get<1>(tree[x]);
    std::get<1>(tree[x]) = find(t);
    std::get<2>(tree[x]) = f(std::get<2>(tree[t]), std::get<2>(tree[x]));
    return std::get<1>(tree[x]);
  }
  value_type potential(const size_type x) {
    assert(x < tree.size());
    find(x);
    return std::get<2>(tree[x]);
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < tree.size());
    assert(y < tree.size());
    return f(potential(y), g(potential(x)));
  }
  bool unite(size_type x, size_type y, value_type d) {
    assert(x < tree.size());
    assert(y < tree.size());
    d = f(d, diff(y, x));
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (std::get<1>(tree[x]) < std::get<1>(tree[y]))
      std::swap(x, y), d = g(d);
    std::get<1>(tree[x]) += std::get<1>(tree[y]);
    tree[y] = std::forward_as_tuple(0, x, d);
    return true;
  }
  bool same(const size_type x, const size_type y) {
    assert(x < tree.size());
    assert(y < tree.size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < tree.size());
    return std::get<1>(tree[find(x)]);
  }
};
 
#include<iostream>
int main(void) {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n, 0);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

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

 
int main() {
  int n;
  cin >> n;
  vector<vector<ll>> a(n,vector<ll>(n,0));
  vector<vector<ll>> b(n,vector<ll>(n,0));
  rep(i,n)rep(j,n) cin >> a.at(i).at(j);
  
  rep(i,n)rep(j,n) b[i][j] = a[i][j];
  
  rep(k,n)rep(i,n)rep(j,n) a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
  
  rep(i,n)rep(j,n){
    if(a[i][j] != b[i][j]){
      cout << -1 << endl;
      return 0;
    }
  }
  
  ll sum = 0;
  rep(i,n)for(int j= i+1;j<n;j++){
    bool ok = true;
    rep(k,n){
      if(k== i || k == j) continue;
      if(a[i][j] == a[i][k] + a[k][j]) ok = false;
    }
    if(ok) sum += a[i][j];    
  }
      
  cout << sum << endl;    
  return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int a,b,c,d;
    int min,max;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    min=c;
    max=d;
    if(a>c)min=a;
    if(b<d)max=b;
   int ans=max-min;
    if(ans>=0){
        printf("%d\n",ans);
    }else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if(a>b){
        swap(a,b);
    }
    if((b-a)%2==0){
        ll ans = (b-a)/2;
        cout << ans << endl; 
    }else{
        ll s = a;
        s += (b-a)/2;
        ll t = n-b+1;
        t += (b-a)/2;
        cout << min(s,t) << endl;
    }
    
    return 0;
}

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


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

    char tmp = s[0];
    int ans = 1;
    rep(i,s.size()){
        if(s[i]!=tmp){
            ans++;
            tmp = s[i];
        }
    }

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

Measured memory_bytes: 512
import java.util.*;
import java.util.Map.Entry;

class Main {
	Scanner sc = new Scanner(System.in);

	public int des(int count,int index){
		if(count==n){
			int _s=0;
			for(int i=0;i<10;i++){
				if(use[i])_s+=i;
			}
			return (s==_s)?1:0;
		}
		int sum=0;
		for(int i=index;i<10;i++){
			if(!use[i]){
				use[i]=true;
				sum+=des(count+1,i+1);
				use[i]=false;
			}
		}
		return sum;
	}
	
	int n,s;
	boolean[] use=new boolean[10];
	public void run() {
		while(true){
			n=sc.nextInt();
			s=sc.nextInt();
			if(n==0 && s==0)break;
			ln(des(0,0));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = 1001001001;

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;

  while(n > 0) {
    n /= k;
    ans++;
  }

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



Measured memory_bytes: 888
#include <stdio.h>

int main(void){
  int a = 0;
  int b = 0;
  int res = 0;
  scanf("%d %d", &a, &b);
  for(int i = 0;i < 2;i++){
	if(a < b){
	  res = res + b;
	  b--;
	}else{
	  res = res + a;
	  a--;
	}
  }
  printf("%d\n", res);
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    int N;
    long M;
    scanf("%d%ld",&N,&M);

    //A[0]~A[N-1]に格納する
    long* A;
    NEW(A,N+1);
    for(int i=1;i<=N;i++){
        scanf("%ld",&A[i]);
    }

    //累積和(mod M)を入れる
    long* S;
    NEW(S,N+1);
    S[0]=0;
    for(int i=1;i<=N;i++){
        S[i]=(S[i-1]+A[i])%M;
    }
    qsort(S,N+1,sizeof(long),asc);

    long ans=0;
    long tmp=0;

    for(int i=1;i<=N;i++){
        if(S[i]==S[i-1]){
            tmp++;
        }
        else{
            ans+=tmp*(tmp+1)/2;
            tmp=0;
        }
    }
    ans+=tmp*(tmp+1)/2;
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
const double pi = acos(-1);
struct node {
	int x, y;
}a[200005];
bool operator < (const node & a, const node & b) {
	if(a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator == (const node & a, const node & b) {
	return a.x == b.x && a.y == b.y;
}
const int INF = 2000000000;
int x_1, x_2, y_1, y_2;
int n;
int f[200005];
int main() {
	scanf("%d%d%d%d", &x_1, &y_1, &x_2, &y_2);
	int bj = 1;
	if(x_1 > x_2) swap(x_1, x_2), bj *= -1;
	if(y_1 > y_2) swap(y_1, y_2), bj *= -1;
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%d%d", &a[i].x, &a[i].y);
		if(a[i].x < x_1) a[i].x = INF, a[i].y = INF;
		else if(a[i].x > x_2) a[i].x = INF, a[i].y = INF;
		else if(a[i].y < y_1) a[i].x = INF, a[i].y = INF;
		else if(a[i].y > y_2) a[i].x = INF, a[i].y = INF;
		else a[i].x *= bj;
	}
	sort(a + 1, a + 1 + n);
	while(a[n].x == INF) --n;
	int as = 0;
	rep(i, 1, n) {
		if(as == 0) f[++as] = a[i].y;
		else {
			int k = upper_bound(f + 1, f + 1 + as, a[i].y) - f;
			while(k <= as && f[k] < a[i].y) ++k;
			f[k] = a[i].y;
			as = max(as, k);
		}
	}
	printf("%0.15f", ((LL) x_2 - x_1 + y_2 - y_1) * 100.0 - (20 - 5 * pi) * as + ((as == min(x_2 - x_1 + 1, y_2 - y_1 + 1)) ? 5.0 * pi : 0));
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int n, k, q;
int a[110000];
int r[110000] = {0};

int main(){
    cin >> n >> k >> q;
    for (int i = 1; i <= q; i++)
    {
        cin >> a[i];
        ++r[a[i]];
    }
    for (int i = 1; i <= n; i++)
    {
        if(k>q-r[i]) cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
    }
}

Measured memory_bytes: 1408
n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(n)]
XY.sort(key=lambda x: x[0])
XY = [xy + [x] for x, xy in enumerate(XY)]
XY.sort(key=lambda x: x[1])
XY = [xy + [y] for y, xy in enumerate(XY)]

gr = [[0] * n for _ in range(n)]
for _, _, i, j in XY:
  gr[i][j] = 1
  
rui = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
  for j in range(n):
    rui[i + 1][j + 1] = rui[i + 1][j] + rui[i][j + 1] - rui[i][j] + gr[i][j]
    
# XYの2点,3点,4点を総当たり
ans = 10 ** 21
for i in range(n - 1):
  for j in range(i + 1, n):
    x = [XY[m][0] for m in [i, j]]
    y = [XY[m][1] for m in [i, j]]
    ii = [XY[m][2] for m in [i, j]]
    jj = [XY[m][3] for m in [i, j]]
    innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                + rui[min(ii)][min(jj)] \
                - rui[min(ii)][max(jj) + 1] \
                - rui[max(ii) + 1][min(jj)]
    if innerPoints >= k:
      area = (max(x) - min(x)) * (max(y) - min(y)) 
      if area < ans:
        ans = area

if n > 2:
  for i in range(n - 2):
    for j in range(i + 1, n - 1):
      for l in range(j + 1, n):
        x = [XY[m][0] for m in [i, j, l]]
        y = [XY[m][1] for m in [i, j, l]]
        ii = [XY[m][2] for m in [i, j, l]]
        jj = [XY[m][3] for m in [i, j, l]]
        innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                    + rui[min(ii)][min(jj)] \
                    - rui[min(ii)][max(jj) + 1] \
                    - rui[max(ii) + 1][min(jj)]
        if innerPoints >= k:
          area = (max(x) - min(x)) * (max(y) - min(y)) 
          if area < ans:
            ans = area

if n > 3:
  for i in range(n - 3):
    for j in range(i + 1, n - 2):
      for l in range(j + 1, n - 1):
        for o in range(l + 1, n):
          x = [XY[m][0] for m in [i, j, o, l]]
          y = [XY[m][1] for m in [i, j, o, l]]
          ii = [XY[m][2] for m in [i, j, o, l]]
          jj = [XY[m][3] for m in [i, j, o, l]]
          innerPoints = rui[max(ii) + 1][max(jj) + 1] \
                      + rui[min(ii)][min(jj)] \
                      - rui[min(ii)][max(jj) + 1] \
                      - rui[max(ii) + 1][min(jj)]
          if innerPoints >= k:
            area = (max(x) - min(x)) * (max(y) - min(y)) 
            if area < ans:
              ans = area

print(ans)

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
ll pm(int n,int p){
    ll ret = 1;
    ll now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	map<pair<ll,ll>,pair<int,int>>mp;
	int c0 = 0;
	f (n) {
		ll x, y;
		cin >> x >> y;
		if (y < 0) {
			x = -x;
			y = -y;
		}
		if (x == 0 && y == 0) {
			c0++;
		}
		else {
			ll g = abs(__gcd(x, y));
			x /= g;
			y /= g;
			if (x <= 0) {
				mp[{y, -x}].S++;
			}
			else {
				mp[{x, y}].F++;
			}
		}
	}
	ll ans = 1;
	for (auto &i : mp) {
		ll add = (pm(2, i.S.F) + pm(2, i.S.S) - 1 + mod) % mod;
		ans *= add;
		ans %= mod;
	}
	ans += mod - 1 + c0;
	ans %= mod;
	cout << ans << '\n';
}


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

int main() {
  int N, sum, temp;
  cin >> N;
  sum = 0;
  temp = N;

  while (temp != 0) {
    sum += (temp % 10);
    temp /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){
  vector<ll>a(5);
  
  rep(i,5){
    cin>>a[i];
    if(a[i]==0){
      cout<<i+1<<endl;
      break;
    }
    
  }
  }
   

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

#define ll long long
#define mod 998244353
#define mx 1000009

ll ans[mx];
ll sumsq[mx];
ll sqsum[mx];

vector<int>v[mx];

ll bigmod(ll n, ll p)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return (n + mod) % mod;
    if (p % 2)
        return (bigmod(n, p - 1) * n + mod) % mod;
    else
    {
        ll x = bigmod(n, p / 2);
        return (x * x + mod) % mod;
    }
}

ll modinverse(ll n)
{
    return bigmod(n, mod - 2) % mod;
}

void divisors()
{
    for (int i = 1; i < mx; i++)
    {
        for (int j = i; j < mx; j += i)
            v[j].push_back(i);
    }
}

///(a*b)/x+(b*c)/x+(c*a)/x=  (ab+bc+ca)/x
///(a+b+c)^2=a*a+b*b+c*c+2(ab+bc+ca)
///(ab+bc+ca)=((a+b+c)^2-(aa+bb+cc))/2


int main()
{
    // freopen("input.txt", "r", stdin);
    divisors();

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int val;

        scanf("%d", &val);

        for (int it : v[val])
        {
            sumsq[it] = ((sumsq[it] + val) % mod);
            sqsum[it] = (sqsum[it] + bigmod(val, 2)) % mod;
        }
    }

    ll re = 0;

    for (ll i = mx - 1; i >= 1; i--)
    {
        ll cur = (bigmod(sumsq[i], 2) - sqsum[i]);

        cur = (cur + mod) % mod;

        for (ll j = i + i; j < mx; j += i)
        {
            cur -= ans[j];
            cur = (cur + mod) % mod;
        }

        ans[i] = cur;

        re = (re + (cur * modinverse(i)) % mod) % mod;
    }

    re = (re * modinverse(2)) % mod;

    printf("%lld\n", re);




    return 0;
}

Measured memory_bytes: 141568
/*
 * Coder: @SumitRaut
 */
#include <bits/stdc++.h>

using namespace std;
inline void solve() {
    string s,t;
    cin>>s>>t;
    int ns=s.length(),nt=t.length();
    int ans=INT_MAX;
    for(int i=0;i<=ns-nt;++i) {
        int cnt=0;
        for(int j=0,k=i;j<nt;++j,++k) {
            if(s[k]!=t[j]) ++cnt;
        }
        if(cnt<ans) ans=cnt;
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t; cin>>t; while(t--)
        solve();
    return 0;
}


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

int main() {
  int N,M,SUM=0;
  cin>>N>>M;

  vector<int> A(N);
  rep(i,N){cin >> A.at(i);
          SUM+=A.at(i);}
  
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  int flg=0;
  
rep(i,N){if(A.at(i)*4*M>=SUM){flg++;if(flg>=M){break;}
                         }else{break;}
        }
  if(flg>=M){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(50);
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
  }
  int count;
  for(int j = 0; j < H; j++){
    for(int k = 0; k < W; k++){
      count = 0;
      if(S.at(j).at(k) == '.'){
        if(j != 0 && k != 0)
          if(S.at(j-1).at(k-1) == '#')
          	count++;
        if(j != 0)
          if(S.at(j-1).at(k) == '#')
          	count++;
        if(j != 0 && k != (W-1))
           if(S.at(j-1).at(k+1) == '#')
          	count++;
        if(k != 0)
           if(S.at(j).at(k-1) == '#')
          count++;
        if(k != (W-1))
          if(S.at(j).at(k+1) == '#')
          count++;
        if(j != (H-1) && k != 0)
          if(S.at(j+1).at(k-1) == '#')
          count++;
        if(j != (H-1))
          if(S.at(j+1).at(k) == '#')
          count++;
        if(j != (H-1) && k != (W-1))
           if(S.at(j+1).at(k+1) == '#')
          	count++;
        S.at(j).at(k) = '0' + count;
      }
    }
  }
  for(int l = 0; l < H; l++){
    cout << S.at(l) <<endl;
  }
}




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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

int main(){
    
    string s;
    cin >> s;
    
    int ret = 0;
    if(s.size()>=4 && s[0]=='Y' && s[1]=='A' && s[2] == 'K' && s[3]=='I')ret = 1;
    if(ret)printf("Yes\n");
    else printf("No\n");
}

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

int main(){
    string c1, c2;
    cin >> c1 >> c2;
    if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a , b , c , d , e;
  cin >> a;
  b = a / 100;
  c = a - ( b * 100 ) ;
  d = c / 10;
  e = c - ( d * 10);
  cout << b + d + e << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <functional>
#include <iomanip>

int main() {
	int n;
	std::cin >> n;

	std::priority_queue<double, std::vector<double>, std::greater<>> que;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		que.push(a);
	}

	while (que.size() >= 2) {
		double x = que.top(); que.pop();
		double y = que.top(); que.pop();

		que.push((x + y) / 2);
	}

	std::cout << std::fixed << std::setprecision(5) << que.top() << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c=0,a;
int main(){
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)cin>>b[i];
  sort(b.begin(),b.end());
  for(int i=1;i<a;i++)if(b[i-1]-b[i])c++;
  cout<<c+1<<endl;
}

Measured memory_bytes: 256