akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        //System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int t = s.nextInt();
        double d=s.nextInt();
//        int n;
//        String str;
//        while(t-- > 0){
//
//        }
        d=Math.pow(d,2);
        int count=0;
        int x,y;
        while(t-- > 0){
            x=s.nextInt();y=s.nextInt();
            if(((Math.pow(x,2))+(Math.pow(y,2)))<=d) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 45660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000007;

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = A; i <= B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3620
Scanf.scanf "%s %s %s" (fun sa sb sc ->
    let rec loop cur ai bi ci =
        match cur with
        | 'a' -> if ai = String.length sa then "A" else loop sa.[ai] (ai + 1) bi ci
        | 'b' -> if bi = String.length sb then "B" else loop sb.[bi] ai (bi + 1) ci
        | 'c' -> if ci = String.length sc then "C" else loop sc.[ci] ai bi (ci + 1)
        | _ -> failwith "??"
    in
    loop 'a' 0 0 0 |> print_endline
)

Measured memory_bytes: 3720
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op=="?":
        break
    else:
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b)
        elif op=="*":
            print(a*b)
        elif op=="/":
            print(int(a/b))


Measured memory_bytes: 5596
/*
  user: sky48
  language: c++
  for dream for young
*/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mod 234
typedef long long ll;
using namespace std;
int gets()
{
	int v=0; char ch;bool f=0;
	while(!isdigit(ch=getchar())) if(ch=='-') f=1; v=ch-48;
	while( isdigit(ch=getchar())) v=(v<<1)+(v<<3)+ch-48;
	return f?-v:v;
}
int main ()
{
	int a,b;
	a=gets(), b=gets();
	if(a==0 || b==0){ puts("Zero"); return 0;}
	if(a<=0 && b>=0){ puts("Zero"); return 0;}
	if(a>0){ puts("Positive"); return 0;}
	a=(b-a)%2;
	if(!a) puts("Negative");
	else puts("Positive");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

#define all(v) (v).begin() + 1, (v).end()
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n + 1)
using namespace std;

struct query_info
{
    int left, right, query_no;

    query_info(int L, int R, int N)
    {
        left = L, right = R, query_no = N;
    }

    int operator<(const query_info &A)
    {
        return (right < A.right);
    }
};

struct train_info
{
    int left, right;

    train_info(int L, int R)
    {
        left = L, right = R;
    }

    int operator<(const train_info &A)
    {
        return (right < A.right);
    }
};

const int MAX_N = 515;
int sum_tree[4*MAX_N];

void update(int n, int left, int right, int position, int value)
{
    if(position < left || right < position)
        return;

    if(left == right)
    {
        sum_tree[n] += value;
        return;
    }

    int mid = (left + right) >> 1;

    update(LEFT(n), left, mid, position, value);
    update(RIGHT(n), mid + 1, right, position, value);

    sum_tree[n] = sum_tree[LEFT(n)] + sum_tree[RIGHT(n)];
}

int get_sum(int n, int left, int right, int query_left, int query_right)
{
    if(right < query_left || query_right < left)
        return 0;

    if(query_left <= left && right <= query_right)
    {
        return sum_tree[n];
    }

    int mid = (left + right) >> 1;
    int left_sum = get_sum(LEFT(n), left, mid, query_left, query_right);
    int right_sum = get_sum(RIGHT(n), mid + 1, right, query_left, query_right);

    return (left_sum + right_sum);
}

int main()
{
    int no_of_cities, no_of_trains, no_of_queries;
    scanf("%d %d %d", &no_of_cities, &no_of_trains, &no_of_queries);

    vector <train_info> train(no_of_trains + 1, train_info(0, 0));
    for(int i = 1; i <= no_of_trains; i++)
        scanf("%d %d", &train[i].left, &train[i].right);

    sort(all(train));

    //for(int i = 1; i <= no_of_trains; i++) printf("Train %d (%d, %d)\n", i, train[i].left, train[i].right);

    vector <query_info> query(no_of_queries + 1, query_info(0, 0, 0));
    for(int i = 1; i <= no_of_queries; i++)
    {
        scanf("%d %d", &query[i].left, &query[i].right);

        query[i].query_no = i;
    }

    sort(all(query));

    //for(int i = 1; i <= no_of_queries; i++)
        //printf("Query %d (%d, %d)\n", query[i].query_no, query[i].left, query[i].right);

    memset(sum_tree, 0, sizeof(sum_tree));
    vector <int> answer(no_of_queries + 1);

    int last_train = 1;
    for(int i = 1; i <= no_of_queries; i++)
    {   //printf("query %d %d\n", query[i].left, query[i].right);
        while(last_train <= no_of_trains && train[last_train].right <= query[i].right)
        {  // printf("train %d %d \n", train[last_train].left, train[last_train].right);
            update(1, 1, no_of_cities, train[last_train].left, 1);

            last_train++;
        }

        answer[query[i].query_no] = get_sum(1, 1, no_of_cities, query[i].left, query[i].right);
    }

    for(int i = 1; i <= no_of_queries; i++)
        printf("%d\n", answer[i]);

    return 0;
}


