akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int ans = 0;
	int Max = 0;
	rep(i, 5) {
		int t;
		cin >> t;
		int div = t / 10;
		if (t % 10) {
			++div;
			Max = max(Max, 10 - (t % 10));
		}

		ans += div * 10;
	}
	ans -= Max;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
using namespace std;
#define int         long long int
#define vi           vector<int>
#define pii          pair<int,int>
#define vpp          vector<pii>
#define mii          map<int,int>
#define pb           push_back
#define rep(i,a,bb)  for(int i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         int T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzint(x)
#define endl '\n'
#define debug(x)  cerr<<"[ "<<#x<<" : "<<x<<" ]"<<endl
#define debugp(x) cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define debugs(x) cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define debugm(x) cerr<<"----------"<<endl; for(auto i:x) cerr<<i.ff<<":"<<i.ss<<endl; cerr<<"----------"; 
#define PI 3.14159265359
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int dxk[]={0,0,1,-1,1,1,-1,-1};
int dyk[]={1,-1,0,0,1,-1,1,-1};
const int inf = 1e+18;
const int mod = 1e+9 + 7;

void solve()
{
	int l, r, d;
	cin>>l>>r>>d;
	int ans = 0;
	rep(i,l,r+1){
		if(i%d==0)
		 ++ans;
	}
	cout<<ans<<endl;
}

int32_t main()
{
  fast;
  //test
  solve();
  return 0;
}


