akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < (int)(n); i++)
using ull = unsigned long long;
using ll = long long;


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

    vector<int> prime;
    int N2 = N;

    for (int i=2; i*i<=N2; i++) {
        while (N2%i == 0) {
            prime.push_back(i);
            N2 /= i;
        }
    }
    
    if (N2 > 1) prime.push_back(N2);


    cout << N << ":";
    for (auto p : prime) cout << " " << p;
    cout << endl;

    return 0;
}




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

bool check(int x) {
  int temp = x;
  vector<int> A(5, 0);
  for (int i = 0; i < 5; i++) {
    A[i] = x % 10;
    x /= 10;
  }
  if (A[0] == A[4] && A[1] == A[3]) return true;
  return false;
}

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

  int A; cin >> A;
  int B; cin >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    if (check(i)) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<string> vs;

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

  int n;
  cin >> n;
  vs w(n);
  rep(i, n)cin >> w[i];
 
  string ans="Yes";
  rep(i ,n-1){
    int a=(int)w[i].size();
    if(w[i][a-1]!=w[i+1][0]){
      ans="No";
      break;
    }
    for(int j=i+1; j<n; j++){
      if(w[i]==w[j]){
        ans="No";
        break;
      }
    }
  }
 
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
A,B,C,X,Y = [int(i) for i in input().split()]
if A + B < C * 2:
    print(A*X + B*Y)
else:
    p1 = min(X,Y) * C * 2 + (X - min(X,Y))*A + (Y - min(X,Y))*B
    p2 = max(X,Y) * C * 2
    print(min(p1, p2))

Measured memory_bytes: 9084
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int a,p;
    cin>>a>>p;
    int ans=((a*3)+p)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    int A,B;
    cin>>A>>B;
    B--;
    int ans=0;
    while(B>0){
        B-=(A-1);
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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



int main(){
    string s;
    vector<bool>j(26,false);
    cin >> s;
    int x;
    int y=inf;
    x=s.length();
    rep(i,x){
        int a=s[i]-'a';
        j[a]=true;
    }
    rep(i,26){
        if(j[i]==false) {
            y=i;
            break;
        }
    }
    char ans='a'+y;
    if(y==inf) cout << "None" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] L = new long[N + 1];
		L[0] = 2;
		L[1] = 1;
		for (int i = 2; i < L.length; i++) {
			L[i] = L[i - 1] + L[i - 2];
		}
		System.out.println(L[L.length - 1]);
		sc.close();
	}
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,s=0;
  cin>>n;
  for (int i=1;i<=n;i++) {
    int x;
    cin>>x;
    s+=(i%2+x%2==2);
  }
  cout<<s<<"\n";
  return 0;
}


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

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

	vector<int> height(N);
	for (int i = 0; i < N; i++) {
		cin >> height.at(i);
	}

	vector<int> judge(N, 1);

	int a, b;
	while (M--) {
		cin >> a >> b;
		if (height.at(a-1) > height.at(b-1)) {
			judge.at(b-1) = 0;
		} else if (height.at(a-1) < height.at(b-1)) {
			judge.at(a-1) = 0;
		} else {
			judge.at(a-1) = 0;
			judge.at(b-1) = 0;
		}
	}	

	int output = 0;

	for (int i = 0; i < N; i++) {
		if (judge.at(i) == 1) {
			output++;
		}
	}

	cout << output << endl;

	return 0;
}


Measured memory_bytes: 4008
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,t=0,h=0;
    string taro,hanako;
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> taro >> hanako;
        if (taro > hanako) t+=3;
        else if (taro < hanako) h+=3;
        else {
            t+=1;
            h+=1;
        }
    }
    cout << t << " " << h << endl;
    return 0;
}


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

int main() {
  string a;

  cin >> a;

    if (a[0] == a[1] && a[1] == a[2]) {
      cout << "No";
      return 0;
    } else {
      cout << "Yes";
      return 0;
    }
    
    
}

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

int main() {
    char a;
    char b;
    cin >> a;
    cin >> b;
    if (a == 'D'){
      if (b == 'D'){
        cout << "H" << endl;}
      else{
        cout << "D" << endl;}}
    else{
      if (b == 'D'){
        cout << "D" << endl;}
      else{
        cout << "H" << endl;}}
	return 0;
}

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

using namespace std;

