akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque

n,m = map(int, input().split())
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start, dist_all):
    q = deque([start])
    dist_all[i] = 0
    while(len(q) > 0):
        w = q.popleft()
        for x in adj_list[w]:
            if dist_all[x[0]] is None:
                dist_all[x[0]] = dist_all[w] + x[1]
                q.append(x[0])
            elif dist_all[x[0]] != dist_all[w] + x[1]:
                return False
    return True
dist_all = [None for i in range(n)]
for i in range(n):
    if dist_all[i] is None:
        if not search(i, dist_all):
            print('No')
            exit(0)
print('Yes')

Measured memory_bytes: 66256
#include <stdio.h>
#include<math.h>
#include <algorithm>
#include <stack>
using namespace std;


int main(){

	char buf[200];
	stack<double> S;
	double tmp,op1,op2;
	bool numFLG,negFLG;

	while(fgets(buf,200,stdin)!=0){
		numFLG = false;
		negFLG = false;
		tmp = 0;
		for(int i=0;buf[i] != '\n' && buf[i] != '\0';i++){
			if(buf[i] >= '0' && buf[i] <= '9'){
				numFLG = true;
				tmp = 10*tmp + (buf[i] - '0');

				if(buf[i+1] == '\n' || buf[i+1] == '\0'){
					if(negFLG){
						tmp = -1*tmp;
						negFLG = false;
					}
					S.push(tmp);
				}

			}else{
				if(numFLG){
					numFLG = false;
					if(negFLG){
						tmp = -1*tmp;
						negFLG = false;
					}
					S.push(tmp);
					tmp = 0;
				}

				if(buf[i] == ' '){
					//Do nothing
				}else if(buf[i] == '+'){
					op2 = S.top();
					S.pop();
					op1 = S.top();
					S.pop();
					S.push(op1+op2);
				}else if(buf[i] == '-'){
					if(buf[i+1] != '\n' && buf[i+1] >= '0' && buf[i+1] <= '9'){
						negFLG = true;
					}else{
						op2 = S.top();
						S.pop();
						op1 = S.top();
						S.pop();
						S.push(op1-op2);
					}
				}else if(buf[i] == '*'){
					op2 = S.top();
					S.pop();
					op1 = S.top();
					S.pop();
					S.push(op1*op2);
				}else if(buf[i] == '/'){
					op2 = S.top();
					S.pop();
					op1 = S.top();
					S.pop();
					S.push(op1/op2);
				}
			}
		}

		printf("%.6lf\n",S.top());
		S.pop();

	}

    return 0;
}

Measured memory_bytes: 2512
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S, T;
	LL q;
	in >> S >> T >> q;
	std::vector<LL>a(q), b(q), c(q), d(q);
	rep(i, q) in >> a[i] >> b[i] >> c[i] >> d[i];

	std::vector<std::vector<LL>>S_cnt(S.length(), std::vector<LL>(2)), T_cnt(T.length(), std::vector<LL>(2));
	std::vector<std::vector<LL>>S_imos(S.length() + 1, std::vector<LL>(2)), T_imos(T.length() + 1, std::vector<LL>(2));
	rep(i, S.length()) ++S_cnt[i][S[i] - 'A'];
	rep(i, T.length()) ++T_cnt[i][T[i] - 'A'];
	rep(i, S.length()) rep(j, 2) S_imos[i + 1][j] = S_imos[i][j] + S_cnt[i][j];
	rep(i, T.length()) rep(j, 2) T_imos[i + 1][j] = T_imos[i][j] + T_cnt[i][j];

	rep(i, q)
	{
		LL S_cntA = S_imos[b[i]][0] - S_imos[a[i] - 1][0], S_cntB = S_imos[b[i]][1] - S_imos[a[i] - 1][1];
		LL T_cntA = T_imos[d[i]][0] - T_imos[c[i] - 1][0], T_cntB = T_imos[d[i]][1] - T_imos[c[i] - 1][1];
		LL S_minus = std::min(S_cntA, S_cntB), T_minus = std::min(T_cntA, T_cntB);
		S_cntA -= S_minus; S_cntB -= S_minus; T_cntA -= T_minus; T_cntB -= T_minus;
		S_cntA += S_cntB * 2; S_cntB = 0; T_cntA += T_cntB * 2; T_cntB = 0;
		S_cntA %= 3; T_cntA %= 3;
		out << (S_cntA == T_cntA ? "YES" : "NO") << std::endl;
	}
}


