akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    vector<vector<ll>> item(n);
    REP(i, n) {
        ll kind, value;
        cin >> kind >> value;
        --kind;
        item[kind].push_back(value);
    }
    vector<ll> y0, y1;
    REP(i, n) {
        if (item[i].size() == 0)
            continue;
        sort(ALL(item[i]));
        y1.push_back(item[i].back());
        item[i].pop_back();
        y0.insert(y0.end(), item[i].begin(), item[i].end()); // まとめてinsert
    }
    sort(ALL(y1), greater<ll>());
    sort(ALL(y0), greater<ll>());

    ll Y = max(1LL, k - ll(y0.size())); // はじめの 1 の数(なるべく0が多くなるように = 1が少なくなるように)

    ll X = 0;
    REP(i, Y) { X += y1[i]; }
    REP(i, k - Y) { X += y0[i]; }
    ll ans = 0;
    while (1) {
        ans = max(ans, X + Y * Y);
        if (Y >= k || Y >= y1.size())
            break;
        X += y1[Y];
        X -= y0[k - Y - 1];
        Y++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6904
#include<bits/stdc++.h>
#define endl "\n" 
#define ll long long 
#define sp " "
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	int q=1;//cin>>q;
	while(q--){
		int x;cin>>x;
		if(x<30)
			cout<<"No";
		else 
			cout<<"Yes";
	}
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}

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


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    if(n%k)
        ppp(1);
    else
        ppp(0);






    return 0;
}


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

int max_digit(int64_t a, int64_t b)
{
	int max_digit = 0;

	while (true)
	{
		a /= 10;
		b /= 10;

		max_digit += 1;

		if (a == 0 && b == 0)
		{
			break;
		}
	}

	return max_digit;
}

int main()
{
	int64_t N;

	cin >> N;

	int minmax_d = 100;
	for (int64_t A = 1; A <= sqrt(N); ++A)
	{
		if (N % A != 0)
		{
			continue;
		}

		int64_t B = N / A;
		minmax_d = min(minmax_d, max_digit(A, B));
	}

	cout << minmax_d << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
h,w=map(int,input().split())
maze=[]
for i in range(h):
    maze.append(list(input()))
for i in range(h):
    for j in range(w):
        if maze[i][j]=="#":
            flg=False
            for l,m in [(0,1),(1,0),(-1,0),(0,-1)]:
                if 0<=i+l<h and 0<=j+m<w:
                    if maze[i+l][j+m]=="#":
                        flg=True
            if flg==False:
                print("No")
                sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  vector<ll> a(3); cin >> a[0] >> a[1] >> a[2];
  for (int i = 0; i < 3; ++i) {
    if (a[i]%2==0) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << min({a[0]*a[1], a[1]*a[2], a[2]*a[0]}) << endl;
}

Measured memory_bytes: 256
n = int(input())
ns = [0]
ns += list(map(int, input().split()))
ns.append(0)
total_cost = sum(abs(ns[i]-ns[i+1]) for i in range(n+1))
for i in range(1, n+1):
    print(total_cost-(abs(ns[i-1]-ns[i])+abs(ns[i]-ns[i+1]))+abs(ns[i-1]-ns[i+1]))


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

#define forn(i,a,b) for(int i=(a);i<(b); ++i)
#define nfor(i,b,a) for(int i=(b-1);i>=a;--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ifile freopen("point1.in", "r", stdin)
#define ofile freopen("point1.out   ", "w", stdout)
#define fast ios_base::sync_with_stdio(0);\
             cin.tie(0);\
             cout.tie(0);
//#define mp make_pair
#define pb push_back
//#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll_min LONG_LONG_MIN
#define ll_max LONG_LONG_MAX
#define _1 first
#define _2 second
#define sqr(a) ((a)*(a))
const ld PI = 3.141592653589793238462643383279;
const ld EPS = 1e-6;
const ll INF = 1e9 + 7;
const ll MOD = INF;
const ll maxn = 2e5+2;
const ll HASH_MODS[] = { 1000000007333,1000000009367, 1000000075747, 1000000158923, 1000000203119 };
//||||||||||||||||||||LOCAL||||||||||||||||||||||||||
int main(){
    int a,b;
    cin>>a>>b;
    if (a==1){
        if (b!=1)
            cout<<"Alice";
        else
            cout<<"Draw";
    }
    else if (b==1){
        if (a!=1)
            cout<<"Bob";
        else
            cout<<"Draw";
    }
    else if (a<b)
        cout<<"Bob";
    else if (b<a)
        cout<<"Alice";
    else
        cout<<"Draw";
}


Measured memory_bytes: 256
import sys;sys.setrecursionlimit(int(1e7))

class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N+1)]

