akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

namespace mine
{
	const int MAXN=110000;
	
	int n;
	
	int tr[2*MAXN];
	int lowbit(int x) {return x&-x;}
	void change(int d)
	{
		d+=MAXN;
		while(d<2*MAXN) tr[d]++,d+=lowbit(d);
	}
	int sum(int d)
	{
		d+=MAXN;
		int ans=0;
		while(d>=1) ans+=tr[d],d-=lowbit(d);
		return ans;
	}
	
	int a[MAXN],b[MAXN];
	int c[MAXN];
	
	typedef long long ll;//debug 爆int 
	bool check(int now)
	{
		for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i]<=now?1:-1);//1小于等于,-1大于
		
		memset(tr,0,sizeof tr);//debug
		change(c[0]);//debug 
		
		ll tot=0;//<=now的数，产生的贡献 
		for(int r=1;r<=n;r++)
		{
			//c[r]-c[l-1]>0 => c[l-1]<c[r] (l-1<r)
			tot+=sum(c[r]-1);
			change(c[r]);
		}
		ll all=(long long)(n+1)*n/2;
		all=all/2+1;
		return tot>=all;
	}
	void main()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]);
		
		int l=1,r=1e9,ans=-1;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(check(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}
		printf("%d",ans);
	}
};

int main()
{
	mine::main();
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll amin = 1000001;
    ll amax = -1000001;
    ll asum = 0;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (amin > a[i]) {
            amin = a[i];
        }
        if (amax < a[i]) {
            amax = a[i];
        }
        asum += a[i];
    }
    cout << *min_element(a.begin(), a.end()) << " " << *max_element(a.begin(), a.end()) << " " << accumulate(a.begin(), a.end(), 0ll) << endl;
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string si;
		cin >> si;
		mp[si]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}

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

//infinity
#define INTINF 2000000000
#define LONGINF 20000000000

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

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

	long long MAX = -1;
	for(long long i = 0; i < n; i++){
		for(long long j = i; j < n; j++){
			long long t;
			if(a[i] > a[j]){
				t = a[i] - a[j];
			}else{
				t = a[j] - a[i];
			}
			MAX = (MAX > t) ? MAX : t;
		}
	}
	cout << MAX << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100001

int main(){
  int i,A[MAX],n,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=Partition(A,0,n-1);
  for(i=0;i<n-1;i++){
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
    printf(" ");
  }
  printf("%d\n",A[i]);
  return 0;
}

int Partition(int A[],int p, int r){
  int x,i,j,atai;
  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      atai=A[i];
      A[i]=A[j];
      A[j]=atai;
    }
  }
  atai=A[i+1];
  A[i+1]=A[r];
  A[r]=atai;
  return i+1;
}

Measured memory_bytes: 992
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

