akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int
main(void)
{
        int n;
        int *height;
        int hotel;

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

        height = malloc(n * sizeof(int));

        for (int i = 0; i < n; i++)
                scanf("%d%*c", &height[i]);

        hotel = 1;
        if (n > 1) {
                for (int i = 1; i < n; i++) {
                        int sea = 1;
                        for (int j = 0; j < i; j++) {
                                if (height[i] < height[j])
                                        sea = 0;
                        }
                        hotel += sea;
                }
        }

        printf("%d", hotel);
}


Measured memory_bytes: 128
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
	int A;
	int cnt = 0;

	rep(i, 3)
	{
		cin >> A;
		cnt += A;
	}

	if (cnt >= 22)
	{
		cout << "bust";
	}
	else
	{
		cout << "win";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x[200005];
ll y[200005];
int main() {
  ll n, d, ans = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    if (x[i] * x[i] + y[i] * y[i] <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    crap;
    string n;
    cin >> n;
    bool ok = false;
    for(char c : n) {
        if(c=='7') {
            ok = true;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main(){
  string S;
  cin >> S;
  int f=0;
  for(int i=0; i<4; i++){
    if(S[i]=='+'){
      f++;
    }else{
      f--;
    }
  }
  cout << f << endl;

  return 0;
}

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

const int MAX = 1e7;
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() {
    // 前処理
    int X , Y ;
    cin >> X >> Y ;
    if( (X+Y)%3!=0 ){
        cout << 0 << endl;
        return 0 ;
    }
    int N = (X+Y)/3 ;
    COMinit();
    X -= N ; 
    int A = COM( N , X )  ;
    cout << A << endl;
    return 0 ;
}


Measured memory_bytes: 234624
N = int(input())
#listA = []
#listB = []
listC = []
while True:     
  try:         
    #a, b = map(int,input().split())
    #listA.append(a)
    #listB.append(b)
    listC.append(list(map(int,input().split())))
  except:         
    break; 
#print(listA)  
#print(listB)
#print(listC)
#print(sum(listA))
#print(max(listB))
listC.sort(key=lambda x:(x[1],x[0]))
#print(listC)
time = 0
ans = "Yes"
for i in range(N):
  time += listC[i][0]
  if time <= listC[i][1]:
    continue
  else:
    ans = "No"
    break
print(ans)

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

typedef long long ll;

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct edge{
    int to,cap,cost,rev;
    edge(int a,int b,int c,int d):to(a),cap(b),cost(c),rev(d){}
};
const int MAX_V=6010;
const ll INF=1001001001001ll;
int V;
vector<edge>G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
bool used[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));

}

int min_cost_flow(int s,int t,int f){
    vint deg(MAX_V);
    rep(i,MAX_V)for(auto &e:G[i])if(e.cap)deg[e.to]++;

    fill_n(h,MAX_V,INF);
    queue<int>que;
    rep(i,MAX_V)if(deg[i]==0){
        if(i==s)h[i]=0;
        que.push(i);
    }
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto &e:G[v])if(e.cap){
            chmin(h[e.to],h[v]+e.cost);
            if(--deg[e.to]==0)que.push(e.to);
        }
    }

    int res=0;
    while(f>0){
        fill_n(dist,MAX_V,INF);
        dist[s]=0;
        memset(used,0,sizeof(used));
        while(true){
            int v=-1;
            for(int u=0;u<MAX_V;u++)if(!used[u]&&(v==-1||dist[v]>dist[u]))v=u;
            if(v==-1)break;
            used[v]=true;
            for(int i=0;i<G[v].size();i++){
                edge &e=G[v][i];
                if(e.cap==0||dist[e.to]<=dist[v]+e.cost+h[v]-h[e.to])continue;
                dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                prevv[e.to]=v;
                preve[e.to]=i;
            }
        }
        if(dist[t]==INF)return -1;
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }
        for(int v=0;v<MAX_V;v++)h[v]+=dist[v];

        f-=d;
        res+=d*h[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }
    return res;
}



signed main(){
    int n,v,xl,xr;

    cin>>n>>v>>xl>>xr;
    vint x(n),t(n),p(n);

    rep(i,n){
        cin>>x[i]>>t[i]>>p[i];
    }
    int src=MAX_V-2,snk=MAX_V-1,l=MAX_V-3,r=MAX_V-4;

    rep(i,n){
        add_edge(i*2,i*2+1,1,-p[i]);
        add_edge(i*2+1,snk,1,0);

        if(abs(xl-x[i])<=t[i]*v)add_edge(l,i*2,1,0);
        if(abs(xr-x[i])<=t[i]*v)add_edge(r,i*2,1,0);
    }

    for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j){
        if(abs(x[i]-x[j])<=v*(t[j]-t[i])){
            add_edge(i*2+1,j*2,1,0);
        }
    }
    add_edge(src,snk,2,0);
    add_edge(src,l,1,0);
    add_edge(src,r,1,0);

    cout<<-min_cost_flow(src,snk,2)<<endl;
    return 0;
}