Measured memory_bytes: 4096
using System;
class program
{
  		static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var datas = read.Split(new char[] { ' ' });
            int a = Convert.ToInt32(datas[0]);
            int b = Convert.ToInt32(datas[1]);

            int c = a * b;
            if (c % 2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
}

Measured memory_bytes: 11348
n,m = map(int,input().split())
cnt = [0]*(m+1)
ans = 0
a = [list(map(int,input().split())) for _ in range(n)]
for l in a:
  for i in range(1,len(l)):
    cnt[l[i]] += 1
for i in range(1,m+1):
  if cnt[i] == n:
    ans += 1
print(ans)

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  string ans = "delicious";
  int d = B - A;
  if (d > 0) {
    if (d <= X)
      ans = "safe";
    else
      ans = "dangerous";
  }
  cout << ans << endl;
}

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

using namespace std;
vector<set<int> >adj;
int vis[1005];
int parent[1005];

bool flag=false;
int mn=1e17;
vector<int>temp;
vector<int>ans;

void check(int a,int b)
{
    temp.clear();
    while (a!=b)
    {
        temp.push_back(a);
        a=parent[a];
    }
    temp.push_back(a);
    if(temp.size()<mn)
    {
        mn=temp.size();
        ans.clear();
        for(auto i:temp)
            ans.push_back(i);
    }
}