int main() {
	string s; cin >> s;
	bool ret = false;
	for (int i = 0; i <= s.size(); i++) {
		for (int j = i; j <= s.size(); j++) {
			string x;
			for (int k = 0; k < i; k++)x += s[k];
			for (int k = j; k < s.size(); k++)x += s[k];
			if (x == "keyence")ret = true;
		}
	}
	cout << (ret ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x == 0) cout << (n/x)*t << endl;
    else cout << (n/x)*t + t << endl; 
}

Measured memory_bytes: 3596
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: u32 = 1000000007;

#[derive(Clone, Copy)]
struct ModInt {
    v: u32
}

use::std::ops::*;

impl Add for ModInt {
    type Output = ModInt;
    fn add(self, other: ModInt) -> ModInt {
        let mut d = self.v + other.v;
        if d >= MOD {
            d -= MOD;
        }
        ModInt { v: d }
    }
}

impl Sub for ModInt {
    type Output = ModInt;
    fn sub(self, other: ModInt) -> ModInt {
        let mut d = MOD + self.v - other.v;
        if d >= MOD {
            d -= MOD;
        }
        ModInt { v: d }
    }
}

impl Mul for ModInt {
    type Output = ModInt;
    fn mul(self, other: ModInt) -> ModInt {
        let d = ((self.v as u64) * (other.v as u64) % (MOD as u64)) as u32;
        ModInt { v: d }
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(v: u32) -> ModInt {
        ModInt { v: v % MOD}
    }
    pub fn one() -> ModInt {
        ModInt { v: 1 % MOD}
    }
    pub fn zero() -> ModInt {
        ModInt { v: 0 }
    }
    pub fn pow(r: ModInt, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = r;
        while n > 0 {
            if (n & 1) == 1 {
                t = t * s;
            }
            s = s * s;
            n >>= 1;
        }
        t
    }
}

impl std::fmt::Display for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.v)
    }
}

// ここまで

fn run() {
    input! {
        n: usize,
        x: usize,
        s: [u32; n],
    }
    let mut s = s;
    s.sort();
    let mut dp = vec![ModInt::zero(); x + 1];
    for i in 0..(x + 1) {
        dp[i] = ModInt::new(i as u32);
    }
    for i in 0..n {
        let s = s[i] as usize;
        let i = ModInt::new(i as u32);
        for j in (0..(x + 1)).rev() {
            dp[j] = i * dp[j] + dp[j % s];
        }
    }
    println!("{}", dp[x]);
}

fn main() {
    run();
}


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

int main(){
    int sec;
    cin >> sec;
    int h = 0;
    int m = 0;
    if ( sec >= 3600) {
        h = sec / 3600;
        sec = sec - (3600 * h);
    }
    if ( sec >= 60) {
        m = sec / 60;
        sec = sec - (60 * m);
    }

    cout << h << ':' << m << ':' << sec << endl;
    return 0;
}


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

using namespace std;

const int M = 1e3 + 3;
int n, a[M][M];
map <pair <int, int>, int> mp;
vector <int> adj[M*M];
int in[M*M], vis[M*M], ans = 1;

int main () {
  scanf ("%d", &n);
  int k = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n-1; j++) {
      int x;
      scanf ("%d", &a[i][j]);
      x = a[i][j];
      int a = min (x-1, i);
      int b = max (x-1, i);
      if (mp[{a, b}] == 0) {mp[{a, b}] = k; k++;}
    }
    for (int j = 1; j < n-1; j++) {
      adj[mp[{min(i, a[i][j-1]-1), max(i, a[i][j-1]-1)}]].push_back(mp[{min(i, a[i][j]-1), max(i, a[i][j]-1)}]);
      in [mp[{min(i, a[i][j]-1), max(i, a[i][j]-1)}]]++;
      //cout << mp[{min(i, a[i][j-1]-1), max(i, a[i][j-1]-1)}] << ' '<< mp[{min(i, a[i][j]-1), max(i, a[i][j]-1)}] << endl;
    }
  }
    vector<int> order;
  queue<int> q;
  for (int i = 1; i < k; ++i)
    if (in[i] == 0){
      vis[i] = 1, q.push(i);
      //cout << i << endl;
    }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    order.push_back(u);
    for (int i = 0; i < adj[u].size(); ++i) {
      --in[adj[u][i]];
      if (in[adj[u][i]] == 0) {
        q.push(adj[u][i]);
        vis[adj[u][i]] = vis[u]+1;
        ans = max (ans, vis[u]+1);
      }
    }
  }
  if (order.size() != k-1)
    puts("-1");
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 84468
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 2e5 + 10;
const int inf = 1e9;