for i in range(N-1):
    a,b,c = map(int,input().split())
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = map(int,input().split())
K = K - 1
depth = [None]*N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = map(int, input().split())
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])


Measured memory_bytes: 152180
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
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;}

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

    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    cout << (n-1 + k-1 -1) / (k-1) << endl;
}


Measured memory_bytes: 640
N = int(input())

flag = 1
for i in range(N):
    t, x, y = map(int, input().split())

    # violation case1: distance is more than time
    if x + y > t:
        flag = 0

    # validation case2: t has to be odd if x + y is odd, and vice versa for even number
    if (t + x + y) % 2 != 0:
        flag = 0

print("Yes") if flag == 1 else print("No")


Measured memory_bytes: 43864
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e9+7 ;
int main()
{
    ll n,i,j,ans=0,s=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
    }
    ll pre[n]={0};
    pre[0]=ara[0];
    for(i=1;i<n;i++){
        pre[i]=(pre[i-1]+ara[i]);
    }
    for(i=0;i<n;i++){
        s= (ara[i]%M* ((pre[n-1]-pre[i])%M) )%M;
        ans= ( ans+s)%M;
    }
    ans= (ans+M)%M;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6732
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use std::collections::HashMap;

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
  }
  
  let mut result = 1;
  let mut v = 1;
  while v * v <= m {
    if m % v == 0 {
      let b = m / v;
      if  v * n <= m {
        result = std::cmp::max(result, v);
      }
      if b * n <= m {
        result = std::cmp::max(result, b);
      }
    }
    v += 1;
  } 
  println!("{}", result);
}

Measured memory_bytes: 2152
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
long long int N,A,B,C,D,E;
string S[200];
vector<long long int>pl,mi;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>A>>B>>C>>D>>E;
    cout<<(N+min({A,B,C,D,E})-1)/min({A,B,C,D,E})+4<<endl;
}    


Measured memory_bytes: 256
def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)
    j = -1
    for i in range(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return tuple(nx)
def kmpSearch(s, w):
    ls = len(s)
    start = 0
    w_idx = 0
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):
                ret.append(start)
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:
                start += 1
            else:
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return tuple(ret)
T = input()
P = input()
ans = kmpSearch(T, P)

if ans:
    print(*ans, sep="\n")
#    print("\n".join(map(str, ans)))	



Measured memory_bytes: 55548
import sys
readline = sys.stdin.readline

H,W,N = map(int,readline().split())
from collections import defaultdict

# 9x9のマスの左上のマスの座標をキーにして、各正方形の黒マス数をdictionaryで管理
# 10 ** 5 * 9程度

dic = defaultdict(int)

for i in range(N):
  a,b = map(int,readline().split())
  a,b = a - 1,b - 1
  for A in range(max(0,a - 2), min(a + 1,H - 2)):
    if A < 0:
      continue
    for B in range(max(0,b - 2), min(b + 1,W - 2)):
      if B < 0:
        continue
      dic[(A,B)] += 1

ans = [0] * 10
for v in dic.values():
  ans[v] += 1

ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for a in ans:
  print(a)