void bfs(int ver,int dest)
{
    flag=false;
    queue<pair<int,int> >q;
    q.push({ver,ver});
    while (!q.empty())
    {
        pair<int,int> pp=q.front();
        q.pop();
        if(vis[pp.first]==1)
            continue;
        vis[pp.first]=1;
        parent[pp.first]=pp.second;
        if(pp.first==dest)
        {
            flag=true;
            return;
        }
        for(auto i:adj[pp.first])
        {
           if(vis[i]==0)
           {
               q.push({i,pp.first});
           }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    int x,y;
    vector<pair<int,int> >p;
    for (int i = 0; i < m; ++i) {
        cin>>x>>y;
        adj[x].insert(y);
        p.push_back({x,y});
    }

    for(auto i:p)
    {
        pair<int,int>z=i;
        adj[i.first].erase(i.second);

        fill_n(vis,1005,0);
        fill_n(parent,1005,0);

        bfs(i.second,i.first);
        if(flag)
        {
            check(i.first,i.second);
        }
        adj[z.first].insert(z.second);
    }

    if(mn!=1e17)
    {
        cout<<ans.size()<<"\n";
        for(auto i:ans)
            cout<<i<<"\n";
    }
    else
    {
        cout<<-1;
    }
}

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

const int MAX = 200010;
long long dp[MAX], accum[MAX];
const long long INF = 1LL<<62;

int main(){
    long long i, j, k;
    long long N, X;
    cin >> N >> X;
    long long x[MAX];
    for(i=1; i<=N; i++) scanf("%lld", &x[i]);
    for(i=1; i<=N; i++) accum[i] = x[i] + accum[i-1];

    long long ans = INF;
    for(k=1; k<=N; k++){
        long long result = k*X, rem = N%k;
        for(j=0; j<(N-1)/k+1; j++){
            int M = N - j*k;
            int m = max(0LL, M-k);
            long long c = j==0 ? 5 : 2*j+3;
            result += c * (accum[M] - accum[m]);
            if(result < 0) break;
        }
        if(result > 0) ans = min(ans, result);
    }
    cout << ans+N*X << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
char s[N];
int dp[N][4],n;
int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	memset(dp,0xa0,sizeof(dp));
	dp[1][1]=1;
	rep(i,2,n+1) for (int p=1;p<=2;p++) {
		if (i-p==0) dp[i][p]=1;
		else {
			for (int q=1;q<=2;q++) {
				if (p!=q) dp[i][p]=max(dp[i][p],dp[i-p][q]+1);
				else {
					bool sm=1;
					rep(l,0,q) sm&=s[i-l]==s[i-p-l];
					if (!sm) dp[i][p]=max(dp[i][p],dp[i-p][q]+1);
				}
			}
		}
	}
	printf("%d\n",max(dp[n][1],dp[n][2]));
}


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

double inputData();
double calcArea();
double outputData();

int main(){
	int a; CI a;
	ll mmin = 10000000000;
	ll mmax = 1;
	vector<ll> v(a); CI v;

	REP(i, a){
		mmax=max(mmax, v[i]);
		mmin=min(mmin, v[i]);
	}
	
	CO mmax - mmin EN;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> v,w;
int n,m,ans,cnt,ok,ng=1e18;

int f(int a){
  return v.end()-lower_bound(v.begin(),v.end(),a);
}

bool can(int a){
  int tmp=0;
  for(int p:v)tmp+=f(a-p);
  return tmp>=m;
}

signed main(){
  cin>>n>>m;
  v.resize(n);w.resize(n+1);
  for(int &p:v)cin>>p;
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)w[i+1]=w[i]+v[i];
  while(ng-ok>1){
    int mid=(ok+ng)>>1;
    if(can(mid))ok=mid;
    else ng=mid;
  }
  for(int p:v){
    int q=f(ok-p);
    ans+=p*q+w[n]-w[n-q];
    cnt+=q;
  }
  ans-=(cnt-m)*ok;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+c+b>21)
    {
        cout<<"bust";
    }
    else
    {
        cout<<"win";
    }
    return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	int ans1 = -1, ans2 = -1, ans3 = -1;
	int N, Y;
	cin >> N >> Y;
	for (int i = 0;i <= N;i++) {
		for (int j = 0;j <= N - i;j++) {
			int k = N - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k;
				return 0;
			}
		}
	}
	
	cout << ans1 << " " << ans2 << " " << ans3;

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

x,y = li()

print("Brown") if abs(x-y) <= 1 else print("Alice")

Measured memory_bytes: 3064
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

string s;

int main() {
	cin >> s;
	int ans = 0;
	char a = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (a == s[i]) {

		}
		else
		{
			a = s[i];
			ans++;
		}
	}
	cout << ans << endl;
//	cin >> s;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};



int main(){
    FIO;
    ll k; cin >> k;
    ll ans = 0;
    ll number = 0;
    for(ll i = 0;i<10000000;i++){
        number *= 10LL;
        number += 7;
        number %= k;
        if(number == 0){
            ans = i+1;
            break;
        }
    }
    if(ans == 0) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
fun main(args: Array<String>) {
    val (n,m)= readLine()!!.split(" ").map { it.toInt() }
    val ab = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }

    val ans = ab.flatten().groupBy { it }.mapValues { it.value.size }
    (1..n).forEach { println(ans[it]?:0) }

}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " ";cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

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...);
}

const int N = 2e5 + 3;