pii arr[maxn];

int main () {
	ios_base::sync_with_stdio (false);
	int n;
	cin >> n;
	
	bool found = 0;
	int mn = inf;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i].F >> arr[i].S;
		sum += arr[i].F;
		if (arr[i].F > arr[i].S) {
			found = 1;
			mn = min (mn, arr[i].S);
		}
	}
	
	if (!found)
		return cout << 0 << endl, 0;
	cout << sum - mn << endl;
}


Measured memory_bytes: 384
function main(input) {
    input = input.trim().split('\n')
    let n = parseInt(input[0])
    let a = input[1].split(' ').map(BigInt)

    const mod = BigInt(10**9 + 7)
    let sum = a.reduce((a,b)=>a+b, BigInt(0))

//  console.log(Number(sum))

    let ans=BigInt(0)
    for(let i=0; i<n; i++) {
        sum -= a[i]
        ans += a[i] * sum
        ans %= mod
    }
    console.log(Number(ans))

}
process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 73668
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int L = Integer.parseInt(sc.next());
		String s[] = new String[N];
		String ans = "";
      
		for(int i = 0;i < N; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);
		
		for(String ss : s) {
			ans += ss;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25684
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            String[] strAry = line.split(" ");
            int a = Integer.parseInt(strAry[0]);
            int b = Integer.parseInt(strAry[1]);
            if(a < b){
            	System.out.println("a < b");
            }else if(a > b){
            	System.out.println("a > b");
            }else if(a == b){
            	System.out.println("a == b");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

struct UnionFind{
    vector<int> p;
    UnionFind(int N){ p = vector<int>(N,-1); }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(p[x] < p[y]) swap(x,y);
        p[y] += p[x];
        p[x] = y;
    }

    int find(int x){
        if(p[x] < 0) return x;
        else return p[x] = find(p[x]);
    }

    int size(int x){
        return -p[find(x)];
    }
};

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

    UnionFind UF(N);
    int A,B;
    for(int i=0; i<M; ++i){
        cin>>A>>B;
        --A;
        --B;
        UF.unite(A,B);
    }

    int ans=0;    
    for(int i=0; i<N; ++i){
        ans = max(ans, UF.size(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4004
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
#define ll long long int
#define  INF pow(10,9)
#define vi vector<long long int>
#define fast ios_base::sync_with_stdio(false)
#define pb push_back
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vi start(n+1,0);
    vi end(n+1,0);
    vi zero(n+1,0);

    ll c=0;

    for(ll i=0;i<n;i++){
        if((int)s[i]==49){
            c++;
        }
        else{
            zero[i+1] = c;
            c=0;
        }
    }


    ll m=0;
    if((int)s[0]==48){
        m++;
        end[m] = 1;
        if(!start[m]){
            start[m] = 1;
        }
    }
    else{
        start[0] = 1;
    }

    for(ll i=1;i<n;i++){
        if((int)s[i]==48 && (int)s[i-1]==49){
            m++;
        }
        end[m] = (i+1);
        if(!start[m]){
            start[m] = (i+1);
        }
    }

    end[0] = start[1]-1;

    start.resize(m+1);
    end.resize(m+1);



    if(k>=m){
        cout<<n<<endl;
    }
    else{
        ll max = end[k];
        for(ll i=1;(i+(k-1))<(m+1);i++){
            ll temp = end[i+(k-1)] - start[i] + 1 + zero[start[i]];
            if(temp>max){
                max = temp;
            }

        }
        cout<<max<<endl;
    }
}


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

int main(){
    int d;
    int result;

    while(cin >> d){
        result = 0;
        for(int i=1; 600-i*d > 0; i++){
            result += d * d * d * i * i;
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

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

    LL k,a,b;
    cin>>k>>a>>b;
    bool ok = false;
    REP(i,2000){
        if(a <= k*i && k*i <= b){
            ok = true;
        }
    }
    PUTS(ok? "OK" : "NG");
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  if(N%2==1) {
  	cout << "No";
  	return 0;
  }
  int k= N/2;
  rep(i,k){
  	if(S[i]!=S[k+i]){
  		goto no;
  	}
  }
  cout << "Yes";
  return 0;
  no:
  cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double T,X;
    cin >> T >> X;
    cout << setprecision(10) << T/X << endl;

}


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

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
const bool DEBUG = false;

signed main() {
	for (string S[3]; cin >> S[0] >> S[1] >> S[2];) {
		int k = 0;
		int cnt[3] = { -1,-1,-1 };
		int ans;
		S[0] += 'a';
		S[1] += 'b';
		S[2] += 'c';
		while (true) {
			cnt[k]++;
			dump(k);
			dump(cnt[k]);
			if (cnt[k] == S[k].size()) {
				ans = k; break;
			}
			k = S[k][cnt[k]] - 'a';
		}
		cout << (char)(k + 'A') << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<string> s(n);
  cout << 0 << endl;
  cin >> s[0];
  if(s[0]=="Vacant"){
    return 0;
  }
  cout << n-1 << endl;
  cin >> s[n-1];
  if(s[n-1]=="Vacant"){
    return 0;
  }
  int l=0,r=n-1;
  while(1){
    int mid=(l+r)/2;
    cout << mid << endl;
    cin >> s[mid];
    if(s[mid]=="Vacant"){
      return 0;
    }
    if((s[l]==s[mid])^((mid-l)%2==0)){
      r=mid;
    }
    else{
      l=mid;
    }
  }
}


Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1;i <= 9;i++) {
        if((i-1)*111<n && n<=i*111) {
            cout << i*111 << endl;
            return 0;           
        }
    }
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	int a, b, h;

	cin >> a >> b >> h;
	cout << (int)((a+b)*h/2) << endl;

	return 0;
}


Measured memory_bytes: 764
package main

import "fmt"

func main() {
	var N, M, cnt int
	fmt.Scan(&N, &M)
	a := make([]int, M)
	b := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&a[i], &b[i])
		a[i] -= 1
		b[i] -= 1
	}
	for i := 0; i < M; i++ {
		un := UnionFind{}
		un.init(N)
		for j := 0; j < M; j++ {
			if i != j {
				un.unite(a[j], b[j])
			}
		}
		var c int
		for j := 0; j < N; j++ {
			if j == un.par[j] {
				c++
			}
		}
		if 1 < c {
			cnt++
		}
	}
	fmt.Println(cnt)
}

// UnionFind
type UnionFind struct {
	par []int
	cnt int
}

func (u *UnionFind) init(n int) {
	for i := 0; i <= n; i++ {
		u.par = append(u.par, i)
	}
}
func (u *UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	} else {
		u.par[x] = u.root(u.par[x])
		return u.par[x]
	}
}
func (u *UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}
func (u *UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}
	u.par[x] = y
}