Measured memory_bytes: 25728
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll q,h,s,d;
  cin >> q >> h >> s >> d;
  ll n;
  cin >> n;
  ll one = 0;
  if(4*q >= 2*h){
    one = 2*h;
  }
  else
    one = 4*q;
  if(one >= s)
    one = s;

  ll two;
  if(one*2 <= d)
    two = one*2;
  else
    two = d;
  ll sum = 0;
  if(2*one <= two){
    sum = one*n;
  }
  else{
    if(n%2 == 1)
      sum = two*(n/2)+one;
    else
      sum = two*(n/2);
  }
  cout << sum << endl;
    
  return 0;
}


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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define pi              acos(-1)
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX             2005
#define MOD             1000000007

typedef long long ll;

int main()
{
    ll k,ans;

    cin>>k;

    queue<ll>q;

    q.push(1);
    q.push(2);
    q.push(3);
    q.push(4);
    q.push(5);
    q.push(6);
    q.push(7);
    q.push(8);
    q.push(9);

    while(k--)
    {
        ll x = q.front();

        q.pop();

        ll rem = x%10;

        if(x%10!=0)
            q.push((10*x)+rem-1);

        q.push((10*x)+rem);

        if(x%10!=9)
            q.push((10*x)+rem+1);

        ans = x;
    }

    cout<<ans;

}


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

int main(){
    int N, a = 0, b = 0, c = 0, d = 0;
    cin >> N;
    vector<string>S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
        if (S.at(i) == "AC") {
            a++;
        }
        else if (S.at(i) == "WA") {
            b++;
        }
        else if (S.at(i) == "TLE") {
            c++;
        }
        else {
            d++;
        }
    }
    cout << "AC x " << a << endl << "WA x " << b << endl << "TLE x " << c << endl << "RE x " << d;
} 

Measured memory_bytes: 6416
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin >> n;
    multiset<int> st;
    for(int i = 0;i < n;i++)
    {
        int d;
        cin >> d;
        st.insert(d);
    }
    cin >> m;
    bool flag = true;
    for(int i = 0;i < m;i++)
    {
        int t;
        cin >> t;
        if(st.find(t) == st.end())
        {
            flag = false;
        }
        else
        {
            st.erase(st.find(t));
        }
    }
    if(flag)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
    
    return 0;
}

Measured memory_bytes: 9600
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(M):
  c_temp = list(map(int, input().split()))
  c.append(c_temp)

min_price = min(a) + min(b)

for i in range(M):
  discount_price = a[c[i][0] - 1] + b[c[i][1] - 1] - c[i][2]
  if discount_price < min_price:
    min_price = discount_price

print(min_price)

Measured memory_bytes: 38556
import Data.List
main = getContents >>= putStrLn . itp1_11_a . (\[ns,os] -> (words ns, os)) . lines