intmax_t gcd(intmax_t a, intmax_t b)
{
    while (b != 0) {
        intmax_t r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(void)
{
    intmax_t K;
    intmax_t ans = 0;

    scanf("%jd", &K);

    for (size_t a = 1; a <= K; a++) {
        for (size_t b = 1; b <= K; b++) {
            for (size_t c = 1; c <= K; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, sum = 0, num = 0; cin >> n;
	int a[123456];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (n % 2 == 0) {
		for (int h = 0; h < n; h++) {
			if (h % 2 == 0) {
				num += a[h];
			}
			else {
				sum += a[h];
			}
		}
	}
	else {
		for (int h = 0; h < n; h++) {
			if (h % 2 != 0) {
				num += a[h];
			}
			else {
				sum += a[h];
			}
		}
	}
	cout << sum - num << endl;
	cin >> n;
}

Measured memory_bytes: 256
def cut(loc,s,C):
    c1,c2=[],[]
    Cw,Cd=C[1:]
    if loc:
        a,b=max(s,Cw-s),min(s,Cw-s)
        c1=[a*Cd,a,Cd]
        c2=[b*Cd,b,Cd]
    else:
        a,b=max(s,Cd-s),min(s,Cd-s)
        c1=[a*Cw,Cw,a]
        c2=[b*Cw,Cw,b]    
    return c1,c2



while(1):
    [n,w,d]=[int(x) for x in raw_input().split()]
    if w==0:    break
    A=[[w*d,w,d]]
    for i in range(n):
        [j,s]=[int(x) for x in raw_input().split()]
        j-=1
        AA=A[:j]+A[j+1:]
        C=A.pop(j)
        loc=1
        while(1):
            if loc%2:
                if s>C[1]:
                    loc+=1
                    s-=C[1]
                else:
                    break
            else:
                if s>C[2]:
                    loc+=1
                    s-=C[2]
                else:
                    break
        loc%=2
        [c1,c2]=cut(loc,s,C)
        AA+=[c2,c1]
        A=AA[:]
    A.sort(key=lambda x:x[0])
    print ' '.join([str(x[0]) for x in A])

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;

int main() {
  vector<ll> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end());
  ll cnt = 0;
  while(a.at(2) - a.at(0) > 1) {
    a.at(0) += 2;
    cnt++;
  }
  while(a.at(2) - a.at(1) > 1) {
    a.at(1) += 2;
    cnt++;
  }
  if((a.at(2) == a.at(1)) && (a.at(2) == a.at(0))) cout << cnt << endl;
  else if((a.at(2) != a.at(1)) && (a.at(2) == a.at(0))) cout << cnt + 2 << endl;
  else if((a.at(2) == a.at(1)) && (a.at(2) != a.at(0))) cout << cnt + 2 << endl;
  else cout << cnt + 1 << endl;
}


Measured memory_bytes: 256
// ARC62-D.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int p_sum = 0;
	int g_sum = 0;
	int w_sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (g_sum - p_sum > 0) {
			w_sum += (s[i] == 'g' ? 1 : 0);
			p_sum++;
			//cout << 'p';

		}
		else {
			g_sum++;
			w_sum += (s[i] == 'g' ? 0 : -1);
			//cout << 'g';
		}
		
	}

	cout << w_sum << endl;

    return 0;
}



Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int[] T = new int[N];
		int ans = 0;
		int count = 0;
		int a = 0;

		for (int i=0; i < N; i++) {
			T[i] = sc.nextInt();
		}


		Arrays.sort(T);

		a = T[0];

		for (int i = 0; i < N; i++) {
			//System.out.println(T[i]);

			if (count == 0) {
				a = T[i];
			}
			if (i == N -1 ) {
				if(a + K >= 0) {
//					System.out.println("入った");
					count++;
					if (count == C) {
						count=0;
						ans++;
//						System.out.println("出発4");
					}
				}else {
					count = 0;
					ans++;
//					System.out.println("出発5");

				}
			} else if(a + K >= T[i+1]) {
			//	System.out.println("入った");
				count++;
				if (count == C) {
					count=0;
					ans++;
	//				System.out.println("出発1");
				}
			}else {
				count = 0;
				ans++;
		//		System.out.println("出発2");
			}
		}
		if (count > 0) {
			count = 0;
			ans++;
			//System.out.println("出発3");
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 49364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String c = scanner.next();
		switch(c){

		case "a":
			System.out.println("vowel");
			break;
		case "e":
			System.out.println("vowel");
			break;
		case "i":
			System.out.println("vowel");
			break;
		case "o":
			System.out.println("vowel");
			break;
		case "u":
			System.out.println("vowel");
			break;
		default:
			System.out.println("consonant");
			break;
		}
	}

}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, ans;
string s;
map<string, int> dp[nsz + 5];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> s;
    n = (int) s.size();
    s = ' ' + s;
    dp[0][""] = 0;
    cont (i, n) {
        string cur;
        cur += s[i];
        foreach (it, dp[i - 1]) {
            if (it->first == cur)  continue;
            dp[i][cur] = max(dp[i][cur], it->second + 1);
        }
        if (i > 1) {
            cur = s[i - 1] + s[i];
            foreach (it, dp[i - 2]) {
                if (it->first == cur)  continue;
                dp[i][cur] = max(dp[i][cur], it->second + 1);
            }
        }
    }
    foreach (it, dp[n]) {
        ans = max(ans, it->second);
    }
    cout << ans << ln;
}


Measured memory_bytes: 53584
#include <stdio.h>
#include <stdlib.h>

int SelectionSort(int *a, int n);

int main(void){
  int i, n, *a, ans;

  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);
  if(a == NULL){
    printf("?????¢????¢??????¨??????\n");
    return -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  ans = SelectionSort(a, n);
  for(i = 0; i < n; i++){
    printf("%d", a[i]);
    if(i < n-1){
      printf(" ");
    }
  }
  printf("\n%d\n", ans);
  free(a);
  return 0;
}


int SelectionSort(int *a, int n){
  int min, i, j, temp, count = 0;

  for(i = 0; i < n-1; i++){
    min = i;
    for(j = i+1; j < n; j++){
      if(a[min] > a[j]){
	min = j;
      }
    }
    if(min != i){
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
      count++;
    }
  }
  return count;
}

Measured memory_bytes: 604
N, a, b, c = gets.chomp.split.map(&:to_i)
N.freeze
s = N.times.map{gets.chomp.to_s} 
ary = Array.new(N, "foo") # 引数あり

#ゼロが２つ以上あれば強制終了
#if (a == 0 && b == 0) || (a == 0 && c == 0) || (b == 0 && c == 0) then
#  puts "No"
#  exit
#end