void solve()
{
	int a[3];
	loop(i, 0, 3)cin >> a[i];
	swap(a[0], a[1]);
	swap(a[0], a[2]);
	loop(i, 0, 3) cout << a[i] << " ";


	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<sstream>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<algorithm>
#define fi first
#define se second
#define MP make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define lc (p<<1) 
#define rc (p<<1|1)	
#define MID (tree[p].l+tree[p].r)>>1
#define Sca(x) scanf("%d",&x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x)
#define Scl2(x,y) scanf("%lld%lld",&x,&y)
#define Scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define Pri(x) printf("%d\n",x)
#define Prl(x) printf("%lld\n",x)
#define For(i,x,y) for(int i=x;i<=y;i++)
#define _For(i,x,y) for(int i=x;i>=y;i--)
#define FAST_IO std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define STOP system("pause")
#define ll long long
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const double Pi = acos(-1.0);
using namespace std;
template <class T>void tomax(T&a,T b){ a=max(a,b); }  
template <class T>void tomin(T&a,T b){ a=min(a,b); }
const int N=2e5+5;
const int M=2e5+5;
int idx=0,dis[N];
int head[N];
bool vis[N];
struct E{
	int v;
	int nxt;
}edge[M<<1];
void add_edge(int u,int v){ edge[idx]=E{v,head[u]}; head[u]=idx++; }
struct Node{
	int val;
	int step;
	bool operator <(const Node b)const{
		return step > b.step;
	}
};
bool bfs(){
	priority_queue<Node> q;
	memset(dis,INF,sizeof(dis));
	q.push(Node{1,0}); dis[1]=0;
	while(!q.empty()){
		Node u=q.top(); q.pop();
		if(vis[u.val]) continue;
		vis[u.val]=1;
		for(int i=head[u.val];~i;i=edge[i].nxt){
			int v=edge[i].v;
			if(dis[v] > dis[u.val]+1){
				dis[v]=dis[u.val]+1;
				q.push(Node{v,dis[v]});
			}
		}
	}
}
void init(int n){
	For(i,1,n){
		head[i]=-1;
		vis[i]=0;
	}
}
int main(){
	int n,m; Sca2(n,m);
	init(n);
	while(m--){
		int u,v; Sca2(u,v);
		add_edge(u,v);
		add_edge(v,u);
	}
	bfs();
	if(dis[n]==2) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}



















Measured memory_bytes: 6264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int z=12800;
bitset<256001> dp[81][81];
int n,m;
int a[81][81],b[81][81];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)scanf("%d",&b[i][j]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)a[i][j]=abs(a[i][j]-b[i][j]);
    }
    dp[0][1][z]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]|=dp[i-1][j];
            dp[i][j]|=dp[i][j-1];
            dp[i][j]=(dp[i][j]<<a[i][j])|(dp[i][j]>>a[i][j]);
        }
    }
    int ans=1000000000;
    for(int i=0;i<=25600;i++)if(dp[n][m][i])ans=min(ans,abs(i-z));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 203520
#include <stdio.h>

int main(void)
{
	int city,road;
	int a,b;
	int d,c;
	int x[500] = {0};
	
	scanf("%d %d",&city,&road);
	
	for(d = 0;d < road;++d){
		scanf("%d %d",&a,&b);
		x[a-1]++;
		x[b-1]++;
	}
	for(d = 0;d < city;++d){
		printf("%d\n",x[d]);
	}
	
	return(0);
}


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

int main() {

    ll A, B, N;
    cin >> N >> A >> B;

    // if(A + B > N){
        // cout << A << endl;
    // } else {
        cout << A * (N / (A+B)) + min(A, N % (A+B)) << endl;
    // }


    return 0;
}

Measured memory_bytes: 3572
N = int(input())
A_LIST = input().split(" ")
B_LIST = input().split(" ")
C_LIST = input().split(" ")

n = 0
start = 1 #最初のみ例外処理
S = 0
for i in A_LIST:
    i = int(i)
    if start == 1:
        start = 0
    else:
        if i == n + 1:
            S += int(C_LIST[i - 2])
        else:
            n = i
    
    S += int(B_LIST[i - 1])
    n = i
    
print(S)

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