Measured memory_bytes: 145312
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

    public static final int MOD = (int) (Math.pow(10, 9) + 7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        ArrayDeque<Long> q = new ArrayDeque<>();
        for (int i = 1; i < n + 1; i++) {
            long a = Long.parseLong(sc.next());
            if (i % 2 != 0) {
                q.addLast(a);
            } else {
                q.addFirst(a);
            }
        }
        StringBuilder sb = new StringBuilder();
        if (n % 2 == 0) {
            for (long a : q) {
                sb.append(a);
                sb.append(" ");
            }
            sb.setLength(sb.length() - 1);
            sb.append("\n");
        } else {
            for (int i = 0; i < n; i++) {
                sb.append(q.pollLast());
                sb.append(" ");
            }
            sb.setLength(sb.length() - 1);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 71108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////

int n,k;
vector<int> gr[100001];
int ans=1;
int mo=1000000007;
void dfs(int i,int pr)
{
	int h=k-2;
	if(i==1)
		h=k-1;
	k=max(k,0ll);
	for(auto r:gr[i])
	{
		if(r!=pr)
		{
			ans*=h;
			ans%=mo;
			--h;
			h=max(h,0ll);
			dfs(r,i);
		}
	}
}
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	cin>>n>>k;
	for(int i=0;i<n-1;++i)
	{
		int a,b;
		cin>>a>>b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	dfs(1,-1);
	ans*=k;
	ans%=mo;
	cout<<ans;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int x = n/500;
    int ans = x*1000;
    n%=500;
    x = n/5;
    ans += (x*5);
    cout<<ans;
    return 0;
}







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

int a[105];
int main()
{
	int n, x;
	ignore = scanf("%d %d", &n, &x);
	
	long long s = 0;
	for (int i = 0; i < n; i++) {
		ignore = scanf("%d", a + i);
		s += a[i];
	}
	sort(a, a + n);
	
	if (s == x) {
		printf("%d\n", n);
		return 0;
	}
	if (x > s) {
		printf("%d\n", n - 1);
		return 0;
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
			x -= a[i];
			ans++;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int a, b, k;
    cin>>k>>a>>b;
    bool ok= false;
    for(int i = a;i<=b;i++){
        if(i%k == 0) ok = true;
    }
    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3632
S=input()
Slist =list(S)
Sg=Slist[0::2]
Sk=Slist[1::2]
SG = ''.join(Sg)
SK = ''.join(Sk)
a=SG.count("0")
b=SG.count("1")
x=SK.count("0")
y=SK.count("1")
	
print(min(a+y,b+x))

Measured memory_bytes: 4724
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var d = cin.ReadInt;
            var x = new List<List<int>>();

            for (int i = 0; i < n; i++)
            {
                x.Add(cin.ReadIntArray(d).ToList());
            }

            x.Add(x.First());

            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    var sum = 0;
                    for (int k = 0; k < d; k++)
                    {
                        var yz = Math.Abs(x[i][k] - x[j][k]);
                        sum += yz * yz;
                    }
                    var sqrt = Math.Sqrt(sum);

                    if (sqrt == Math.Ceiling(sqrt)) ans++;
                }
            }

            Console.WriteLine(ans);

        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13396
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

ans=[]
count=0

def binary (l,num):#自分で実装しててえらいと思う
    high=len(l)-1
    low=0
    
    if num<=l[0]:
        return 0
    elif num>l[-1]:
        return len(l)
        
    while True:
        #print(high,low)
        mid=int((high+low))//2
        if l[mid]<num:
            if l[mid+1]>=num:
                return mid+1
            else:
                #print("a")
                low=mid
        elif l[mid]>=num:
            if l[mid-1]<num:
                return (mid-1)+1
            else:
                #print("b")
                high=mid
                
for i in range(len(B)):
    if i==0:
        ans.append(binary(A,B[i]))
    else:
        ans.append(binary(A,B[i])+ans[i-1])

for item in C:
    z=binary(B,item)
    if z==0:
        continue
    else:
        count+=ans[binary(B,item)-1]

print(count)



Measured memory_bytes: 23328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, K; cin >> N >> K;
	int x[100005];
	for (int i = 0; i < N; i++)
		cin >> x[i];
	int res = 1000000000;
	for (int i = 0; i + K - 1 < N; i++) {
		int l = x[i], r = x[i + K - 1];
		int dif = abs(r - l);
		// debug
		// cout << l << " " << r << " " << dif << endl;
		res = min(res, dif + abs(l));
		res = min(res, dif + abs(r));
	}
	cout << res << endl;
	// system("pause");
	return 0;
}


Measured memory_bytes: 640
let n = Scanf.scanf "%d " (fun x -> x)
let ar = Array.init n (fun _ -> Scanf.scanf "%s " (fun s -> s))
let buf = Buffer.create 50

let remove_char s c =
  Str.replace_first (Str.regexp_string (Char.escaped c)) "" s

let string_to_char_list s =
  let rec f i ls =
    if i = String.length s then ls else f (i + 1) (s.[i] :: ls)
  in
  f 0 []

let () =
  Array.fast_sort (fun pre nex -> String.length pre - String.length nex) ar ;
  let shortest = ar.(0) in
  String.iter
    (fun c ->
       let rec search_all_strings i =
         if i = n then true
         else if String.contains ar.(i) c then search_all_strings (i + 1)
         else false
       in
       if search_all_strings 1 then Buffer.add_char buf c ;
       let rec replace_string i =
         if i = n then () else
           (ar.(i) <- remove_char ar.(i) c ; replace_string (i + 1))
       in
       replace_string 1)
    shortest ;
  Buffer.contents buf |> string_to_char_list |> List.sort compare 
  |> List.iter print_char ;
  print_newline ()

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    ll n,an;
    cin>>n;
    vector<ll> v(n);
    vector<pair<ll,ll>> ans;

    for(ll i=0;i < n;i++)
    {
        cin>>v.at(i);
    }

    sort(all(v));
    ll min=v.at(0),max=v.back();
    
    for(ll i=1;i<n-1;i++)
    {
        if(v.at(i)<0){
            ans.pb({max,v.at(i)});
            max-=v.at(i); 
        }else{            
            ans.pb({min,v.at(i)});
            min-=v.at(i);
        }
    }
    ans.pb({max,min});

    cout << max-min << endl;
    for(ll i=0;i < (ll)ans.size();i++)
    {
        cout << ans.at(i).fi<<" "<<ans.at(i).se << endl;
    }
}
/*操作を簡単に言い換えると、 */

