akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

// sのoffset文字目まで決まっているとき，
// 13で割って5余る数が何通りあるか
const int md = 1e9 + 7;

using ll = long long;

ll solve(string &s, vector<vector<ll>> &memo, ll offset = 0, ll mod = 0) {
  if (offset == s.size()) {
    return mod == 5 ? 1 : 0;
  }

  if (memo[offset][mod] < 0) {
    if (s[offset] != '?') {
      ll d = s[offset] - '0';
      memo[offset][mod] = solve(s, memo, offset + 1, (mod * 10 + d) % 13) % md;
    } else {
      ll ans = 0;
      for (int i = 0; i < 10; ++i) {
        ans += solve(s, memo, offset + 1, (mod * 10 + i) % 13) % md;
      }

      memo[offset][mod] = ans % md;
    }
  }

  return memo[offset][mod];
}

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  vector<vector<ll>> memo(s.size(), vector<ll>(13, -1));
  cout << solve(s, memo) << '\n';
  return 0;
}

Measured memory_bytes: 21504
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll N, X, ans = 0, pos = 1;
ll p[55];//p[i] = レベルiバーガーに含まれるパティの数
ll t[55];//t[i] = レベルiバーガーの層の数

//p[]の初期化
void init(){
	p[0] = 1;
	t[0] = 1;
	for(int i = 1; i <= N; i ++){
		p[i] = 2 * p[i - 1] + 1;
		t[i] = 2 * t[i - 1] + 3;
	}
}
ll solve(ll level, ll layer){
	if(level == 0){
		if(layer > 0)return 1;
		return 0;
	}
	/*if(layer == 1)return 0;
	if(layer <= t[level - 1] + 1)return solve(level - 1, layer - 1);
	if(layer == t[level - 1] + 2)return p[level - 1] + 1;
	if(layer <= 2 * t[level - 1] + 2)return p[level] + 1 + solve(level - 1, layer - 2 - t[level - 1]);
	if(layer == 2 * t[level - 1] + 3)return 2 * p[level - 1] + 1;*/
	if(layer == 1)return 0;
	if(layer < t[level - 1] + 1)return solve(level - 1, layer - 1);
	if(layer == t[level - 1] + 1)return p[level - 1];
	if(layer == t[level - 1] + 2)return p[level - 1] + 1;
	if(layer < t[level - 1] + 2 + t[level - 1])return p[level - 1] + 1 + solve(level - 1, layer - 2 - t[level - 1]);
	if(layer == t[level - 1] + 2 + t[level - 1])return p[level - 1] + 1 + p[level - 1];
	if(layer == t[level - 1] + 3 + t[level - 1])return p[level - 1] + 1 + p[level - 1];
}
int main(){

	cin >> N >> X;
	init();
	cout << solve(N, X) << endl;
	
	return 0;
}

Measured memory_bytes: 256
input_N_x = readline(STDIN)
input_a_arr = readline(STDIN)
N, x = map(x -> parse(Int64,x), split(input_N_x))
a_arr = sort(map(x -> parse(Int64,x), split(input_a_arr)), rev=true)
count = 0 
while length(a_arr) > 0
    value = pop!(a_arr)
    x = x - value
    if x < 0
        break
    else
        count = count + 1
    end
end

if (length(a_arr) == 0) && (x > 0)
    print(count - 1)
else
    print(count)
end

Measured memory_bytes: 140992
// A - AtCoder Beginner Contest 999
#include <bits/stdc++.h>
using namespace std;

int main(){
	string N; cin>>N;
	N[0] = N[0]=='1'?'9':'1';
	N[1] = N[1]=='1'?'9':'1';
	N[2] = N[2]=='1'?'9':'1';
	cout<< N <<endl;
}

Measured memory_bytes: 256
def examA():
    N, K = LI()
    if (N+1)//2>=K:
        print("YES")
    else:
        print("NO")
    return

def examB():
    d = [0]*4
    for _ in range(3):
        a, b = LI()
        a -=1; b -=1
        d[a] +=1
        d[b] +=1
    for i in d:
        if i>=3 or i==0:
            print("NO")
            return
    print("YES")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

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