Measured memory_bytes: 512
package main

import "fmt"

var C [][]int

func main() {

	C = make([][]int, 3)

	for i := 0; i < 3; i++ {
		C[i] = make([]int, 3)
	}

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scanf("%d", &C[i][j])
		}
	}

	ans := true
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			ans = ans && (C[i][j]-C[i+1][j]+C[i+1][j+1] == C[i][j+1])
		}
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    int n;
    cin >> n;

    std::multimap<i64, int, std::greater<i64>> as;
    for (int i=0; i<n; ++i) {
        i64 a;
        cin >> a;
        as.insert(make_pair(a, i+1));
    }
    mat2d_t<i64> dp(n+1, n+1, 0);

    i64 ans{0};

    auto it = as.begin();
    for (int i=1; i<n+1; ++i, ++it) {
       int idx = it->second;
       i64 a = it->first;

       if (i==1) {
           dp[i][0] = a * abs(n-idx);
           dp[i][1] = a * abs(idx-1);
           continue;
       }

       for (int j=0; j<=i; ++j) {
           if (j == 0)
               dp[i][0] = dp[i-1][0] + a*abs(n-(i-1-j)-idx);
           else
               dp[i][j] = max(dp[i-1][j] + a*abs(n-(i-1-j)-idx),
                          dp[i-1][j-1] + a*abs(idx-j));
           //cout << "i:" << i << " j:" <<j << " dp:" << dp[i][j] << endl;
           ans = max(ans,dp[i][j]);
       }
    }

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 34660
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

