akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
int n;
int my_max,sum;
int main(void) {
    cin >> n;
    vector<int> vec(n);
    rep(i, n) {
        cin >> vec[i];
        sum += vec[i];
        my_max = max(my_max, vec[i]);
    }
    (my_max < sum - my_max? cout << "Yes" << endl : cout << "No" << endl);
    return 0;
}

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

int main(){
    double s,w,h;
    while(scanf("%lf,%lf,%lf", &s, &w, &h)!=EOF){
        if(w/h/h >= 25.0){
            cout << s << endl;
        }
    }
    return 0;
}



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

int x;

int main() {
  cin >> x;
  for (int i = 1; i <= 1000000; i++) {
    int min = 100 * i;
    int max = 105 * i;

    if (x >= min && x <= max) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define y1 DCXISSOHANDSOME
#define lowbit(x) (x&-x)
#define ldb long double

struct node { int x,y,yy; }a[200010];

const ldb pi=acos(-1.0);

int h[200010],c[200010],res[200010],n,x1,y1,x2,y2,tt;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool cmp(node x,node y) { return x.x<y.x; }

inline void add(int x,int y) { for (;x<=tt;x+=lowbit(x)) c[x]=max(c[x],y); }

inline int query(int x)
{
	int res=0;
	for (;x;x-=lowbit(x)) res=max(res,c[x]);
	return res;
}

int main()
{
	x1=rd();y1=rd();x2=rd();y2=rd();
	if (x1>x2) swap(x1,x2),swap(y1,y2);
	n=rd();tt=0;
	for (int i=1;i<=n;i++)
	{
		int x=rd(),y=rd();
		if (x<x1||x>x2||y<min(y1,y2)||y>max(y1,y2)) continue;
		a[++tt].x=x;a[tt].y=y;
	}
	sort(a+1,a+tt+1,cmp);
	if (x1==x2)
	{
		bool flag=false;
		for (int i=1;i<=tt;i++) if (a[i].x==x1) flag=true;
		printf("%.12Lf\n",(abs(x1-x2)+abs(y1-y2))*100.0+(flag?(pi*10.0-20.0):0));
		return 0;
	}
	if (y1==y2)
	{
		bool flag=false;
		for (int i=1;i<=tt;i++) if (a[i].y==y1) flag=true;
		printf("%.12Lf\n",(abs(x1-x2)+abs(y1-y2))*100.0+(flag?(pi*10.0-20.0):0));
		return 0;
	}
	for (int i=1;i<=tt;i++) h[i]=a[i].y;
	sort(h+1,h+tt+1);
	for (int i=1;i<=tt;i++) a[i].yy=lower_bound(h+1,h+tt+1,a[i].y)-h;
	if (y1>y2) for (int i=1;i<=tt;i++) a[i].yy=tt-a[i].yy+1;
	for (int i=1;i<=tt;i++)
	{
		res[i]=query(a[i].yy-1)+1;
		add(a[i].yy,res[i]);
	}
	ldb ans=abs(x1-x2)+abs(y1-y2);
	int hh=0;
	ans*=100.0;
	for (int i=1;i<=tt;i++) hh=max(hh,res[i]);
	if (hh==min(abs(x1-x2)+1,abs(y1-y2)+1)) printf("%.12Lf\n",ans-(ldb)(hh-1)*(20.0-pi*5.0)+(pi*10.0-20.0));
	else printf("%.12Lf\n",ans-(ldb)hh*(20.0-pi*5.0));
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int n, v[100], c[100];
int ans;

int main() {

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] >= 0)ans += v[i] - c[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] h = getIntArr(in, n);
		int[] a = getIntArr(in, n);
		long r = solve(n, h, a);
		System.out.println(r);
		in.close();
	}

	static int N = 200005;
	static long[] bit = new long[N + 1];

	static void upd(int i, long v) {
		while (i <= N) {
			bit[i] = Math.max(bit[i], v);
			i += i & -i;
		}
	}

	static long max(int i) {
		long r = 0;
		while (i != 0) {
			r = Math.max(r, bit[i]);
			i -= i & -i;
		}
		return r;
	}

	private static long solve(int n, int[] h, int[] a) {
		for (int i = 0; i < n; i++) {
			upd(h[i], max(h[i]) + a[i]);
		}
		return max(N);
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 106560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll p[100001] = {};
int main() {
	string s; cin >> s;

	ll L, R;
	bool LR = false;
	ll cnt = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'R' && s[i+1] == 'L') {
			LR = true;
			R = i;
			L = i + 1;
			cnt = 0;
			continue;
		}
		if (LR && s[i] == 'R') {
			LR = false;
			continue;
		}

		if (LR && s[i] == 'L') {
			if (cnt & 1) {
				p[R]++;
			}
			else {
				p[L]++;
			}
			cnt++;
		}
	}

	//
	L = 0, R = 0;
	LR = false;
	cnt = 0;
	rep_re(i, 0, s.size()-1) {
		if (LR && s[i] == 'R') {
			if (cnt & 1) {
				p[L]++;
			}
			else {
				p[R]++;
			}
			cnt++;
			continue;
		}

		if (s[i-1] == 'R' && s[i] == 'L') {
			LR = true;
			R = i-1;
			L = i;
			cnt = 0;
			continue;
		}
		if (LR && s[i] == 'L') {
			LR = false;
			continue;
		}
	}

	rep(i, 0, s.size()) {
		cout << p[i];
		if (i != s.size() - 1) {
			cout << " ";
		}
	}
	return 0;
}


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