#ゲーム開始
num = 0
while num < N do
  case s[num]
  when "AB" then
    if a == 0 && b == 0 then
      puts "No"
      exit
    elsif a == 1 && b == 1 then
      case s[num+1]
      when "AC" then
        a =  a + 1
        b =  b - 1
        ary[num] = "A"
      else
        b = b + 1
        a = a - 1
        ary[num] = "B"
      end
    elsif a > b then
      b =  b + 1
      a =  a - 1
      ary[num] = "B"
    else
      a =  a + 1
      b =  b - 1
      ary[num] = "A"
    end
    when "AC" then
      if a == 0 && c == 0 then
        puts "No"
        exit
      elsif a == 1 && c == 1 then
        case s[num+1]
        when "AB" then
          a =  a + 1
          c =  c - 1
          ary[num] = "A"
        else
          c = c + 1
          a = a - 1
          ary[num] = "C"
        end
      elsif a > c then
        c = c + 1
        a = a - 1
        ary[num] = "C"
      else
        a =  a + 1
        c =  c - 1
        ary[num] = "A"
      end
    when "BC" then
    if b == 0 && c == 0 then
      puts "No"
      exit
    elsif b == 1 && c == 1 then
      case s[num+1]
      when "AB" then
        b = b + 1
        c = c - 1
        ary[num] = "B"
      else
        c = c + 1
        b = b - 1
        ary[num] = "C"
      end
    elsif b > c then
      c = c + 1
      b = b - 1
      ary[num] = "C"
    else
      b = b + 1
      c = c - 1
      ary[num] = "B"
    end
  else
    ##空処理、ありえないはず
  end
  #次のゲームへ・・・
  num = num + 1
end
puts "Yes"
num1 = 0
while num1 < N do
  puts ary[num1]
  num1 = num1 + 1
end

Measured memory_bytes: 26976
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

void test() {
    int n, q;
    cin >> n >> q;
    long long ans = 1ll * (n - 2) * (n - 2);
    set<pair<int, int>> l, r;
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            int en = n;
            if (r.size()) {
                pair<int, int> p = {x, 0};
                auto itr = r.lower_bound(p);
                if (itr != r.end()) {
                    en = (*itr).second;
                }
            }
            ans -= en - 2;
            l.emplace(en, x);
        } else {
            int en = n;
            if (l.size()) {
                pair<int, int> p = {x, 0};
                auto itr = l.lower_bound(p);
                if (itr != l.end()) {
                    en = (*itr).second;
                }
            }
            ans -= en - 2;
            r.emplace(en, x);
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 12972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var AB = Console.ReadLine().Split().Select(int.Parse);
        int A = AB.First(), B = AB.Last();
        var S = Console.ReadLine();
        Console.WriteLine(Regex.IsMatch(S, $"\\d{{{A}}}-\\d{{{B}}}") ? "Yes" : "No");
    }
}

Measured memory_bytes: 15960
N = int(input())
S = str(input())
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N-1):
    for j in range(i+1,N):
        k = j + (j - i)
        if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, a, b;
        cin >> n >> a >> b;
        vector<int> h(n);
        for(int &i : h){
            cin >> i;
        }
        int l = 1, r = 1e9;
        int ans;
        while(l <= r){
            int mid = (l + r) / 2;
            vector<int> curr = h;
            for(int &it : curr){
                it -= b * mid;
            }
            int cnt = 0;
            int left = a - b;
            for(int &it : curr){
                if(it > 0){
                    cnt += (it / left) + (it % left != 0);
                }
            }
            if(cnt <= mid){
                ans = mid;
                r = mid - 1;
            }else{
                l = mid + 1;
            }
        }
        cout << ans << '\n';
    }
}

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

int main () {
  int N,K;
  cin >> N >>K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  vector<int> vec(N);
  }

  sort(vec.begin(), vec.end());
  int out =0;
  for (int i =0;i < K; i++)
    out += vec.at(i);
  cout << out << endl;

}