struct State{
	int left,right,step,prev,violate;
	State(){}
	State(int l,int r,int s,int p,int v):left(l),right(r),step(s),prev(p),violate(v){}
};

bool ok(int left,int right)
{
	return left!=4 && right!=4 && left!=right && left%3<=right%3;
}

int solve(string s,int first)
{
	for(char& c:s) c--;
	
	queue<State> q;
	for(int i=0;i<9;i++) for(int j=0;j<9;j++)
		if(i!=4 && j!=4)
			q.emplace(i,j,0,!first,0);
	
	const int INFTY=0x20202020;
	static int dp[100001][9][9][2];
	memset(dp,0x20,sizeof dp);
	
	while(!q.empty()){
		State cur=q.front(); q.pop();
		if(dp[cur.step][cur.left][cur.right][cur.prev]<=cur.violate) continue;
		dp[cur.step][cur.left][cur.right][cur.prev]=cur.violate;
		if(cur.step==s.size()) continue;
		
		int next=s[cur.step]-'0';
		if(cur.prev==0 && cur.left!=next)
			if(ok(cur.left,next))
				q.emplace(cur.left,next,cur.step+1,1,cur.violate);
			else
				q.emplace(next,cur.right,cur.step+1,0,cur.violate+1);
		else
			if(ok(next,cur.right))
				q.emplace(next,cur.right,cur.step+1,0,cur.violate);
			else
				q.emplace(cur.left,next,cur.step+1,1,cur.violate+1);
	}
	
	int res=INFTY;
	for(int i=0;i<9;i++) for(int j=0;j<9;j++)
		res=min(res,min(dp[s.size()][i][j][0],dp[s.size()][i][j][1]));
	return res;
}

int main()
{
	for(string s;getline(cin,s),s!="#";)
		cout<<min(solve(s,0),solve(s,1))<<endl;
}

Measured memory_bytes: 64760
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

void piyo(int& a, int& b, int& c, int& d) {
	int tmp = a;
	a = b;
	b = c;
	c = d;
	d = tmp;
}

void hoge(vector<int>& a, char c) {
	switch (c) {
	case 'W': piyo(a[0], a[2], a[5], a[3]); break;
	case 'S': piyo(a[0], a[4], a[5], a[1]); break;
	case 'N': piyo(a[0], a[1], a[5], a[4]); break;
	case 'E': piyo(a[0], a[3], a[5], a[2]); break;
	}
}

int main() {
	vector<int> a(6);
	for (int i = 0; i < 6; i++) cin >> a[i];
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++)
		hoge(a, s[i]);
	cout << a[0] << endl;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2 - (h1 * 60 + m1) - k) << endl;
}


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

int main() {
  int n, h, a[100005], b[100005];
  cin >> n >> h;
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);

  int max_a = *max_element(a, a+n);
  sort(b, b+n, greater<int>());

  int dam = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] < max_a) break;
    dam += b[i];
    ans++;
    if (dam >= h) {
      cout << ans << endl;
      return 0;
    }
  }

  cout << ans + (h-dam+max_a-1) / max_a << endl;

  return 0;

}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a;
	cin >> a;
	if (1000 > a) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    LL int sum=0,a,b;

    cin >> a >> b;

    FOR(i,1,b-a)sum += i;

    cout << sum - a;

    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
a=[input() for _ in range(h)]
a=[i for i in a if "#" in i]
b=[("").join(list(i)) for i in list(zip(*a))]
b=[i for i in b if "#" in i]
c=[("").join(list(i))  for i in list(zip(*b))]
for i in c:
    print(i)

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

int main() {
	string s;
	cin >> s;

	int n = s.size(), ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (s[i] == s[i+1]) {
			if (s[i] == '0') s[i+1] = '1';
			else s[i+1] = '0';
			ans++;
		}
	}
	cout << ans << endl; 
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vi> fr(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    fr[a].push_back(b);
    fr[b].push_back(a);
    uf.unite(a, b);
  }
  vi ans(n);
  rep(i, n) ans[i] = uf.size(i) - fr[i].size() - 1;
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if(uf.same(c, d)) {
      ans[c]--;
      ans[d]--;
    }
  }
  rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");
}

Measured memory_bytes: 7416
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