int main() {
    int n, temp = 1, ans = INT_MAX;
    cin >> n;
    vector<int> num(n);
    rep(i, n) {
        cin >> num.at(i);
        if(num.at(i) == temp) temp++;
    }
    if(temp == 1) ans = -1;
    else ans = n - temp + 1;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#define INF 1<<30
using namespace std;
int main() {
  int n; cin >> n;
  int graph[100][100];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) graph[i][j] = INF;
  for (int i = 0; i < n; ++i) {
    int u, k, v; cin >> u >> k;
    for (int j = 0; j < k; ++j) {
      cin >> v;
      cin >> graph[u][v];
    }
  }
  int mincost[100], flag[100] = {};
  mincost[0] = 0;
  for (int i = 1; i < n; ++i) mincost[i] = INF;
  while (1) {
    int x = -1;
    for (int i = 0; i < n; ++i)
      if (!flag[i] && (x == -1 || mincost[x] > mincost[i])) x = i;
    if (x == -1) break;
    flag[x] = 1;
    for (int i = 0; i < n; ++i)
      if (mincost[i] > mincost[x]+graph[x][i]) mincost[i] = mincost[x]+graph[x][i];
  }
  for (int i = 0; i < n; ++i) cout << i << " " << mincost[i] << endl;
  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll M=1000010;

int main() {
	ll N, ans=0;
	set<ll> st;

	cin >> N;
	vector <ll> f(N+1);

	for (ll x = 1; x <= N;x++){
		f[x] = x*(N/x)*(N/x + 1) / 2;
		ans += f[x];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 81380
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	string n,m; cin >> n>>m;
	vector<string>a(3), b(3);
	for (int i = 0; i < 3; i++) {
		a[i] = n[i];
		b[i] = m[i];
	}

	if (a[0] == b[2] && b[0] == a[2] && a[1] == b[1])cout << "YES";
	else cout << "NO";
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int A, B, C;
  scanf("%d%d%d",&A,&B,&C);
  if (A < C && C < B || B < C && C < A) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

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

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, c, count=0; cin >> n >> m >> c;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    for(int i=0;i<m;i++) cin >> b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin >> a[i][j];
    }
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<m;j++) sum += b[j]*a[i][j];
        sum += c;
        if(sum > 0) count++;
    }
    cout << count << endl;
    return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const string FOUR[4] = 
{
	"aabc",
	"ddbc",
	"efgg",
	"efhh"
};

const string FIVE[5] = 
{
	"aabba",
	"bcc.a",
	"b..cb",
	"a..cb",
	"abbaa"
};

const string SIX[6] = 
{
	"aabc..",
	"ddbc..",
	"..aabc",
	"..ddbc",
	"bc..aa",
	"bc..dd"
};

const string SEVEN[7] = 
{
	"aabbcc.",
	"dd.dd.a",
	"..d..da",
	"..d..db",
	"dd.dd.b",
	"..d..dc",
	"..d..dc"
};

int main() {
	int N; cin >> N;
	if (N == 2) {
		puts("-1");
		return 0;
	}
	if (N == 3) {
		puts("aab");
		puts("c.b");
		puts("cdd");
		return 0;
	}

	VV<char> f(N, V<char>(N, '.'));
	int i = 0;

	for (; i + 8 <= N; i += 4) {
		rep(j, 4) rep(k, 4) {
			f[i+j][i+k] = FOUR[j][k];
		}
	}

	while (i+4>N) i-=4;

	if (N == i + 4) {
		rep(j, 4) rep(k, 4) {
			f[i+j][i+k] = FOUR[j][k];
		}
	} else if (N == i + 5) {
		rep(j, 5) rep(k, 5) {
			f[i+j][i+k] = FIVE[j][k];
		}		
	} else if (N == i + 6) {
		rep(j, 6) rep(k, 6) {
			f[i+j][i+k] = SIX[j][k];
		}			
	} else {
		rep(j, 7) rep(k, 7) {
			f[i+j][i+k] = SEVEN[j][k];
		}	
	}

	rep(i, N) {
		rep(j, N) printf("%c", f[i][j]);
		puts("");
	}


	return 0;
}