itp1_11_a (ns,os) = ns !! (head (foldl' roll [1,2,3] os) - 1)
 where
  roll [x,y,z] 'E' = [(7-z),y,x]
  roll [x,y,z] 'N' = [y,(7-x),z]
  roll [x,y,z] 'S' = [(7-y),x,z]
  roll [x,y,z] 'W' = [z,y,(7-x)]

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

int main() {
  int A;
  string op;
  int B;
  int ans;

  cin >> A >> op >> B;

  if (op == "+" ){
    ans = A + B;
  }else{
    ans = A - B;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3628
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long a,b,n;cin>>a>>b>>n;
  long long mx = 0;
  if(n%b != 0){
    mx = max(mx,(a*n)/b-(n/b)*a);
  }
  if(n/b*b-1 > 0){
    long long z = n/b*b-1;
    mx = max(mx,(a*z)/b-(z/b)*a);
  }
  cout << mx << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long n, i, k, j, a[100001] = {0}, s = 0, dp[100001] = {0}, sum[100001][2] = {0};
int main()
{
	cin >> n >> k;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(i = 0; i <= a[0]; i++)
	{
		sum[i][0] = 1 + i;
		dp[i] = 1;
	}
	s = a[0];
	for(i = a[0] + 1; i <= k; i++)
		sum[i][0] = sum[a[0]][0];
	for(i = 1; i < n; i++)
	{
		s += a[i];
		sum[0][i % 2] = 1;
		sum[0][1 - (i % 2)] = 1;
		long long x = 1 - (i % 2);
		for(j = 1; j <= min(k, s); j++)
		{
			dp[j] = ((sum[j - 1][x] % mod) + (dp[j] % mod)) % mod;
			if(j > a[i])
			{
				dp[j] = ((dp[j] % mod) - (sum[j - a[i] - 1][x] % mod) + mod + mod) % mod;
			}
			sum[j][i % 2] = ((sum[j - 1][i % 2] % mod) + (dp[j] % mod)) % mod;
		}
		for(int g = s + 1; g <= k; g++)
			sum[g][i % 2] = sum[s][i % 2];
	}
	cout << dp[k];
	return 0;
}

Measured memory_bytes: 5964
cnt = 0
def merge(S,left,right,mid):
    a = mid - left
    b = right - mid
    L = S[left:left+a]+[float("inf")]
    R = S[mid:mid+b]+[float("inf")]
    j = 0
    k = 0
    for i in range(left,right):
        global cnt
        cnt+=1
        if L[j] <= R[k]:
            S[i] = L[j]
            j += 1
        else:
            S[i] = R[k]
            k += 1
            
def mergeSort(S,left,right):
    if left+1<right:
        mid = (int)((left+right)/2)
        mergeSort(S,left,mid)
        mergeSort(S,mid,right)
        merge(S,left,right,mid)
        
n = int(input())
S = list(map(int, input().split()))
mergeSort(S,0,n)
print(*S)
print(cnt)


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

using namespace std;


int main(){

	long long int n,k,inf=10000000000000;
	
	cin >> n >> k;
	vector<int>v(n+k+10,inf),p(n+k+10);
	v[0]=0;

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

	for(int i=0;i<n;i++){

			for(int j=1;j<=k and i+j<n;j++){
				v[i+j] = min (v[i+j], v[i] + abs(p[i] - p[i+j]));
			}

	}

	cout << v[n-1] << endl;
	
	return 0;		
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll mod = 1000000007;
const ll INF = mod * mod;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, n) {
		ans++;
		while (i + 1 && s[i] == s[i + 1])i++;
	}
	cout << ans << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();

	//stop
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define pw(x,y) trunc(exp(log((x))*(y)))
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int N = 2e5+7;
const int M = 1e4+7;
int n,p;
ll ans=0;
int f[N]={1}, invf[N]={1}, sum[N]={0};
vi cnt(M,0);
string st;

int fexp(int x, int y, int m) {
    int res=1;
    while(y) {
        if(y&1) res=(res*x)%m;
        x=(x*x)%m;
        y/=2;
    }
    return res%m;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    cin >> n >> p >> st;
    if(p==2||p==5) {
        forw(i,0,n) if((st[n-i-1]-'0')%p==0) ans+=n-i;
        return cout << ans, 0;
    }
    forw(i,0,n) {
        f[i+1]=(f[i]*10)%p;
        invf[i+1]=(invf[i]*fexp(10,p-2,p))%p;
        sum[i+1]=(sum[i]+f[i]*(st[n-i-1]-'0'))%p;
        cnt[sum[i+1]]++;
    }
    cnt[0]++;
    forw(i,0,n) {
        cnt[sum[i]]--;
        if(invf[i]==0) ans+=n-i;
        else ans+=cnt[sum[i]];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2964
// package other2018.soundhoundmaster2018;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    static long __startTime = System.currentTimeMillis();

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = in.nextInt();
        int b = in.nextInt();
        if (a + b == 15) {
            out.println('+');
        } else if (a * b == 15) {
            out.println('*');
        } else {
            out.println('x');
        }
        out.flush();
    }

    private static void printTime(String label) {
        debug(label, System.currentTimeMillis() - __startTime);
    }

    private static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y;
};

int main(){

	ll x,k,d;
	cin>>x>>k>>d;

	x=abs(x);
	if(k<=x/d)cout<<x-d*k<<endl;
	else{
		k-=x/d;
		x%=d;
		if(k%2==0)cout<<x<<endl;
		else cout<<d-x<<endl;
	}

	return 0;
}




Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

int m;
string s;

int main(){
	cin >> m;
	for(int i = 0; i < m; i++){
		set<string> sa;
		cin >> s;
		for(int j = 1; j < s.length(); j++){
			string s1 = s.substr(0, j);
			string s2 = s.substr(j, s.length() - j);
			sa.insert(s1 + s2);
			sa.insert(s2 + s1);
			reverse(s1.begin(), s1.end());
			sa.insert(s1 + s2);
			sa.insert(s2 + s1);
			reverse(s2.begin(), s2.end());
			sa.insert(s1 + s2);
			sa.insert(s2 + s1);
			reverse(s1.begin(), s1.end());
			sa.insert(s1 + s2);
			sa.insert(s2 + s1);
		}
		cout << sa.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 1234
#define NN 10001000
#define PII pair<int, int>
#define MP make_pair
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
char s[N][N];
int n, m;
int sx, sy, fx, fy;
int col[N][N], ctot;
PII que[N * N];
int front, rear;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
inline void bfs(int x, int y) {
	front = rear = 0;
	col[x][y] = ++ctot;
	que[++rear] = MP(x, y);
	while (front < rear) {
		PII pr = que[++front];
		int x = pr.first, y = pr.second;
		for (int d = 0; d < 4; ++d) {
			int nx = x + dx[d], ny = y + dy[d];
			if (col[nx][ny] || nx > n || nx < 1 || ny > m || ny < 1 || s[nx][ny] == '#')	continue;
			col[nx][ny] = ctot;
			que[++rear] = MP(nx, ny);
		}
	}
}
int ddx[5] = {-2, -1, 0, 1, 2};
int ddy[5] = {-2, -1, 0, 1, 2};
struct edge{
	int nxt, to;
}e[NN];
int head[N * N], ecnt;
inline void addedge(int from, int to) {
	e[++ecnt] = (edge){head[from], to};
	head[from] = ecnt;
}
int dis[N * N], q[N * N];
inline void work() {
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) if (s[i][j] == '.') {
			for ( int tx = 0; tx < 5; ++tx) {
				for ( int ty = 0; ty < 5; ++ty) {
					int nx = i + ddx[tx], ny = j + ddy[ty];
					if (nx <= n && nx >= 1 && ny <= m && ny >= 1 && s[nx][ny] == '.') {
						if (col[i][j] != col[nx][ny]) addedge(col[i][j], col[nx][ny]);
					}
				}
			}
		}
	}
	memset(dis, 0x3f, sizeof(dis));
	front = rear = 0;
	dis[col[sx][sy]] = 0;
	q[++rear] = col[sx][sy];
	while (front < rear) {
		int cur = q[++front];
		for (int i = head[cur]; i; i = e[i].nxt) {
			int to = e[i].to; if (dis[to] < NN)	continue;
			dis[to] = dis[cur] + 1;
			q[++rear] = to;
		}
	}
	if (dis[col[fx][fy]] < NN)	printf("%d\n", dis[col[fx][fy]]);
	else	puts("-1");
}
int main() {
	read(n), read(m);
	read(sx), read(sy), read(fx), read(fy);
	for (int i = 1; i <= n; ++i)	scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) if (s[i][j] == '.' && !col[i][j]) {
			bfs(i, j);
		}
	}
	work();
	return 0;
}



Measured memory_bytes: 30180
from bisect import bisect_left

def primes(n):
    memo = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i << 1
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return [i for i in range(n + 1) if memo[i] and i >= 2]

X = int(input())
table = primes(100003)

print(table[bisect_left(table, X)])

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

int main() {
  string s;
  cin>>s;
  bool ex=true;
  if(s[0]!='A'){
    ex=false;
  }
  if(isupper(s[s.size()-1])||isupper(s[1])){
    ex=false;
  }
  if(ex){
    int co=0;
    rep2(i,2,s.size()-1){
      if(s[i]=='C'){
        co++;
      }
    }
    if(co!=1){
      ex=false;
    }
  }
     
  if(ex){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

int main()
{
    ull_t N, A, B;
    cin >> N >> A >> B;

    ull_t out = (N / (A + B)) * A + min(A, N % (A + B));
    cout << out << endl;
}


Measured memory_bytes: 256
n,d = gets.chomp.split(" ").map{|i|i = i.to_i}
arr = []
n.times {|i|
  arr << gets.chomp.split(" ").map{|i|i = i.to_i}
  #pp arr
}

count = 0
(n-1).times {|i|  
  j = i+1
  while (j < n) do
    sum = 0
    d.times{|arr_i|
      sum += (arr[i][arr_i] -arr[j][arr_i]) ** 2
    }
    #puts "now i = #{i}, j = #{j} sum = #{sum}"
    m = Math.sqrt(sum)
    if(m - m.to_i == 0.0) then count += 1 end 
    j+=1
  end
}

puts count




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

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict'

function main(s) {

  const n = s.split('\n')[0].split('');
  const ans = (s[0] === '9' || s[1] === '9') ? 'Yes' : 'No';
  
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
module IntSet = Set.Make (struct type t = int let compare = (-) end)
let _ =
  let s = read_int () in
  let rec find i set n =
    if IntSet.mem n set then
      i
    else
      find (i + 1) (IntSet.add n set) @@ if n mod 2 = 0 then n / 2 else 3 * n + 1
  in
    find 1 IntSet.empty s |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i,N){
        cin >> L[i];
    }

    ll ans = 0;
    rep(i,N){
        rep(j,N){
            rep(k,N){
                if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
                    if(0 <= i && i < j && j < k && k <= (N-1)){
                        ll x = max(max(L[i],L[j]),L[k]);
                        if(L[i] == x){
                            if(x < (L[j]+L[k])){
                                ans++;
                            }
                        }else if(L[j] == x){
                            if(x < (L[i]+L[k])){
                                ans++;
                            }
                        }else if(L[k] == x){
                            if(x < (L[j]+L[i])){
                                ans++;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 3544
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############


N,K = inputIL()
P = inputILL(N)



xtic = list(set([xy[0] for xy in P]))
ytic = list(set([xy[1] for xy in P]))
xtic.sort()
ytic.sort()


o_list = []
for x in xtic:
  for y in ytic:
    o_list.append([x,y])
ans = INF

for p in o_list:
  x0,y0 = p
  for xmax in xtic:
    if xmax < x0:
      continue
    else:
      tempP = []
      for q in P:
        if x0 <= q[0] <= xmax and y0 <= q[1]:
          tempP.append(q)
      if len(tempP) < K:
        continue
      tempP = sorted(tempP, key=lambda x:x[1])
      ans = min(ans,(xmax-x0)*(tempP[K-1][1]-y0))
      
      
      
      

      
print(ans)


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b){
    cout << 0 << endl;
    return 0;
  }else if(a == b){
    cout << 1 << endl;
    return 0;
  }
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }else if(n == 2){
    cout << 1 << endl;
    return 0;
  }
  ll num = n - 2;
  cout << (b - a) * num + 1 << endl;
}

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

namespace AIZU {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new long[] { };
			string[] ss = s.Split(spliter);
			var Res = new long[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = long.Parse(ss[i]);
			return Res;
		}
		static long[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			int N = cin();
			long[] I = cins();
			long[] Diff = new long[N+1];//taken for i cards
			Diff[0] = I.Sum();
			for (int j = 0; j < N; j++) {
				Diff[j + 1] = Diff[j] - 2 * I[j];
			}
			long Res = Diff.Take(N).Skip(1).Select(j => Math.Abs(j)).Min();
			print(Res);
			Console.Read();
		}

	}
}

Measured memory_bytes: 31964
#include <stdio.h>

int main(){

    int a, b, A, B, C;

    scanf("%d %d", &a, &b);
    A = a + b;
    B = a - b;
    C = a * b;
    if(A >= B && A >= C){
        printf("%d\n", A);
    }
    else if(B >= A && B >= C){
        printf("%d\n", B);
    }
    else{
        printf("%d\n", C);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  int sum = 0;
  vector<int> a(n+5, 0);
  for (int i = 1; i <= n; i++){
    cin >> a[i];
  }

  a[0] = 0;
  a[n + 1] = 0;
  
  for (int i = 0; i <= n; i++){
    sum += abs(a[i + 1] - a[i]);
  }

  vector<int> ans(n + 5, sum);
  for (int i = 1; i <= n; i++){
    ans[i] -= abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]);
    ans[i] += abs(a[i + 1] - a[i - 1]);
  }

  for (int i = 1; i <= n; i++){
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 2048
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<vector<int> > a(n, vector<int>(m));
  vector<int>c(n);
  rep(i,n){
      cin>>c[i];
      rep(j,m)cin>>a[i][j];
  }
int minx=1000000000;
for(int bit=0;bit<(1<<n);++bit){
    int y=0;
    vector<int>s(m);
    rep(i,n){
        if(bit&(1<<i)){
            y+=c[i];
            rep(j,m)s[j]+=a[i][j];
        }
    }
int w=1;
rep(i,m){if(s[i]<x){w=0;break;}}
if(w)minx=min(minx,y);
}

if(minx==1000000000)cout<<"-1";
else cout<<minx;
return 0;
}

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

int main () {
    int N;
    cin >> N;
    int ans = 0;
    if (N % 10 != 0) {
        while (N > 0) {
        ans += N % 10;
        N /= 10;
        }
    }
    else if (N % 10 == 0) {
        ans = 10;
    }
    if (N < 10) {
        ans += N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C, D := getInt(), getInt(), getInt(), getInt()

	lcm := LCM(C, D)
	t := B / lcm
	f := A / lcm
	tc := B / C
	fc := A / C
	td := B / D
	fd := A / D

	// out(lcm)
	ans := B - A + 1
	// out(ans, t, f, ",", tc, fc, ",", td, fd)
	ans -= tc - fc
	if A%C == 0 {
		ans--
	}
	// out(ans)
	ans -= td - fd
	if A%D == 0 {
		ans--
	}
	//out(ans)
	ans += t - f
	if A%lcm == 0 {
		ans++
	}

	out(ans)
}


Measured memory_bytes: 640
d,g = map(int,input().split())
pc = []
for i in range(d):
    p,c = map(int,input().split())
    pc.append([p,c])
ans = 10 ** 18
for bit in range(2**d):
    count = 0
    sump = 0
    se = set()
    for i in range(d):
        if bit >> i & 1:
            sump += pc[i][0]*(i+1)*100 + pc[i][1]
            count += pc[i][0]
        else:
            se.add(i+1)
    if sump >=g:
        ans=min(ans,count)
    else:
        s = max(se)
        tmp = min(pc[s-1][0],((g-sump+100*s-1)//(100*s)))
        count += tmp
        sump+=tmp*s*100
        if sump>=g:
            ans=min(ans,count)
print(ans)

Measured memory_bytes: 44396
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

int n, k;
vector<int> p, q, rp, rq;

template<typename T, typename U>
vector<int> mult(T&& a, U&& b) {
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        c[i] = b[a[i]];
    }
    return c;
}

template<typename T>
vector<int> rev(T&& a) {
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        c[a[i]] = i;
    }
    return c;
}

template<typename T>
vector<int> binpow(T&& p, int k) {
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[i] = i;
    }
    while (k) {
        if (k & 1) {
            ans = mult(p, ans);
        }
        p = mult(p, p);
        k >>= 1;
    }
    return ans;
}

template<typename T>
void out(T&& q) {
    for (int i = 0; i < n; ++i) {
        if (i) {
            cout << " ";
        }
        cout << q[i] + 1;
    }
    cout << endl;
    exit(0);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
//   n = 5;
//   out(mult(vector<int>({1, 3, 2, 0, 4}), vector<int>({0, 1, 2, 3, 4})));
    p.resize(n);
    q.resize(n);
    rq.resize(n);
    rp.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
        --q[i];
    }
    rp = rev(p);
    rq = rev(q);
    vector<vector<int>> v = {{}, p, q};
    for (int i = 3; i <= 6; ++i) {
        v.push_back(mult(rev(v[i - 2]), v[i - 1]));
    }
    auto a = mult(mult(rq, p), mult(q, rp));
    auto beginning = binpow(a, (k - 1) / 6);
    vector<int> b;
    b = mult(mult(p, rq), mult(rp, q));
    auto ending = binpow(b, (k - 1) / 6);
    vector<int> mid = v[(k - 1) % 6 + 1];
    auto ans = mult(mult(beginning, mid), ending);
    out(ans);
}

Measured memory_bytes: 7536
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {

	string S;
	cin >> S;

	uint ans = 0;
	for(uint i=0; i<S.length()/2; i++) {
		if(S[i] != S[S.length() - 1 - i]) {
			ans++;
		}
	}
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const string INF="{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{";
int main()
{
	ios::sync_with_stdio(0);
	string s,t,ans=INF,tmp;
	cin>>s;
	cin>>t;
	int lens=s.size(),lent=t.size();
	for(int i=0;i<lens-lent+1;i++)
	{
		bool sign=true;
		for(int j=0;j<lent;j++)
			if(!(s[i+j]==t[j]||s[i+j]=='?'))
			{
				sign=false;
				break;
			}
		if(sign)
		{
			tmp=s.substr(0,i)+t+s.substr(i+lent);
			for(int j=0;j<tmp.size();j++)
				if(tmp[j]=='?')
					tmp[j]='a';
			ans=min(ans,tmp);
		}
	}
	if(ans==INF)
		cout<<"UNRESTORABLE"<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#coding=UTF-8

# exsistp k s.t. k*A % B == C
# B <= 100

mozir=input()
hyo=mozir.split(' ')
A=int(hyo[0])
B=int(hyo[1])
C=int(hyo[2])

ans=False
for idx in range(0,B,1):
    amari= idx*A % B
    if amari == C:
        ans = True
        break

if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
using namespace std;
int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    }
    else if (a - 1 > n - b) {
        cout << n - b + (n - (a + (n - b) + 1)) / 2 + 1 << endl;
    }
    else {
        cout << a - 1 + (b - a - 1) / 2 + 1 << endl;
    }
    return 0;
}

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

typedef long long ll;
const int maxn = 101;
const int maxv = 1001;

ll dp[maxn][maxn*maxv];
int w[maxn], v[maxn];

int n;

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

	int W;
	cin >> n >> W;
	
	for(int i = 0; i < n; i++)
		cin >> w[i] >> v[i];

	int lim = maxn * maxv;
	for(int i = 0 ; i < maxn ; i++)
		for(int j = 0; j < maxn * maxv; j++)
			dp[i][j] = INT_MAX;
	dp[0][0] = 0;

	
	for(int i = 0; i < n; i++)
		for(int j = 0; j < lim; j++) {
			if(j < v[i])
				dp[i+1][j] = dp[i][j];
			else {
				dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
			}
		}

	ll ans = 0;
	for(int i = 0; i < lim; i++) 
		if(dp[n][i] <= W) ans = i;

	cout << ans << endl;

	return 0;
}


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

using namespace std;

const int MAXN = 100005;

int n, m;
int a[MAXN];
vector <int> v[2], sol;

int main () {
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        cin >> a[i];
        v[a[i] & 1].push_back(a[i]);
    }
    if (m == 1) {
        if (a[0] == 1) {
            cout << 1 << endl << 1 << endl << 1;
        } else {
            cout << a[0] << endl << 2 << endl << a[0] - 1 << " " << 1;
        }
        return 0;
    }
    if (v[1].size() > 2) {
        cout << "Impossible";
        return 0;
    }
    if (v[1].size() >= 1) sol.push_back(v[1][0]);
    for (auto val : v[0]) sol.push_back(val);
    if (v[1].size() >= 2) sol.push_back(v[1][1]);
    for (auto val : sol) cout << val << " "; cout << endl;
    cout << sol.size() - (sol.back() == 1) << endl;
    for (int i=0; i<sol.size(); i++) {
        int val = sol[i] + (i == sol.size()-1 ? -1 : (i == 0));
        if (val != 0) cout << val << " ";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double a,b;
    while(scanf("%lf%lf",&a,&b) != EOF){
        if(a < 35.5 && b < 71.0)printf("AAA\n");
        else if(a < 37.5 && b < 77.0)printf("AA\n");
        else if(a < 40.0 && b < 83.0)printf("A\n");
        else if(a < 43.0 && b < 89.0)printf("B\n");
        else if(a < 50.0 && b < 105.0)printf("C\n");
        else if(a < 55.0 && b < 116.0)printf("D\n");
        else if(a < 70.0 && b < 148.0)printf("E\n");
        else printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 1192
a = input()
T,A = map(int,input().split())
li = list(map(int,input().split()))

min = 1000
ans = 0

for index, i in enumerate(li):
  b = T - (i * 0.006)
  if abs(A - b) < min:
    min = abs(A - b)
    ans = index + 1
  
print(ans)

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string N; cin >> N;
	reverse(N.begin(), N.end());
	int K; cin >> K;
	int ans = 0;
	for (; K >= 1; K--) {
		while (!N.empty() && N.back() == '0') N.pop_back();
		int L = int(N.size());
		if (N.empty()) break;
		if (K == 1) {
			ans += N.back() - '0' + (L-1) * 9;
		} else if (K == 2) {
			ans += (N.back() - '0' - 1) * (L-1) * 9 + (L-1) * (L-2) / 2 * 9 * 9;
		} else if (K == 3) {
			ans += (N.back() - '0' - 1) * (L-1) * (L-2) / 2 * 9 * 9 + (L-1) * (L-2) * (L-3) / 6 * 9 * 9 * 9;
		} else assert(false);
		N.pop_back();
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

  int max = 0;

  for ( int i = 0; i < n; i++ ) {
    int tmp = 0;
    for ( int j = i; j < n; j++ ) {
      tmp += B[j];
    }
    for ( int k = 0; k <= i; k++ ) {
      tmp += A[k];
    }
    if ( tmp > max ) {
      max = tmp;
    }
  }

  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int h1, m1, s1, h2, m2, s2, n = 3, t, h, m, s;
   while ( n ) {
      scanf("%d %d %d %d %d %d", &h1, &m1, &s1, &h2, &m2, &s2);
      s1 = m1 * 60 + h1 * 3600 + s1;
      s2 = m2 * 60 + h2 * 3600 + s2;
      t = s2 - s1;
      h = m = 0;
      h = t / 3600;
      m = ( t % 3600 ) / 60;
      s = t % 60;
      printf("%d %d %d\n", h, m, s );
      n--;
   }
   return 0;
}

Measured memory_bytes: 1816
n,a,b,c = map(int, input().split(' '))
l = [int(input()) for i in range(n)]
INF = 10**9
def dfs(cur, ai, bi, ci):
  if cur == n:
    return abs(ai-a) + abs(bi-b) + abs(ci - c) - 30 if min(ai,bi,ci) > 0 else INF
  ret0 = dfs(cur + 1, ai, bi, ci)
  ret1 = dfs(cur + 1, ai+l[cur], bi, ci) + 10
  ret2 = dfs(cur + 1, ai, bi+l[cur], ci) + 10
  ret3 = dfs(cur + 1, ai, bi, ci+l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3316
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <vector>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
long ans;
int N, K;
vector<int> g[100005];

void bfs(int now, int par){
    int mul;
    if(par == -1) mul = K-1;
    else mul = K-2;
    for(auto next : g[now]){
        if(next == par) continue;
        ans = ans * mul % MOD;
        mul = max(mul-1, 0);
        bfs(next, now);
    }
    return;
}

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

    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans = K;
    bfs(0, -1);

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


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	for (int i=1; i<=a; i++)
		if (a>=b)
			cout<<b; 
	for (int i=1; i<=b; i++)
		if (a<b)
			cout<<a;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = abs(i - (n - 1 - i));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(a != b){
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for(int i=0; i<n/2; ++i){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define x first 
#define y second
#define vec vector
#define ll long long
#define mp make_pair
#define pii pair<ll ,ll >
#define THICC 6942091166600000
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define loop(it) for(auto it = mep.begin();it!=mep.end();++it)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> arr(420);
	vector<ll> pref(420);
    vector<vector<ll>> dp(666,vector<ll>(420 , 0));
    for(int i=1;i<=n;i++){
		cin>>arr[i];
		pref[i]=pref[i-1]+arr[i];
	}
    for(int i=1;i<=n-1;i++){
        for(int j=1;j+i<n+1;j++){
			int l = j , r = j+i;
			dp[l][r] = THICC;
            for(int k=j;k<j+i;k++){
				dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]);
			}
            dp[l][r]+=pref[r]-pref[l-1];
        }
	}
    cout<<dp[1][n]<<endl;
}

Measured memory_bytes: 2432
N=int(input())
B=list(map(int,input().split()))

i=0
A=[B[i]]
for i in range(1,N-1):
  if B[i] <= B[i-1]:
    A.append(B[i])
  else: A.append(B[i-1])
A.append(B[N-2])
print(sum(A))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(x,a,b) for(int x=(a),_e=(b);x<=_e;x++)
#define fd(x,a,b) for(int x=(a),_e=(b);x>=_e;x--)
using namespace std;
typedef long long ll;
const int N=55;
ll f[N*N*N],W[N*N],V[N*N],val[N],w[N],ans=0;
int fa[N],id[N],n,x,D,lim,top=0,tot=0;
bool cmp(int x,int y){
	return val[x]*w[y]>val[y]*w[x];
}
int main(){
	scanf("%d %d %d",&n,&x,&D);
	scanf("%lld",&w[1]);val[1]=1;
	fo(i,2,n) scanf("%lld %d",&w[i],&fa[i]);	
	fd(i,n,2) val[i]++,val[fa[i]]+=val[i],w[fa[i]]+=w[i];
	lim=min(n,D);
	fo(i,1,n) top+=val[i]*lim,id[i]=i;
//	fo(i,1,n) printf("val:%lld w:%lld\n",val[i],w[i]);
	sort(id+1,id+n+1,cmp);
	
	fo(i,1,n) {
		ll dw=w[i],dv=val[i];int l=1,now=lim;
		while(now>=l) {
			W[++tot]=dw;V[tot]=dv;
			now-=l;
			dw=dw<<1,dv=dv<<1,l=l<<1;
		}
		if(now) W[++tot]=w[i]*now,V[tot]=val[i]*now;
	}

	memset(f,0x3f,sizeof(f));f[0]=0;
	fo(i,1,tot) {
		fd(j,top-V[i],0) f[j+V[i]]=min(f[j+V[i]],f[j]+W[i]);
	}

	fo(i,0,top) {
//		printf("i:%d f:%lld\n",i,f[i]);
		if(f[i]>x) continue;
		ll res=x-f[i],got=i,cs;
		fo(j,1,n) {
			cs=res/w[id[j]];
			if(id[j]>1) cs=min(cs,1ll*max(D-n,0));
			got+=cs*val[id[j]];
			res-=cs*w[id[j]];
//			printf("v:%lld w:%lld cs:%lld res:%lld\n",val[id[j]],w[id[j]],cs,res);
			if(!res) break;
		}
//		printf("%lld\n",got);
		ans=max(ans,got);
	}
	printf("%lld",ans);
	return 0;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))



int main(){
  string s;
  std::cin >> s;
  bool t=false;
  rep(i,s.size()){
    if(s[i]=='C') t=true;
    if(s[i]=='F'&&t==true) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    void solve(Scanner sc) {
        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a * b <= 0l) {
            System.out.println("Zero");
            return;
        }

        if (a > 0l) {
            System.out.println("Positive");
            return;
        }

        if ((b - a) % 2l == 1l) {
            System.out.println("Positive");
        } else {
            System.out.println("Negative");
        }
    }
}

Measured memory_bytes: 21716