Measured memory_bytes: 3628
/*
&#39064;意：7数&#30721;&#38382;&#39064;。在2×4的棋&#30424;上，&#25670;有7个棋子，&#27599;个棋子上&#26631;有1至7的某一数字，不同棋子上&#26631;的数字不相同。棋&#30424;上&#36824;有一个空格（用0表示），与空格相&#37051;（上下左右）的棋子可以移到空格中，&#35813;棋子原先位置成&#20026;空格。&#32473;出一个初始状&#24577;（保&#35777;可以&#36716;移到最&#32456;状&#24577;），找出一&#31181;从初始状&#24577;&#36716;&#21464;成&#32473;定最&#32456;状&#24577;的移&#21160;棋子&#27493;数最少的移&#21160;&#27493;&#39588;。

&#36755;入：多&#32452;&#36755;入，&#27599;&#32452;8个数，表示初始状&#24577;前四个数&#20026;第一行从左到右，后四个数&#20026;第二行从左到右。 

&#36755;出：至少需要多少&#27493;可以从&#36755;入状&#24577;到&#36798;最&#32456;状&#24577;（0 1 2 3 4 5 6 7）
*/ 
// 
// Input
// 1つ目のパズルの状態(整数;空白区切り)
// 2つ目のパズルの状態(整数;空白区切り)
// :
// :
// 与えられるパズルの数は1000以下です。
// 
// Output
// 1つ目のパズルの状態から最終状態へ移行する最小手数(整数)
// 2つ目のパズルの状態から最終状態へ移行する最小手数(整数)
// :
// :
// Sample Input
// 0 1 2 3 4 5 6 7
// 1 0 2 3 4 5 6 7
// 7 6 5 4 3 2 1 0
// Output for the Sample Input
// 0
// 1
// 28
#include <cstdio>
#include <queue>
#include <string>
#include <iostream>
#define INF 1000000
using namespace std;

void debug()
{
	freopen("AOJ-0121-in.txt","r",stdin);
	freopen("AOJ-0121-out.txt","w",stdout);
}

int Jie[8]={0,1,2,6,24,120,720,5040};
int Step[42000];

int J(const string &s8)
{
	int res=0;
	for (int i=0;i<7;++i)
	{
		int k=s8[i]-'0';
		for (int kk=0;kk<i;++kk)
		{
			if (s8[kk]<s8[i])
			{
				--k;
			}
		}
		res+=k*Jie[7-i];
	}
	return res;
}

int main()
{
// 	debug();
// 
// 	int e=1;
// 	for (int i=1;i<9;++i)
// 	{
// 		e*=i;	printf ("%d\n",e);
// 
// 	}
// 		1
// 		2
// 		6
// 		24
// 		120
// 		720
// 		5040
// 		40320
	for (int si=0;si<42000;++si)
	{
		Step[si]=INF;
	}

	queue<string> q;
	string sa="01234567";
	q.push (sa);
	Step[J(sa)]=0;
	while (q.size ())
	{
		string ss=q.front ();
		q.pop ();
		int stp=Step[J(ss)];
		int i0=0;
		for (;i0<8;++i0)
		{
			if (ss[i0]=='0')
			{
				break;
			}
		}
		if (i0!=3&&i0!=7)
		{
			string p=ss;
			p[i0]=p[i0+1];
			p[i0+1]='0';
			int ssss=J (p);
			if (Step[J(p)]>stp+1)
			{
				q.push(p);
				Step[J(p)]=stp+1;
			}
		}
		if (i0!=0&&i0!=4)
		{
			string p=ss;
			p[i0]=p[i0-1];
			p[i0-1]='0';
			if (Step[J(p)]>stp+1)
			{
				q.push (p);
				Step[J(p)]=stp+1;
			}
		}
		if (i0<4)
		{
			string p=ss;
			p[i0]=p[i0+4];
			p[i0+4]='0';
			if (Step[J(p)]>stp+1)
			{
				q.push (p);
				Step[J(p)]=stp+1;
			}
		}
		else 
		{
			string p=ss;
			p[i0]=p[i0-4];
			p[i0-4]='0';
			if (Step[J(p)]>stp+1)
			{
				q.push (p);
				Step[J(p)]=stp+1;
			}
		}
	}
	while(getline(cin,sa))
	{
		string str;
		for (int i=0;i<sa.size ();++i)
		{
			if (sa[i]>='0'&&sa[i]<='7')
			{
				str+=sa[i];
			}
		}
		printf ("%d\n",Step[J(str)]);
	}
	return 0;
}

Measured memory_bytes: 1504
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    const I_INF: usize = 1 << 50;
    const U_INF: isize = 1 << 50;
    
    let n: usize = read!();
    let w: usize = read!();
    const VALUE: usize = 100000 * 2;
    
    let mut vs = Vec::with_capacity(n);
    let mut ws = Vec::with_capacity(n);
    
    for _ in 0..n {
        let wi: usize = read!();
        let vi: usize = read!();
        ws.push(wi);
        vs.push(vi);
    }
    
    let mut dp = vec![vec![I_INF; VALUE*2]; n + 10];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..VALUE {
            dp[i + 1][j] = dp[i + 1][j].min(dp[i][j]);
            dp[i + 1][j + vs[i]] = dp[i + 1][j + vs[i]].min(dp[i][j] + ws[i]);
        }
    }
    
    println!("{}", dp[n].iter().enumerate().filter_map(|(j, &wi)| if wi <= w { Some(j) } else { None }).max().unwrap());
}

Measured memory_bytes: 346068
import java.util.Scanner;
 