string re(char c, int n) {
	return string(n, c);
}

int main() {
	int w, h; char c;
	cin >> w >> h >> c;
	VS str(3);
	str[0] += "+"; str[0] += re('-', w - 2); str[0] += "+";
	str[1] += "|"; str[1] += re('.', w - 2); str[1] += "|";
	str[2] += "|"; str[2] += re('.', (w - 3) / 2); str[2] += c; str[2] += re('.', (w - 3) / 2); str[2] += "|";
	rep(i, h)
		Cout(i == 0 || i == h - 1 ? str[0] : i == h / 2 ? str[2] : str[1]);
}


Measured memory_bytes: 3144
#include<stdio.h>
int main()
{
    int i,count=0;
    char s[5];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='+')
            count=count+1;
        else if(s[i]=='-')
            count=count-1;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
module S = Set.Make (struct type t = int let compare (a:int) (b:int) = compare a b end)

let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else ( match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let p = Array.of_list (split (read_line ())) in
        let rev = Array.make n 0 in
        Array.iteri (fun i v -> rev.(v - 1) <- i) p;
        let rec loop i set acc =
            if i < 0 then acc else
                let left, _, right = S.split (rev.(i) * 2) set in
                let l0 = S.max_elt left in
                let l1 = S.max_elt (S.remove l0 left) / 2 in
                let r0 = S.min_elt right in
                let r1 = S.min_elt (S.remove r0 right) / 2 in
                let l0 = l0 / 2 in
                let r0 = r0 / 2 in
                let acc = acc + ((r1 - r0) * (rev.(i) - l0) + (l0 - l1) * (r0 - rev.(i))) * (i + 1) in
                let set = S.add (rev.(i) * 2) set in
                loop (i - 1) set acc
        in
        let r = loop (n - 1) (S.of_list [-2; -3; n * 2; n * 2 + 1]) 0 in
        Printf.printf "%d\n" r
    in
    main ()

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

int main()
{
    int N,a,b,c,sum;
    vector<int> A,B,C;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++){
        cin>>b;
        B.push_back(b);
    }
    for(int i=0;i<N-1;i++){
        cin>>c;
        C.push_back(c);
    }
    
    sum=accumulate(B.begin(), B.end(), 0);
    
    for(int i=0;i<N-1;i++){
        if(A[i+1]-A[i]==1) sum+=C[A[i]-1];
    }
    cout<<sum;
    return 0;
}



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

using namespace std;

#define ll long long

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

    int ans = INT32_MAX;

    int n;

    cin >> n;

    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];

    for (int i = 1; i <= 100; i++) {
        int tmp = 0;
        for (int xx : x) {
            tmp += (xx - i) * (xx - i);
        }
        if (tmp < ans) ans = tmp;
    }

    cout << ans;



    return 0;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;

typedef pair<long long, string> pls;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e,H, W,Q;
long long A[200000]= {};
long long B[200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S[200];
set <long long>sll;
pl buf;
pls bufls;
vector <long long>vl;
vector <pl>vpl;
vector <pls>vpls;
vector <string> vs;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];

float aa;
float bb = 0;

int main() {

	cin >> N>>M>>a;
	bb = 100000000;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		aa = (float)M - A[i] * 0.006 - (float)a;
		if (aa < 0) {
			aa *= -1;
		}
		if (aa < bb) {
			bb = aa;
			c = i + 1;
		}
	}
	
	cout << c << endl;

	return 0;

}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
        if(b==c)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    else
    {
        if(a==c)
            cout<<"Yes"<<endl;
        else if(b==c)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int board[10][10];
using state=tuple<int,int,int>;
vector<state> ans;

void dfs(int rest){
	if(rest==0){
		bool ng=false;;
		rep(i,10)rep(j,10) ng|=board[i][j];
		if(ng==false){
			for(auto &it:ans){
				int y,x,s;
				tie(y,x,s)=it;
				cout << x << " " << y << " " << s << endl;
			}
			exit(0);
		} 
		return;
	}

	rep(i,10)rep(j,10){
		if(board[i][j]==0) continue;

		// small
		{
			int num=0;
			int ci=i+1,cj=j;
			rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=1) num+=min(1,board[a][b]);

			if(num==5){
				rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=1) board[a][b]--;
				ans.push_back(state(ci,cj,1));
				dfs(rest-1);
				ans.pop_back();
				rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=1) board[a][b]++;
			}
		}

		// med
		{
			int num=0;
			int ci=i+1,cj=j+1;
			rep(a,10)rep(b,10) if(max(abs(a-ci),abs(b-cj))<=1) num+=min(1,board[a][b]);

			if(num==9){
				rep(a,10)rep(b,10) if(max(abs(a-ci),abs(b-cj))<=1) board[a][b]--;
				ans.push_back(state(ci,cj,2));
				dfs(rest-1);
				ans.pop_back();
				rep(a,10)rep(b,10) if(max(abs(a-ci),abs(b-cj))<=1) board[a][b]++;
			}
		}

		// large
		{
			int num=0;
			int ci=i+2,cj=j;
			rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=2) num+=min(1,board[a][b]);

			if(num==13){
				rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=2) board[a][b]--;
				ans.push_back(state(ci,cj,3));
				dfs(rest-1);
				ans.pop_back();
				rep(a,10)rep(b,10) if(abs(a-ci)+abs(b-cj)<=2) board[a][b]++;
			}
		}

		
		return;
	}
	return;
}


