akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

n,m,r = li()
r = list(li_())
abc = []
graph = np.zeros((n,n))
for _ in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
    
floyd_warshall(graph, directed=False, overwrite=True)

routes = list(permutations(r))

ans = float("inf")
for route in routes:
    cand = 0
    for i in range(len(route)-1):
        cand += graph[route[i]][route[i+1]]
        
    ans = min(ans, cand)
        
print(int(ans))

Measured memory_bytes: 29948
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, x: "List[int]", y: "List[int]"):
    ds = []
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx = x[j] - x[i]
            dy = y[j] - y[i]
            ds.append((dx, dy))

    return 1 if N == 1 else (N - max(Counter(ds).values()))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    result = solve(N, x, y)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    int flag = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < (int)s.length(); ++i){
        if(s[i] != t[i]){
            flag = 1;
            break;
        }
    }
    if(flag == 1) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N; cin >> N; char S; string ans="Three";
REP(i, N){ cin >> S; if(S=='Y'){ ans="Four"; } }
cout << ans << "\n";
}

Measured memory_bytes: 3616
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int D=sc.nextInt();
		int X[][]=new int[N][D];
		int Distsq=0;
		double Residue;
		int count=0;
		for(int i=0;i<N;i++) {
			for(int j=0;j<D;j++) {
				X[i][j]=sc.nextInt();
			}
		}
		for(int k=0;k<(N-1);k++) {
			for(int l=(k+1);l<N;l++) {
				for(int m=0;m<D;m++) {
					Distsq+=(int)Math.pow((X[k][m]-X[l][m]),2);
				}
				Residue=Math.sqrt(Distsq)-Math.round(Math.sqrt(Distsq));
				if(Residue==0) {
					count++;
				}
				Distsq=0;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e3 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



int main() {
    fast;

    ll ar[N], n, x, tmp;
    unordered_map<int, bool> M;

    cin >> x >> n;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        M[tmp] = true;
    }

    int l = x, r = x, ans;
    while( (M[l] && M[r]) ) l--,r++;

    if(!M[r]) ans = r;
    if(!M[l]) ans = l;


    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3620
local n = io.read("*n")
local a = io.read("*n")
local b = io.read("*n")
local function add(n,a,b)
	if b < a then
		print(0)
		return
	end
	if n == 1 then
		if a ~= b then
			print(0)
			return
		else
			print(1)
			return
		end
	elseif n == 2 then
			print(1)
			return
	end
	local total = a + b
	local min = total + (n - 2) * a
	local max = total + (n-2)*b
	print( max - min + 1)
end

add(n,a,b)

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

int main(){

    int x, y ,z, cont = 1;

    scanf("%d %d %d", &x, &y, &z);

    int esp_sem_z = x - (2*z);

    while (esp_sem_z) {
        esp_sem_z -= y;
        if (esp_sem_z >= (y+z)) {
            esp_sem_z -= z;
            cont++;
        } else
            break;
    }

    printf("%d\n", cont );

    return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();

  ll s, t, d;

  cin >> s >> t >> d;

  ll lmin = 0, sum = 0;
  int a[d + 1];
  for (int i = 0; i < d; i++) {
    int x;
    cin >> x;
    a[i] = x;
    sum += x;
    lmin = min (lmin, sum);
  }
  ll days = 0;
  while (s + lmin > t && sum < 0)
    days += d, s += sum;
  for (int i = 0; i < d; i++) {
    s += a[i];
    if (s <= t) {
      cout << days + i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  


  return 0;
}






// Coded by Z..e


Measured memory_bytes: 3540
s = input()
f = 0
for i in range(len(s)):
  if (i + 1) % 2 == 1 and not (s[i] == 'R' or s[i] == 'U' or s[i] == 'D'):
    f = 1
  if (i + 1) % 2 == 0 and not (s[i] == 'L' or s[i] == 'U' or s[i] == 'D'):
    f = 1
if f:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
        var k, s int
        fmt.Scan(&k, &s)
        var numOfSatisfied int
        for x := 0; x <= k; x++ {
                for y := 0; y <= k; y++ {
                        rest := s - (x + y)
                        if rest >= 0 && rest <= k {
                                numOfSatisfied++
                        }
                }
        }
        fmt.Printf("%d\n", numOfSatisfied)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
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;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int H, W; cin >> H >> W;
  int a[H][W];
  rep(row,H) rep(col,W) cin >> a[row][col];

  vector<tuple<int,int,int,int>> log; 
  
  rep(row,H){
    rep(col,W-1){
      if (a[row][col]%2) {
        --a[row][col];
        ++a[row][col+1];
        log.emplace_back(row+1,col+1,row+1,col+2);
      }
    }
  }
  rep(row,H-1){
    if (a[row][W-1]%2) {
      --a[row][W-1];
      ++a[row+1][W-1];
      log.emplace_back(row+1,W,row+2,W);
    }
  }

  cout << log.size() << endl;
  rep(i,(int)log.size()){
    cout << get<0>(log[i]) << " " << get<1>(log[i]) << " " << get<2>(log[i]) << " " << get<3>(log[i]) << endl;
  }


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 6348
n,m=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for _ in range(m)]

BC.sort(key=lambda x:(x[1],x[0]),reverse=True)
cnt=0
for b,c in BC:
  for _ in range(b):
    if cnt>=n: break
    A.append(c)
    cnt+=1
A.sort(reverse=True)
print(sum(A[:n]))

Measured memory_bytes: 40900
import sys
def input(): return sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def size(self,x):
        #xが属するグループの要素数
        return -self.parents[self.find(x)]
    def same(self,x,y):
        #xとyが同じグループ？
        return self.find(x)==self.find(y)
    def members(self,x):
        #xと同じグループに属する要素のリスト
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        #全ての根の要素のリスト
        return [i for i, x in enumerate(self.parents) if x<0]
    def group_count(self):
        #グループの数
        return len(self.roots())
    def all_group_members(self):
        #各ルート要素のグループに含まれる要素のリストの辞書
        return {r: self.members(r) for r in self.roots()}
    def all_group_members_list(self):
        #各ルート要素のグループに含まれる要素のリストのリスト
        #[[0, 2], [1, 3, 4, 5]]
        return list(self.all_group_members().values())
    def __str__(self):
        #各ルート要素のグループに含まれる要素のリストをprint()
        return '\n'.join('{}: {}'.format(r,self.members(r)) for r in self.roots())

def main():
    n, m = map(int,input().split())
    AB_union = UnionFind(n)
    for i in range(m):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        AB_union.unite(a, b)
    print(AB_union.group_count() - 1)



if __name__=='__main__':
    main()

Measured memory_bytes: 72364
#coding: UTF-8

while True:
    N, X = map(int, input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for i in range(1, N+1):
        for j in range(1, N+1):
            if i >= j:
                continue
            c = X - (i + j)
            if c > j and c <= N:
                ans += 1
    print("%d"%(ans))



Measured memory_bytes: 5592
from fractions import gcd

def solve(a, b, c, d):
    if a < b or d < b:
        return False

    if c >= b - 1:
        return True

    g = gcd(b, d)
    return (b + a % g - g) <= c

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    if solve(*t):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 5472
let i=readLine()!.characters.split(" ").map{Int(String($0))!},N=i[3]
var ans=0
for r in 0...N {
    for g in 0...N {
        let b = N-r*i[0]-g*i[1]
        if b>=0&&b%i[2]==0 {
            ans++
        }
    }
}
print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    int ans=min(b,d)-max(a,c);
    if(ans<0)ans=0;
    cout <<ans <<endl;
    return 0;
}

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

typedef long long ll;

const int MAX_N = 1e5 + 5;;
int lp[MAX_N];
int pr[MAX_N];
int ind;
int psum[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 2; i < MAX_N; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr[ind++] = i;
		}

		for (int j = 0; j < ind && pr[j] <= lp[i] && i * pr[j] < MAX_N; j++)
			lp[i * pr[j]] = pr[j];
	}

	for (int i = 3; i < MAX_N; i++) {
		psum[i] = psum[i - 1];
		if (lp[i] == i && lp[(i + 1) / 2] == (i + 1) / 2)
			psum[i]++;
	}

	int q;
	cin >> q;

	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << psum[r] - psum[l - 1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1536
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  l64 a, b;
  string op;
  cin >> a >> op >> b;
  cout << (op == "+" ? a+b : a-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



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

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  pair<int, int> p[100001];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(b,a);
  }
  sort(p, p+m);
  int tmp = 0;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if(tmp < p[i].second) 
    {
      tmp = p[i].first - 1;
      ans++;;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int a,b,c,d,t;

int gett(int x,int y){
	int l=1,r=max(a,b),ret=0;
	while(l<=r){
		int mid=(l+r)/2;
		if((max(a,b)-1)/mid<=min(a,b)) ret=mid,r=mid-1;
		else l=mid+1;
	}
	return ret;
}

bool check(int x){
	int ta=x/(t+1)*t+x%(t+1),tb=x/(t+1);
	if(ta>a||tb>b) return false;
	if(x%(t+1)==0&&x) return (b-tb)/t<=a-ta;
	else return (b-tb-1)/t<=a-ta;
}

int main(){
	int T=readint();
	while(T--){
		a=readint(); b=readint(); c=readint(); d=readint();
		t=gett(a,b);
		int l=0,r=a+b,pl=-1;
		while(l<=r){
			int mid=(l+r)/2;
			if(check(mid)) pl=mid,l=mid+1;
			else r=mid-1;
		}
		if(d<=pl){
			for(int i=c;i<=d;i++) printf("%c",i%(t+1)==0?'B':'A');
		}
		else if(c<=pl){
			for(int i=c;i<=pl;i++) printf("%c",i%(t+1)==0?'B':'A');
			for(int i=pl+1;i<=d;i++) printf("%c",(a+b-i+1)%(t+1)==0?'A':'B');
		}
		else{
			for(int i=c;i<=d;i++) printf("%c",(a+b-i+1)%(t+1)==0?'A':'B');
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// 二項係数計算
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  
  int n,m;cin>>n>>m;
  if (n==m) {
    cout << (2*fac[n]*fac[n])%MOD;
  } else if (abs(n-m)==1) {
    cout << (fac[n]*fac[m]) %MOD;
  } else cout << 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    vector<int> a(n);
    bool flg = true;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0)
                flg = true;
            else if (a[i] % 5 == 0)
                flg = true;
            else
                flg = false;
        }
        if (!flg)
            break;
    }
    if (flg)
    {
        c("APPROVED")
    }
    else
    {
        c("DENIED");
    }

    return 0;
}

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

int main(){
  ll n, m;
  cin >> n;
  m = n;

  stack<ll> num;
  ll t = 0;
  while(1){
    t = m % (-2);
    if(t != 0 && m < 0){
      t *= -1;
      m = (m - 2) / (-2);
    }else{
      m /= (-2);
    }  
    num.push(t);
    if(m == 0) break;
  }

  ll size = num.size();
  for(int i = 0; i < size; i++){
    cout << num.top();
    num.pop();
  }
  cout << endl;

  return 0;

}

Measured memory_bytes: 256
/*input
6 2 4

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vii;
#define pb push_back
#define print(a) for(auto x:a){cout<<x<<' ';}cout<<endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n, a, b;cin>>n>>a>>b;
	int ans = n/(a+b);ans *= a;
	ans += min(a, n%(a+b));
	cout<<ans<<endl;
    
}

signed main(){
	IOS
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

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

using namespace std;

int main(){
  int N; cin >> N;
  double ans = 0.;
  vector<double> xs(N), rs(N);
  for(int i=0;i<N;++i){
	cin >> rs[i];
	xs[i] = rs[i];
	for(int j=0;j<i;++j)
	  xs[i] = max(xs[i], xs[j] + 2*sqrt(rs[j]*rs[i]));
	ans = max(ans, xs[i]+rs[i]);
  }
  cout << fixed << setprecision(9) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,cnt;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0)
  {
      cnt++;
      if(cnt%2==1) 
       c-=b;
       else a-=d;
  }
  if (a<=0) cout<<"No"; else cout<<"Yes";
  
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

		int d = 0;
		int div = N;
		while ( div > 0 ) {
			div = div / K;
			d++;
		}
		System.out.println(d);
	}
}


Measured memory_bytes: 21716
package main

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

func main() {
	h, w, m := readI(), readI(), readI()
	counth, countw := make([]int, h), make([]int, w)
	type pos struct {
		h, w int
	}
	target := make(map[pos]bool)
	for i := 0; i < m; i++ {
		tmph, tmpw := readI()-1, readI()-1
		target[pos{tmph, tmpw}] = true
		counth[tmph]++
		countw[tmpw]++
	}

	max := 0
	maxh, maxw := make([]int, 0), make([]int, 0)
	for i := 0; i < h; i++ {
		if max < counth[i] {
			max = counth[i]
			maxh = []int{i}
		} else if max == counth[i] {
			maxh = append(maxh, i)
		}
	}
	max = 0
	for i := 0; i < w; i++ {
		if max < countw[i] {
			max = countw[i]
			maxw = []int{i}
		} else if max == countw[i] {
			maxw = append(maxw, i)
		}
	}

	for i := 0; i < len(maxh); i++ {
		for j := 0; j < len(maxw); j++ {
			if target[pos{maxh[i], maxw[j]}] == false {
				fmt.Println(counth[maxh[0]] + countw[maxw[0]])
				return
			}
		}
	}
	fmt.Println(counth[maxh[0]] + countw[maxw[0]] - 1)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 53428
//https://codeforces.com/contest/1328/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    string s;
    cin>>s;
    int f=1;
    if(s[2]!=s[3])f=0;
    if(s[4]!=s[5])f=0;
    if(f==0)p1("No");
    else p1("Yes");
    
    return 0;
}

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

int main(){
  int N,M; cin >> N >> M;
  priority_queue<pair<int,int>> p;
  for(int i=0; i<N; i++){
    int a,b; cin >> a >> b;
    p.emplace(M-a,b);
  }
  
  int result=0;
  priority_queue<int> b;
  for(int i=M-1; i>=0; i--){
    if(!p.empty()){
      while(!p.empty()&&p.top().first==i){
        b.emplace(p.top().second);
        p.pop();
        if(p.empty()) break;
      }
    }
    if(!b.empty()){
      result+=b.top();
      b.pop();
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 1908
n,m = map(int,input().split())
l = []
for i in range(n):
    pair = list(map(int,input().split()))
    l.append(pair)
else:
    l.sort()

res = 0
for i in range(n):
    m -= l[i][1]
    res += l[i][0]*l[i][1]
    if m <= 0:
        res += l[i][0]*m
        print(res)
        break


Measured memory_bytes: 27760
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;
int main()
{
	ll a,b,c,s,x,y,z;
	cin>>a>>b>>c;
	x=abs(a-b)+abs(a-c);
	y=abs(b-c)+abs(b-a);
	z=abs(c-a)+abs(c-b);
	s=min(x,min(y,z));
	cout<<s;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int dp[110][110];

int main(){
    int H,W; cin >> H >> W;
    vector<vector<char>> s(H,vector<char>(W));
    rep(i,H)rep(j,W) cin >> s[i][j];
    rep(i,110)rep(j,110) dp[i][j] = INF;
    dp[H-1][W-1] = (s[H-1][W-1] == '#'?1:0);
    for(int i = H-1; i >= 0; i--){
        for(int j = W-1; j >= 0; j--){
            if(i >= 1){
                dp[i-1][j] = min(dp[i-1][j],dp[i][j]+(s[i-1][j] == '#' && s[i][j] != '#'?1:0));
            }
            if(j >= 1){
                dp[i][j-1] = min(dp[i][j-1],dp[i][j]+(s[i][j-1] == '#' && s[i][j] != '#'?1:0));
            }
        }
    }
    cout << dp[0][0] << endl;
}



Measured memory_bytes: 256
#include<iostream>

#define lli long long int

using namespace std;

int main() {
    int N;

    cin >> N;

    lli A[N];

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

    int leftIndex = 0;
    int rightIndex = N - 1;
    lli left = 0;
    lli right = 0;

    while(leftIndex <= rightIndex) {
        if(left < right) {
            left += A[leftIndex];
            leftIndex++;
        } else {
            right += A[rightIndex];
            rightIndex--;
        }
    }

    lli ans = left > right ? left - right : right - left;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,K,d;
  cin >> N >> K;
  
  long snuke[N+1]={0};
  
  for(int i=1; i<N+1; i++){
    cin >> d;
    int temp;
    for(int k=0; k<d; k++){
      cin >> temp;
      snuke[temp]++;
    }
  }
  
  int ans = 0;
  for(int i=1; i<N+1; i++){
    if(snuke[i]==0) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Random;

//The Closest Circle
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
	
	class R implements Comparable<R>{
		double x, y, r;
		public R(double x, double y, double r) {
			this.x = x;
			this.y = y;
			this.r = r;
		}
		public int compareTo(R o) {
			if(Math.abs(x-o.x)<EPS)return (int)Math.signum(y-o.y);
			return (int)Math.signum(x-o.x);
		}
	}
	
	double EPS = 1e-8;
	
	void run(){
		Scanner sc = new Scanner();
		Random rand = new Random(System.currentTimeMillis());
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int rot = rand.nextInt(179)+1;
			double sin = Math.sin(rot*Math.PI/180), cos = Math.cos(rot*Math.PI/180);
			R[] rs = new R[n];
			for(int i=0;i<n;i++){
				double r = sc.nextDouble(), x = sc.nextDouble(), y = sc.nextDouble();
				rs[i] = new R(cos*x-sin*y, sin*x+cos*y, r);
			}
			Arrays.sort(rs);
			double res = 1L<<60;
			for(int i=0;i<n;i++){
				int t = Math.min(n, i+100);
				for(int j=i+1;j<t;j++){
					res = Math.min(res, Math.sqrt((rs[i].x-rs[j].x)*(rs[i].x-rs[j].x) + (rs[i].y-rs[j].y)*(rs[i].y-rs[j].y))-rs[i].r-rs[j].r);
				}
			}
			System.out.printf("%.9f\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????§????????????????????????
				//????????\???
				Scanner sc = new Scanner(System.in);
				//int???????????????a
				int a = sc.nextInt();
			     //int???????????????b
				int b = sc.nextInt();
			     //int???????????? ???
				int c = sc.nextInt();
			     //3?????????????????????
			     if(a <  b && b < c){
			    	 System.out.println("Yes");
			     }else {
			    	 System.out.println("No");
			     }
	}
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var d = ria();
		Console.WriteLine(d[0] == d[1] ? d[2] : d[1] == d[2] ? d[0]: d[1]);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
import math
import numpy as np

n = int(input())
n_2 = int(math.sqrt(n) + 1)
x = np.arange(1, n_2)
div = x[n % x == 0]
ans = 10 ** 12
for i in div:
    j = (n // i) + i - 2
    ans = min(ans, j)
print(ans)

Measured memory_bytes: 37004
using System;
using System.Linq;

namespace _152C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            var a_dash = Array.ConvertAll(a,i=>i-1);
            Console.WriteLine(Enumerable.Sum(a_dash));
        }
    }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var HAndW = ReadIntegersWithSpaces();
            var hAndw = ReadIntegersWithSpaces();

            int H = HAndW[0];
            int W = HAndW[1];

            int h = hAndw[0];
            int w = hAndw[1];

            Console.WriteLine((W - w) * (H - h));
        }


        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static List<int> ReadIntList(int length)
        {
            var list = new List<int>();
            for(int k = 1; k <= length; k++)
            {
                list.Add(ReadInt());
            }

            return list;
        }

        public static List<int> ReadIntegersWithSpaces()
        {
            var strings = Console.ReadLine().Split(' ');
            var integers = new List<int>();
            foreach(var str in strings)
            {
                integers.Add(int.Parse(str));
            }

            return integers;
        }

        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        public static List<long> ReadLongList(int length)
        {
            var list = new List<long>();
            for (int k = 1; k <= length; k++)
            {
                list.Add(ReadLong());
            }

            return list;
        }
    }
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    int ans = 0;
    for (int i=0; i<N; i++) {
       if (i < K) ans += X;
       else ans += Y;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N)cin>>A[i];
    rep(i,N){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;

    return 0;
}

//a=97,z=122

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

typedef long long lli;

int main(){
  lli N,price=1,ans=0;
  lli A[100000];
  cin>>N;
  for(lli i=0;i<N;i++){
    cin>>A[i];
    if(i==0){
      ans+=A[i]-1;
      price++;
    }else{
      if(A[i]%price==0){
	ans+=(A[i]/price)-1;
	if(A[i]==price)
	  price++;
      }else{
	ans+=A[i]/price;
      }
    }
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n;

void dfs( string s, int used, int cnt ){
	if( cnt == n ){
		cout << s << endl;
		return;
	}
	for( int i = 0; i <= used; ++i ){
		dfs( s+(char)('a'+i), max(used, i+1), cnt+1 );
	}
}

int main(){
	cin >> n;
	dfs( "a", 1, 1 );
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = -1;
		for(var i=0;i<=50000;i++){
			int a = i*108/100;
			if(a==N){
				ans = i;
				break;
			}
		}
		if(ans==-1){
			Console.WriteLine(":(");
		} else {
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	if(a >= b){
		printf("delicious");
	}else if(b > a + x){
		printf("dangerous");
	}
	else{
		printf("safe");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
using namespace std;
const int maxn = 1005;
int a[maxn];
map<int,int> mp;
int main(int argc, char const *argv[])
{
	mp.clear();
	int x,y;
	cin>>x>>y;
	for(int i = 1;i <= 999; ++i)
	{
		a[i] = a[i - 1] + i;
		// printf("a[%d] = %d,",i,a[i]);
		mp[a[i]] = i;
	}
	for(int i = 1;i <= 499500; ++i)
	{
		if(mp[x + i] && mp[y + i] && abs(mp[x + i] - mp[y + i]) == 1)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
struct Card{
    char suit;
    int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],ll n,ll left,ll mid ,ll right){
    ll n1 = mid   - left;
    ll n2 = right - mid;
    REP(i,n1)L[i] = A[left+i];
    REP(i,n2)R[i] = A[mid+i];
    L[n1].value = R[n2].value = SENTINEL;
    ll i = 0,j = 0;
    REP2(k,left,right){
        
        if(L[i].value<=R[j].value){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}
void mergeSort(struct Card A[],ll n,ll left,ll right){
    
    if(left+1<right){
        ll mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int partition(struct Card A[],int n,int p, int r){
    struct Card x,t;
    int i,j;
    x = A[r];
    i = p-1;
    for(j=p;j<r;j++){
        if(A[j].value <= x.value){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
    int q;
    if(p<r){
        q = partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}
int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable = 1;
    cin >> n;
    REP(i,n){
        cin >> S >> v;
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    REP(i,n){
        if(A[i].suit!=B[i].suit)stable=0;
    }
    if(stable==1) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    REP(i,n){
        cout << B[i].suit << " "<<B[i].value << endl;
    }
    return 0;
}


Measured memory_bytes: 5476
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ld long double
#define pb push_back
#define N 1000003
typedef long long int ll;
using namespace std;
int main(void){

	fast;
	//sieve();
	int n,ans=0,bad,i,j,good,temp,x;
	cin>>n;
	int a[n];
	map<int,int>mp1;
	for(i=0;i<n;i++){
	cin>>a[i];
	mp1[a[i]]++;
	}
	sort(a,a+n);
	map<int,int>mp;
	for(i=0;i<n;i++){
		bad=0;
		for(j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				if(mp[j]>0||mp[a[i]/j]>0)
				bad=1;
			}
		}
		if(!bad&&mp1[a[i]]==1)
		ans++;
		mp[a[i]]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 42728
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e9
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007 
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}



int main() {
    
    fastio;
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int ans = 0;
    for(int i=0;i<=n-m;i++)
    {
        int cnt = 0;
        for(int j=i;j<i+m;j++)
        {
            if(s[j] != t[j-i])
                cnt++;
        }
        if(i == 0)
            ans = cnt;
        else
            ans = min(ans, cnt);
    }  
    cout << ans;



    return 0; 
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  if (s[0] == '1'){
    count++;
  }
  if (s[1] == '1'){
    count++;
  }
  if (s[2] == '1'){
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    ans = 2-(n==2)
    for k in range(2,int(n**0.5)+1):
        if n % k == 1:
            ans += 2
            ans -=k**2+1==n
        elif n % k == 0:
            g = n//k
            while g % k == 0:
                g = g//k
            ans += g % k == 1
    
    print(ans)


if __name__ == '__main__':
    main()

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

int main(){ 
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x = (c-1)/b+1;
  int y = (a-1)/d+1;
  if(x<=y) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3636
a, b=input().split(' ')
mi = 0
a=int(a)
b=int(b)
if a<0 and b<0:
    a*=-1
    b*=-1
if b<0:
    a*=-1
    b*=-1
if a<0:
    mi=1
    a*=-1
print(a//b*(-1)**mi)


Measured memory_bytes: 5600
N = int(input())
p = 1
for i in range(2, N + 1):
    p *= i
ans = 1
for i in range(2, N + 1):
    if p % i != 0:
        continue
    c = 1
    while p % i == 0:
        p //= i
        c += 1
    ans *= c
print(ans % 1000000007)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int a, b;
  cin >> n >> m;
  int cnt[200000] = {};
  REP(i,m){
    cin >> a >> b;
    if (a==1){
      cnt[b]++;
      if (cnt[b]==2){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
    if (b==n){
      cnt[a]++;
      if (cnt[a]==2){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
using namespace std;

map<int, int>M;
signed main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		M[a]++;
	}
	vector<int>V;
	for (pair<int,int> i : M) {
		V.push_back(i.second);
	}
	sort(V.begin(), V.end());
	int ans = 0;
	for (int i = 0; i < (int)V.size() - k; i++) {
		ans += V[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 10748
n = int(input())
list_a = list(map(int, input().split()))
def partition(list_a, p, r):
    x = list_a[r]
    i = p-1
    for j in range(p,r):
        if list_a[j] <= x:
            i = i+1
            list_a[j], list_a[i] = list_a[i], list_a[j]
    list_a[i+1], list_a[r] = list_a[r], list_a[i+1]
    return i+1, list_a

ind,list_a = partition(list_a, 0, n-1)
for i in range(n):
    list_a[i] = str(list_a[i])
    if i == ind:
        list_a[i] = "[" + list_a[i] + "]"
print(" ".join(list_a))



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

int main() {
  //入力
  int n; cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];

  int count=0,before=100;
  rep(i,n) {
    count+=b[i];
    if(before+1==a[i]) {
      count+=c[before-1];
    }
    before=a[i];
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws IOException{
       BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
         String str = a.readLine();
        int x = Integer.parseInt(str);
        System.out.println(x*x*x);
    }
}

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;  
#define ll long long int
#define All(a) (a).begin(),(a).end()

void solve(){
  int n;
  scanf("%d",&n);
  vector<int> a(n),b(n),c(n);

  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }

  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  sort(All(a));
  sort(All(b));
  sort(All(c));
  ll count=0;
  for (int j = 0; j < n; j++)
  {
    auto tmp = lower_bound(All(a),b[j]);
    auto l=tmp-a.begin();
      int tmp2 = c.end()-upper_bound(All(c),b[j]);
      count+=l*tmp2;
      
    
  }
  printf("%lld\n",count);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
int a[N], l[N], r[N];
signed main(void) {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) l[i] = __gcd(l[i - 1], a[i]);
	for (int i = n; i >= 1; i--) r[i] = __gcd(r[i + 1], a[i]);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, __gcd(l[i - 1], r[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5904
#include <iostream>
#include <math.h>
using namespace std;
int a, b, c, k, ans = 0;
int main(void){
    // Your code here!
    cin >> a >> b >> c >> k;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if (i + j <= k) {
                int h = k - i - j;
                int test = a * pow(2, i) + b * pow(2, j) + c * pow(2, h);
                if (test > ans) ans = test;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,n,i,min=1000000,max=-1000000;
    int long long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum=sum+a;
        if(min>a)
        min=a;
        if(max<a)
        max=a;
        }
    printf("%d %d %lld\n",min,max,sum);
    
    return 0;
    }


Measured memory_bytes: 2692