Measured memory_bytes: 4336
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int c[n],s[n],f[n];
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&c[i],&s[i],&f[i]);
  }

  int x=0;

  for(int i=0;i<n-1;i++){
    x=s[i]+c[i];
    for(int j=i+1;j<n-1;j++){
      if(x<=s[j]) x=s[j]+c[j];
      else{
        if((x-s[j])%f[j]!=0) x+=f[j]-(x-s[j])%f[j];
        x+=c[j];
      }
    }
  printf("%d\n",x);
  }
  printf("0\n");
}

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

int main(){
  int N,M;
  cin>>N>>M;
  unordered_set<int> a;
  for(int i=0;i<M;i++){
    int j;
    cin>>j;
    a.insert(j);
  }
  int j=0,k=1;
  for(int i=0;i<N;i++){
    k+=j;
    j=k-j;
    if(a.count(i+1))
      k=0;
    if(k/1000000007)
      k%=1000000007;
    if(j/1000000007)
      j%=1000000007;
  }
  cout<<k<<endl;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int a=1,b,n,i,j,sum=0;
    string s;
    cin>>n>>s;
    if(n%2!=0)
        cout<<"No";
    else
    {
        for(i=0;i<n/2;i++)
        {
            if(s[i]!=s[(n/2)+i])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
        return 0;
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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 (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,k;
map<ll,ll> m;

ll ans=INF;

void dfs(ll res){
  if(res>=n){
    chmin(ans,res);
    return;
  }
  rep(i,10){
    if(m[i]) continue;
    dfs(res*10+i);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>k;
  rep(i,k){
    int d; cin>>d;
    m[d]=1;
  }
  reps(i,9) if(!m[i]) dfs(i);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll n,k;cin>>n>>k;
  cout<<min(n%k,k-n%k)<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace LCY{
	#define double long double
	const double EPS=1e-10;
	inline int dcmp(double x){if(fabs(x)<EPS)return 0;return (x<0)?-1:1;}
	struct Point{double x,y;Point(double _x=0,double _y=0){x=_x;y=_y;}};
	struct Vector{double x,y;Vector(double _x=0,double _y=0){x=_x;y=_y;}};
	
	Vector operator - (Point a,Point b){return Vector(a.x-b.x,a.y-b.y);}
	Vector operator * (Vector a,double d){return Vector(a.x*d,a.y*d);}
	Point operator + (Point a,Vector b){return Point(a.x+b.x,a.y+b.y);}
	
	inline double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
	inline double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
	inline double norm(Vector a){return dot(a,a);}
	
	struct Line{
		Point p1,p2;
		Line(Point _p1=Point(0,0),Point _p2=Point(0,0)){p1=_p1;p2=_p2;}
	};
	
	Point project(Line l,Point p){
		Vector base=l.p2-l.p1;
		double r=dot(p-l.p1,base)/norm(base);
		return l.p1+base*r;
	}
	Point reflect(Line l,Point p){
		Point q=project(l,p);
		Vector v=p-q;v.x=-v.x;v.y=-v.y;
		return q+v;
	}
	string ccw(Vector v1,Vector v2){
		if(dcmp(cross(v1,v2))>0)return "COUNTER_CLOCKWISE";//return 1;
		else if(dcmp(cross(v1,v2))<0)return "CLOCKWISE";//return 2;
		else{
			if(dcmp(dot(v1,v2))<0)return "ONLINE_BACK";//return 3;
			else{
				if(dcmp(norm(v1)-norm(v2))<0)return "ONLINE_FRONT";//return 4;
				else return "ON_SEGMENT";//return 5;
			}
		}
	}
}
using namespace LCY;
int main(){
	Point p0,p1,p2;int n;cin>>p0.x>>p0.y>>p1.x>>p1.y>>n;while(n--){
		cin>>p2.x>>p2.y;
		cout<<ccw(p1-p0,p2-p0)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3244
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var A, B int
func main() {
	A = scanInt()
	B = scanInt()
	fmt.Println(lcm(A, B))
}

func lcm(a, b int) int {
    return a * b / gcd(a, b);
}

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}
// --------------- BASE DEFINITIONS ---------------

var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
 
func scanIntSlice(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt()
	}
 
	return is
}


Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[300005] = {}, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < 60; i++) {
        ll b = 0;
        for (int j = 0; j < n; j++) if (a[j] & (1ll << i)) b++;
        z = (z + (1ll << i) % mod * b % mod * (n - b)) % mod;
    }
    cout << z;
}


Measured memory_bytes: 5948
def nmx(x):
    r = 0
    for a in As:
        r += d2[max(0, x-a)]
    return -r
def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1
N, M = map(int, input().split())
As = sorted(list(map(int, input().split())))
mn, mx = As[0], As[-1]

j = 0
n = N
d2 = []
for i in range(mx*2):
    while True:
        if j>=N:
            break
        if i <= As[j]:
            break
        j += 1
        n -= 1
    d2.append(n)
# d2[i] : i以上のaがいくつあるか
# nmx(x) : x以上のペアが何通りあるか
r = bsearch(-M, 1, mx*2, nmx)
r += 1
from itertools import accumulate
aas = list(accumulate([0]+As[::-1]))
rr = 0
c = 0
for a in As[::-1]:
    idx = min(mx*2-1, max(0, r-a))
    rr += a*d2[idx] + aas[d2[idx]]
    c += d2[idx]
rr += (r-1)*(M-c)
print(rr)


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

int main() {
    long long int a, b, k;
    cin >> a >> b >> k;
    long long int ansa = a;
    long long int ansb = b;
    if (k <= a) ansa = a - k;
        else if (k <= a + b) {
            ansa = 0;
            ansb = a + b - k;
        }
            else {
                ansa = 0;
                ansb = 0;
            }
    cout << ansa << " " << ansb << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

ans = 0
P_sum = 0

for i in range(N):
  P[i] = (P[i] + 1) / 2

for j in range(K):
  P_sum += P[j]

ans = P_sum
for t in range(K, N):
  P_sum -= P[t - K]
  P_sum += P[t]
  ans = max(ans, P_sum)

print(ans)

Measured memory_bytes: 32224
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    s = input()
    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")

Measured memory_bytes: 67968
#include <math.h>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  long long N, M;
  cin >> N >> M;
  long long ans = N + M;
  ans = max(ans, N - M);
  ans = max(ans, N * M);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    string s; cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        cout << 3;
    } else if ((s[1] == 'R' && s[2] == 'R') || (s[0] =='R' && s[1] == 
        'R'))
        cout << 2;
    else if (s[0] == 'R' || s[1] == 'R' || s[2]=='R')
        cout << 1;
    else
        cout << 0;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

typedef pair<int, int> p;

const int mod = 1e9+7;
const int AC=100010;

long long n,ans,res=1;
long long a[AC],b[AC],t[AC],s[AC];

inline void read(long long &x)
{
	long long f=1;
	char s=getchar();
	x=0;
	while ( s<'0' || s>'9' )
	{
		if ( s=='-' ) f=-1;
		s=getchar();
	}
	while ( s>='0' && s<='9' )
	{
		x=x*10+s-'0';
		s=getchar();
	}
	x*=f;
}

inline long long quick(long long a,long long b)
{
	long long base=a,ans=1;
	while ( b )
	{
		if ( b&1 ) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
} 

long long inv(long long n){
	return quick(n, mod-2);
}

int main(){
	read(n);
	for ( int i=1;i<=n;i++ )
	{
		read(a[i]);
		s[i]=(s[i-1]+inv(i))%mod;
	}
	for ( int i=1;i<=n;i++ )
	{
		b[i]=(s[n-i+1]+s[i]-1)%mod;
	}	
	for ( int i=1;i<=n;i++ )
	{
		t[i]=(b[i]*a[i])%mod;
		ans=(ans+t[i])%mod;
		res=(res*i)%mod;
	}
	ans=(ans*res)%mod;
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy";
  }
  if(s == "Cloudy"){
    cout << "Rainy";
  }
  if(s == "Rainy"){
    cout << "Sunny";
  }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll L[100];

int main()
{
    int N;
    cin >> N;
    L[0] = 2;
    L[1] = 1;
    FOR(i, 100, 2)
    {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val l = readLine().split(" ").map(_.toInt).toSeq

  require(3 <= n && n <= 30)
  require(l.forall(i => 1 <= i && i <= 100))

  val m   = l.max
  val sum = l.sum

  if (sum - m > m) println("Yes")
  else println("No")
}


Measured memory_bytes: 54944
#ABC132 B

n = int(input())
P = list(map(int,input().split()))
K = 0
for i in range(n-2):
    if (P[i] < P[i+1] and P[i+1] < P[i+2]) or (P[i+2] < P[i+1] and P[i+1] < P[i]):
        K += 1
        
print(K)

Measured memory_bytes: 9052
#include <iostream>
#include <string.h> 
#include <stdio.h>
#include <queue>
#include <math.h>
#include <utility>//pair
#include <cmath>//abs()
using namespace std;
#define MAX 1000000000+7
#define rep(i, n) for(int i = 0;i < n;i++)

int main(){
    int n;
    unsigned long long int p=1;
    cin>>n;
    for(int i=2;i<=n;i++){
        p*=i;
        p%=MAX;
    }
    p%=(1000000000+7);
    cout<<p<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    a.at(0) = 0;
    for(auto i=1;i<n;i++)
    cin >> a.at(i);
    vector<int> b(n+1);
    for(auto&& e:a){
        ++b.at(e);
    }
    for(auto i=1;i<n+1;i++)
    cout << b.at(i) << endl;
}


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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),q=in();
    string s;
    cin >> s;
    int l,r,ans=0,ac[n-1];
    for (int i=0;i<n-1;i++){
        if (s[i]=='A' && s[i+1]=='C'){
            ans++;
        }
        ac[i]=ans;
    }
  cout << endl;
    for (int i=0;i<q;i++){
        cin >> l >> r;
        cout << ac[r-2]-ac[l-2] << endl;
    }
}

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[] = new int[n];//??¶???????????¨
		int b[] = new int[m];//????????????
		int cnt[] = new int[n];//????????????
		int max = 0, idx = 0;//?????§?????¨????????????????????????
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
			cnt[i] = 0;//????????????????????????
		}
		for(int i = 0;i < m;i++){
			b[i] = sc.nextInt();
		}
		for(int i = 0;i < m;i++){
			for(int k = 0;k < n;k++){
				if(a[k] <= b[i]){
					cnt[k]++;
					break;
				}
			}
		}
		for(int i = 0;i < n;i++){
			if(max < cnt[i]){
				max = cnt[i];
				idx = i;
			}
		}
		System.out.println(idx + 1);
	}
}

Measured memory_bytes: 32136
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool used[1000005];

signed main()
{
    int s; cin>>s;
    
    used[s]=true;
    for(int i=2;i<=1000000;i++){
        if(s%2==0)
            s/=2;
        else
            s=3*s+1;
        if(used[s]){
            cout<<i<<endl;
            return 0;
        }
        used[s]=true;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int mod;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n;
  string s;
  cin >> n >> mod >> s;
  reverse(all(s));
  if(mod == 2 || mod == 5) {
    ll ans = 0;
    rep(i, n) if((s[i] - '0') % mod == 0) ans += n - i;
    cout << ans << endl;
    return 0;
  }
  vector<mint> sum(n + 1, 0);
  map<ll, ll> mp;
  mp[0]++;
  rep(i, n) {
    sum[i + 1] = sum[i] + mint(10).pow(i) * (s[i] - '0');
    mp[sum[i + 1].x]++;
  }
  ll ans = 0;
  for(auto v : mp) ans += v.second * (v.second - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 2692
object Main {
  def solve(n: Long, m: Long, acc: Long): Long = {
    if (n == 0){
      if (m == 0){
        acc
      }else{
        0
      }
    }else {
      solve(m, n-1, (acc * n) % (1e9 + 7).toLong)
    }
  }

  def main(args: Array[String]): Unit = {
    val Seq(n,m): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
    val x = (solve(n,m,1) + solve(m,n,1)) % (1e9 + 7).toLong
    println(x)
  }
}

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

const int N = 1e3 + 5;
typedef long long LL;

int n, k, a[N], ans;

int main() {

	cin>>n>>k;
	for(int i = 1; i <= n; i++) cin>>a[i];

	sort(a + 1, a + n + 1);
    for(int i = 1; i <= k; i++) 
    	ans += a[i];
    cout<<ans;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int i = 1; i <= N; i++){
        int point = i;
        int cnt = 0;
        while (0 < point && point < K){
            point *= 2;
            cnt++;
        }
        double p = 1.0 / pow(2, cnt);
        ans += p;
    }
    cout << fixed << setprecision(15);
    cout << ans/N << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

// 1-based
struct BIT{
    vector<int> data;
    BIT(int n): data(n + 1){ }
    void add(int idx, int num){
        for(; idx < (int)data.size(); idx += idx & -idx){
            data[idx] += num;
        }
    }
    int sum(int idx){
        int ret = 0;
        for(; idx; idx -= idx & -idx){
            ret += data[idx];
        }
        return ret;
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int, int>> lrs(m), pqs(q);
    cin >> lrs >> pqs;
    sort(lrs.begin(), lrs.end());
    vector<int> anss(q), qis(q);
    iota(qis.begin(), qis.end(), 0);
    sort(qis.begin(), qis.end(), [&](int i, int j){ return pqs[i] > pqs[j]; });
    int idx = m - 1;
    BIT bit(n);
    for(auto& qi : qis){
        while(idx >= 0 && pqs[qi].first <= lrs[idx].first){
            bit.add(lrs[idx].second, 1);
            idx--;
        }
        anss[qi] = bit.sum(pqs[qi].second);
    }
    for(auto& ans : anss){
        cout << ans << '\n';
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int k, n;
    cin>>k>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];

    as.push_back(k + as[0]);
    int m = 0;
    rep(i, n) {
        m = max(m, as[i + 1] - as[i]);
    }
    cout<<k - m<<endl;
}

Measured memory_bytes: 2428