public class Main {
 
    public static void main(String args[]) {
 
        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next()); // 未使用となる変数n
        Integer q = Integer.parseInt(sc.next());
        String s = sc.next();
        Integer[] l = new Integer[q];
        Integer[] r = new Integer[q];
        for (int i = 0; i < q; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
 
        // 主処理
        int[] count = new int[n];
        count[0] = 0;
        for (int i = 1; i < n; i++) {
            if (s.charAt(i) == 'C' && s.charAt(i - 1) == 'A') {
                count[i] = count[i-1] + 1;
            } else {
                count[i] = count[i-1];
            }
        }
        String[] str = new String[q];
        for (int i = 0; i < q; i++) {
            int num = count[r[i] - 1] - count[l[i] - 1];
            str[i] = Integer.toString(num);
        }
 
        // 出力
        System.out.println(String.join("\r\n", str));
        sc.close();
    }
}

Measured memory_bytes: 65384
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] ans = new int[N];
    for (int i=0; i<N; i++) {
      ans[i] = sc.nextInt();
    }
    int count =0;
    int end =0;
    while (true) {
      for (int i=0; i<N; i++) {
        if (ans[i] % 2 == 0) {
          ans[i] /= 2;
        } else {
          end++;
          break;
        }
      }
      if (end != 0) break;
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 22868
#include<iostream>

using namespace std;

int main()
{
	int m[51], f[51], r[51];
	int total;
	int i = 0;
	while (cin >> m[i] >> f[i] >> r[i], m[i] + f[i] + r[i] != -3) { i++; }
	i = 0;
	while (1)
	{
		if (m[i] == -1 && f[i] == -1 && r[i] == -1) break;
		total = m[i] + f[i];
		if (m[i] == -1 || f[i] == -1)
		{
			cout << "F" << endl;
		}
		else if (total < 30)
		{
			cout << "F" << endl;
		}
		else if (30 <= total && total < 50)
		{
			if (50 <= r[i])
			{
				cout << "C" << endl;
			}
			else
			{
				cout << "D" << endl;
			}
		}
		else if (50 <= total && total < 65)
		{
			cout << "C" << endl;
		}
		else if (65 <= total && total < 80)
		{
			cout << "B" << endl;
		}
		else
		{
			cout << "A" << endl;
		}
		i++;
	}
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    double r;
    cin >> r;
    double c;
    double d;
    d = 2.0*r*3.141592653589;
    c = r*r*3.141592653589;
    printf("%f %f\n",c,d);
}

/* ここでcをfloatとすると桁が足りなくなる。 */


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll p[maxn], c[maxn], sum[maxn];
vector<ll> v;

void solve() {
	ll n,k,ans=-1e18; cin >> n >> k;
	rep(i,1,n+1) cin >> p[i];
	rep(i,1,n+1) cin >> c[i];
	rep(i,1,n+1) {
		ll t = p[i], cnt=1, res=c[i];
		v.clear();
		v.push_back(0); v.push_back(c[i]);
		ans = max(ans, c[i]);
		while(t != i && cnt < k) {
			res += c[t];
			ans = max(res, ans);
			v.push_back(c[t]);
			t = p[t];
			cnt++;
		}
		ll mxi = 1;
		rep(j,1,cnt+1) {
			sum[j] = sum[j-1] + v[j];
			if (sum[j] > sum[mxi]) {
				mxi = j;
			}
		}
		//rep(i,1,cnt+1) cout << v[i] << " \n"[i==cnt];
		//cout << ans << '\n';
		ll tmp = res;
		if (k - cnt > 0) {
			// cout << cnt << '\n';
			// cout << k-cnt << ' ' << (k-cnt)%cnt << '\n';
			if (sum[cnt] > 0) {
				res += sum[cnt]*((k-cnt)/cnt);
				ans = max(ans, res);
				rep(j,1,(k-cnt)%cnt+1) {
					res += v[j];
					//cout << i << "----" << j << ' ' <<  v[j] << ' ';
					ans = max(ans, res);
					//cout << ans << '\n';
				}
				if ((k-cnt)%cnt==0) {
					res = tmp + sum[cnt]*((k-cnt)/cnt-1);
					ans = max(ans, res);
					rep(j,1,cnt+1) {
						res += v[j];
						ans = max(ans, res);
					}
				}
			}
			res = tmp;
			rep(j,1,min(cnt,k-cnt)+1) {
				res += v[j];
				ans = max(ans, res);
			}
			//cout << res << '\n';
			
			//res -= sum[cnt]*((k-cnt)/cnt);
			
			// rep(i,1,k-cnt+1) {
			// 	res += v[i%cnt+1];
			// 	ans = max(ans, res);
			// }
		}
	}
	cout << ans << '\n';
}

int main(int argc, char * argv[]) 
{
	//ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

ll x;

ll fun(ll a) {
    return a*a*a*a*a;
}

ll nibun(ll z) {
    ll a = 0;
    ll c = 1000;
    ll x1 = x + fun(z);
    ll x2 = x - fun(z);
    while(c - a != 1) {
        ll b = (a + c) / 2;
        if(fun(b) <= x1) {
            a = b;
        } else {
            c = b;
        }
    }
    ll res = LINF;
    if(fun(a) == x1) {
        res = a;
    }
    a = 0;
    c = 1000;
    if(x2 >= 0) {
        while(c - a != 1) {
            ll b = (a + c) / 2;
            if(fun(b) <= x2) {
                a = b;
            } else {
                c = b;
            }
        }
    }
    if(fun(a) == x2) {
        res = -a;
    }
    return res;
}

int main() {
    cin >> x;
    rep(i, 1000) {
        ll ii = i;
        ll vv = nibun(ii);
        if(vv != LINF) {
            if(vv < 0) swap(ii, vv);
            cout << vv << ' ' << ii << endl;
            return 0;
        }
    }
}

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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}

int fact[1000000],fact_inv[1000000];
int ncr(int n,int r){
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int s;
    cin>>s;int ans=0;
    fact[0]=1;
    for(int i=1;i<1000000;i++){
        fact[i]=(fact[i-1]*i)%mod;
        fact_inv[i]=power(fact[i],mod-2);
    }



    for(int i=1;i<=2000;i++)
    {
        int x=s-3*i;
        if(s<0)continue;
        ans+=ncr(i+x-1,i-1);
        ans%=mod;
    }
    ans+=mod;ans%=mod;
    cout<<ans<<endl;
}


return 0;
}





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