int main() {
  int x;
  cin >> x;
  
  if(x == 2)
    cout << 2 << endl;
  
  else{for(int i=0; i<x; i++) {
    bool flag = true;
    for(int j=2; j<min(x,400); j++) {
      if((x+i) % j == 0) {
        flag = false;
        break;
      }
    }
    if(flag == false) {
      continue;
    }
    flag = true;
    cout << x + i << endl;
    break;
  }
      }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {

  string alp = "IVXLCDM";
  int num[7] = {1, 5, 10, 50, 100, 500, 1000};

  string s;
  while(cin >> s){
    reverse(s.begin(), s.end());
    int n = 0;
    int b = 0;
    for(int i=0; i<s.size(); i++){
      for(int j=0; j<7; j++){
        if( s[i] == alp[j] ){
          // cerr << n << " " << b << endl;
          if( num[j] < b ) n -= num[j];
          else n += num[j];

          b = num[j];
        }
      }

    }
    cout << n << endl;

  }

  return 0;
}

// EOF

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>

long long x,y;
int main(){
  std::cin>>x>>y;
  auto abx=std::abs(x);
  auto aby=std::abs(y);
  
  if(abx>aby){
    abx*=-1;
    aby*=-1;
  }
  long long ans=0;
  if(abx!=x)
    ++ans;
  if(aby!=y)
    ++ans;
  ans+=aby-abx;
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char sieve[1000001];

int main()
{
  int i, j, n, t;
  sieve[0] = sieve[1] = 1;
  for (i = 2; i * i <= 1000000; i++) {
    for (j = i * 2; j <= 1000000; j += i) {
      sieve[j] = 1;
    }
  }
  while (scanf("%d", &n) != EOF) {
    t = 0;
    for (i = 1; i <= n; i++) {
      if (sieve[i] == 0) t++;
    }
    printf("%d\n", t);
  }
  return (0);
}

Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int a,b;
    cin>>a>>b;
    rep(i,1,10001){
        int aa=i*0.08,bb=i*0.1;
        if(a==aa&&b==bb){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];


#define ld long double
void solve()
{
      ld a, b, c;
      cin >> a >> b >> c;

      int a1 = 4*a*b;
      int a2 = (c-(a+b));
      a2 *= a2;

      if( a1 < a2 and (c - (a+b) > 0 ) ) cout << "Yes";
      else cout << "No";

      
}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
 
      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 256
nums = list(map(int, input().split()))
N =  nums[0] 
M = nums[1] 
K = N - M + 1
a = 0
b = 0
m = [[]]
n  = [[]]
while(a<N):
	if a == 0:
		n[0] = list(input())
	else:
		n.append(list(input()))
	a+=1
while(b<M):
	if b == 0:
		m[0] = list(input())
	else:
		m.append(list(input()))
	b+=1
judge = 0
for i in range(K):
	for j in range(K):
		num = 0
		for h in range(M):
			for k in range(M):
				if(m[h][k] == n[h+i][k+j]):
					num+=1
		if num == M*M:
			judge = 1

if judge == 1:
	print('Yes')
if judge == 0:
	print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e7;
const ll LINF = 1e18;

struct UF{
    vector<int> d;
    UF(int size):d(size,-1){}
    bool u(int x,int y){
        x = r(x); y = r(y);
        if(x != y){
            if(d[y] < d[x]) swap(x,y);
            d[x] += d[y]; d[y] = x;
        }
        return x!=y;
    }
    bool f(int x,int y){
        return r(x) == r(y);
    }
    int r(int x){
        return d[x] < 0 ? x:d[x] = r(d[x]);
    }
    int s(int x){
        return -d[r(x)];
    }
};
void solve(){
    int n,q; cin >> n >> q;
    UF uf(n);
    while(q--){
        int com,x,y; cin >> com >> x >> y;
        if(com == 0){
            uf.u(x,y);
        }else{
            cout << uf.f(x,y) << endl;
        }
    }
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3256
#include<stdio.h>

int main(){
		int n,a[100],i,j;
		scanf("%d",&n);
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=0;i<n;i++){
				for(j=0;j<n;j++){
						if(a[i]<a[j]){
								int tmp=a[i];
								a[i]=a[j];
								a[j]=tmp;
						}
				}
		}
		printf("%d",a[n-1]-a[0]);
		return 0;
}





Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
pair<int,int>p[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int s,t;scanf("%d%d",&s,&t);
		p[i]=make_pair(t,s);
	}
	std::sort(p,p+a);
	long long cur=0;
	for(int i=0;i<a;i++){
		cur+=p[i].second;
		if(cur>p[i].first){
			printf("No\n");return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int n,l;
    cin >> n >> l;
    if(l+n-1<0) cout << n*(2*l+n-1)/2-(l+n-1) << endl;
    else if(l>0) cout << n*(2*l+n-1)/2-l << endl;
    else cout << n*(2*l+n-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <memory.h>
#include <deque>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int M=100005;
const int N=1000001;
const int K=1000000000;
const ll MAX=1000000000000000000ll;
int n,w[100],c[100],k;
ll dp[2][M];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	scanf("%d%d",w+i,c+i);
    for(int i=n-1;i>=0;i--)
    {
    	for(int j=0;j<=k;j++)
    	{
    		ll &ret=dp[i%2][j];
    		if(w[i]<=j)
    			ret=max(dp[(i+1)%2][j-w[i]]+c[i],dp[(i+1)%2][j]);
    		else
    			ret=dp[(i+1)%2][j];
    	}
    }
    cout<<dp[0][k];
}

Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

int main(void)
{
	int c1, n, temp;
	set <int> color;
	cin >> n;

	c1 = 0;
	
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if (temp >= 3200)
		{
			c1++;
		}
		else
		{
			for (int i = 0; i < 3200; i += 400)
			{
				if (temp >= i && temp < i + 400)
				{
					color.insert(i);
					break;
				}
			}
		}
	}


	if (color.size() == 0)
	{
		cout << "1 " << c1 << endl;
	}
	else
	{
		cout << color.size() << " " << color.size() + c1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		
        int A = sc.nextInt();
        int B = sc.nextInt();
      	int C = sc.nextInt();
       
       if(A==B&&A==C){
System.out.print("Yes");
}else{
System.out.print("No");
}

	}
}

Measured memory_bytes: 22868
import math
inf = 1000000001

def merge(A,left,mid,right):
	L = A[left:mid] 
	n1 = len(L)
	L += [inf]
	R = A[mid:right] + [inf]
	i = 0
	j = 0
	cnt = 0
	
	for k in range(left,right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
			cnt += n1 - i
	return cnt

def mergeSort(A,left,right):
	if left + 1 < right:
		mid = (left + right) // 2
		v1 = mergeSort(A,left,mid)
		v2 = mergeSort(A,mid,right)
		v3 = merge(A,left,mid,right)
		return v1 + v2 + v3
	else:
		return 0
	

n = int(input())
A = list(map(int, input().split()))

#cnt = 0
n_ivs = mergeSort(A,0,n)
#print(*A)
#print(cnt)
print(n_ivs)


Measured memory_bytes: 28956
#include<bits/stdc++.h>
using namespace std;
int n;
int t, a;
int main()
{
	scanf("%d%d%d", &n, &t, &a);
	double mn = 1000000000;
	int flag = 0;
	for(int i = 1; i <= n; ++ i)
	{
		int h;
		scanf("%d", &h);
		double x = t - 0.006 * h;
		if(abs(x - a) < mn){
			mn = abs(x - a);
			flag = i;
		}
	}
	printf("%d", flag);
	return 0;
}

Measured memory_bytes: 256
ss = gets.chomp.chars
a_i = 200000
z_i = -1
ss.each_with_index do |s,i|
  if s == "A"
    a_i = i if i < a_i
  elsif s == "Z"
    z_i = i if i > z_i
  end
end
puts z_i - a_i +1

Measured memory_bytes: 16764
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let s= read::<String>()
        .chars()
        .enumerate()
        .filter(|&(i, _)| i % 2 == 0)
        .map(|(_, c)| c)
        .collect::<String>();
    println!("{}", s);
}


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

using namespace std;

constexpr int M = 2e5 + 10;
constexpr int N = 8000 + 10;
constexpr int O = 4010;
constexpr int MOD = 1e9 + 7;
//
long long n, a[M], b[M], dp[O][O], fact[N], ans;

long long mypow (long long a, long long b) {
    return b ? (mypow (a * a % MOD, b >> 1) * (b & 1 ? a : 1)) % MOD : 1;
}

long long ch (long long a, long long b) {
    return (fact[a] * mypow (fact[b] * fact[a - b] % MOD, MOD - 2)) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        dp[a[i] + 2000][b[i] + 2000]++;
    }
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
    for (int i = 4000; ~i; i--)
        for (int j = 4000; ~j; j--)
            dp[i][j] = (dp[i][j] + dp[i + 1][j] + dp[i][j + 1]) % MOD;
    for (int i = 0; i < n; i++)
        ans = (ans + dp[2000 - a[i]][2000 - b[i]]) % MOD;
    for (int i = 0; i < n; i++)
        ans = (ans - ch(a[i] * 2 + b[i] * 2, a[i] * 2)) % MOD;
    ans = ((ans %  MOD) + MOD) % MOD;
    ans *= mypow (2, MOD - 2);
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}

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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 50;
int n, a[N], f[N][36], L, Q; 
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	n = read();
	rep(i, 1, n) a[i] = read();
	L = read(); Q = read();
	rep(i, 1, n) f[i][0] = (int) (upper_bound(a+1, a+n+1, a[i] + L) - a - 1);
	rep(j, 1, 30) rep(i, 1, n) f[i][j] = f[f[i][j-1]][j-1];
	while(Q --> 0) {
		int ans = 0, l = read(), r = read();
		if(l > r) swap(l, r);
		int now = l;
		per(i, 30, 0) if(f[now][i] < r) ans += (1<<i), now = f[now][i];
		printf("%d\n", ans+1); 
	}
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    string s, ans;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            if (ans.size()) ans.pop_back();
        } else ans.push_back(s[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long 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 ll INF = 1LL<<60;

int main(){

    int  N,K;
    cin >> N>>K;
    ll tower[100200];
    rep(i,N)cin >> tower[i];
    ll dp[100200];
    rep(i,100200)dp[i]=INF;
    dp[0]=0;

    for(int i =1;i<N;i++){
        for(int j = 1;j<=K;j++){
            if(i>=j)chmin(dp[i],dp[i-j]+abs(tower[i]-tower[i-j]));
        }
    }
    cout<<dp[N-1]<<endl;

    
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
    int t;
    cin >> t;
    set<string> items;
    while (t--) {
        string s;
        cin >> s;
        items.insert(s);
    }
    cout << items.size() << endl;
    return 0;
}


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

using namespace std;

#define Int int64_t

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

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

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

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

int main() {
	int n; cin >> n ;
	vector<int> p(n);

	for (int i = 0; i < n; i++) {
			cin >> p[i];
	}
	int cnt = 0,a;
	double temp=0;
	vector<pair<int, int>> x[1000];
	

	for (int i = 1; i < n - 1; i++) {
		for (int j = -1; j < 2; j++) {
			x[i-1].push_back(make_pair(p[i + j], j + 2));
			sort(x[i - 1].begin(), x[i - 1].end());
			//if (x[i - 1][1].second == 2) cnt++;
		}
	}
	for (int i = 0; i < n - 2; i++) {
		if (x[i][1].second == 2) cnt++;
	}
	//cout << x[0][0].first << " " << x[0][0].second << endl;
	//cout << x[0][1].first << " " << x[0][1].second << endl;
	//cout << x[0][2].first << " " << x[0][2].second << endl;
	cout << cnt;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun h w k ->
    let rec loop i acc =
        let check i =
            let rec loop i prev =
                if i = 0 then true else
                    if prev * (i land 1) = 1 then false else
                        loop (i lsr 1) (i land 1)
            in
            loop i 0
        in
        if i < 0 then acc else
            loop (i - 1) (if check i then i :: acc else acc)
    in
    let amidas = loop ((1 lsl (w - 1)) - 1) [] in
    let total = List.length amidas in
    let count = Array.make (w - 1) 0 in
    List.iter (fun v ->
        for t = 0 to w - 2 do
            if v land (1 lsl t) <> 0 then count.(t) <- count.(t) + 1
        done
    ) amidas;
    let m = 1_000_000_000 + 7 in
    let ( +@) a b = (a + b) mod m in
    let ( *@) a b = (a * b) mod m in
    let rec loop i arr =
        if i = h then arr.(k - 1) else
            let newarr = Array.init w (fun j ->
                let acc = if j > 0     then arr.(j - 1) *@ count.(j - 1) else 0 in
                let acc = if j < w - 1 then arr.(j + 1) *@ count.(j) + acc else acc in
                let v = if j > 0     then count.(j - 1) else 0 in
                let v = if j < w - 1 then count.(j) + v else v in
                acc +@ (total - v) *@ arr.(j)
            )
            in
            loop (i + 1) newarr
    in
    let init = Array.init w (fun i -> if i = 0 then 1 else 0) in
    loop 0 init |> Printf.printf "%d\n"
)

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

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

    //n = 10;
   //s = "aabbcaabbc";

    if(n%2 == 1){
      printf("No");
      return 0;
    }

    const char* ss = s.c_str();

    for(int i = 0; i < n/2; i++){
      if(ss[i] != ss[i + n/2]){
        printf("No");
        return 0;
      }
    }

    printf("Yes");
    return 0;
}


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


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

    int n, ans = 0;
    cin >> n;
    vector<int> edge(n);
    for (int i = 0; i < n; ++i) {
        cin >> edge[i];
    }
    sort(edge.begin(), edge.end());

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                int l1 = edge[i];
                int l2 = edge[j];
                int l3 = edge[k];
                if (l1 == l2 || l2 == l3 || l1 == l3) continue;
                if (l3 < l1 + l2 && l1 > l3 - l2) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664