Measured memory_bytes: 3644
#define FILEIO(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
#include <stdio.h>
#include <queue>
#include <algorithm>
#define N 10005
using namespace std;
int n,k,q,a[N],b[N],c[N];
inline void smin(int &a,int b){b<a?a=b:0;}
inline int read() {
	char c=getchar();int x=0;
	while(c<48||c>57) c=getchar();
	while(c>47&&c<58) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x;
}
int solve(int x) {
	int i,j,ans,m,t,p;
	ans=0;m=0;
	for(i=0;i<n;++i) {
		for(j=i;j<n&&a[j]>=x;++j);
		if(j-i>=k) {
			p=j-i-k;
			for(t=0;i<j;) b[t++]=a[i++];
			sort(b,b+t);
			while(~p) c[m++]=b[p--];
		}
	}
	if(m<q) return 1<<30;
	sort(c,c+m);
	return c[q-1]-x;
}
int main() {
//	FILEIO("operation");
	int i,ans=1<<30;
	n=read();k=read();q=read();
	for(i=0;i<n;++i) a[i]=read();
	for(i=0;i<n;++i) smin(ans,solve(a[i]));
	printf("%d",ans);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();

		long P = B / C - (A - 1) / C;
		long Q = B / D - (A - 1) / D;
		long R = B / lcm(C, D) - (A - 1) / lcm(C, D);

		long ans = (B - A + 1) - P - Q + R;

		System.out.println(ans);

	}

	public static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	public static long gcd(long a, long b) {
		long c = a % b;
		if (c == 0)
			return b;

		return gcd(b, c);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

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

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n,tmp,h,i;
  cin>>n;
  cin>>tmp;
  tmp--;
  for(i=1;i<n;i++){
    cin>>h;
    if(h<tmp){
      cout<<"No"<<endl;
      return 0;
    }
    else if(h==tmp){
      tmp=h;
    }
    else{
      tmp=h-1;
    }
  }
  cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

const int MAX_N = (1 << 21);
int N, A[MAX_N], B[MAX_N]; vector<int>X[MAX_N];
long long dp0[MAX_N], dp1[MAX_N], ans, mod = 1000000007;

long long solve(vector<pair<int, int>> Z) {
	for (int i = 0; i <= Z.size(); i++) { dp0[i] = 0; dp1[i] = 0; }
	
	long long s0 = 1, s1 = 0; dp0[0] = 1;
	for (int i = 0; i < Z.size(); i++) {
		if (Z[i].first == 0) { dp0[i + 1] = 1LL * s1 * Z[i].second; dp0[i + 1] %= mod; }
		if (Z[i].first == 1) { dp1[i + 1] = 1LL * s0 * Z[i].second; dp1[i + 1] %= mod; }
		s0 += dp0[i + 1]; s0 %= mod;
		s1 += dp1[i + 1]; s1 %= mod;
	}
	return (dp0[Z.size()] + dp1[Z.size()]) % mod;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; B[i] = (B[i - 1] ^ A[i]); }
	for (int i = 0; i <= N; i++) X[B[i]].push_back(i);

	for (int i = 1; i < MAX_N; i++) {
		if (X[i].size() == 0) continue;
		if (B[N] != 0 && B[N] != i) continue;

		vector<pair<int, int>> Z; Z.push_back(make_pair(1, 1));
		for (int j = 0; j < X[i].size() - 1; j++) {
			int pos1 = lower_bound(X[0].begin(), X[0].end(), X[i][j]) - X[0].begin();
			int pos2 = lower_bound(X[0].begin(), X[0].end(), X[i][j + 1]) - X[0].begin();
			if (pos2 - pos1 >= 1) Z.push_back(make_pair(0, pos2 - pos1));
			Z.push_back(make_pair(1, 1));
		}
		int pos3 = lower_bound(X[0].begin(), X[0].end(), X[i][X[i].size() - 1]) - X[0].begin();
		int pos4 = lower_bound(X[0].begin(), X[0].end(), N - 1) - X[0].begin();
		if (pos4 - pos3 >= 1) Z.push_back(make_pair(0, pos4 - pos3));

		if (B[N] == 0) Z.push_back(make_pair(0, 1));
		if (B[N] == i) Z.push_back(make_pair(1, 1));
		
		ans += solve(Z);
	}

	if (B[N] == 0) {
		int cnt = 0;
		for (int i = 1; i <= N - 1; i++) { if (B[i] == 0) cnt++; }
		long long rem = 1; for (int i = 0; i < cnt; i++) { rem *= 2; rem %= mod; }
		ans += rem; ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 72036
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

void add(ll &a, ll b){
    a += b;
    if(a >= MOD) a -= MOD;
}

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;
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    ll ans = 0;
    rep(i, n){
        ll cnt = 0;
        ll r = 0;
        rep(j, n){
            if(v[i] > v[j] && i < j) r++;
            if(v[i] > v[j]) cnt++;
        }


        ll a = (((cnt*k)%MOD)*(k-1))%MOD;
        a = a * modinv(2, MOD);
        a %= MOD;

        ll b = (r*k)%MOD;
        add(a, b);
        add(ans, a);
    }

    cout << ans << endl;
}

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

using namespace std;
const int MAXN=1e5+5;
int dp[MAXN][4];
int a[MAXN],b[MAXN],c[MAXN];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][1]=a[1];dp[1][2]=b[1];dp[1][3]=c[1];
	for(int i=2;i<=n;++i)
	{
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	int ans=-1; 
	for(int i=1;i<=3;++i)
	 	ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

	int a;

	cin >> a;

	cout << pow(a,3) + pow(a,2) + pow(a,1) << '\n';
	
	return 0;
}

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