Measured memory_bytes: 176316
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(d);

        if (n % 2 == 0)
        {
            var f = true;
            for (int i = 0; i < n / 2; i++)
            {
                f &= d[i * 2] == i * 2 + 1;
                f &= d[i * 2 + 1] == i * 2 + 1;
            }

            if (f) Console.WriteLine(m1(n / 2));
            else Console.WriteLine(0);
        }
        else
        {
            var f = d[0] == 0;
            for (int i = 0; i < n / 2; i++)
            {
                f &= d[i * 2 + 1] == i * 2 + 2;
                f &= d[i * 2 + 2] == i * 2 + 2;
            }

            if (f) Console.WriteLine(m1(n / 2));
            else Console.WriteLine(0);
        }
    }

    static long m1(int n)
    {
        var ans = 1L;
        for (int i = 0; i < n; i++)
        {
            ans = ans * 2 % 1000000007;
        }
        return ans;
    }
}


Measured memory_bytes: 18912
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main() {
  int A, B;
  cin >> A >> B;
  
  if (B % A == 0) {
    cout << B + A << endl;
  } else {
	cout << B - A << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9+10;
const double eps=1e-9;
const int maxn=1e5+10;
int a[maxn],b[maxn];
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	n=read();
	ll sum=0,Max=INF;
	int flag=0;
	for(i=1;i<=n;i++){
		a[i]=read(),b[i]=read();
		if(a[i]!=b[i])flag=1;
		sum+=a[i];if(a[i]>b[i])Max=min(Max,1ll*b[i]);
	}
	if(!flag)puts("0");
	else printf("%lld\n",sum-Max);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int arr[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s; cin >> s;
    int n = s.size(), cur = 0;

    for(int i = 0 ; i < n ; ++i){
        if(s[i] == 'R') ++cur;
        else if(s[i - 1] == 'R'){
            ++cur;
            arr[i] += cur - (cur >> 1);
            arr[i - 1] += cur >> 1;
            cur = 0;
        }
    }

    cur = 0;

    for(int i = n - 1; i >= 0; --i){
        if(s[i] == 'L') ++cur;
        else if(s[i + 1] == 'L' && cur > 1) {
            --cur;
            arr[i] += cur - (cur >> 1);
            arr[i + 1] += cur >> 1;
            cur = 0;
        } else cur = 0;
    }

    for(int i = 0; i < n; ++i)
        cout << arr[i] << " ";

    return 0;
}

Measured memory_bytes: 1104
#include <stdio.h>

int main(void) {
	int n,a[200],i,j,c=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(a[i]>max){max=a[i];}
	}
	for(i=0;i<max/2;i++){
		for(j=0;j<n;j++) {
			if(a[j]%2==0){a[j]=a[j]/2;}
			else{break;}
			if(j==n-1){c++;}
		}
	}		
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;import java.io.*;import java.math.*;

public class Main
{
	static HashMap<Long, Long> map = new HashMap<>();
	static long rec(long n){
		if(n==1)
			return 1l;
		if(map.containsKey(n))
			return map.get(n);

		long dp=rec(n/2);
		map.put(n,dp);
		return 1l+2l*dp;
	}
    public static void process()throws IOException
    {
    	long h=nl();
    	pn(rec(h));
    }


   	static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    	//oj = System.getProperty("ONLINE_JUDGE") != null;
    	if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
	
	
	

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int l = stdIn.nextInt();
        int[] t = new int[n]; // 味
        for (int i = 0; i < n; i++) {
            t[i] = l + i;
        }
        int min = Math.abs(t[0]);
        for (int i = 1; i < n; i++) {
            if (min > Math.abs(t[i]))
                min = Math.abs(t[i]);
        }
        int total = 0;
        for (int i = 0; i < n; i++) {
            total += t[i];
        }
        if (t[n - 1] < 0)
            System.out.println(total + min);
        else
            System.out.println(total - min);
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;




int main() {

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {

			printf("%dx%d=%d\n", i, j, i * j);


		}

	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3096
n,m = gets.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
g = n.gcd(m)
ans = true
for i in 0..g-1
    ans = false if s[n/g*i] != t[m/g*i]
end
if ans
    puts n*m/g
else
    puts -1
end

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N; string s; cin >> N;
  map<string, int> mp;
  REP(i, N){
    cin >> s;
    sort(ALL(s));
    mp[s]++;
  }
  int ans = 0;
  for(auto i : mp){
    ans += nCr(i.second, 2ll);
  }
  cout << ans << endl;
}

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

int main() {
    //
    long long num;
    long long kekka = 1;
    long long waru = 1000000007;
    vector<int> vec(26, 0);
    string str;

    cin >> num >> str;

    for (int i = 0; i < str.size(); i++){
        vec.at(str.at(i) - 'a')++;
    }

    for (int i = 0; i < 26; i++){
        kekka *= vec.at(i)+1;
        kekka %= waru;
    }

    cout << kekka - 1;

    //
}


Measured memory_bytes: 3752
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**8
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,M,R = LI()
    r = _LI()
    root = [[] for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        root[a-1].append((b-1,c))
        root[b-1].append((a-1,c))

    memo = [[0] * N for _ in range(N)]

    min_r = INF
    for x in itertools.permutations(r):
        it = 0
        s = x[0]
        for t in x[1:]:
            if memo[s][t]:
                it += memo[s][t]
            else:
                node = [INF] * N
                q = []
                heapify(q)
                heappush(q,(0,s))
                node[s] = 0
                while q:
                    l,u = heappop(q)
                    for v,m in root[u]:
                        if node[v] > l + m:
                            node[v] = l + m
                            heappush(q,(l+m,v))
                memo[s][t] = node[t]
                memo[t][s] = node[t]
                it += node[t]
            s = t
        min_r = min(min_r,it)
    print(min_r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52056
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

bool b[100010];
unordered_map<ll,int> mp;

int main(){
    ll n;cin>>n;
    ll a[n];
    int c=1;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(mp[a[i]]==0){
            mp[a[i]]=c;
            a[i]=mp[a[i]];
            c++;
        }else{
            a[i]=mp[a[i]];
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(b[a[i]]){
            ans--;
            b[a[i]]=false;
        }else{
            ans++;
            b[a[i]]=true;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 5284
# MAX = int(1e6)+2


n = int(input())
lis = list(map(int,input().split()))
lis.sort()
MAX = lis[-1]
lis2 = [0]*(MAX+1)
# lis.sort()
# m = max(lis)
ans = 0

for num in lis:
    for i in range(num, MAX+1, num):
            lis2[i] += 1

for j in set(lis):
    if lis2[j] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 39384
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;

typedef long long ll;

int t[200002];

int main(){
  int n;

  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }

    ll ans = 0;
    int x = 0;
    int rht = 0;
    
    for (int lft = 0; lft < n; lft++) {
      if (rht <= lft) {
        x = t[lft];
        rht = lft + 1;
      }
      ans += (ll)rht - lft;
      
      while (rht < n) {
        if ((x & t[rht]) == 0) {
          x ^= t[rht];
          rht++;
          ans++;
        } else {
          x ^= t[lft];
          break;
        }
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int ab[][] = new int[n][2];
            for (int i = 0; i < n; i++) {
                ab[i][0] = Integer.parseInt(in.next());
                ab[i][1] = Integer.parseInt(in.next());
            }
            int cd[][] = new int[m][2];
            for (int i = 0; i < m; i++) {
                cd[i][0] = Integer.parseInt(in.next());
                cd[i][1] = Integer.parseInt(in.next());
            }
            int dist[][] = new int[n][m];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    dist[i][j] = Math.abs(ab[i][0] - cd[j][0]) + Math.abs(ab[i][1] - cd[j][1]);
                }
            }

            // 出力
            int ans = 0;
            int mindist = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                ans = 0;
                for (int j = 0; j < m; j++) {
                    if (mindist > dist[i][j]) {
                        mindist = dist[i][j];
                        ans = j + 1;
                    }
                }
                out.println(ans);
                mindist = Integer.MAX_VALUE;
            }

        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e6+7;
ll n,t,zer;
ll z[maxn],f[maxn];
struct node
{
	ll a,b;
}e[maxn];
bool cmp(node x,node y)
{
	return y.a*(x.b+1)<x.a*(y.b+1);
}
int main()
{
//    freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n>>t;
	for(ll i=1;i<=35;i++) f[i]=t+1;
	
	for(ll i=1;i<=n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x==0) z[zer++]=y+1;
		else e[i-zer].a=x,e[i-zer].b=y;
	}
	n-=zer;
	sort(e+1,e+n+1,cmp);
	sort(z,z+zer);
	
	for(ll i=1;i<zer;i++)
	{
		z[i]+=z[i-1];
	}
	for(ll i=1;i<=n;i++)
	{
		for(ll j=35;j>=1;j--)
		{
			f[j]=min(f[j],(f[j-1]+1)*(e[i].a+1)+e[i].b);
		}
//		cout<<f[i]<<endl;
	}
	
	ll ans=0;
	for(ll i=0;i<=35;i++)
	{
//		cout<<f[i]<<endl;
		if(f[i]>t) continue;
		ll s=0;
		if(zer) s=upper_bound(z,z+zer,t-f[i])-z;
//		if(s==zer+1) s=zer;
//		if(f[i]+z[s]>t) continue;
		ans=max(ans,i+s);
	}
	cout<<ans<<endl;
	return 0;
}
 
 

Measured memory_bytes: 6760
#include <iostream>

using namespace std;

int main()
{
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    //cout << int('A');
    //cout << int('a');
    //cout << endl;
    k--;
    s[k] = char(int(s[k]) + int('a')-int('A'));
    cout << s;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	setIO();
	map<string, int > ans;
	cin >> n;
	while(n--) {
		cin >> s;
		ans[s]++;
	}

	vector < string > st = {"AC", "WA", "TLE", "RE"};

	for (auto it : st) {
		cout << it << " x " << ans[it] << '\n';
	}

	return Accepted;
}

// B...a

Measured memory_bytes: 17744
#include<iostream>
using namespace std;
int main(){
	int n,c=0;
  	long long d;
  	cin>>n>>d;
	d=d*d;
	long long x,y;
  	for(int i=0;i<n;++i){
      	cin>>x>>y;
		if(x*x+y*y<=d){
  			c++;
		}
  	}
  	cout<<c<<endl;
  	return 0;
}


Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll ans;
	ll n,x,m;

	cin >> n >> x >> m;
	
    vector<ll> sum_a(m+1,0);
	unordered_map<ll,ll> mem;

	ll sum = 0;

	ll first_i=0, final_i=0;
    for(ll i=0; i<n; i++){
		print(x)
		if(mem.find(x)!=mem.end()){
			first_i = mem[x];
			final_i = i;
			break;
		}
		sum += x;
		mem[x] = i;
		sum_a[i+1] = sum;
        x = (x*x)%m;
	}

	ll times = 0;
	ll bsec = sum;
	ll sec = 0;
	ll asec = 0;
	ll md = 0;
	if(final_i!=first_i){
		times = (n-first_i)/(final_i - first_i);
		md = (n-first_i)%(final_i - first_i);
		print(first_i, final_i)
		bsec = sum_a[first_i];
		sec = sum_a[final_i] - sum_a[first_i];
		asec = sum_a[first_i+md] - sum_a[first_i];
	}

	print(bsec, sec,asec, first_i,final_i, sum, times, md)

	ans = bsec + sec*times + asec;

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


Measured memory_bytes: 6108
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
        --p[i];
    }
    UnionFind tree(n);
    rep(i,m) {
        int x,y;
        cin >> x >> y;
        tree.unite(x-1,y-1);
    }
    int ans=0;
    rep(i,n) {
        if (tree.root(i)==tree.root(p[i])) ++ans;
    }
    cout << ans << endl; 
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;
static const int NIL = -1;

int N, M;
int p[MAX_N];

vector<int> G[MAX_N];
int island[MAX_N];

void dfs(int s, int cnt){
	island[s] = cnt;
	for(int i = 0; i < G[s].size(); i++){
		if(island[G[s][i]] == NIL) dfs(G[s][i], cnt);
	}
	return;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> p[i];
		p[i]--;
	}
	for(int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	fill(island, island + N, NIL);
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(island[i] == NIL){
			dfs(i, cnt);
			cnt++;
		}
		if(island[p[i]] == island[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9472
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int dp[301][301];

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


	int N, M;
	scanf("%d %d", &N, &M);

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = 1000;
		xm[i][2] = 1000;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	rep1(i, N) {
		for (int j = i - 1; j >= 0; j--) for (int k = i - 1; k >= j; k--) {
			int tmp = dp[j][k];
			dp[j][k] = 0;
			int jj = j;
			int kk = k;
			int OKJ = 1, OKK = 1;
			if (xm[i][1] < kk) OKK = 0;
			if (xm[i][2] < jj) OKJ = 0;
			if (xM[i][2] >= kk) OKK = 0;
			if (xM[i][3] >= jj) OKJ = 0;
			if (OKJ && OKK) dp[jj][kk] = tmp;
			kk = i;
			OKK = 1;
			if (xm[i][1] < kk) continue;
			if (xM[i][2] >= kk) continue;
			if (OKJ) {
				dp[jj][kk] += tmp;
				if (dp[jj][kk] >= mod) dp[jj][kk] -= mod;
			}
			jj = k;
			OKJ = 1;
			if (xm[i][2] < jj) OKJ = 0;
			if (xM[i][3] >= jj) OKJ = 0;
			if (OKJ) {
				dp[jj][kk] += tmp;
				if (dp[jj][kk] >= mod) dp[jj][kk] -= mod;
			}
		}
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[j][k];
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x, y;
    cin >> x >> y;
    if(x>y) {
        cout << ">" << endl;
    } else if(x==y) {
        cout << "=" << endl;
    } else {
        cout << "<" << endl;
    }
}

Measured memory_bytes: 256
<?php
  list($n, $x, $y) = explode(" ", trim(fgets(STDIN)));

  $a = [];

  for($i=1;$i<=$n;$i++){
    if(!isset($a[$i])){
      $a[$i]=0;
    }
    for($j=$i+1;$j<=$n;$j++){
      if($i <= $x && $j <= $x){
//        echo "1:".$j." ".$i.PHP_EOL;
        $dist = $j-$i;
      }
      else if($i <= $x && ($j > $x && $j < $y)){
//        echo "2:".$j." ".$i.PHP_EOL;
        $dist = min($j-$i, $x-$i+$y-$j+1);
      }
      else if($i <= $x && $j >= $y){
//        echo "3:".$j." ".$i.PHP_EOL;
        $dist = $x-$i+$j-$y+1;
      }
      else if(($i > $x && $i < $y) && ($j > $x && $j < $y)){
//        echo "4:".$j." ".$i.PHP_EOL;
        $dist = min($j-$i, $i-$x+$y-$j+1);
      }
      else if(($i > $x && $i < $y) && $j >= $y){
        $dist = min($j-$i, $i-$x+$j-$y+1);
      }
      else if($i >= $y){
//        echo "5:".$j." ".$i.PHP_EOL; 
        $dist = $j-$i;
      }
      if(!isset($a[$dist])){
        $a[$dist]=0;
      }
//      if($dist==1){
//        echo $i." ".$j.PHP_EOL;
//      }
      $a[$dist]++;
    }
  }
  for($i=1;$i<=$n-1;$i++){
    echo $a[$i].PHP_EOL;
  }

Measured memory_bytes: 4728
#include <iostream>
using namespace std;
#define LL	long long
const LL MOD=1e9+7;

int N, K;
int main() {
	cin >> N >> K;
	LL ans = 0;
	for(int i=K; i<=N+1; i++) {
		LL left = 1LL * (0+i-1)*i/2;
		LL right = 1LL * (N-i+1+N)*i/2;
		ans += right - left + 1;
		ans %= MOD;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3604
X,K,D=map(int,input().split())
 
x=min(K,abs(X)//D)
 
if X>0:
    X_=X-(D*x)
else:
    X_=X+(D*x)
 
k=K-x
if k%2!=0:
    ans=min(abs(X_-D),abs(X_+D))
else:
    ans=abs(X_)
print(ans)

Measured memory_bytes: 9168
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int a,x,y;
    scanf("%d",&a);
    x=a%10;
    y=a/10;
    if(x == 9 || y == 9)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3128
N,K = map(int,input().split())
A = list(map(int,input().split()))
L,R,C = [0],[0],[sum(A[:K])]
for i in range(N):
    L.append(L[-1]+max(A[i],0))
    R.append(R[-1]+max(A[N-i-1],0))
for i in range(N-K):
    C.append(C[-1]+A[i+K]-A[i])
ans = 0
for i in range(N-K+1):
    ans = max(ans,L[i]+C[i]+R[N-K-i],L[i]+R[N-K-i])
print(ans)

Measured memory_bytes: 21440
#include <stdio.h>
int main(void)
{
 int n,i;
  double x,goukei;
 char u[10];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%lf %s",&x,&u[i]);
   if(u[i]=='B')
     goukei=goukei+x*380000;
    else 
      goukei=goukei+x;
   
  }
  printf("%lf\n",goukei);
 
}

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

long gcd(long a, long b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long lcm(long a, long b) {
    return a / gcd(a, b) * b;
}
int main() {
  int n;cin>>n;
  long tn[n];
  rep(i,n)cin>>tn[i];
  sort(tn,tn+n);
  
  long l=1;
  rep(i,n) {
    if (i>0 and tn[i]==tn[i-1]) continue;
    l = lcm(l,tn[i]);
  }
  cout << l;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
stores = []
for _ in range(N):
  stores.append(tuple(map(int, input().split())))
res = 0
for store in sorted(stores):
  if M <= 0:
    break
  num = min(M, store[1])
  res += num * store[0]
  M -= num
print(res)

Measured memory_bytes: 17756
#include <stdio.h>

int main(void) {

  int a, b;

  scanf("%d %d", &a, &b);

  if(a < b)
    printf("a < b\n");
  else if (a > b)
    printf("a > b\n");
  else
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	const ll mod = 1000000007;
	ll n, a, b, nCa, nCb = 1, ans;
	std::cin >> n >> a >> b;

	a--;
	rep(i, 0, b) {
		nCb = nCb * (n - i) % mod;
		nCb = nCb * modinv(1 + i, mod)%mod;
		if (nCb > mod) {
			nCb = nCb;
		}
		if (i == a) {
			nCa = nCb;
		}
	}
	ans = pow2(2, n, mod) - 1 - nCa - nCb;
	while (ans < 0) {
		ans += mod;
	}

	std::cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end());
    
    for(int i = 1; i < n; i++) {
        if(v[i] == v[i - 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}


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

int mygcd(int m, int n) {
  if(n==0) {
    return m;
  }
  else {
    return mygcd(n, m % n);
  }
}

long long mylcm(long long a, long long b) {
    return a * b / mygcd(a, b);
}

void solve(long long A, long long B, long long C, long long D){
  long long a = (A-1)/C;
  a += (A-1)/D;

  long long b = B/C;
  b += B/D;

  long long l = mylcm(C,D);


  cout << (((B-b)+(B/l)) - (((A-1)-a)+((A-1)/l)))<< endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long D;
  scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    ll n,h,w;
    cin>>n>>h>>w;
    int ans=0;
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        if(a>=h&&b>=w)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3540
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	B := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		var a int
		fmt.Scan(&a)
		B[i] = a
	}
	A := make([]int, N)
	A[0] = B[0]
	A[N-1] = B[N-2]
	for i := 0; i < N-2; i++ {
		A[i+1] = B[i+1]
		if B[i] < B[i+1] {
			A[i+1] = B[i]
		}
	}
	sum := 0
	for _, a := range A {
		sum += a
	}
	fmt.Println(sum)

}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int h,w;
char field[10][10];

void dfs(int x,int y){
    field[x][y] ='.';
    bool flag =false;
    if(!flag &&0<=x+1 && x+1<h && field[x+1][y] =='#'){
        flag =true;
        dfs(x+1,y);
    }
    if(!flag &&0<=y+1 && y+1<w && field[x][y+1] =='#'){
        flag =true;
        dfs(x,y+1);
    }
    return ;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>field[i][j];
        }
    }
    dfs(0,0);
    bool can=true;
    rep(i,h){
        rep(j,w){
            if(field[i][j]=='#') can=false;
        }
    }
    if(can){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll X, A;
int main(){
    scanf("%lld%lld", &X,&A);
    if(X>=A)
        printf("10");
    else 
        printf("0");

    return 0;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  if (S.at(K - 1) == 'A'){
    S.at(K - 1 ) = 'a';
  }
  else if (S.at(K-1) == 'B'){
    S.at(K-1) = 'b';
  }
  else {
    S.at(K-1) = 'c';
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
k=int(input())
# num から始まる digit 桁（num 含む）のルンルン数の個数を返す
def count(digit,num):
    if digit==1:
        return 1
    c=0
    if num!=0:
        c+=count(digit-1,num-1)
    c+=count(digit-1,num)
    if num!=9:
        c+=count(digit-1,num+1)
    return c

# num から始まる digit 桁（num 含む）のルンルン数の中で i 番目の ans を返す
def answer(digit,num,i,ans):
    # print(digit,num,i,ans)
    if digit==2:
        add=(i+num-2)
        if num==0:
            add+=1
        return ans*10+add
    if num!=0:
        c=count(digit-1,num-1)
        if c>=i:
            return answer(digit-1,num-1,i,ans*10+num-1)
        i-=c
    c=count(digit-1,num)
    if c>=i:
        return answer(digit-1,num,i,ans*10+num)
    i-=c
    if num!=9:
        c=count(digit-1,num+1)
        if c>=i:
            return answer(digit-1,num+1,i,ans*10+num+1)
    return 0

size=9
num=1
digit=2
while True:
    s=count(digit,num)
    if s+size>=k:
        break
    size+=s
    num+=1
    if num==10:
        num=1
        digit+=1
ans=0
if k<=9:
    ans=k
else:
    ans=answer(digit,num,k-size,num)
print(ans)


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

int main(){
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S == U){
        cout << A - 1 << ' ' << B << endl;
    }else{
        cout << A << ' ' << B - 1 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
i = 0
cnt = 0
while A[i] < X:
	cnt += 1
	i += 1
if A[i] == X:
	opp = M - cnt -1
else:
	opp = M - cnt
print(min(cnt, opp))

Measured memory_bytes: 3060
/* ex4_3
   moka223711 */

#include <stdio.h>

int snow(int h_west, int h_east); // 積雪量を求める関数のプロトタイプ宣言

int main(void){
    // 高さがn(n+1)/2[m](n=1,2,…,999)の999本の塔が西から順に立っている
    // 雪に埋もれていない塔の高さから雪が何m積もっているか求める
    // 雪に埋もれていない西側の塔の高さをh_west、東側の塔の高さをh_eastとする
    
    int h_west, h_east;
    scanf("%d %d", &h_west, &h_east);
    
    printf("%d\n", snow(h_west, h_east));
    
    return 0;
}

    // 積雪量を求める関数の定義
int snow(int h_west, int h_east){
    int dif, ans;
    
    // 東側の塔の高さから西側の塔の高さを引き、差difを求める
    dif = h_east - h_west;
    // ここでdifは東側の塔がdif番目の塔であることを表す
    
    // 差difから東側の塔の高さを求めて、雪に埋もれていない塔の高さを引くことで
    // 雪が何m積もっているかを求める
    ans = dif * (dif + 1) / 2 - h_east;
    
    // ansを返り値として返す
    return ans;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool k[100];
int main(void){
    string s; cin>>s;
    string S="keyence";
    for(int i=0;i<s.size();i++){
		int a=0;
		bool k=true;
		for(int j=0;j<i;j++){
			if(S[a]==s[j]){
				
			}else{
				k=false;
			}
			a++;
		}
		for(int j=i+s.size()-7;j<s.size();j++){
			if(S[a]==s[j]){
				
			}else{
				k=false;
			}
			a++;
		}
		if(k){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
    
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,K;
	int[] a;
	public void solve() {
		N = nextInt();
		K = nextInt();
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		long ans = Long.MAX_VALUE;

		for(int i = 0;i < 1 << N;i++){
			int maxh = 0;
			int count = 0;
			long cost = 0;
			for(int j = 0;j < N;j++){

				int add = 0;

				if(maxh >= a[j]){
					if((i>>j&1) == 1){
						add = (maxh - a[j] + 1);
						cost += add;
						count++;
					}
				}else{
					count++;
				}
				maxh = Math.max(maxh, a[j] + add);
			}

			if(count >= K)ans = Math.min(ans, cost);
		}

		out.println(ans);
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21588