int main(void){
	int n;
	cin >> n;
	rep(i,10)rep(j,10) cin >> board[i][j];
	dfs(n);
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;

int main()
{

	int n,k,s;
	while(cin>>n>>k>>s,n){

		long long res=0;
		for(long long bit=0;bit<(1<<n);bit++){
			int sum=0,cnt=0;
			for(int i=0;i<n;i++){
				if(bit&(1<<i)){
					sum+=i+1;
					cnt++;
				}
			}
			if(cnt==k && s==sum) res++;
		}

		cout<<res<<endl;

	}

	return 0;
}

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

int sumup(int n){
  int s=0, c=1;
  
  for (int i = 0; i < 6; i++){
    s += (n / c) % 10;
    c = c * 10;
  }
  return s;
}

int main() {
  int N, x, S=100000, A, B;
  cin >> N;
  
  for (int i = 1; i < N; i++){
    A = i;
    B = N-i;
    S = min(sumup(A) + sumup(B), S);
  }
 cout << S << endl;
}

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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define ALL(a) (a).begin(),(a).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

    int n, m;
    cin >> n >> m;

    vector<int> vc;
    REP(i, m) {
        int el;
        cin >> el;
        vc.pb(el);
    }

    if (vc.size() == 1) {
        cout << 0 << '\n';
        return 0;
    }

    sort(vc.begin(), vc.end());

    vector<int> diff;
    vector<int>::iterator it = vc.begin();
	vector<int>::iterator endIt = vc.end();
	while (it < (endIt - 1)) {
		int d = *(it+1) - *it;
        diff.pb(d);
		it++;
	}

    sort(diff.begin(), diff.end());

    int ans = 0;
    int minus;
    if (n >= m) {
        minus = m;
    } else {
        minus = n;
    }
    vector<int>::iterator dit = diff.begin();
	vector<int>::iterator dendIt = diff.end();
	while (dit < (dendIt - minus + 1)) {
		ans += *dit;
		dit++;
	}
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1400
//Name: Citation Format
//Level: 2
//Category: 実装
//Note:

/**
 * 数値が連続している間を検出する。
 */
#include <iostream>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    int prev = -1;
    int cur_start = -1;
    bool first = true;
    for(int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        if(p != prev+1) {
            if(prev != -1) {
                if(!first) cout << ' ';
                if(prev == cur_start) cout << prev;
                else cout << cur_start << '-' << prev;
                first = false;
            }
            cur_start = p;
        }
        prev = p;
    }
    if(!first) cout << ' ';
    if(prev == cur_start) cout << prev;
    else cout << cur_start << '-' << prev;
    cout << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            int N = In.Int();
            List<int> inputs = In.Ints().OrderBy(a => a).ToList();
            int n = 0;
            for(int i = 0; i < N; i++)
            {
                n += inputs[0];
                inputs.RemoveAt(0);
                inputs.RemoveAt(0);
            }

            Out(n);



            return;
        } 

        private static void Out(Object arg)
        {
            Console.WriteLine(arg);
        }
    }

    class In
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static IEnumerable<int> Ints()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i));
        }
    }
}


Measured memory_bytes: 3160