int main() {
  int n,k,x,res=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x<k-x){
      res+=x;
    }else{
      res+=k-x;
    }
  }
  cout << res*2 << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n;
    cin >> n;

    LL ans = 0;
    
    REP(i, sqrt(n) + 1)
    {
        LL dd = n - (i+1);
        LL dv = (n - (i+1)) / (i+1);
        if(dv == 0) continue;
        if(dd % dv == 0 && n % dv != 0)
        {
            if(n / dv == n % dv) ans += dv;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N;
  cin>>N;
  D sum=0;
  for(int i=0;i<N;i++){
    D A;
    cin>>A;
    sum+=1.0/A;
  }
  cout<<fixed<<setprecision(12)<<1/sum<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007,maxn=10001000;
inline int ksm(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) res=1ll*res*a%mod;
	return res;
}
int fac[maxn],invfac[maxn];
inline int C(int n,int m){return (n<0||m>n)?0:(1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod);}
inline void write(int x){if(x>=10) write(x/10);putchar(x%10+'0');}
int main()
{
	fac[0]=1;for(int i=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
	invfac[maxn-1]=ksm(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++) write(1ll*C(k-1,i-1)*C(n-k+1,i)%mod),putchar('\n');
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

double dist(double x1, double x2, double y1, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main(void)
{
    int N;

    cin >> N;
    vector<int> v(N);
    for (int i; i < N; i++)
    {
        v[i] = i;
    }
    vector<double> x(N), y(N);

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    double count = 0;
    do
    {
        for (int i = 0; i < N - 1; i++)
        {
            sum += dist(x[v[i]], x[v[i + 1]], y[v[i]], y[v[i + 1]]);
        }
        count++;

    } while (next_permutation(v.begin(), v.end()));

    double ans = sum / count;

    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main():
    N = int(input())

    divisors = make_divisors(N)

    mi = float("inf")
    for v in divisors:
        x = N // v
        mi = min(mi, x + v - 2)

    print(mi)

    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >>n;
  vector<int>data(n);
  for (int i=0;i<n-1;i++){
  cin >>data.at(i);
  }
  data.at(n-1)=100000;
  int s=0;
  s+=data.at(0);
  for (int i=1;i<n;i++){ 
    s+=min(data.at(i-1),data.at(i));
  }
  cout <<s<<endl;
}
    

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        String s = sc.next();
        Integer[] l = new Integer[q];
        Integer[] r = new Integer[q];
        for (int i = 0; i < q; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int[] arr = new int[n];
        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
                arr[i] = arr[i - 1] + 1;
            } else {
                arr[i] = arr[i - 1];
            }
        }

        // 出力
        for (int i = 0; i < q; i++) {
            int result = arr[r[i] - 1] - arr[l[i] - 1];
            System.out.println(result);
        }
    }
}


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

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

int main()
{
    string S, T;
    cin >> S;
    cin >> T;

    int ans = 1e9;
    rep(si, S.size())
    {
        if (si + T.size() > S.size())
            break;
        int cnt = 0;
        rep(i, T.size())
        {
            if (S[si + i] != T[i])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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




int main(){
    int i;
    int j;
    int P;
    int N, M;
    // pair<int,int> city;     // city : Y, i
    
    
    cin >> N >> M;
    
    vector< vector< pair<int,int> > > pref(N);
    
    vector< pair<int,int>* > citymap(M);
    
    
    for(i=0;i<M;i++){
        pair<int,int> city;     // city : Y, i
        city.second = i;
        cin >> P >> city.first;
        pref[P-1].push_back(city);
    }
    
    for(i=0;i<N;i++){
        sort(pref[i].begin(), pref[i].end());
        j=0;
        
        //////////////
        // cout << i << " " << pref[i].size() << endl;
        //////////////
        
        while(j<pref[i].size()){
            
            /////////////////////
            //cout << "P:" << i+1 << " num:" << j+1 << endl;
            /////////////////////
            
            citymap[pref[i][j].second] = &pref[i][j];
            pref[i][j].first = i+1;
            pref[i][j].second = j+1;  // city : P, j
            j++;
        }
    }
    
    for(i=0;i<M;i++){
        cout << setfill('0') << right << setw(6) << citymap[i]->first ;
        cout << setfill('0') << right << setw(6) << citymap[i]->second << endl ;
    }
    
    
    return 0;
}



Measured memory_bytes: 7808
from collections import deque, defaultdict, Counter
from math import ceil, floor
from string import ascii_lowercase as AL
import sys
def input():
    return sys.stdin.readline().strip()


# N
# 1 a
# 2 aa, ab
# 3 aaa, aab, aba, abb, abc

def dfs(s, mx, N):
    # print("call |{}|{}|{}|{}|{}|".format(s, mx, N, len(s), len(s) == N))
    if len(s) == N:
        print(s)
    else:
        for ch in AL:
            if ord(ch) <= ord(mx):
                next_ch = chr(ord(ch) + 1) if ch == mx else mx
                dfs(s + ch, next_ch, N)

N = int(input())
dfs("", 'a', N)

# print(AL)
# for c in AL:
#     print(c, ord(c))

Measured memory_bytes: 60120
func disco2020c() {
    let HWK = readLine()!.toIntList()
    let H = HWK[0]
    let W = HWK[1]
    var K = HWK[2]
    var G:[[String]] = []
    var ANS:[[Int]] = Array(repeating: Array(repeating: 0, count: W), count: H)
    for _ in 1...H{ G.append(readLine()!.toList())}
    var yLists:[[Int]] = []
    var list:[Int] = []
    var i = 0
    for y in 0..<H{
        if G[y].contains("#"){
            list.append(y)
            i = y+1
            break
        }
        list.append(y)
    }
    for y in i..<H{
        if G[y].contains("#"){
            yLists.append(list)
            list = [y]
        }else{
            list.append(y)
        }
    }
    if list.count > 0 { yLists.append(list)}
    func isInStrovery(_ yList:[Int],_ x:Int) -> Bool{
        for y in yList{
            if G[y][x].contains("#"){
                return true
            }
        }
        return false
    }
    for yList in yLists{
        var xLists:[[Int]] = []
        var xl:[Int] = []
        var i = 0
        for x in 0..<W{
            if isInStrovery(yList, x){
                xl.append(x)
                i = x+1
                break
            }
            xl.append(x)
        }
        
        for x in i..<W{
            if isInStrovery(yList, x){
                xLists.append(xl)
                xl = [x]
            }else{
                xl.append(x)
            }
        }
        if xl.count > 0 {xLists.append(xl)}
        for xl in xLists{
            for x in xl{
                for y in yList{
                    ANS[y][x] = K
                }
            }
            K -= 1
        }
    }
    
    for y in 0..<H{
        for x in 0..<W{
            print(ANS[y][x],terminator: " ")
        }
        print("")
    }
}
import Foundation

extension String {
    func toIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }
    
    func toList() -> [String] {
        return self.map{String($0)}
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}


disco2020c()


Measured memory_bytes: 16684
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

// (x, y) を始点とした BFS をして、(x, y) から最も遠いマスへの距離を答える
int bfs(const vector<string> &v, ll x, ll y) {
    ll H = v.size(), W = v[0].size();
    vvl dist(H, vl(W, -1));//-1で埋める
    queue<pair<ll,ll>> que;

    ll res = 0;
    que.push(make_pair(x,y));
    dist[x][y] = 0;
    while (!que.empty()) {
        ll x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        rep(dir,4){
            ll nx = x+ dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '.'&&dist[nx][ny]==-1){ //未探索の道なら
                dist[nx][ny] = dist[x][y] + 1; //前のマス+1
                que.push({nx, ny}); //4方位をqueueに追加
            }
        }
    }
    return res;
}
ll ans=0;
int main() {
    SS(string,s,t)
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    s<t?p("Yes"):p("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  int N;
  std::cin >> N;
  vector<tuple<string, int, int>> v(N);
  REP(i, N) {
    string s;
    int a;
    std::cin >> s >> a;
    v[i] = make_tuple(s, a, i + 1);
  }
  sort(ALL(v),
       [](const auto &x, const auto &y) { return get<0>(x) < get<0>(y); });
  string id = get<0>(v[0]);
  int index = 0;
  for (int i = 1; i < N; i++) {
    if (id != get<0>(v[i])) {
      sort(v.begin() + index, v.begin() + i,
           [](const auto &x, const auto &y) { return get<1>(x) > get<1>(y); });
      id = get<0>(v[i]);
      index = i;
    }
    if (i == N - 1) {
      sort(v.begin() + index, v.end(),
           [](const auto &x, const auto &y) { return get<1>(x) > get<1>(y); });
    }
  }
  // REP(i, N) {
  //   std::cout << get<0>(v[i]) << ' ' << get<1>(v[i]) << ' ' << get<2>(v[i])
  //             << '\n';
  // }
  REP(i, N) { std::cout << get<2>(v[i]) << '\n'; }
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int N;
	cin >> N;
	int ans;
	for (ans = 1; ans * 2 <= N; ans *= 2);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) cin >> l.at(i);
    sort(l.begin(), l.end(), greater<int>());
    cout << accumulate(l.begin(), l.begin() + k, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{   long long a,b,c;
    cin>>a>>b>>c;
    if(a==(b+c)){cout<<"Yes"<<endl;}
    else if(c==(a+b)){cout<<"Yes"<<endl;}
    else if(b==(a+c)){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a, c;
  string b;
  cin >> a >> b >> c;
  if((1000000000 >= a) && (1000000000 >= c)){
    if(b.compare("+") == 0){
          cout << (a + c) << endl;  
    }else if(b.compare("-") == 0){
          cout << (a - c) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import  math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

d1=0
d2=0
d3=0
d4=0

for i in range(n):
    d1+=abs(x[i]-y[i])

for i in range(n):
    d2+=(x[i]-y[i])**2
d2=math.sqrt(d2)
for i in range(n):
    d3+=(abs(x[i]-y[i])**3)

d3=d3**(1/3)

for i in range(n):
    tmp=abs(x[i]-y[i])
    d4=max(d4,tmp)

print(d1)
print(d2)
print(d3)
print(d4)


Measured memory_bytes: 5688
n = int(input())
a = [0] * n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        k, l = map(int, input().split())
        x[i].append(k)
        y[i].append(l)

def dfs(cur, l):
    global ok
    if cur == n:
        ok = True
        for i in range(n):
            if l[i]==1 and any([l[x[i][j]-1]!=y[i][j] for j in range(a[i])]):
                ok = False
        return sum(l) if ok else 0
    else:
        l1 = l[:]
        l1[cur] += 1
        return max(dfs(cur+1, l), dfs(cur+1, l1))

print(dfs(0, [0]*n))

Measured memory_bytes: 3064
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

bool u[30];

char s[30];

int n;

void solve() {                   
	scanf("%s", s);

    for (n = 0; s[n]; ++n);

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

    if (n == 26) {     
		for (int i = n - 1; i >= 0; --i) {
			int p = -1;

			for (int j = s[i] - 'a' + 1; j < 26; ++j) {
				if (!u[j]) {
					p = j;
					break;
				}
			}

			if (p != -1) {
				for (int j = 0; j < i; ++j) {
					printf("%c", s[j]);
				}

				printf("%c", p + 'a');                
				return;
			}

			u[s[i] - 'a'] = 0;
		}

    	printf("-1\n");
    	return;
    }

    printf("%s", s);

    for (int i = 0; i < 26; ++i) {
    	if (!u[i]) {
    		printf("%c", i + 'a');
    		break;
    	}
    } 
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

using namespace std;


template<class T>
void print (vector<T>& v, bool spaced = true) {
    int n = v.size();
    string space = (spaced ? " ": "");
    for (int i = 0; i < n; ++i) {
        cout << v[i] << space;
    }cout << '\n';
}

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;
    int N = s.size();
    long long ans = 0;
    for (int mask = 0; mask < (1 << N-1); ++mask) {
        string ss = "";
        for (int i = 0; i < N; ++i) {
            ss += s[i];
            if ((1 << i) & mask)
                ss += '+';
        }

        string t = "";
        for (int i = 0; i < (int) ss.size(); ++i) {
            if (ss[i] != '+') {
                t += ss[i];
            }else {
                ans += stoll(t);
                t = "";
            }
        }
        ans += stoll(t);
    }
    
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll x,y;
	scanf("%lli %lli",&x,&y);
	x = x%y;
	if(x>(y-x))				printf("%lli",y-x);
	else					printf("%lli",x);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int n, W, v[105], w[105];
int dp[105][10005];

int search(int i, int j)
{
  if (dp[i][j] >= 0) return dp[i][j];
  int res;
  if (i == n) res = 0;
  else if (j < w[i]) res = search(i + 1, j);
  else
  {
    res = max(search(i + 1, j), max(search(i + 1, j - w[i]) + v[i], search(i, j - w[i]) + v[i]));
  }
  return dp[i][j] = res;
}

int main()
{
  cin >> n >> W;
  REP(i, n) cin >> v[i] >> w[i];
  memset(dp, -1, sizeof(dp));
  cout << search(0,W) << endl;
  return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,N) cin >> A[i];

    multiset<int> ans;
    rep(i,N) ans.insert(A[i]);

    REP(i, 1, N+1)
    {
        if( ans.find(i) != ans.end() )
        {
            cout << ans.count(i) << endl;
        }
        else cout << 0 << endl;
    }
}


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

int main() {
	int X,Y;
  	cin >> X >> Y;
  
    int money;
  	
  	if(X <= 3){
      money += 100000 * (4-X);
    }
  
  	if(Y <= 3){
      money += 100000 * (4-Y);
    }
  
	if(X == 1 && Y == 1){
      money += 400000;
    }
  
  	cout << money << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i] >> B[i];
  reverse(A.begin(), A.end()), reverse(B.begin(), B.end());
  vector<long long> ans(N + 1);
  for (int i = 0; i < N; ++i)
    ans[i + 1] = (B[i] - (A[i] + ans[i]) % B[i]) % B[i] + ans[i];
  cout << ans[N] << endl;
}

Measured memory_bytes: 1920
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[11][30],b[10],m,n,o,d;
  char c;
  while(cin>>n&&n){
    cin>>m>>o>>d;
    memset(a,0,sizeof(a));
    for(i=0;i<d;i++){
      for(j=1;j<n;j++){
	cin>>c;
	a[j][i]=c-'0';
      }
    }
    memset(b,0,sizeof(b));
    b[o-1]=1;
    for(i=d-1;i>-1;i--){
      for(j=1;j<n;j++){
	if(a[j][i])
	  swap(b[j-1],b[j]);
      }
    }
    if(b[m-1])
      cout<<0<<endl;
    else{
      for(i=0;i<d;i++){
	for(j=1;j<n;j++){
	  if(a[j-1][i]==0&&a[j][i]==0&&a[j+1][i]==0){
	    a[j][i]=1;
	    memset(b,0,sizeof(b));
	    b[o-1]=1;
	    for(k=d-1;k>-1;k--){
	      for(l=1;l<n;l++){
		if(a[l][k])
		  swap(b[l-1],b[l]);
	      }
	    }
	    if(b[m-1])
	      break;
	    a[j][i]=0;
	  }
	}
	if(j!=n)
	  break;
      }
      if(i==d)
	cout<<1<<endl;
      else
	cout<<i+1<<" "<<j<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin >> N >> X;
    int L[N];
    for(int i=0;i<N;i++) cin >> L[i];

    int now = 0;
    int ans = 0;
    //cout << now << endl;
    for(int i=1;i<N+1;i++){
        now = now + L[i-1];
        //cout << now << endl;
        if(now <= X) ans++;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 256
n, d = map(int, input().split())
x = []
for i in range(n):
   x.append([int(i) for i in input().split()])

count = 0
for i in range(n):
   for j in range(i+1, n):
      d = (sum([(y-z)**2 for y, z in zip(x[i], x[j])]))**0.5
      if (d.is_integer()):
         count += 1

print(count)


Measured memory_bytes: 3188
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int arr[maxx];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int i = 1, res = 0;
    while (i <= n) {
        if (i + 1 <= n && arr[i + 1] < arr[i]) {
            while (i + 1 <= n && arr[i + 1] <= arr[i]) {
                i++;
            } i++;
        } else if (i + 1 <= n && arr[i + 1] > arr[i]) {
            while (i + 1 <= n && arr[i + 1] >= arr[i]) {
                i++;
            } i++;
        } else if (i + 1 <= n && arr[i + 1] == arr[i]) {
            while (i + 1 <= n && arr[i + 1] == arr[i]) i++;
            continue;
        } else i++;
        res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
//╔╗───────────╔╗────────────────────╔╗─
//║║──────────╔╝╚╗──────────────────╔╝╚╗
//║╚═╗╔══╗╔══╗╚╗╔╝╔══╗╔═╗╔╗╔╗╔══╗ ╔╗╚╗╔╝
//║╔╗║║╔╗║║╔╗║─║║─║║═╣║╔╝║╚╝║║╔╗║─╣║─║║─
//║╚╝║║╔╗║║║║║─║╚╗║║═╣║║─║║║║║╚╝║─║║─║╚╗
//╚══╝╚╝╚╝╚╝╚╝─╚═╝╚══╝╚╝─╚╩╩╝╚══╝─╚╝─╚═╝ 

#include <bits/stdc++.h>

#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define fornite(i, n) for (int i = 1; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
    IO;
    long long n, sum = 0; cin >> n;
    long long sums[n] = {};
    forn(i,n){
    	int a;
    	cin >> a;
    	sum+=a;
    	sums[i] = sum;
    }
    long long mini = abs(sums[0] - (sums[n-1] - sums[0]));
    fornite(i,n-1){
    	mini = min(mini, abs(sums[i] - (sums[n-1] - sums[i])));
    }
    cout << mini;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>

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

   int max = 0;
   for(int i=0; i<N; ++i){
      for(int j=i+1; j<N; ++j){
	 if(max<abs(A[i]-A[j])) max = abs(A[i]-A[j]);
      }
   }
   std::cout << max << std::endl;
   return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = nextInt(br);
        int[] arr = nextIntArray(br, n);
        int count = 0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                for(int k = j + 1; k < n; k++){
                    if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k]) continue;
                    if(arr[i] + arr[j] > arr[k] &&
                        arr[j] + arr[k] > arr[i] &&
                        arr[i] + arr[k] > arr[j]){
                        count++;
                    }
                }
            }
        }
        sb.append(count);
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 33208
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int ans = inf;
    rep(i,n){
        int sum1 = 0, sum2 = 0;
        rep(j,i+1){
            sum1 += v[j];
        }
        for(int j = i+1;j<n;j++){
            sum2 += v[j];
        }
        ans = min(ans,abs(sum1-sum2));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=998244353;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi dp,to;
ll n;
ll N=1;
vi segma;
void init(vi v){
    while(N<v.size())N*=2;
    segma=vi(N*2-1,-inf);
}
void update(int i,ll x){
    i+=N-1;
    segma[i]=x;
    while(i>0){
        i=(i-1)/2;
        segma[i]=max(segma[i*2+1],segma[i*2+2]);
    }
}
ll getma(int a,int b,int k,int l,int r){
    if(a<=l&&r<=b)return segma[k];
    if(r<=a||b<=l)return -inf;
    ll c1=getma(a,b,k*2+1,l,(l+r)/2);
    ll c2=getma(a,b,k*2+2,(l+r)/2,r);
    return max(c1,c2);
}
ll dfs(int i){
    if(i==n)return 1;
    if(dp[i]!=-1)return dp[i];
    dp[i]=(dfs(i+1)+dfs(segma[i+N-1]))%mod;
    return dp[i];
}
int main(){
    cin>>n;
    vector<P> v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    sort(all(v));
    to=vi(n,-inf);
    init(to);
    update(n-1,n);
    for(int i=n-2;i>=0;i--){
        update(i,i+1);
        update(i,getma(i,lb(v,P(v[i].fi+v[i].se,-inf)),0,0,N));
    }
    dp=vi(n+1,-1);
    out(dfs(0));
}



Measured memory_bytes: 16868
grid = readlines.map { |line| line.chomp.split.map(&:to_i) }

d1 = grid[0][0] - grid[1][0]
d2 = grid[0][1] - grid[1][1]
d3 = grid[0][2] - grid[1][2]

d4 = grid[1][0] - grid[2][0]
d5 = grid[1][1] - grid[2][1]
d6 = grid[1][2] - grid[2][2]

d7 = grid[0][0] - grid[0][1]
d8 = grid[0][1] - grid[0][2]

d9 = grid[1][0] - grid[1][1]
d10 = grid[1][1] - grid[1][2]

d11 = grid[2][0] - grid[2][1]
d12 = grid[2][1] - grid[2][2]

if d1 == d2 && d1 == d3 && d4 == d5 && d4 == d6 &&
    d7 == d9 && d7 == d11 && d8 == d10 && d8 == d12
  puts('Yes')
else
  puts('No')
end

Measured memory_bytes: 1788
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, K, Q = map(int, input().split())
counter = Counter(int(input()) - 1 for _ in range(Q))
for i in range(N):
    if K - (Q - counter[i]) > 0:
        print('Yes')
    else:
        print('No')


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

int main(){
  int input[3]={};
  int count5=0;
  int count7=0;
  
  for(int i=0;i<=3;i++){
    cin>>input[i];
    if(input[i]==5){
      count5++;
    }
    else if(input[i]==7){
      count7++;
    }
  }
  
  if(count5==2&&count7==1){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
 return 0; 
}
      


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e6+3;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_map<ll, ll> minvmap;
ll minv(ll a, ll m) {
  auto k = a; auto p = minvmap[a]; if (p != 0) return p;
  ll b = m, u = 1, v = 0;
  while (b) { ll t = a/b; swap(a -= t*b, b); swap(u -= t*v, v); }
  p = (u%m+m)%m; minvmap[k] = p; return p;
}
struct mint {
    ll x;
    mint():x(0){}
    mint(ll x):x((x%mod+mod)%mod){}
    mint& fix() { x = (x%mod+mod)%mod; return *this;}
    mint operator-() const { return mint(0) - *this;}
    mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
    mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
    mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
    mint& operator/=(const mint& a){ (x*=minv(a.x, mod))%=mod; return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a;}
    mint operator-(const mint& a)const{ return mint(*this) -= a;}
    mint operator*(const mint& a)const{ return mint(*this) *= a;}
    mint operator/(const mint& a)const{ return mint(*this) /= a;}
    bool operator<(const mint& a)const{ return x < a.x;}
    bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

int MAXN = mod;
// factorial
vector<mint> fact(MAXN+1);
void init() {
  fact[0] = 1;
  for(int i=1; i<=MAXN; i++) fact[i] = fact[i-1]*i;
}

mint mod_pow(mint a, ll x) {
  mint res = 1;
  while(x > 0) {
    if (x & 1) res *= a;
    a *= a; x >>= 1;
  }
  return res;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int q; cin >> q;
  init();

  while(q--) {
    int x, d, n; cin >> x >> d >> n;
    if (x==0) {
      cout << 0 << '\n';
      continue;
    }
    if (d==0) {
      cout << mod_pow(mint(x), n) << '\n';
      continue;
    }
    if (n>=mod) {
      cout << 0 << '\n';
      continue;
    }

    mint s = (mint)x/d;
    mint p = s+n-1;
    if (s.x > p.x) {
      cout << 0 << '\n';
      continue;
    }
    mint r = p-n;
    mint pw = mod_pow(d, n);
    cout << pw*(fact[p.x]/fact[r.x]) << '\n';
  }
}

Measured memory_bytes: 15396
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N, K;
string S;

int main(){
	cin >> N >> K >> S;
	S[K - 1] += 32;

	cout << S << endl;

	return 0;
}

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


int main() {
	int h, w;
	cin >> h >> w;
	string a[50];
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	const int x[8] = { 1,0,-1,0,1,-1,-1,1 };
	const int y[8] = { 0,1,0,-1,1,1,-1,-1 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') { continue; }
			int num = 0;
			for (int k = 0; k < 8; k++) {
				const int ni = i + y[k];
				const int nj = j + x[k];
				if (ni < 0 or h <= ni) { continue; }
				if (nj < 0 or w <= nj) { continue; }
				if (a[ni][nj] == '#') { num += 1; }
			}

			a[i][j] = char(num + '0');

		}
	}
	

	for (int i = 0; i < h; i++) {
		cout << a[i] << endl;
	}
	
	
	return 0;
}










Measured memory_bytes: 256