Measured memory_bytes: 2176
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  double n, m, d;
  cin >> n >> m >> d;
  if (d == 0.0) {
    cout << n * (m - 1.0) / n / n << endl;
  } else {
    cout << 2.0 * (n - d) * (m - 1.0) / n / n << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   string ans = "";
   cin >> n;
   while (n != 0)
   {
      if (n % 2 == 0)
      {
         ans += '0';
         n = -(n / 2);
      }
      else
      {
         ans += '1';
         n = -((n - 1) / 2);
      }
   }
   if (ans.empty())
      ans = "0";
   reverse(ans.begin(), ans.end());
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int a[]={1,2,3};

int main()
{
  double d;
  scanf("%lf", &d);
  double res = 0;
  res = max(res, sqrt(SQ(d)/2)*2);
  for(int i=0;i<3;i++){
    //   cout << SQ(d) << " " << SQ(a[i]) << endl;
    if(SQ(d) >= SQ(a[i]) && SQ(d) - SQ(a[i]) <= 1){
      double e;
      if(SQ(d) - SQ(a[i]) <= 0 + EPS)  e = 0;
      else e = sqrt(SQ(d)-SQ(a[i]));
      //      cout << SQ(d) - SQ(a[i]) << endl;
      res = max(res, a[i]+(1-e)+e);
      //      cout << e << endl;
      //      cout << a[i]+(1-e)+e << endl;
    }
  }
  printf("%.12lf\n", res);
  return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

struct Dice {
  string input;
  size_t pos;
  int values[6];

  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;

  void Init() {
    pos = 0;
    top = 1;
    bottom = 6;
    front = 2;
    back = 5;
    left = 4;
    right = 3;
  }

  int Value() const {
    return values[top - 1];
  }

  bool Done() const {
    return pos == input.size();
  }

  void Next() {
    const char d = input[pos];
    int temp = 0;
    switch (d) {
      case 'S':
        temp = front;
        front = top;
        top = back;
        back = bottom;
        bottom = temp;
        break;
      case 'N':
        temp = back;
        back = top;
        top = front;
        front = bottom;
        bottom = temp;
        break;
      case 'E':
        temp = right;
        right = top;
        top = left;
        left = bottom;
        bottom = temp;
        break;
      case 'W':
        temp = left;
        left = top;
        top = right;
        right = bottom;
        bottom = temp;
        break;
    }
    ++pos;
  }
};

int main() {
  Dice dice;
  dice.Init();
  for (int i = 0; i < 6; ++i) {
    cin >> dice.values[i];
  }
  cin >> dice.input;

  for (;;) {
    if (dice.Done()) {
      break;
    }
    dice.Next();
  }
  cout << dice.Value() << endl;
  return 0;
}

Measured memory_bytes: 1204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn fact(n:usize) -> Vec<(usize, usize)> {
    let s = (n as f64).sqrt().floor() as usize;
    let mut n_tmp = n;
    let mut r = 0;
    let mut ans = (0,0);
    let mut result: Vec<(usize, usize)> = Vec::<(usize, usize)>::new();
    for i in 2..s {
        if n_tmp%i==0 {
            r = 0;
            while n_tmp%i==0 {
                r += 1;
                n_tmp = n_tmp / i;
            }
            ans = (i,r);
            result.push(ans);
        }
    }

    if n_tmp > s {
        ans = (n_tmp, 1);
        result.push(ans);
    }
    result
}

fn main(){

    input!{
        n: usize,
    }

    let result = fact(n);
    
    // for i in result {
    //     print!("{}, ", i.0);
    //     println!("{}", i.1);
    // }

    let mut cnt = 0;
    let mut m = n;

    for i in result {
        for j in 1..i.1+1 {
            if m%(i.0).pow(j as u32)==0 {
                cnt += 1;
                m /= (i.0).pow(j as u32);
            }
        }
    }

    println!("{}", cnt);

}

Measured memory_bytes: 2640
n = int(input())
a = [int(input())-1 for i in range(n)]

used = [0]*n
current = 0
count = 0
while True:
    if used[current] == 1:
        print(-1)
        exit()
    used[current] = 1
    current = a[current]
    count += 1
    

    if current == 1:
        print(count)
        break

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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    int n = s.size();
    ll cnt = 0;
    ll res = 0;
    rep(i, n-1){
        if(s[i] == 'A'){
            cnt++;
        }else if(s[i] == 'B' && s[i+1] == 'C'){
            res += cnt;
            i++;
        }else{
            cnt = 0;
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b;
cin >> a >> b;
(((a % 3 == 0) || (b%3 == 0)) || ((a+b) % 3 == 0)) ? cout << "Possible\n" : cout << "Impossible\n";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <stdlib.h>
#include <ctime>
#include <list>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#define INF 10000000
#define I64 long long int
#define rep(i) for(I64 i=0;;++i)
#define rep2(i,n,m) for(I64 i=n;i<(m);++i)
using namespace std;

typedef vector<pair<int, int> > PV;

void swapPair(pair<int, int> &p1, pair<int, int> &p2){
	pair<int, int> temp;
	temp = p1;
	p1 = p2;
	p2 = temp;
}

int main(){
	PV ranking;

	while(true){
		int num, score;
		scanf("%d,%d", &num, &score);
		if(!(num || score)) break;
		ranking.push_back( pair<int, int>(num, score) );
	}
	
	int n = ranking.size();
	for(int i=n;i>0;--i){
		for(int j=0;j<n-1;++j){
			if(ranking[j].second < ranking[j+1].second)
				swapPair(ranking[j], ranking[j+1]);
		}
	}
	
	
	PV res;
	int currentRank = 1;
	int bufScore = ranking[0].second;
	for(int i=0;i<n;++i){
		if(ranking[i].second < bufScore){
			currentRank++;
			bufScore = ranking[i].second;
		}
		
		res.push_back( pair<int, int>(ranking[i].first, currentRank) );
	}

	int input;
	while(cin >> input){
		for(int i=0;i<n;++i){
			if(res[i].first == input){
				cout << res[i].second << endl;
				break;
			}
		}
	}
}

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

int main() {

	int N;

	cin >> N;

	int value[10000];
	int cost[10000];
	int a[10000];

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

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

	for (int i = 0; i < N; i++) {
		a[i] = value[i] - cost[i];
	}

	int g = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] > 0) {
			g += a[i];
		}
	}
	
	cout << g << endl;
	

	return 0;

}

Measured memory_bytes: 256
import sys

H, W, M = map(int, sys.stdin.readline().split())

h_obj = [0 for _ in range(H)]
w_obj = [0 for _ in range(W)]
objs = set()
for _ in range(M):
    h, w = map(int, sys.stdin.readline().split())
    h -= 1
    w -= 1
    h_obj[h] += 1
    w_obj[w] += 1
    objs.add((w, h))

ans = 0
h_max = max(h_obj)
w_max = max(w_obj)
h_cond = set()
w_cond = set()
for i in range(W):
    if w_max == w_obj[i]:
        w_cond.add(i)
for i in range(H):
    if h_max == h_obj[i]:
        h_cond.add(i)

# print(h_cond, w_cond)
ans = h_max + w_max
for w in w_cond:
    for h in h_cond:
        if (w, h) not in objs:
            print(ans)
            sys.exit()

print(ans - 1)

Measured memory_bytes: 167572
import java.io.*;
import java.util.*;
public class Main{
    static int dfs(ArrayList<Integer>list[],int idx,int par){
        int min = 0;
        //int cnt = 0;
        ArrayList<Integer>node = new ArrayList<>();
        for(int temp : list[idx]){
            if(temp == par)continue;
            int child = dfs(list,temp,idx);
            node.add(child);
        }
        Collections.sort(node);
        for(int temp : node){
            min = Math.max(temp,min) + 1;
        }
        //System.out.println(min + cnt + " " + idx);
        return min;
    }
    public static void main(String[] args)throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        ArrayList<Integer>list[] = new ArrayList[n + 1];
        for(int i = 1;i <= n;i++)
            list[i] = new ArrayList<>();
        for(int i = 2;i <= n;i++){
            int temp = Integer.parseInt(br.readLine());
            list[i].add(temp);
            list[temp].add(i);
        }
        System.out.println(dfs(list,1,-1));
    }
}