int main() {
    string  a;
    string b;
    string c;
    cin >> a >> b;
    c = b.substr(0,b.length()-1);
    if(a == c){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3524
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

static const int MOD = 1000000007;

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

	ll ans = 1;

	for (int i = 1;i <= N;i++) {
		ans = (ans*i) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	for i := 1; i < len(s); i = i + 2 {
		if s[i] == 'R' {
			fmt.Println("No")
			return
		}
	}
	for i := 0; i < len(s); i = i + 2 {
		if s[i] == 'L' {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


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

int main()
{
     int n, m;
     cin >> n >> m;
     vector <pair<int, int> > v(n);
     for(int i=0; i<n; i++)
     {
         cin >> v[i].first >> v[i].second;
     }
     priority_queue <int> pq;
     sort(v.begin(), v.end());
     int sum=0, cnt=0;
     for(int i=0; i<m; i++)
     {
         while(cnt<n && v[cnt].first==i+1)
         {
             pq.push(v[cnt].second);
             cnt++;
         }
         if(!pq.empty())
         {
             sum+=pq.top();
             pq.pop();
         }

     }
     cout << sum << endl;
     return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    // x[i]: 深さiで葉でない, sum[i]: a[i]までの累積和
    vector<ll> a(n+1), b(n+1, 0), sum(n+1, 0);
    rep(i, n+1) cin >> a[i];
    sum[0] = a[0];
    rep(i, n) {
        sum[i+1] = sum[i] + a[i+1];
    }
    ll ans = 0;

    bool ok = true;
    rep(i, n+1) {
        if(i == 0) {
            b[i] = 1-a[i];
            if(b[i] < 0) {
                ok = false;
                break;
            }
            ans++;
        }
        else {
            ll ub = min(2*b[i-1]-a[i], sum[n]-sum[i]);
            if(b[i-1]-a[i] > ub || ub < 0) {
                ok = false;
                break;
            }
            else {
                b[i] = ub;
                ans += (a[i] + b[i]);
            }
        }
    }

    if(ok) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
const string str[4] = {"maerd", "esare", "resare", "remaerd"};

int main() {
    string s;
    cin >> s;
    int n = s.length();
    reverse(s.begin(), s.end());
    
    bool ans = true;
    int i = 0;
    while (i < (int)s.length()) {
        bool flag = true;
        for (int j = 0; j < 4; j++) {
            int sz = str[j].length();
            if (s.substr(i, sz) == str[j]) {
                flag = false;
                i += sz;
                break;
            }
        }
        if (flag == true) {
            ans = false;
            break;
        }
    }
    
    cout << ((ans) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

int main()
{
    ll n,i,j,cnt=1,k=1,w1,w2,w3,t,a,b,c,d,e,s,r;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	ll h[n];
	ll dp[n];

	for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1];


    return 0;
}


Measured memory_bytes: 1792
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**6)
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
od=998244353
n,k,x=list(map(int,input().split()))

n_c_i=[1]
pow_k=pow(k-1,n,od)
inv_k=pow(k-1,od-2,od)
each_cal=[]
zenpou=[1]
kouhou=[]
for i in range(1,x+1):
    n_c_i.append((n_c_i[-1]*(n-i)*pow(i,od-2,od))%od)
for i in range(n-1):   
    zenpou.append(zenpou[-1]*(k-1)%od)
for i in range(x+1):
    pow_k=pow_k*inv_k%od
    kouhou.append(pow_k)
    each_cal.append(pow(k-1,n-i-1,od))
#zenpou=zenpou[n-x-1:]
zenpou.reverse()
#print(zenpou[0],each_cal[0])
#print(zenpou[-1],each_cal[-1])
#print(len(zenpou))
#print(len(each_cal))
ans=0
for i in range(x+1):
    #each_calのみAC
    #zenpouとkouhouはWA
    #なぜ？
    ans+=(n_c_i[i]*k*zenpou[i])%od
    ans%=od

print(ans)



Measured memory_bytes: 58340
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main(void){
	int n;
	cin >> n;
	
	if(n%4==0 || n%7==0){
		cout << "Yes" << endl;
		exit(0);
	}

	for(int i=1;i<=25;i++){
		for(int j=1;j<=14;j++){
			if(n==(4*i)+(7*j)){
				cout << "Yes" << endl;
				exit(0);
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N,P = map(int,input().split())
S = list(map(int,list(input())))
if P==2:
    cnt = 0
    for i in range(N):
        if S[i]%2==0:
            cnt += i+1
elif P==5:
    cnt = 0
    for i in range(N):
        if S[i]==0 or S[i]==5:
            cnt += i+1
else:
    A = [0 for _ in range(N)]
    a = 0
    b = 1
    for i in range(N-1,-1,-1):
        a = (a+b*S[i])%P
        A[i] = a
        b = (b*10)%P
    C = {i:0 for i in range(P)}
    for i in range(N):
        C[A[i]] += 1
    cnt = 0
    for i in range(P):
        cnt += (C[i]*(C[i]-1))//2
    cnt += C[0]
print(cnt)

Measured memory_bytes: 100032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;
ll com(string a,string b,ll k){
	bool f = true ;
	rep(i,k)
		if(a[i]==b[i])
			f = false ;
	return 	f ;
}


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// int t ;
	// cin>>t;
	// whln(t){
	ll n,cnt=0 ;
	cin>>n;
	string a ;
	cin>>a;
	rep(i,n-2){
		if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
			cnt++;

	}
	cout<<cnt<<"\n";
		
	return 0 ;
	 // }
		
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll>a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  rep(i,n)a[i]*=-1;
  if(n<=k){
    cout<<0<<endl;
    return 0;
  }
  
  sort(a.begin(),a.end());
  rep(i,n)a[i]*=-1;
  rep(i,k)sum-=a[i];
  cout<<sum<<endl;
  
  
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int flag=0;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='7')flag=1;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3592
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
public class Main {
    
    public static char[] ans;
    public static char[] s;
    public static char[] t;
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        s = sc.next().toCharArray();
        t = sc.next().toCharArray();
        int n = s.length;
        int m = t.length;
        int[][] dp = new int[n+1][m+1];
        //deb(Arrays.toString(dp[0]));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                dp[i][j] = dp[i-1][j-1];
                if(s[i-1]==t[j-1]){
                    dp[i][j]++;
                } else {
                    dp[i][j] = Math.max(dp[i][j],dp[i][j-1]);
                    dp[i][j] = Math.max(dp[i][j],dp[i-1][j]);
                }
                
            }
            //deb(Arrays.toString(dp[i]));
        }
        ans = new char[dp[n][m]];
        find(dp,n,m,dp[n][m]-1);
        str.append(new String(ans));
        
        
        pw.println(str.toString());
        
        pw.close();
    }
    public static void find(int[][] dp,int x,int y,int i){
        if(x==0||y==0||i<0){
            return;
        }
        if(s[x-1]==t[y-1]){
            ans[i]=s[x-1];
            find(dp,x-1,y-1,i-1);
        } else if(dp[x][y]==dp[x-1][y]){
            find(dp,x-1,y,i);
        } else if(dp[x][y]==dp[x][y-1]){
            find(dp,x,y-1,i);
        } else if(dp[x][y]==dp[x-1][y-1])
            find(dp,x-1,y-1,i);
    }
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   public static <T> void deb(T x){
       System.out.println(x);
   }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 84660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    vector<string>strings;
    int k;
    cin >> s >> k;
    REP(i,s.length()){
        FOR(j,1,k+1){
            if(i+j > s.length())break;
            string a = s.substr(i,j);
            strings.push_back(a);
        }
    }
    sort(ALL(strings));
    int tmp = k-1;
    REP(i,strings.size()){
        //cout << strings[i] << endl;
        if(tmp<=0){
            cout << strings[i] << endl;
            return 0;
        }
        if(strings[i] != strings[i+1]){
            tmp--;
        }
    }
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n,k;
    cin >> n >> k;

    vector<ll> num_rest(k, 0);
    for(int i = 1; i <= n; ++i) {
        num_rest[i%k]++;
    }

    ll res = 0;
    for(int a = 0; a < k; ++a) {
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k != 0) {
            continue;
        }

        res+=num_rest[a] *  num_rest[b] * num_rest[c];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define M 100000

int m, a, b;
int p, q;
long max;
long prime[M];
long prime2[M] = {};
int tmp = 0;

void c()
{
    for (int i = 0; i < 50000; i++)
    {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;

    for (int i = 2; i < 317; i++)
    {
        if (prime[i])
        {
            for (int j = i * 2; j < M; j += i)
            {
                prime[j] = 0;
            }
        }
    }
    for (int i = 2; i < M; i++)
    {
        if (prime[i])
        {
            prime2[tmp] = i;
            tmp++;
        }
    }
}

int main()
{
    c();
    while (1)
    {
        scanf("%d %d %d", &m, &a, &b);
        if (a == 0 && b == 0 && m == 0)
            return 0;
        max = 0;
        p = q = 0;
        double asu = (double)a / (double)b;

        for (int i = 0; i < tmp; i++)
        {
            if (prime2[i] > m)
                break;
            for (int j = i; j < tmp; j++)
            {
                if (prime2[i] * prime2[j] > m || prime2[i] * 1.0 / prime2[j] < a * 1.0 / b)
                    break;
                if (prime2[i] * prime2[j] > max)
                {
                    max = prime2[i] * prime2[j];
                    p = prime2[i];
                    q = prime2[j];
                }
            }
        }
        printf("%d %d\n", p, q);
    }
    return 0;
}


Measured memory_bytes: 2680
import numpy as np

if __name__ == "__main__":
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    for i in range (N):
        if(V[i] > C[i]):
            ans += V[i] - C[i]
    print(ans)

Measured memory_bytes: 12488
N, L = map(int, input().split())
As = list(map(int, input().split()))
n = -1
for i in range(1, N):
  if As[i-1]+As[i] >= L:
    n = i
    break
#print(n)
if n < 0:
  print("Impossible")
  exit()
print("Possible")
for i in range(n-1):
  print(i+1)
for i in reversed(range(n, N)):
  print(i)


Measured memory_bytes: 14052
package main

import "fmt"

func main() {
	var (
		o, e, a string
		diff bool
		)
	fmt.Scan(&o, &e)

	if len(o) != len(e){
		diff = true
	}

	for i := 0; i < len(o); i++ {
		a += string(o[i])
		if i == len(o)-1 && diff == true{
			break
		}
		a += string(e[i])
	}
	fmt.Println(a)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, K;
constexpr int Nmax = 2000;

int distance_[Nmax];

vector<vector<int>> to;

int search(int a, int b)
{
    REP(i, N) distance_[i] = 3000;

    distance_[a] = 0;
    queue<int> q;
    q.push(a);
    if (K % 2)
    {
        distance_[b] = 0;
        q.push(b);
    }
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        if (distance_[now] < K / 2) for (auto nxt : to[now]) if (distance_[nxt] > 2000)
        {
            distance_[nxt] = distance_[now] + 1;
            q.push(nxt);
        }
    }
    int count = 0;
    REP(i, N) count += (distance_[i] <= K / 2);
    return count;
}

int main()
{
    cin >> N >> K;
    to.resize(N);

    REP(_, N - 1)
    {
        int a, b;
        cin >> a >> b;
        to[a - 1].push_back(b - 1);
        to[b - 1].push_back(a - 1);
    }

    int ikeru = 0;
    REP(a, N) for (auto b : to[a]) ikeru = max(ikeru, search(a, b));
    cout << N - ikeru << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  if(N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
  else if(N[1] == N[2] && N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int _data[105][105];
int f[105][105];
signed main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=m;++j){
			char c;
			while((c=getchar())!='.'&&c!='#');
			_data[i][j]=(c=='#');
		}
	f[1][1]=_data[1][1];
	for(register int i=2;i<=n;i++){
		f[i][1]=f[i-1][1]+(_data[i][1]&&!_data[i-1][1]);
	}
	for(register int j=2;j<=m;j++){
		f[1][j]=f[1][j-1]+(_data[1][j]&&!_data[1][j-1]);
	}
	for(register int i=2;i<=n;i++)
		for(register int j=2;j<=m;j++){
			f[i][j]=min(f[i-1][j]+(_data[i][j]&&!_data[i-1][j]),f[i][j-1]+(_data[i][j]&&!_data[i][j-1]));
		}
	printf("%d\n",f[n][m]);
	return 0;
}

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

int main()
{   
    int i, j;
    int n;
    int a, b;
    int ans = 0;
    int array[100005] = {};
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a >> b;

        for(j = a; j <= b; j++){
            array[j]++;
        }
    }
    
    for(i = 2; i < 100002; i++){
        if(i-1 <= array[i]){
            ans = i-1;
        }
    }
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3488
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    for (int i = 0; i < m; ++i) cin >> c[i] >> d[i];
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        int min = 1 << 29;
        for (int j = 0; j < m; ++j) {
            int dis = (abs(a[i]-c[j]) + abs(b[i]-d[j]));
            if (dis < min) {
                min = dis;
                ans[i] = j+1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << std::endl;
    }
    return 0;
}

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

signed main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  sort(H.begin(), H.end());
  
  int ans = 10000000000;
  for( int i = 0; i < N-K+1; i++ ){
    if( H.at(i+K-1) - H.at(i) < ans ) ans = H.at(i+K-1) - H.at(i);
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 1024
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1E6 + 5;

vector<int> cnt(maxn, 0);

int32_t main() {
    fastIO();
    
    int n, tok = 1;
    cin >> n;
    while (!cnt[n]) ++tok, cnt[n] = 1, n = (n&1 ? 3*n + 1 : n/2);
    cout << tok << "\n";
    
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 500010;
const int mod = 1e9+7;
LL fac[N],inv[N];
LL C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
LL A(int n,int m){
	return C(n,m)*fac[m]%mod;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	fac[0]=fac[1]=1;
	for(int i=2;i<=m;i++){
		fac[i]=fac[i-1]*i;
		fac[i]%=mod;
	}
	inv[0]=inv[1]=1;
	for(int i=2;i<=m;i++){
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	}
	for(int i=2;i<=m;i++){
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
	LL ans=A(m,n);
	for(int i=1;i<=n;i++){
		LL t=C(n,i)*A(m-i,n-i)%mod*(i%2==0?1:-1)%mod;
		ans+=t;
		ans=(ans+mod)%mod;
		//cout<<t<<' '<<C(n,i)<<' '<<A(m-i,n-i)<<endl;
	}
	cout<<ans*A(m,n)%mod<<endl;
	return 0;
}

Measured memory_bytes: 11276
function main(input){
  let s = input.split("\n")[0];
  let t = input.split("\n")[1];
  let sArray = s.split("");
  let tArray = t.split("");
  let count = 0;
  
  for(let i=0; i<sArray.length; i++){
    if(sArray[i]!==tArray[i]){
      count++;
    }
  }
  console.log(count);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36464
$n = <>;chomp $n;
$sum = 0;
for (my $i = 0; $i < $n; $i++) {
    $l = <>;chomp $l;
    @a = split / /, $l;
    $sum += $a[1] eq 'BTC' ? $a[0] * 380000 : $a[0];
}

print $sum;


Measured memory_bytes: 512
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int Lefthand(std::string c) {
	if (c == "#") {
		return -1;
	}else if(c == "y"||c == "u"||c == "i"||c == "o"||c == "p"||c == "h"||c == "j"||c == "k"||c == "l"||c == "n"||c == "m"){
		return 0;
	}else {
		return 1;
	}
}

int main(void) {
	char c;
	std::string str;
	std::string dstr;
	getline(cin, str);
	dstr = str.substr(0,1);
	int mode;
	mode = Lefthand(dstr);
	
	while (!(mode < 0)) {
		int change_num = 0;
		for (int i = 0; i < (str.length()-1); i++) {
			bool seq = true;	
			dstr = str.substr(i,1);
			mode = Lefthand(dstr);
			while (seq && i < (str.length()-1)) {
					int mode_next;
					dstr = str.substr(i+1,1);
					mode_next = Lefthand(dstr);
					if (mode != mode_next) {
						change_num++;
						seq = false;
					} else{
						i++;
					}
			}
		}
		cout << change_num << endl;
		getline(cin, str);
		dstr = str.substr(0,1);
		mode = Lefthand(dstr);
	}
	return 0;
}

Measured memory_bytes: 3160
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(m)]
l,r = [list(i) for i in zip(*k)]

x = max(l)
y = min(r)

p = 0
for i in range(1,n+1):
    if x <= i and i <= y:
        p += 1

print(p)

Measured memory_bytes: 35632
while True:
  m, f, r = list(map(int, input().split()))
  ABSENT = m==-1 or f==-1
  A = 80<=m+f 
  B = 65<=m+f<80
  C = 50<=m+f<65
  D = 30<=m+f<50
  DC = D and 50<=r
  F = m+f<30
  if m == f == r == -1:
    break
  elif ABSENT or F:
    print("F")
  elif A:
    print("A")
  elif B:
    print("B")
  elif C or DC:
    print("C")
  elif D:
    print("D")


Measured memory_bytes: 5596
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i=a; i<=b; i++){
			if(i%k == 0){
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}


Measured memory_bytes: 27072
N, M = map(int, input().split(" "))
high = list(map(int, input().split(" ") ) )
bad = set()

for _ in range(M):
    a, b = map(int, input().split(" "))
    if high[a-1] > high[b-1] :
        bad.add(b)
    elif high[b-1] > high[a-1] :
        bad.add(a) 
    else :
        bad.add(a)
        bad.add(b)

print(N-len(bad))

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

using namespace std;
int dp[100001];
int solve(int h[],int n)
{
    if(dp[n]!=-1)return dp[n];
   if(n==0)return 0;
   if(n==1)return dp[n]=abs(h[1]-h[0]);

   int c1=solve(h,n-1)+abs(h[n]-h[n-1]);
   int c2=solve(h,n-2)+abs(h[n]-h[n-2]);
   return dp[n]=min(c1,c2);


}



int main()
{
    int n;
    cin>>n;
    int h[n];

    memset(dp,-1,sizeof(dp));
    dp[0]=0;

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

    }
    cout<<solve(h,n-1)<<endl;
    //for(int i=0;i<=n;i++)
       // cout<<dp[i]<<" ";
}


Measured memory_bytes: 12164
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[2000005];
  scanf("%s", s);
  ll n = strlen(s);
  ll a = -1, z;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A' && a < 0)
      a = i;
    if (s[i] == 'Z')
      z = i;
  }
  printf("%lld\n", z - a + 1);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << (char)('A' + j) << i + 1 << "\n";
				return 0;
			}
		}
	return 0;

}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

long long dist[10][10];

int main()
{
  long long h, w;
  scanf("%lld%lld", &h, &w);
  for (int i = 0; i < 10; ++i)
  {
    for (int j = 0; j < 10; ++j)
    {
      scanf("%lld", &dist[i][j]);
    }
  }
  for (int k = 0; k < 10; ++k)
  {
    for (int i = 0; i < 10; ++i)
    {
      for (int j = 0; j < 10; ++j)
      {
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  
  long long ans = 0;
  for (long long y = 0; y < h; ++y)
  {
    for (long long x = 0; x < w; ++x)
    {
      long long a;
      scanf("%lld", &a);
      if (a == -1 || a == 1) continue;
      ans += dist[a][1];
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <cstring>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int n; 
vector<vector<vector<double>>> dp(310,vector<vector<double>> (310,vector<double>(310,-1)));

double rec(int i,int j,int k)
{
	if(i==0&&j==0&&k==0) return dp[0][0][0] = 0.0;
	if(dp[i][j][k]>0) return dp[i][j][k];
	
	int l = i+j+k;
	double ret = n;
	if(i>0) ret += rec(i-1,j,k)*i;
	if(j>0) ret += rec(i+1,j-1,k)*j;
	if(k>0) ret += rec(i,j+1,k-1)*k;
	ret /= l;
	return dp[i][j][k] = ret;
}

int main(void) {
	cin >> n;
	vector<int> a(3,0);
	rep(i,n){
		int num; cin >> num;
		if(num==1) a[0]++;
		if(num==2) a[1]++;
		if(num==3) a[2]++;
	}

	out16(rec(a[0],a[1],a[2]));
}




Measured memory_bytes: 239616
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int comb = pow(2, b);
    cout<<1900*comb*b+comb*(a-b)*100<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String d = sc.nextLine();
        int sum = 0;
        while (true) {
            String a = sc.nextLine();
            if (a.equals("END_OF_TEXT")) {
                break;
            }
            for (String s : a.split(" ")) {
                if (s.equalsIgnoreCase(d)) {
                    sum++;
                }
            }
        }
        System.out.println(sum);

    }
}



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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll ans = 1e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i == 0){
            ans = min(ans, n/i+i-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    int temp, min_num;
    int ans = 1;
    cin >> min_num;
    for(int i = 1; i < N; i++){
       cin >> temp;
       if(min_num >= temp){
           ans++;
           min_num = temp;
       }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 101

int main() {
	int point[MAX] = {};
	for (int a, b; cin >> a >> b;) {
		point[a]++; point[b]++;
		if (a == 0 && b == 0) {
			int odd = 0;
			point[1]++; point[2]++;
			for (int i = 1; i < MAX; i++) {
				//cout << i << " " << point[i] << endl;
				odd += point[i] % 2;
			}
			if (odd == 0)cout << "OK" << endl;
			else cout << "NG" << endl;

			fill(point, point + MAX, 0);
		}
	}
	return 0;
}

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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e5+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()

#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree< long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
void erase ( ordered_set &s, long long val )
{
    auto it = s.upper_bound(val);

    if ( it == s.begin() && val == *s.begin() )
        s.erase ( s.upper_bound(val) );
    else
        s.erase ( s.upper_bound(val) );
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

int dp[mx][4],h[mx][5],n;

int fact(int i,int k)
{
    if(i>n)
        return 0;

    if(dp[i][k]!=-1)
        return dp[i][k];

    int ret=INT_MIN;

    for(int j=1; j<=3; j++)
    {
        if(j!=k)
        {
            ret=max(ret,h[i][j]+fact(i+1,j));
        }
    }

    dp[i][k]=ret;

    return dp[i][k];
}

int main()
{
    su;

    mem(dp,-1);

    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>h[i][1]>>h[i][2]>>h[i][3];
    }

    cout<<fact(1,0)<<nl;
    return 0;
}


Measured memory_bytes: 14904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll comb[51][51];
int N, M, L;
int P[110], T[110], V[110];
double pos[110][51], cpos[110][51];
double t[110][51];

void init() {
  for (int i = 0; i <= 50; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++) {
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  cin >> N >> M >> L;
  for (int i = 0; i < N; i++) {
    cin >> P[i] >> T[i] >> V[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= M; j++) {
      double tmp = 1.0;
      for (int k = 0; k < j; k++) {
        tmp *= P[i] / 100.0;
      }
      for (int k = 0; k < M - j; k++) {
        tmp *= (100 - P[i]) / 100.0;
      }
      pos[i][j] = comb[M][j] * tmp; 
    }
    cpos[i][M] = pos[i][M];
    for (int j = M-1; j >= 0; j--) {
      cpos[i][j] = pos[i][j] + cpos[i][j+1];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= M; j++) {
      t[i][j] = (double)L / V[i] + j * T[i];
    }
  }

  for (int i = 0; i < N; i++) {
    double sum = 0;
    for (int j = 0; j <= M; j++) {
      double tmp = pos[i][j];
      for (int k = 0; k < N; k++) {
        if (k == i) continue;
        bool cant = true;
        for (int l = 0; l <= M; l++) {
          if (t[i][j] < t[k][l]) {
            tmp *= cpos[k][l];
            cant = false;
            break;
          }
        }
        if (cant) tmp = 0;
      }
      sum += tmp;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3444