akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
int N, v[1002];
long double x[1002], y[1002], r[1002], g[1002][1002], dis[1002];
int main()
{
	scanf("%Lf%Lf%Lf%Lf%d", x, y, x + 1, y + 1, &N);
	N += 2;
	std::swap(x[1], x[N - 1]);
	std::swap(y[1], y[N - 1]);
	for (int i = 1; i < N - 1; i++)
		scanf("%Lf%Lf%Lf", x + i, y + i, r + i);
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			g[i][j] = std::max(0.0L, std::sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j]);
	for (int i = 1; i < N; i++)
		dis[i] = 1e100;
	do
	{
		int u = -1;
		for (int i = 0; i < N; i++)
			if (!v[i] && (!~u || dis[i] < dis[u]))
				u = i;
		if (!~u)
			break;
		v[u] = 1;
		for (int i = 0; i < N; i++)
			dis[i] = std::min(dis[i], dis[u] + g[u][i]);
	}
	while (1);
	printf("%.10Lf\n", dis[N - 1]);
	return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,ans,sum,a[N],b[N],dp[105][105];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
int dfs(int len,int lim,int zero,int last)
{
	if(len==0)return (zero==0);
	if(!lim&&!zero&&dp[len][last]!=-1)return dp[len][last];
	int ma=9;
	if(lim)ma=a[len];
	int res=0;
	for(int i=0;i<=ma;i++)
	{
		if(zero)
		{
			res+=dfs(len-1,lim&(i==ma),zero&(i==0),i);
		}
		else{
			if(abs(i-last)<=1)res+=dfs(len-1,lim&(i==ma),zero&(i==0),i);
		}
	}
	if(!lim&&!zero)dp[len][last]=res;
	return res;
}
int solve(int n)
{
	int len=0;
	while(n)
	{
		a[++len]=n%10;
		n=n/10;
	}
	return dfs(len,1,1,0);
}
signed main()
{
	memset(dp,-1,sizeof(dp));
	n=read();
	int l=1,r=1e18;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(solve(mid)<n)l=mid+1;
		else r=mid;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <queue>


/**
 * @Author MaxHeap
 **/


using namespace std;

bool all_even(vector<int> v){

	for(int i = 0; i < v.size(); i++) if(v[i] % 2 == 1) return false;
	return true;
}

int main(){

int n; cin >> n;
vector<int> v(n); for(int i = 0; i < n; i++) cin >> v[i];
int ans = 0;
while(all_even(v)){

	for(int i = 0; i < n; i++) v[i] /= 2;
	++ans;
}
cout << ans << endl;


}


Measured memory_bytes: 256
//author Eterna King
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
int a, b;
int main()
{
	cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (a < 6)cout << 0 << endl;
	else cout << b / 2 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();
    let x1: f64 = ws.next().unwrap().parse().unwrap();
    let y1: f64 = ws.next().unwrap().parse().unwrap();
    let x2: f64 = ws.next().unwrap().parse().unwrap();
    let y2: f64 = ws.next().unwrap().parse().unwrap();

    let dis = ((x1-x2).powi(2) + (y1-y2).powi(2)).sqrt();
    println!("{}", dis);
}



Measured memory_bytes: 5064
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

x = k()
if x <= 999:
    print("ABC")
else:
    print("ABD")


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

struct Node {
  int ParIdx, ParDepth, Deep; // Deep: HeavyEdge?????§?????±???
  int Size;
};
typedef vector< vector< int > > Graph;

int N, Q;
Graph graph;
int treesz[100000], sz;
Node nodes[100000];
vector< int > Nodes[100000];
int nowtreeIdx[100000], nowtreeDepth[100000]; 

int sizeDFS(int idx, int prev) {
  treesz[idx] = 1;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) treesz[idx] += sizeDFS(graph[idx][i], idx);
  }
  return(treesz[idx]);
}
void makeDFS(int idx, int prev, int treeIdx, int treeDepth, int ParDepth) {
  nodes[treeIdx].Size++;
  Nodes[treeIdx].push_back(idx);
  nowtreeIdx[idx] = treeIdx;
  nowtreeDepth[idx] = treeDepth;
  int ret = 0;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) ret = max(ret, treesz[graph[idx][i]]);
  }
  bool done = false;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) {
      if(treesz[graph[idx][i]] == ret && !done++) {
        makeDFS(graph[idx][i], idx, treeIdx, treeDepth + 1, ParDepth);
      } else {
        nodes[sz++] = (Node){ treeIdx, treeDepth, ParDepth + 1, 0};
        makeDFS(graph[idx][i], idx, sz - 1, 0, ParDepth + 1);
      }
    }
  }
}
void HL() { // ??????????§£
  sizeDFS(0, -1);
  sz = 0;
  nodes[sz++] = (Node){ -1, -1, 0, 0};
  makeDFS(0, -1, 0, 0, 0);
}
int main() {
  int N, Q;
  scanf("%d", &N);
  graph.resize(N);
  for(int i = 0; i < N; i++) {
    int k;
    scanf("%d", &k);
    for(int j = 0; j < k; j++) {
      int c;
      scanf("%d", &c);
      graph[i].push_back(c);
    }
  }
  HL();
  scanf("%d", &Q);
  for(int i = 0; i < Q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);

    int TreeIdxA = nowtreeIdx[u], TreeDepthA = nowtreeDepth[u];
    int TreeIdxB = nowtreeIdx[v], TreeDepthB = nowtreeDepth[v];
    while(TreeIdxA != TreeIdxB) {
      if(nodes[TreeIdxA].Deep > nodes[TreeIdxB].Deep) {
        TreeDepthA = nodes[TreeIdxA].ParDepth;
        TreeIdxA   = nodes[TreeIdxA].ParIdx;
      } else {
        TreeDepthB = nodes[TreeIdxB].ParDepth;
        TreeIdxB   = nodes[TreeIdxB].ParIdx;
      }
    }
    if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
    printf("%d\n", Nodes[TreeIdxA][TreeDepthA]);
  }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