int main() 
{
  int N;
  cin>>N;
  int A,B;
  int YN = 1;
  
  for(A=1;A<10;A++)
  {
    B = 1;
    if(N == A*B)
      YN = 0;
  }
  
  for(A=1;A<10;A++)
  {
    B = 2;
    if(N == A*B)
      YN = 0;
  }
  
  for(A=1;A<10;A++)
  {
    B = 3;
    if(N == A*B)
      YN = 0;
  }
  
  for(A=1;A<10;A++)
  {
    B = 4;
    if(N == A*B)
      YN = 0;
  }
  
  for(A=1;A<10;A++)
  {
    B = 5;
    if(N == A*B)
      YN = 0;
  }
  for(A=1;A<10;A++)
  {
    B = 6;
    if(N == A*B)
      YN = 0;
  }
  for(A=1;A<10;A++)
  {
    B = 7;
    if(N == A*B)
      YN = 0;
  }
  for(A=1;A<10;A++)
  {
    B = 8;
    if(N == A*B)
      YN = 0;
  }
  for(A=1;A<10;A++)
  {
    B = 9;
    if(N == A*B)
      YN = 0;
  }
  
  
  if(YN == 0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  char s[11];
  scanf("%s",s);

  int j=0;
  char array[11]={'\0'};
  int len=strlen(s);
  for(int i=0;i<len;i++){
    if(s[i]=='0'){
      array[j]='0';
      j++;
    }else if(s[i]=='1'){
      array[j]='1';
      j++;
    }else if(s[i]=='B'){
      if(j!=0){
        j--;
        array[j]='\0';
      }
    }
  }
  printf("%s",array);
  return 0;
}

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

#define int long long

typedef long long li;
typedef long double ld;

void solve();
int32_t main() {
    #ifndef ONLINE_JUDGE
   //     freopen("input.txt", "r", stdin);
    #endif
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

string s;
void solve() {
	cin >> s;
	map<char, int> m;
	for (auto i: s)
		m[i]++;
	if ((int) m.size() != 2) {
		cout << "No";
		return;
	}
	for (auto i: m) {
		if (i.second != 2) {
			cout << "No";
			return;
		}
	} cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
unsigned long long A;
char B[100];
scanf("%llu %s", &A, B);
size_t l = strlen(B);
B[l-3] = B[l-2]; B[l-2] = B[l-1]; B[l-1] = '\0';
unsigned long long ans = A * atoll(B);
printf("%llu", ans / 100);
return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  int count=0;
  vector<int> v(n),v2(n);
  if(s[0]=='0')v[0]=-1;
  for(int i=0;i<n-1;i++){
    if(s[i]=='0'&&s[i+1]=='1'){
      count++;
      v[count]=i;
    }
    if(s[i]=='1'&&s[i+1]=='0'){
      v2[count]=i;
    }
  }if(s[n-1]=='1')v2[count]=n-1;
  else{
    count++;
    v[count]=n-1;
    v2[count]=n-1;
  }
  if(k>=count)cout<<s.size()<<endl;
  else{
    int ma=0;
    for(int i=k;i<count+1;i++){
      ma=max(v2[i]-v[i-k],ma);
    }
    cout<<ma<<endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    string N;
    cin >> N;

    string ans = "No";
    rep(i, N.size()) {
        if (N[i] == '7') ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int n;
vector<int> s;
int q;
vector<int> t;

int main() {
	cin >> n;
	s.resize(n);
	rep(i, n) cin >> s[i];
	cin >> q;
	t.resize(q);
	rep(i, q) cin >> t[i];

	int cnt = 0;

	rep(i, q) {
		//t[i]がsにいるかどうか?
		bool flag = binary_search(all(s), t[i]);

		if (flag) cnt++;
	}

	cout << cnt << endl;
}


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


int N, count2=0;
//void dfs(long long, unsigned char);//这里用了long long 
void dfs(long long nextNum,unsigned char flag357)
{
    if(nextNum<=N)
    {
        if(flag357==07)    // 07 is BIN 111，即357全都出现 
            count2++;
        dfs(nextNum*10+3,flag357|01); // BIN 001 续上3 
        dfs(nextNum*10+5,flag357|02); // BIN 010 续上5 
        dfs(nextNum*10+7,flag357|04); // BIN 100 续上7 
    }
}
int main(void)
{
    scanf("%d",&N);
    dfs(0,0);
    printf("%d\n",count2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int i = 0, j = 0, ans = 0;
    while (R * i <= N)
    {
        while (R * i + G * j <= N)
        {
            if ((N - (R * i + G * j)) % B == 0)
            {
                ans++;
            }
            j++;
        }
        j = 0;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    rep(i, n)cin >> x[i] >> y[i] >> z[i];
    
    ll ans = 0;
    rep(i, 2)rep(j, 2)rep(k, 2){
        ll si = -1 + i * 2;
        ll sj = -1 + j * 2;
        ll sk = -1 + k * 2;
        vector<ll> a(n);
        rep(i, n)a[i] = x[i]*si + y[i]*sj + z[i]*sk;
        sort(a.begin(), a.end(), greater<ll>());
        ll sum = 0;
        rep(i, m)sum += a[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = INF;
    for (int i = -100; i <= 100; ++i) {
        int now = 0;
        rep(j, n) {
            now += (a[j] - i) * (a[j] - i);
        }
        chmin(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int n,y,a[3]={-1,-1,-1};

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

	y/=1000;

	for(int i=0;i<n+1;i++){
		for(int j=0;j<n-i+1;j++){
			if(9*i+4*j==y-n){
				a[0]=i; a[1]=j; a[2]=n-i-j;
				break;
			}
		}

		if(a[0]!=-1) break;
	}

	printf("%d %d %d\n",a[0],a[1],a[2]);

	return 0;
}


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

int n,x;

int main()
{
    scanf("%d %d",&n,&x);
    int sum = 0;
    int ans = 1;
    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d",&a);
        ans++;
        sum += a;
        if(sum > x)
        {
            ans--;
            break;
        }
        else if(sum == x)
            break;
    }
    printf("%d\n",ans);
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3624
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d %d', $a, $b);
    printf("%d %d\n", gcd($a, $b), lcm($a, $b));
}

function gcd($a, $b)
{
    if ($a < $b) {
        list($a, $b) = array($b, $a);
    }

    while ($b > 0) {
        list($a, $b) = array($b, $a % $b);
    }

    return $a;
}

function lcm($a, $b)
{
    return $a * $b / gcd($a, $b);
}

Measured memory_bytes: 6628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

long long roundup(long long A,long long B){
    return (A+B-1)/B;
}

int main(void){
    int n,d,ans=0;
    scanf("%d%d",&n,&d);
    int x[n][d];
    for (int i=0; i<n; i++){
        for (int j=0; j<d; j++){
            scanf("%d",&x[i][j]);
        }
    }
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            int tmp=0;
            for (int k=0; k<d; k++){
                tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for (int k=0; k<4000; k++){
                if (k*k==tmp){
                    ans++;
                    break;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

l,r,d = MAP()
ans = 0

for i in range(l,r+1):
  if i%d == 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f; 
typedef long long ll;
ll a[200005];
ll vis[200005];
ll town[200005];
 
int main(){
	ll n,k,i,j;
    scanf("%lld%lld",&n,&k);
    k++;
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	vis[1]=1;
	town[1]=1;
	ll now=1;
	i=2;
	while(1){
		now=a[now];
		if(vis[now])break;
		else {
			vis[now]=i;
			town[i]=now;
		}
		i++;
	}
	ll step=i-vis[now];
	if(k<=vis[now])printf("%lld",town[k]);
	else {
		k-=(vis[now]-1);
		k%=step;
		if(k==0){
			printf("%lld",town[vis[now]+step-1]);
		}
		else printf("%lld",town[vis[now]+k-1]);
	}
    return 0;
}
 

Measured memory_bytes: 8388
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX (1<<16) + 10
#define mod 1000000007
#define inf 1000000000000000000
#define ll long long
#define endl '\n'
ll dp[MAX],cost[MAX],a[16][16],sum,tempp;
vector<int> temp;
int n;
ll memo(int i){
	if(dp[i] != -inf)return dp[i];
	dp[i] = 0;
	for(int j = i; j > 0; j = (j - 1) & i)
			dp[i] = max(dp[i], memo(i - j) + cost[j]);
	return dp[i];
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i =0 ; i < n; i++)
		for(int j = 0; j < n ; j++)
			cin>>a[i][j];
	
	for(int i = 0; i < (1<<n) ; i++){
		temp.clear();
		tempp = 0;
		for(int j = 0; j < n ; j++){
			if(i&(1<<j))tempp += (1<<j),temp.push_back(j);
		}
		for(int j = 0 ; j < temp.size(); j++){
			for(int k = j ; k < temp.size() ;k++){
				cost[tempp] += a[temp[j]][temp[k]];
			}
		}

	}
	fill(dp,dp + MAX,-inf);
	cout<<memo((1<<n) - 1);
	return 0; 
} 

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

vector<pair<int,pair<int,int>>>v;
vector<pair<int,int>>grp[105];
map<pair<int,int>,int>mp,non;
int vis[105];
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--){
        int a,b,c;
        cin>>a>>b>>c;
        v.pb(make_pair(c,make_pair(a,b)));
        mp[make_pair(a,b)]=c;
        mp[make_pair(b,a)]=c;
        grp[a].pb(make_pair(b,c));
        grp[b].pb(make_pair(a,c));
    }
    sort(all(v));
    for(int i=1;i<=n;++i){
        priority_queue<pair<int,int>>q;
        memset(vis,0x3f,sizeof vis);
        q.push(make_pair(0,i));
        vis[i]=0;
        int prev=0;
        while(!q.empty()){
            pair<int,int> curr=q.top();
            prev=curr.S;
            q.pop();
            for(auto nxt:grp[curr.S]){
                if(vis[nxt.F]>vis[curr.S]+nxt.S){
                    vis[nxt.F]=vis[curr.S]+nxt.S;
                    q.push(make_pair(nxt.S,nxt.F));
                }
            }
        }
        for(int j=1;j<=n;++j){
            if(vis[j]<mp[make_pair(i,j)]){
                non[make_pair(i,j)]=1;
                non[make_pair(j,i)]=1;
            }
        }
        //p();
    }
    int cnt=0;
    for(int i=0;i<sz(v);++i){
        if(non[make_pair(v[i].S.F,v[i].S.S)]==1 and non[make_pair(v[i].S.S,v[i].S.F)]==1){
            cnt+=1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};



int main() {

	
	ll n, m, k;
	cin >> n >> m >> k;

	Combination com(n * m + 10);

	ll ans = 0;
	for (ll i = 1; i <= n-1; i++)
	{
		ans += m * m * i * (n - i);
		ans %= MOD;
	}

	for (ll i = 1; i <= m - 1; i++)
	{
		ans += n * n * i * (m - i);
		ans %= MOD;
	}

	ans *= com.C(n * m - 2, k - 2);
	ans %= MOD;

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 3328
import java.util.*

open class MainKt {
    companion object Static {
        @JvmStatic fun main(args: Array<String> = arrayOf()) {
            MainKt().solve()
        }
    }

    val scanner = Scanner(System.`in`)

    fun printf(pattern: String, vararg args: Any): Unit {
        println(String.format(pattern, *args))
    }

    open fun println(line: String) {
        kotlin.io.println(line)
    }

    fun println(line: Int) {
        println(line.toString())
    }

    fun println(line: Long) {
        println(line.toString())
    }

    open fun readLine(): String {
        return scanner.nextLine()
    }

    fun readArg(): String {
        return readLine()
    }

    fun readInt(): Int {
        return readArg().toInt()
    }

    fun readLong(): Long {
        return readArg().toLong()
    }

    fun readIntList(): List<Int> {
        return readArgList().map { it.toInt() }
    }

    fun readLongList(): List<Long> {
        return readArgList().map { it.toLong() }
    }

    fun readArgList(): List<String> {
        return readLine().split(" ")
    }

    fun solve() {
        val (x, a, b) = readIntList()
        val d = b - a
        if (d > x) {
            println("dangerous")
            return
        }
        if (d <= 0) {
            println("delicious")
            return
        }
        println("safe")
    }
}

Measured memory_bytes: 34164