Measured memory_bytes: 57552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    ll H,W,n,x,y;
    cin >> H >> W >> n;
    cin >> x >> y;
    string ta,ao;
    cin >> ta >> ao;

    ll yl=y;
    
    for(int i=0;i < n;i++)
    {
        if(ta.at(i)=='L'){
            yl--;
        }

        if(yl<1){
            cout << "NO" << endl;
            return 0;
        }

        if(ao.at(i)=='R' && yl+1<=W){
            yl++;
        }    
    }

    ll yr=y;
    for(int i=0;i < n;i++)
    {
        if(ta.at(i)=='R'){
            yr++;
        }

        if(yr>W){
            cout << "NO" << endl;
            return 0;
        }

        if(ao.at(i)=='L' && 0<yr-1){
            yr--;
        }    
    }

    ll xu=x;
    for(int i=0;i < n;i++)
    {
        if(ta.at(i)=='U'){
            xu--;
        }

        if(xu<1){
            cout << "NO" << endl;
            return 0;
        }

        if(ao.at(i)=='D' && xu+1<=H){
            xu++;
        }    
    }
    ll xd=x;
    for(int i=0;i < n;i++)
    {
        if(ta.at(i)=='D'){
            xd++;
        }

        if(xd>H){
            cout << "NO" << endl;
            return 0;
        }

        if(ao.at(i)=='U' && xd-1>0){
            xd--;
        }    
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 776
#include<iostream>

using namespace std;

static const int MAX_N = 4000;

char S[MAX_N + 1];
int N;

int main() {
    long long cnt = 0;

    cin >> N;
    for (int i = 1; i <= N; i++) cin >> S[i];

    long long cnt_r = 0;
    long long cnt_b = 0;
    long long cnt_g = 0;

    for (int i = 1; i <= N; i++) {
        switch (S[i]) {
            case 'R':
                cnt_r += 1;
                break;
            case 'G':
                cnt_g += 1;
                break;
            case 'B':
                cnt_b += 1;
                break;
        }
    }

    cnt = cnt_r * cnt_g * cnt_b;

    int k;
    for (int i = 1; i <= N - 2; i++) {
        for (int j = i + 1; 2 * j <= N + i; j++) {
            k = j + j - i;
            if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) cnt -= 1;
        }
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;
int v[2019];

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int keta=1;
    int a=0;
    for(int i=0;i<2019;i++) v[i]=0;
    v[0]=1;

    for(int i=n-1;i>=0;i--){
        int b=(s[i]-'0')*keta%2019;
        a=(a+b)%2019;
        //cout<<a<<endl;
        v[a]+=1;
        keta=keta*10%2019;
    }
    int ans=0;
    for(int i=0;i<2019;i++){
        ans+=v[i]*(v[i]-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3732
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
ans = 0
MOD = 1000000007
 
LCM = A[0]
for i in range(1, N):
    LCM *= A[i] // gcd(LCM, A[i])
    
for a in A:
  ans += LCM // a
  
print(ans%MOD)


Measured memory_bytes: 6112
int main(){while(1){int n,m,i,j,a,b,x[501]={},c[501][501]={},num[501]={},sum=0;scanf("%d%d",&n,&m);if(n==0)break;for(i=1;i<=m;i++){scanf("%d%d",&a,&b);if(a==1){num[b]++;}c[a][b]=1;c[b][a]=1;}for(i=1;i<=n;i++){for(j=1;j<=n;j++){if(c[1][i]==1&&c[i][j]==1){num[j]++;}}}for(i=2;i<=n;i++){if(num[i]!=0)sum++;}printf("%d\n",sum);}return 0;}

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

int main(){
    int n = 0;
    std::cin >> n;

    std::vector<int> tmp(n);
    for(int i = 0; i < n; ++i){
        std::cin >> tmp[i];
    }

    std::vector<std::vector <long int>> joi;
    joi = std::vector<std::vector<long int>>(n, std::vector<long int>(21, 0));

    joi[0][tmp[0]] = 1;

    for(int i = 1; i < n-1; ++i){
        for(int j = 0; j < 21; ++j){
            if(joi[i-1][j] != 0){
                if(j - tmp[i] >= 0) {
                    joi[i][j-tmp[i]] += joi[i-1][j];
                }
                if(j + tmp[i] < 21) {
                    joi[i][j+tmp[i]] += joi[i-1][j];
                }
            }
        }
    }

    std::cout << joi[n-2][tmp[n-1]]  << std::endl;

    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int N;
  cin>>N;
  
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
    sort(S[i].begin(),S[i].end());
  }
  sort(S.begin(),S.end());
  
  
  long long sum=1;
  
  long long ans=0;
  
  for(int i=0;i<N;i++){
    if(S[i]==S[i+1]){
      sum++;
    }
    else{
      ans+=(sum*(sum-1)/2);
      sum=1;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int w, h, n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> w >> h >> n;
  int ma = max(w, h);

  cout << ((n / ma) + (n % ma == 0 ? 0 : 1)) << endl;
}


Measured memory_bytes: 256
#B
n = int(input())
p = list(map(int,input().split()))

def middle(a,b,c,cnt):
    lst =[a,b,c]
    lst.sort()
    if lst[1] == b:
        cnt += 1
        
    return cnt
cnt = 0
for i in range(n-2):
    cnt = middle(p[i],p[i+1],p[i+2],cnt)
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rg register
#define LL long long 

using namespace std;

const int N=200010;
const int P=1e9+7;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct node{
    int x,y;
    bool operator < (const node &bb) const {return y!=bb.y?y<bb.y:x<bb.x;}
}b[N],a[N];
int n,mx[N][20],mi[N][20],l2[N],sm=1;
int getmax(int l,int r){
    int z=l2[r-l+1];
    return max(mx[l][z],mx[r-(1<<z)+1][z]);
}
int getmin(int l,int r){
    int z=l2[r-l+1];
    return min(mi[l][z],mi[r-(1<<z)+1][z]);
}
int c[N];
void update(int x,int y){
	while(x<=n)
		c[x]=(c[x]+y)%P,x+=x&(-x);
}
int query(int x){
	int an=x>=0;
	while(x>0)
		an=(an+c[x])%P,x-=x&(-x);
	return an;
}
int main()
{
    n=read();
    for(rg int i=1;i<=n;++i) b[i].x=read(),b[i].y=read();
    sort(b+1,b+n+1);
    for(rg int i=1;i<=n;++i) mx[i][0]=mi[i][0]=b[i].x;
    for(rg int i=2;i<=n;++i) l2[i]=l2[i>>1]+1;
    for(rg int j=1;j<=l2[n];++j)
        for(rg int i=1;i+(1<<j)-1<=n;++i){
            mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
            mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
        }
    for(rg int i=1;i<=n;++i){
        a[i].x=a[i].y=i;
        int l=1,r=i-1;
        while(l<=r){
            int mid=(l+r)>>1;
            if(getmax(1,mid)>b[i].x) a[i].x=mid,r=mid-1;
            else l=mid+1;
        }
        l=i+1,r=n;
        while(l<=r){
            int mid=(l+r)>>1;
            if(getmin(mid,r)<b[i].x) a[i].y=mid,l=mid+1;
            else r=mid-1;
        }
    }
    sort(a+1,a+n+1);
    for(rg int i=1;i<=n;++i){
        int ll=a[i].x,rr=a[i].y;
        int nf=(sm-query(ll-2)+P)%P;
        sm=(sm+nf)%P;
        update(rr,nf);
    }
    printf("%d\n",(sm-query(n-1)+P)%P);
    return 0;
}

Measured memory_bytes: 36224
n=int(input())
S=input().split()
q=int(input())
T=input().split()
cnt=0
for i in range(len(T)):
	
	flag=0
	
	for j in range(len(S)):
		
		if T[i]==S[j]:flag=1
		
	if flag==1:cnt+=1;
	
print(cnt)


Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
if c1[0] + c2[1] + c3[2] == c1[1] + c2[2] + c3[0] == c1[2] + c2[0] + c3[1]:
    print('Yes')
else:
    print('No')

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

int main(){
 
  int H,W,ch,cw,dh,dw,res;
  int i,j,h,w;
  string s;
  cin >> H >> W;
  cin >> ch >> cw;
  cin >> dh >> dw;

  vector<vector<int>> A(H+2,vector<int>(W+2,-10));
  queue<pair<int,int>> sm;
  queue<pair<int,int>> sb;
  
  for(i=1;i<=H;i++){
    cin >> s;
    for(j=0;j<W;j++)
      if (s[j] == '.')
        A[i][j+1] = -1;
  }

  A[ch][cw] = 0;
  int t;
  sm.push(pair<int,int>(ch,cw));
  while (sm.size()>0 || sb.size()>0){

    while (sm.size()>0){
      h = sm.front().first;
      w = sm.front().second;
      sb.push(pair<int,int>(h,w));
      sm.pop();
      t = A[h][w];
      if ((A[h][w+1] == -1) || (A[h][w+1] > t)){
        sm.push(pair<int,int>(h,w+1));
        A[h][w+1] = t;
      }
      if ((A[h][w-1] == -1) || (A[h][w-1] > t)){
        sm.push(pair<int,int>(h,w-1));
        A[h][w-1] = t;
      }
      if ((A[h+1][w] == -1) || (A[h+1][w] > t)){
        sm.push(pair<int,int>(h+1,w));
        A[h+1][w] = t;
      }
      if ((A[h-1][w] == -1) || (A[h-1][w] > t)){
        sm.push(pair<int,int>(h-1,w));
        A[h-1][w] = t;
      }
    }

    while(sb.size()>0){
      h = sb.front().first;
      w = sb.front().second;
      sb.pop();
      t = A[h][w];
      for(i=h-2;i<h+3;i++){
        if (i < 0 || H < i)
          continue;
        for(j=w-2;j<w+3;j++){
          if (j < 0 || W < j)
            continue;
          if ((A[i][j] == -1) || (A[i][j] > t+1)){
            sm.push(pair<int,int>(i,j));
            A[i][j] = t+1;
          }
        }
      }
    }
  }
  
  cout << A[dh][dw] << "\n";

  return 0;
}

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

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

int main() {
  int x, y;
  cin >> x >> y;

  cout << gcd(x, y) << endl;

  return 0;
}



Measured memory_bytes: 3100
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    r = 7 % K
    while(True):
        if r == 0:
            print(i)
            break
        r = (r * 10 + 7) % K
        i += 1


Measured memory_bytes: 9168
#include<iostream>

using namespace std;

void test_case()
{
int a[6];
for(int i=1;i<=5;++i)
{
       cin>>a[i];
if(a[i]==0)
{
cout<<i<<"\n";
break;
}

}


}
int main()
{
//ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//int tc;
//cin>>tc;
//while(tc--)
//{
    test_case();
//}

    return 0;
    }

Measured memory_bytes: 3636
import math

A, B = map(int, input().split())

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)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    arr.append(1)
    return arr

A_ = set(factorization(A))
B_ = set(factorization(B))

print(len(A_ & B_))




Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int a[200009],ans[200009];
main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    sort(a,a+n);
    int ans = -1;
    for (int i = 0; i < n-1; i++){
        if(min(abs(a[i] - a[n-1]/2),abs(a[i]-(a[n-1]+1)/2)) <
           min(abs(ans - a[n-1]/2),abs(ans-(a[n-1]+1)/2)) )
            ans=a[i];
    }
    cout<<a[n-1]<<" "<<ans<<endl;


}


Measured memory_bytes: 640
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

	int N, T, A;
	cin >> N >> T >> A;

	int H;
	double tmp,diff;

	double min = 100000000;
	int min_index = 0;

	rep(i, N) {
		cin >> H;
		tmp = (double)T - (double)H * 0.006;
		diff = abs((double)A - tmp);

		if (min >= diff) {
			min = diff;
			min_index = i;
		}
	}


	cout << min_index + 1 << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 100;
const int n = MAX_N+2;
int num[n];
int s, t;

int main()
{
  while(~scanf(" %d %d", &s, &t)){
    int res = 0;
    rep(i, n) num[i] = 0;
    do{
      num[s-1] += 1;
      num[t-1] += 1;
    }while(~scanf(" %d %d", &s, &t) && s || t);
    rep(i, n) if(num[i] & 1) res += 1;
    puts(res == 2 && num[0] & 1 && num[1] & 1 ? "OK" : "NG");
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	int wa =0;
	if(n%2==0){
		for(int i=0;i<n/2;++i){
		
			if(s.at(i)==s.at(n/2+i)){
				ans = 0; 
			}else{
				wa = -1; 
			}
		}
		
	}
	if(n==1) wa = -1;
	if(n%2==1) wa = -1;
	if(ans==0 && wa == 0) cout <<"Yes" << endl;
	if(wa==-1) cout << "No" << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n , m , x; cin >> n >> m >> x;

    vector<int> p(m);
    for(int i = 0 ; i < m ; i++) cin >> p[i];
    
    int ans1 = 0;
    for(int i = 0 ; i < m ; i ++){
        if(p[i] > x) ans1 ++;
    }
    
    int ans2 = m - ans1;
    
    cout << min(ans1 , ans2) << endl;
}


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

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N, 0);
	ll minX = 0;
	ll maxX = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (maxX < A[i]) maxX = A[i];
	}

	while (true) {
		ll X = minX + (maxX - minX) / 2;
		if (X == 0) break;
		ll c = 0;
		for (int i = 0; i < N; i++) {
			c += ( (A[i] % X) == 0 ? A[i] / X - 1 : A[i] / X);
		}
//		cout << minX << "," << X << "," << maxX  << ";" << c << endl;
		if (c <= K) {
			maxX = X;
		}
		else {
			minX = X;
		}
		if (maxX - minX <= 1) break;
	}
	cout << maxX << endl;
	return(0);
}


Measured memory_bytes: 4756
#include <iostream>
#include <cmath>

constexpr double GRAVITY = 9.8;

double floor_velo(int floor);

int main(void)
{
    double crash_velo;
    while (std::cin >> crash_velo) {
        int floor = 1;
        while (crash_velo > floor_velo(floor)) {
            floor++;
        }

        std::cout << floor << std::endl;
    }

    return 0;
}

double floor_velo(int floor)
{
    int height = 5 * (floor - 1);
    return (GRAVITY / sqrt(GRAVITY / 2)) * sqrt(height);
}

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

typedef long long ll;

template<class T>
inline bool xmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool xmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline T vmin(T a, T b){return ((a<b)?a:b);}
template<class T>
inline T vmax(T a, T b){return ((a>b)?a:b);}

ll N,M;
ll L,Q;
ll G[305][305];
ll H[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];
const ll inf=1e17;

void input(){
    cin>>N>>M>>L;
    for (int i=0; i<M; i++){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;B[i]--;
    }
    cin>>Q;
    for(int i=0; i<Q; i++){
        cin>>s[i]>>t[i];
        s[i]--;t[i]--;
    }
}

void solve(){
    input();
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            G[i][j]=inf;
            H[i][j]=inf;
        }
        G[i][i]=0;
        H[i][i]=0;
    }
    for(int i=0; i<M; i++){
        xmin(G[A[i]][B[i]],C[i]);
        xmin(G[B[i]][A[i]],C[i]);
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int k=0; k<N; k++){
                xmin(G[j][k],G[j][i]+G[i][k]);
            }
        }
    }
    
    /*
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout<<G[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i==j)continue;
            if(G[i][j]<=L){
                xmin(H[i][j],1LL);
            }
        }
    }

    /*
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout<<H[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int k=0; k<N; k++){
                xmin(H[j][k],H[j][i]+H[i][k]);
            }
        }
    }

    /*
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout<<H[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    for(int i=0; i<Q; i++){
        if(H[t[i]][s[i]] < inf)cout<<H[t[i]][s[i]]-1<<endl;
        else cout<<-1<<endl;
    }
   
    /*
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(H[i][j]==inf){
                cout<<-1<<" ";
            }
            else{
                cout<<H[i][j]<<" ";
            }
        }
       cout<<endl;
    }
    */
    
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 4864