struct Node {
    parent: u64,
    size: u64,
}

fn main() {
    let n: usize = read();

    let xuv: Vec<Vec<String>> = read_vec2(n);

    let mut ans: f32 = 0.0;

    for xu in xuv {
        let x: f32 = xu[0].parse().unwrap();
        if xu[1] == "JPY" {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>

const int MAXN = (int)3e5 + 1;

std::set<int> bomb_pos[MAXN];

int main() {
  int h, w, m;
  std::cin >> h >> w >> m;
  std::vector<int> col_bomb_num(w + 1);
  for (int i = 0, r, c; i < m; ++i) {
    std::cin >> r >> c;
    bomb_pos[r].insert(c);
    ++col_bomb_num[c];
  }

  std::vector<int> max_col;
  int max = 0;
  for (int i = 1; i <= w; ++i) {
    int cur = col_bomb_num[i];
    if (cur == 0) continue;
    if (cur > max) {
      max_col.clear();
      max_col.emplace_back(i);
      max = cur;
    } else if (cur == max) {
      max_col.emplace_back(i);
    }
  }

  max = 0;
  for (int i = 1; i <= h; ++i) {
    int cur = bomb_pos[i].size() + col_bomb_num[max_col[0]];
    if (max_col.size() <= bomb_pos[i].size()) {
      bool flag = true;
      for (const auto& c : max_col) {
        if (bomb_pos[i].find(c) == bomb_pos[i].end()) {
          flag = false;
          break;
        }
      }
      if (flag) --cur;
    }
    if (cur > max) max = cur;
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 34668
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String number = null;
        while(input.hasNext()){
            number = input.nextLine();
            char[] num = number.toCharArray();
            int sum = 0;
            if(num.length != 1 || num[0] != '0') {
                for(int i = 0; i < num.length; i ++)
                    sum += (num[i] - '0');
                System.out.println(sum);
            }
        }
    }
}


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

int main(){
    int N, M;
    cin >> N >> M;
    char A[N][N], B[M][M];
    string a, b;
    for (int i=0; i<N; i++){
        cin >> a;
        for (int j=0; j<N; j++){
            A[i][j] = a[j];
        }
    }
    for (int i=0; i<M; i++){
        cin >> b;
        for (int j=0; j<M; j++){
            B[i][j] = b[j];
        }
    }

    bool ok;
    for (int l1=0; l1<N-M+1; l1++){
        for (int l2=0; l2<N-M+1; l2++){
            ok = true;
            for (int i=0; i<M; i++){
                for (int j=0; j<M; j++){
                    if (A[l1+i][l2+j] != B[i][j]){
                        ok = false;
                    }
                }
            }
            if (ok){
                break;
            }
        }
        if (ok){
            break;
        }
    }
    if (ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,i;
	scanf("%d %d",&a,&b);
	for(i=1;i<=1000;i++)
	{
		int x,y;
		x=i*0.08;
		y=i*0.1;
		if(x==a&&y==b)
			break;
	}
	if(i==1001)
		printf("-1");
	else 
		printf("%d",i);
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    int n;cin>>n;
    vector<double>x(n),y(n),num(n);

    rep(i,n){
        cin>>x[i]>>y[i];
        num[i]=i;
    }

    double ans=0.0,cnt=0;
    do{
        cnt++;
        for (int i=0;i<n-1;i++) {
            double X=x[num[i]]-x[num[i+1]];
            double Y=y[num[i]]-y[num[i+1]];
            ans+=sqrt(X*X+Y*Y);
        }
    }while (next_permutation(num.begin(),num.end()));

    ans/=cnt;

    cout<<fixed<<setprecision(10)<<ans<<endl;

}



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

int main()
{
	int N, count = 0, flag = 0;
	string S;
	cin >> N;
	cin >> S;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'A') {
			if (S[i + 1] == 'B') {
				if (S[i + 2] == 'C') {
					count++;
					i += 2;
				}
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <algorithm>
using namespace std;
int main(){
    int r,c,z=1;

    char a[100][100];
    cin>>r>>c;
    for (int i=0;i<r;i++)
        for (int j=0;j<c;j++)
            cin>>a[i][j];

        for (int i=0;i<r;i++,z++) {
            for (int j=0;j<c;j++){
                cout<<a[i][j];
        }
            cout<<endl;
            if (z%2!=0)
                i--;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int a, b, k, tmp; cin >> a >> b >> k;
    vector<int> l;
    tmp = 0;
    for (int i = a; i < a + k; i++){ l.push_back(i); }
    for (int i = b; i > b - k; i--){ l.push_back(i); }
    sort(l.begin(), l.end());
    for (auto itr = l.begin(); itr != l.end(); ++itr)
    {
        if (tmp != *itr && *itr >= a && *itr <= b)
        {
            cout << *itr << endl;
            tmp = *itr;
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  while(A>0 && C>0) {
    if(C<=B) {
      C-=B;
      printf("Yes");
      break;
    }else {
      C-=B;
    }
    if(A<=D) {
      A-=D;
      printf("No");
      break;
    }else {
      A-=D;
    }
  }
  return 0;
}

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

S = INT()

X1 = 10**9
Y1 = 1


Y2 = -(-S//X1)
X2 = X1*Y2 - S

print(0, 0, X1, Y1, X2, Y2)

Measured memory_bytes: 10420
import java.util.Scanner;

class Main{

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    }
    
}

Measured memory_bytes: 165300
#include<bits/stdc++.h>
using namespace std;
struct node{
  int a,b,c;
  node(int x,int y,int z){
    a=x;
    b=y;
    c=z;
  }
  bool operator < (const node that) const {
    return a < that.a;
  }
};


struct person{
  int a,b;
  person(int x,int y){
    a=x;
    b=y;
  }
  bool operator < (const person that) const{
    return b < that.b;
  }
};



int main(){
  int n,q;
  cin>>n>>q;
  int s,t,x;
  vector<node> mp;
  for(int i=0;i<n;++i){
    cin>>s>>t>>x;
    mp.push_back(node(x,s-x,t-x));
  }
  sort(mp.begin(),mp.end());
  
  set<person> st;
  for(int i=0;i<q;++i){
    cin>>t;
    st.insert(person(i,t));
  }
  
  vector<int>result(q,-1);
  
  int l,h;
  for(int i=0;i<n;++i){
  	s = mp[i].b;
    t = mp[i].c;
    x = mp[i].a;
    
    
    auto it = st.lower_bound({0, s});
    while (it != st.end()) {
		if (it->b < t) {
			result[it->a] = x;
			st.erase(it++);
		} else {
			break;
		}
	} 
  }
  for(int i=0;i<q;++i){
    cout<<result[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 15088
#include<iostream>
#include<cstdio>
#define N (4009)
#define MOD (1000000000+7)
using namespace std;
long long n,m,k,sum[N],f[N][N][2],ans;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k); m--; k--;
	f[0][0][0]=1;
	for (int i=1; i<=n+m; ++i)
	{
		for (int j=0; j<=n; ++j)
			sum[j+1]=(sum[j]+f[i-1][j][0]+f[i-1][j][1])%MOD;
		for (int j=0; j<=n; ++j)
		{
			f[i][j][0]=(sum[j+1]-sum[j]+MOD)%MOD;
			f[i][j][1]=(sum[j]-sum[max(j-k,0ll)])%MOD;
		}
		for (int j=0; j<=n; ++j)
			if (j%k==n%k && (i*k-j)%k==m%k && i*k-j<=m)
				ans=(ans+f[i][j][1])%MOD;
	}
	printf("%lld\n",(ans+MOD)%MOD);
}

Measured memory_bytes: 245120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
int main()
{
	char s[100005];
	scanf("%s",s+1);
	if(s[1]=='Y'&&s[2]=='A'&&s[3]=='K'&&s[4]=='I')
	printf("Yes");
	else cout<<"No";
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, m;
        cin >> n >> m;
        vector<pair<ll, ll>> ab(n);
        rep(i, n) {
            ll a, b;
            cin >> a >> b;
            ab[i] = make_pair(a, b);
        }
        sort(ab.begin(), ab.end());
        ll ans = 0;
        ll idx = 0;
        while (m > 0) {
            ans += ab[idx].first;
            m--;
            ab[idx].second--;
            if (ab[idx].second == 0) idx++;
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int n;
char s[4010];
unordered_map<char, int> col = { { 'R', 0 }, { 'G', 1 }, { 'B', 2 } };
int main() {
    while (scanf("%d" , &n) == 1) {
        scanf("%s", s); 
        unordered_map<int, int> q;
        long long res = 0;
        for (int i = 0; i < n; i++) {
            int cb = col[s[i]];
            for (int j = i + 1; j < n; j++) {
                int cc = col[s[j]];
                if (cb == cc) continue;
                int ca = 3 - cb - cc;
                res += q[ca];
                int d = j - i;
                if (i - d >= 0 && col[s[i - d]] == ca) res--;
            }
            q[cb]++;
        }
        printf("%lld\n", res);
    }
}


Measured memory_bytes: 3796
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
#define MAX_N 1000000
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	ll res=0;
	REP(i,h-a) {
		res+=mod_comb(b-1+i,b-1)*mod_comb(w-b-1+(h-1-i),w-b-1);
		res%=MOD;
	}
	cout<<res<<endl;
}


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

int main() {
  int64_t N;
  cin>>N;
  int64_t Z=(N+1)*(N+1)*N/2;
  Z-=N*(N+1)*(2*N+1)/6;
  for(int i=1;i<N;i++){
    int64_t a,b;
    cin>>a>>b;
    if(a>b){
      swap(a,b);
    }
    Z-=a*(N+1-b);
  }
  cout<<Z<<endl;
}



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

int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  
  cout << w * h / 2 << endl;
  if (x == 0.5 * w && y == 0.5 * h) cout << '1' << endl;
  else cout << '0' << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long S = scanner.nextLong();
		long X1 = (S + 999999999) / 1000000000, X2 = X1 * 1000000000 - S;
		System.out.print(X1 + " 1 " + X2 + " 1000000000 0 0");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> p(n);
    REP(i,n) cin >> p[i];
    REP(i,n){
      int tmp=0,count=0;
      FOR(j,i,n){
	tmp+=p[j].size();
	if(tmp==5||tmp==12||tmp==17||tmp==24||tmp==31) ++count;
	if(tmp>=31) break;
      }
      if(count==5){
	cout << i+1 << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 3048
c = 0

def merge(A, l, m, r):
  global c
  L = A[l:m]
  L.append(1e10)
  R = A[m:r]
  R.append(1e10)
  i, j = 0, 0
  for k in range(l, r):
    c += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1

def sort(A, l, r):
  if r-l > 1:
    m = (l+r)//2
    sort(A, l, m)
    sort(A, m, r)
    merge(A, l, m, r)

N = int(input())
A = list(map(int, input().split()))
sort(A, 0, N)
print(" ".join(map(str, A)))
print(c)


Measured memory_bytes: 66780
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;

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

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl

ll getdelta(ll a, ll b, ll c) {
    ll maxval = max(a, max(b, c));
    ll minval = min(a, min(b, c));
    return maxval - minval;
}

ll solve(ll h, ll w) {
    ll res = LL_INF;
    for (int i = 1; i < w; i++) {
        res = min(res, getdelta(i * h, h / 2 * (w - i), (h - h / 2) * (w - i)));
        res = min(res, getdelta(i * h, (w - i) / 2 * h, (w - i - (w - i) / 2) * h));
    }
    return res;
}

int main() {
    //freopen(".in", "r", stdin);
    ll h, w;
    scanf("%lld%lld", &h, &w);
    ll ans = LL_INF;
    ans = min(solve(h, w), solve(w, h));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

int main(){
	ll n, m;
	cin >> n >> m;
	ll ans;
	ans = (2 * n + m) / 4LL;
	ans = min(ans, m / 2LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;  
ll n,t,m,c,x,y,sum,mx,mn,avg,pos,dif,j,dis;
vector<vector<int>>g;
bool vis[(int)1e5+2];
bool isPrime(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
void dfs (int node)
{
vis[node]=true;
for (auto i : g[node])
if (!vis[i])dfs(i);
}
int main(void) 
{ 
   
        SpeeD
       // int l;
         double mx,l;
        cin>>l;
        l/=3;
        mx=l*l*l;
    
printf("%lf", mx);}
    

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
int N,M,C;
int l[1<<17];
pair<int,int>p[1<<17];
int a[1<<17],cnt=0;
int main()
{
	cin>>N>>M>>C;
	for(int i=1;i<=C;i++)
	{
		cin>>l[i];
	}
	for(int i=0;i<N;i++)
	{
		cin>>p[i].first>>p[i].second;
		p[i].second*=-1;
	}
	sort(p,p+N);
	for(int i=0;i<N;i++)
	{
		if(l[p[i].first]>0)
		{
			a[cnt++]=-p[i].second;
			l[p[i].first]--;
		}
	}
	sort(a,a+cnt,greater<int>());
	long long ans=0;
	for(int i=0;i<M;i++)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4588
# 適当に入れてく感じ
# 3箇所なので8通りだけ
s = gets.chomp.chars.map(&:to_i)
operator = ["+", "-"]
operator.each do |a|
  operator.each do |b|
    operator.each do |c|
      ret = 0
      if a=="+"
        ret += s[0]+s[1]
      elsif a=="-"
        ret += s[0]-s[1]
      end
      if b=="+"
        ret += s[2]
      elsif b=="-"
        ret -= s[2]
      end
      if c=="+"
        ret += s[3]
      elsif c=="-"
        ret -= s[3]
      end
      if ret == 7
        puts s[0].to_s+a+s[1].to_s+b+s[2].to_s+c+s[3].to_s+"=7"
        exit
      end
    end
  end
end

Measured memory_bytes: 3836
#include <stdio.h>
#define N 100
#define MAX 1000000
int main(){
  int n, u, k, v, c, a[N][N], b[N], d[N], p[N];
  int i, j, min, min2;

  for (i = 0; i < N; i++) {
    d[i] = MAX-1;
  
    for (j = 0; j < N; j++) {
      a[i][j] = MAX-1;
    }
  }

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d %d", &v, &c);
      a[u][v] = c;
    }
  }

  d[0] = 0;

  for (j = 0; j < n; j++){
    min = MAX;
    for (i = 0; i < n; i++) {
      if (min > d[i] && b[i] != 1) {
        min = d[i];
        min2 = i;
      }
    }

    b[min2] = 1;
    for (i = 0; i < n; i++) {
      if (d[min2]+a[min2][i]<d[i] && b[i]!=1){
        d[i] = d[min2] + a[min2][i];
        p[min2] = i;
      }
    }
  }

  for (i = 0; i < n; i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}




Measured memory_bytes: 2112
#include<stdio.h>
int main(){
	int i,j,n=9;
	char str[12];
	int data[11],_data[11];
	for(;scanf("%s",str)!=EOF;n=9){
		for(i=0;i<10;i++)data[i]=str[i]-'0';
		for(i=0;i<10;i++,n--){
			for(j=0;j<n;j++)_data[j]=(data[j]+data[j+1])%10;
			for(j=0;j<n;j++)data[j]=_data[j];
		}
		printf("%d\n",data[0]);
	}
	return 0;
}

Measured memory_bytes: 0
import queue
N=int(input())
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
c=[0 for i in range(N-1)]
VL=[dict() for i in range(N)]
for i in range(N-1):
    a[i],b[i],c[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    VL[a[i]][b[i]]=c[i]
    VL[b[i]][a[i]]=c[i]
Q,K=map(int,input().split())
K-=1
x=[0 for i in range(Q)]
y=[0 for i in range(Q)]
for i in range(Q):
    x[i],y[i]=map(int,input().split())
    x[i]-=1
    y[i]-=1
reached=[False for i in range(N)]
dist=[0 for i in range(N)]
q=queue.Queue()
q.put(K)
reached[K]=True
while(not(q.empty())):
    r=q.get()
    for v in VL[r]:
        if not(reached[v]):
            q.put(v)
            dist[v]=VL[r][v]+dist[r]
            reached[v]=True
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])


Measured memory_bytes: 113436
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;
const int nax = 1e5+5;




int main() {
    IOS

    int n;
     cin>>n;

     unordered_set<int>st;

     for(int i = 1; i <= 9; i++){
         for(int j = 1; j <= 9; j++){
             st.insert(i*j);
         }
     }

     if(st.find(n) != st.end())
         cout<<"Yes";
     else
         cout<<"No";



}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

a, b = inpl()
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void solve(){
    int n,m,in;
    cin>>n>>m;
    int A[n];
    ll sm=0;
    for(int i=0;i<n;i++){
        cin>>in;
        sm+=in;
        A[i]=in;
    }
    sort(A,A+n,greater<int>());
    int tmp=m;
    for(int i=0;i<m;i++){
        if(A[i]*(4*m)<sm){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
void trials(){
    int t;
    for(cin>>t;t--;cout<<endl){
        solve();
    }
}
int main(){
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;


int main()
{      
    string x;
    cin >> x;
    
    string capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        
    for(int i=0; i<capital.length(); i++){
        if(x == capital.substr(i, 1)){
            cout << "A" << endl;
            return 0;
        }
    }
    cout << "a" << endl;
    return 0;

}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_point = 100000+10;
int N;
vector<int> adj[2*max_point];
vector<Int> cnt;
bool visited[2*max_point];

void dfs(int v) {
    if(visited[v])
        return;

    visited[v] = true;
    cnt[v/max_point]++;
    for(auto u: adj[v])
        dfs(u);
}

int main(void) {
    cin>>N;
    
    for(int i = 0;i < N;i++) {
        int x,y;
        cin>>x>>y;
        y += max_point;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    Int ans = 0;
    for(int i = 0;i < 2*max_point;i++) {
        if(visited[i])
            continue;

        cnt = vector<Int>(2);
        dfs(i);
        ans += cnt[0]*cnt[1];
    }

    cout<<ans-N<<endl;

    return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
using namespace std;
int N, F[105][10], P[105][11];
int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> F[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= 10; ++j) {
			cin >> P[i][j];
		}
	}
	int maxprofit = -(1 << 30);
	for (int i = 1; i < 1 << 10; ++i) {
		int profit = 0;
		for(int j = 0; j < N; ++j) {
			int cnt = 0;
			for (int k = 0; k < 10; ++k) {
				if (((i >> k) & 1) && F[j][k] == 1) {
					++cnt;
				}
			}
			profit += P[j][cnt];
		}
		maxprofit = max(maxprofit, profit);
	}
	cout << maxprofit << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int findNum(string str, char c, int start, int end) {
    int num = 0;
    for (int i = start; i < end; ++i) {
        if (str[i] == c) {
            ++num;
        }
    }
    return num;
}

int main(void) {
    string cubes;
    cin >> cubes;
    int u0, u1, d0, d1;
    u0 = findNum(cubes, '0', 0, cubes.size() / 2);
    u1 = findNum(cubes, '1', 0, cubes.size() / 2);
    d0 = findNum(cubes, '0', cubes.size() / 2, cubes.size());
    d1 = findNum(cubes, '1', cubes.size() / 2, cubes.size());

    cout << cubes.size() - (abs(u0 - d1) + abs(u1 - d0)) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		String S = scan.next();

		List<String> A = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			A.add(String.valueOf(S.charAt(i)));
		}

		int count = 1;
		for(int i = 0; i < N -1; i++) {
			if(!(A.get(i).equals(A.get(i+1)))) {
				//System.out.println(A.get(i)+"と"+A.get(i + 1)+"が違う");
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 30272
#include<stdio.h>
#include<string.h>
#define N 2000
#define M 1001
#define O 0
#define I 1

char s1[N];
char s2[N];

int LCS(int,int);

int main(){
  int sumstring,i,j,k;
  scanf("%d",&sumstring);
  for(i=O;i<sumstring;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",LCS(strlen(s1),strlen(s2)));
  }
  return O;
}

int LCS(int len1,int len2){
  int i,j,x,ans[M][M];
  x=O;

  for(i=O;i<len1;i++){
    ans[i][O]=O;
  }
  for(i=O;i<len2;i++){
    ans[O][i]=O;
  }
  for(i=O;i<len1;i++){
    for(j=O;j<len2;j++){
      if(s1[i]==s2[j] && s1[i]!=' ' && s2[i] != ' '){
        if(i==O || j==O){
          ans[i][j]=I;
        }
        else{
          ans[i][j]=ans[i-I][j-I]+I;
        }
      }
      else{
        if(i==O && j!=O){
          ans[i][j]=ans[O][j-I];
        }
        else if(i!=O && j==O){
          ans[i][j]=ans[i-I][O];
        }
        else if(i==O && j==O){
          ans[O][O]=O;
        }
        else if(i!=O && ans[i-I][j] > ans[i][j-I]){
          ans[i][j]=ans[i-I][j];
        }
        else if(ans[i-I][j] <= ans[i][j-I]){
          ans[i][j]=ans[i][j-I];
        }
      }
    }
  }
  return ans[len1-I][len2-I];
}



Measured memory_bytes: 5736
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

const int MAX_N = 3000;
double dp[MAX_N][MAX_N]; //dp[i][j] // i枚目まで見たとき，表がj枚出る確率

int main() {
    int N; cin >> N;
    double p[N]; rep(i, N) cin >> p[i];
    dp[0][0] = 1;
    rep(i, N) {
        for(int j = 0; j <= N; ++j) {
            if(j == 0) {
                dp[i + 1][j] = dp[i][j] * (1.0 - p[i]);
            }else {
                dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1.0 - p[i]);
            }
        }
    }
    double ans = 0.0;
    for(int i = N / 2 + 1; i <= N; ++i) {
        ans += dp[N][i];
    }
    cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
	
int main()
{
    speed;
    int n,m;cin>>n>>m;
    int k;cin>>k;
    map<int,int> mx,my;
    vector<pair<int,int>> v;
    while(k--)
    {
	    int a,b;
	    cin>>a>>b;
	    v.pb({a,b});
	    mx[a]++;
	    my[b]++;
    }
    int maxx=INT_MIN;
    int maxy=INT_MIN;
    int maxo,mayo;
    
    int ans=0;
    
    for(auto u:mx)
    {
	    if(maxx<=u.ss)
	    {
		    maxx=u.ss;
		    maxo=u.ff;
	    }
	    
    }

    for(auto u:my)
    {
	    if(maxy<=u.ss)
	    {
		    maxy=u.ss;
		    mayo=u.ff;
	    }
    }

    if(maxx>=maxy)
    {

	for(auto u:v)
	{
		if(u.ff==maxo)
		{
			my[u.ss]--;
		}
	}
	maxy=INT_MIN;
	 for(auto u:my)
	{
		if(maxy<=u.ss)
		{
			maxy=u.ss;
			mayo=u.ff;
		}
	}
    }
    else
    {
	for(auto u:v)
	{
		if(u.ss==mayo)
		{
			mx[u.ff]--;
		}
	}
	maxx=INT_MIN;
	for(auto u:mx)
	{
		if(maxx<=u.ss)
		{
			maxx=u.ss;
			maxo=u.ff;
		}
		
	}

    }

    

    //cout<<maxo <<" dsfgh "<<mayo<<endl;

    

    for(auto u: v)
    {
	    if(u.ff==maxo)
	    {
		    ans++;
		   // cout<<u.ff<<" "<<u.ss<<endl;
	    }
	    else if(u.ss==mayo)
	    {
		    ans++;
		  //  cout<<u.ff<<" "<<u.ss<<endl;
	    }
    }
    
    cout<<ans<<endl;


}
	
	


Measured memory_bytes: 33676
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << 0.5000000000 << endl;
  }
  else {
    cout << (N + 1.0) / 2.0 / N << endl;
  }

}


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


int main() {
	
	int n, m;
	cin >> n >> m;
	vector<int> wa(n+1);
	int pe=0;
	set<int> a;
	for(int i=0; i<m; i++){
		int p;
		string s;
		cin >> p >> s;
		if(a.count(p)) continue;
		if (s == "AC") {
			a.insert(p);
		}
		else{
			wa.at(p)++;
		}
	}
	for(int i=0; i<=n; i++) if(a.count(i)) pe += wa.at(i);
	cout << a.size() << " "<< pe << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
using namespace std;

int main(int argc, char const *argv[]) {
  string x;
  std::cin >> x;
  deque<int> st;
  st.push_back(-1);
  range(i, x.size()){
    if(st.back() == 1 && x[i] == 'T') st.pop_back();
    else st.push_back((x[i]=='T')?0:1);
  }
  std::cout << st.size() - 1 << '\n';
  return 0;
}


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

int main(){
	float input;
	while(cin >> input){
		if(input <= 48.00) cout << "light fly" << endl;
		else if(input <= 51.00) cout << "fly" << endl;
		else if(input <= 54.00) cout << "bantam" << endl;
		else if(input <= 57.00) cout << "feather" << endl;
		else if(input <= 60.00) cout << "light" << endl;
		else if(input <= 64.00) cout << "light welter" << endl;
		else if(input <= 69.00) cout << "welter" << endl;
		else if(input <= 75.00) cout << "light middle" << endl;
		else if(input <= 81.00) cout << "middle" << endl;
		else if(input <= 91.00) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	string a, b, c;
	cin>>a>>b>>c;
	int ans = 0;
	for(int i=0; i<n; i++){
		if(a[i]==b[i] && b[i]==c[i]){
			continue;
		}
		if(a[i]==b[i]){
			ans++;
		}else if(a[i]==c[i]){
			ans++;
		}else if(b[i]==c[i]){
			ans++;
		}else{
			ans+=2;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
A = [0 for _ in range(20)]
X = [[0 for _ in range(20)] for _ in range(20)]
Y = [[0 for _ in range(20)] for _ in range(20)]

def counter(x):
    if x == 0:
        return 0
    else:
        return counter(x >> 1) + (x & 1)

n = int(input())

for i in range(1, n+1):
    A[i] = int(input())
    for j in range(1, A[i]+1):
        X[i][j], Y[i][j] = map(int, input().split())


ans = 0
for bits in range(1, (1 << n)):
    ok = True
    for i in range(1, n+1):
        if not (bits & (1 << (i-1))):
            continue
        for j in range(1, A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]): ok = False
    if(ok): ans = max(ans, counter(bits))

print(ans)

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

ll ex(char x){
  return ll(x-'0');
}

int main(){
  string S;cin >> S;
  reverse(S.begin(),S.end());
  ll N = S.size();
  vector<ll> count(2019,0);
  count[0] += 1;
  ll sum = 0;
  ll P = 1;
  for(int i=0;i<N;i++){
    sum += ex(S[i])*P;
    sum %= 2019;
    count[sum] ++;
    P = P * 10 % 2019;
  }
  ll ans = 0;
  for(int i=0;i<2019;i++){
    ll x = count[i];
    ans += x*(x-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3704
import sys
sys.setrecursionlimit(10**7)
from collections import deque
from heapq import heappush, heappop
def solve():
    H,W = map(int, input().split())
    A = [ list(input()) for _ in range(H)]
    HMANY = [ [10**9] * W for _ in range(H)]
    
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" :
                HMANY[h][w] = 0
    for w in range(W):
        for h in range(H-1):
            if HMANY[h][w]+1 < HMANY[h+1][w]:
                HMANY[h+1][w] = HMANY[h][w] + 1
        for h in range(H-1, 0, -1):
            if HMANY[h][w]+1 < HMANY[h-1][w]:
                HMANY[h-1][w] = HMANY[h][w] + 1
    
    for h in range(H):
        for w in range(W-1):
            if HMANY[h][w]+1 < HMANY[h][w+1]:
                HMANY[h][w+1] = HMANY[h][w] + 1
        for w in range(W-1, 0, -1):
            if HMANY[h][w]+1 < HMANY[h][w-1]:
                HMANY[h][w-1] = HMANY[h][w] + 1        

    ans = 0
    for h in range(H):
        ans = max(ans, max(HMANY[h]))
    # print(ans-1)
    print(ans)

if __name__ == "__main__":
    solve()

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

typedef long long ll;
ll inf = 1e13;

const int N = 120, V = 1e3 + 20;
pair<ll, ll> a[N];
ll dp[N][N * V];

int main()
{
	ll n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i].first >> a[i].second;
	}
	dp[0][0] = 0;
	for (int i = 1; i <= 1010 * n; i++)
	{
		dp[0][i] = inf;
	}
	ll mx = 0;
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 0; j <= 1005 * n; j++)
		{
			if (a[i].second > j)
			{
				dp[i][j] = dp[i - 1][j];
				if (dp[i][j] <= w) mx = max(mx, j);
				continue;
			}
			dp[i][j] = min(dp[i - 1][j], a[i].first + dp[i - 1][j - a[i].second]);
			if (dp[i][j] <= w) mx = max(mx, j);
		}
	}
	cout << mx;
}


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

typedef long long ll;

int n;

vector<int>v;
vector<ll>wt;

ll w;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>w;
	v.resize(n);
	wt.resize(n);
	
	ll sum=0;
	for(int i=0;i<n;i++)
	{
	  cin>>wt[i]>>v[i];
	  sum+=v[i];
	  
	  }
	  
	  
	 vector<ll>dp(sum+1,1e11);
	 dp[0]=0;
	 for(int i=0;i<n;i++)
	 {
	 
	   for( int val=sum-v[i] ; val>=0;val--)
	   {
			dp[val+v[i]]=min( dp[val+v[i]],dp[val]+wt[i]);
		}
	  }
	  
	  
	  ll ans=0;
	  
	  for( int i=1 ; i<=sum;i++)
	  {  if(dp[i]<=w)
	     ans=max(ans,(ll)i);
	   }  
	     cout<<ans<<endl;
	

return 0;
}


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

int main(){
	int X;
  	cin >> X;
  	vector<int> vec;
  	int a = 1;
  	int b;
  	int bb;
  	vec.push_back(1);
  	while(true){
    	a++;
      	b = a;
      	bb = b*b;
      	while(true){
        	if(bb > X){
            	break;
            }
          	//cout << bb << endl;
          	vec.push_back(bb);
        	bb = bb*b;
        }
		if(b > X){
            	break;
        }
      	
    }
	
  	auto max = *max_element(vec.begin(),vec.end());

    	cout << max<<endl;


}

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

int main(){

  long long X;
  cin >> X;

  long long savings = 100; //現在の貯金額
  int i =0;  //預けてから何年目か
  while( savings < X ){

     savings = (long long)( savings * 1.01 );
     i++;

  }    

  cout << i << endl;

}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

struct graph {
	struct edge {
		int a, b;
		bool isDirected = true; // 向きが決定されたか
		bool dir = true; // trueならa -> b
	};

	int n, m;
	vector<edge> e;
	vector<vector<edge*>> g;
	vector<int> cnt;

	graph(int n, int m) {
		this->n = n; this->m = m;
		g.resize(n); e.resize(m);
		cnt.resize(n, 0);
		for (int i = 0; i < m; ++i) {
			int ai, bi; cin >> ai >> bi;
			--ai, --bi;
			e[i].a = ai; e[i].b = bi;
			e[i].isDirected = true; e[i].dir = true;
			g[ai].push_back(&e[i]);
			g[bi].push_back(&e[i]);
		}
	}

	// 0を根とする根付き木の辺の向きを不定にする
	void dfs(int s = 0) {
		static vector<bool> visited(n, false);
		visited[s] = true;
		for (edge* ed : g[s]) {
			int nx = (*ed).a == s ? (*ed).b : (*ed).a;
			if (!visited[nx]) {
				(*ed).isDirected = false;
				dfs(nx);
			}
		}
	}

	// 各頂点について、何本辺が(今のところ)出ているか調べる
	void count() {
		for (edge ei : e) {
			if (ei.isDirected) {
				if (ei.dir) ++cnt[ei.a];
				else ++cnt[ei.b];
			}
		}
	}

	// 根付き木の辺の向きを決定していく
	void solve(int s = 0) {
		static vector<bool> visited(n, false);
		visited[s] = true;
		for (edge* ed : g[s]) {
			int nx = (*ed).a == s ? (*ed).b : (*ed).a;
			if ((!(*ed).isDirected) && (!visited[nx])) solve(nx);
		}
		for (edge* ed : g[s]) {
			if ((*ed).isDirected) continue;
			if (cnt[s] & 1) { // 自分から生やす
				if ((*ed).a != s) (*ed).dir = false;
				++cnt[s];
			}
			else { // 自分に向ける
				if ((*ed).a == s) (*ed).dir = false;
				++cnt[(*ed).b != s ? (*ed).b : (*ed).a];
			}
			(*ed).isDirected = true;
		}
	}

	// 出力する
	void show() {
		for (auto ed : e) {
			if (ed.dir)
				cout << (ed.a + 1) << " " << (ed.b + 1) << endl;
			else
				cout << (ed.b + 1) << " " << (ed.a + 1) << endl;
		}
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	if (m & 1) { // mが奇数の時は不可
		cout << -1 << endl;
	}
	else { // mが偶数の時は構築可
		graph g(n, m);
		g.dfs();
		g.count();
		g.solve();
		g.show();
	}
	return 0;
}

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

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

	int n;
	long long int temp;
	set<long long int> s;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		s.insert(temp);
		if (s.size() != i + 1)
		{
			cout << "NO"; return 0;
		}
	}
	cout << "YES";


	return 0;
}

Measured memory_bytes: 9600