akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;


int main() {
  int N,M;
  cin >> N >> M;
  vector<Pii> ba(M);
  repeat(i,M){
    cin >> ba[i].second >> ba[i].first;
  }
  sort(ba.begin(),ba.end());
  int ans=0;
  int x = -1;
  repeat(i,M){
    if(ba[i].second <= x) continue;
    ans++;
    x = ba[i].first-1;
  }
  cout << ans << endl;
  return 0;
}


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

int r, g, b, n;

int main()
{
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= n; ++j)
        {
            if (r * i + g * j > n)
                continue;
            if ((n - r * i - g * j) % b == 0)
                ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		double l = sc.nextDouble();
		double r = l/3;
		double ans = Math.pow(r, 3);

		System.out.println(String.format("%.12f", ans));
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int W = in.nextInt();

        long[] cur = new long[W + 1];
        for (int i = 0; i < N; i++) {
            int w = in.nextInt();
            long v = in.nextLong();
            for (int j = W; j >= w; j--) {
                cur[j] = Math.max(cur[j], cur[j - w] + v);
            }
        }
        in.close();
        System.out.println(cur[W]);
    }
}

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

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

    ll now = 0;
    for (int ans = 1; ans <= 1000000; ++ans) {
        now = now * 10 + 7;
        now %= k;

        if (now == 0) {
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

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

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


Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
R, C, K = map(int, input().split())

item = [[0 for _ in range(C + 1)] for _ in range(R + 1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    item[r][c] = v

# dp[n][i][j] = その行で取得したアイテムがn個で、(i,j)でのmax_value
dp = [[[0 for _ in range(C + 1)]for _ in range(R + 1)]for _ in range(4)]

for i in range(R + 1):
    for j in range(C + 1):
        # 下に移動
        if i <= R - 1:
            # アイテムを取らない
            dp[0][i + 1][j] = max(dp[0][i + 1][j],
                                  dp[0][i][j],
                                  dp[1][i][j],
                                  dp[2][i][j],
                                  dp[3][i][j])
            # アイテムを取る
            dp[1][i + 1][j] = max(dp[1][i + 1][j],
                                  dp[0][i][j] + item[i + 1][j],
                                  dp[1][i][j] + item[i + 1][j],
                                  dp[2][i][j] + item[i + 1][j],
                                  dp[3][i][j] + item[i + 1][j])

        # 右に移動
        if j <= C - 1:
            # アイテムを取らない
            dp[0][i][j + 1] = max(dp[0][i][j + 1], dp[0][i][j])
            dp[1][i][j + 1] = max(dp[1][i][j + 1], dp[1][i][j])
            dp[2][i][j + 1] = max(dp[2][i][j + 1], dp[2][i][j])
            dp[3][i][j + 1] = max(dp[3][i][j + 1], dp[3][i][j])
            # アイテムを取る
            dp[1][i][j + 1] = max(dp[1][i][j + 1],
                                  dp[0][i][j] + item[i][j + 1])
            dp[2][i][j + 1] = max(dp[2][i][j + 1],
                                  dp[1][i][j] + item[i][j + 1])
            dp[3][i][j + 1] = max(dp[3][i][j + 1],
                                  dp[2][i][j] + item[i][j + 1])

ans = max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C])
print(ans)


Measured memory_bytes: 474156
N = int(input())
P = []

for _ in range(N):
    t, x, y = input().split()
    p = [int(t), int(x), int(y)]
    P.append(p)

t_before = 0
x_before = 0
y_before = 0
f_enable = True
for p in P:
    t, x, y = p

    t_distance = abs(t_before - t)
    p_distance = abs(x_before - x) + abs(y_before - y)

    distance = t_distance - p_distance

    if distance < 0:
        f_enable = False
        break
    elif distance % 2 != 0:
        f_enable = False
        break

    t_before = t
    x_before = x
    y_before = y

if f_enable:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 25600
#include<iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; long long k;
    cin >> s >> k;
    int first_not_one = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] != '1') {
            first_not_one = i;
            break;
        }
    }
    //cout << first_not_one << endl;
    if (first_not_one >= k) {
        cout << 1 << endl;
    } else {
        cout << s[first_not_one] << endl;
    }
}
/*
 5,000,000,000,000日後
 2は2^5,000,000,000,000文字になる
 
 */


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    
    cin >> n >> k;
    int a = 1;
    for (int i = 0; i < n; i++) {
        if (a * 2 > a + k){
            a = a + k;
        }
        else {
            a = a * 2;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main(){
  double x1,y1,x2,y2,x3,y3,x,y;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x>>y){
    bool b=true;
    if(((y2-y1)*(x3-x1)-(x2-x1)*(y3-y1))*((y2-y1)*(x-x1)-(x2-x1)*(y-y1))<0) b=false;    
    if(((y3-y2)*(x1-x2)-(x3-x2)*(y1-y2))*((y3-y2)*(x-x2)-(x3-x2)*(y-y2))<0) b=false;
    if(((y1-y3)*(x2-x3)-(x1-x3)*(y2-y3))*((y1-y3)*(x-x3)-(x1-x3)*(y-y3))<0) b=false;
    if(b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
int n,m;
int x[100010] = {0};
int y[100010] = {0};
int xc[100010] = {0};
int yc[100010] = {0};
signed main(){
    cin >> n >> m;
    rep(i,n)cin >> x[i];
    rep(i,m)cin >> y[i];
    rep(i,n-1) xc[i] = (i+1)*(n-i-1);
    rep(i,m-1) yc[i] = (i+1)*(m-i-1);
    int xsum = 0;
    rep(i,n-1){
        xsum += (x[i+1]-x[i])*xc[i]%MOD;
        xsum %= MOD;
    }
    int ysum = 0;
    rep(i,m-1){
        ysum += (y[i+1]-y[i])*yc[i]%MOD;
        ysum %= MOD;
    }
    cout << xsum*ysum%MOD << endl;
    

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  // input
  vector <int> a(3);
  for (int i=0; i<3; i++){
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  int ans = a[2]-a[0];
  cout << ans << endl;

  return 0;
}


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

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

    int N;
    cin >> N;

    int n = N;
    int x = 0;

    for(; n != 0; n /= 10) {
        x += n % 10;
    }

    if(N % x == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#include<random>
#pragma warning(disable:4996)
using namespace std;

string say(string st) {
	cout<<st<<endl;
	fflush(stdout);
	string re;cin>>re;
	return re;
}

string mk_rnd() {
	string st;
	random_device rnd;
	std::mt19937 mt(rnd());
	for (int i = 0; i <8; ++i) {
		st.push_back(mt()%26+'a');
	}
	return st;
}

int main() {
	set<string>use_st;

	string next = "?"+mk_rnd()+"a";
	while (true) {
		use_st.emplace(next);
		string said = say(next);
		if (use_st.find(said) != use_st.end()||said[0]!='a') {
			cout<<"!OUT"<<endl;
			return 0;
		}
		else {
			use_st.emplace(said);
		}

		next="?"+string(1,said.back())+mk_rnd()+"a";
	}
	return 0;
} 

Measured memory_bytes: 3240
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto A=vecin(N);

	if(A[0]){
		out(-1);
		return 0;
	}

	ll sum=0;
	for(int i=1;i<N;i++){
		if(A[i]-A[i-1]>1){
			out(-1);
			return 0;
		}
		if(A[i]==A[i-1]+1) sum++;
		else{
			sum += A[i];
		}
	}
	//sum += A[N-1];

	out(sum);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
	x = 0;
	T f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
inline void d_read(double &x) {
	x = 0.0;
	int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	if (c == '.'){
		double num = 1.0;
		c = getchar();
		for (; isdigit(c); c = getchar()) x = x + (num /= 10) * (c ^ 48);
	}
	x *= f;
}

template <typename T>
inline void w(T x) {
	if (x > 9) w(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
	if (x < 0){
		putchar('-');
		x = -x;
	}
	w(x);
	putchar(c);
}
int a[100005];
int main(){
	int n, k;
	read(n); read(k);
	for (int i = 1; i <= n; i ++) {
		read(a[i]);
	}
	sort(a + 1, a + n + 1);
	int ans = 0;
	for (int i = 1; i <= k; i ++) {
		ans += a[i];
	}
	write(ans, '\n');
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  while(n--){
    int mp[12][12],ans[12][12];
    for(int i=1;i<=10;i++)for(int j=1;j<=10;j++) cin>>mp[i][j];
    int cp[12][12];
 
    for(int i=0;i<(1<<10);i++){
       
      for(int j=1;j<=10;j++)
    for(int k=1;k<=10;k++)cp[j][k]=mp[j][k],ans[j][k]=0;
      for(int j=0;j<10;j++){
    if(i&(1<<j)){
      cp[1][j+1]=!cp[1][j+1];
      cp[1][j]=!cp[1][j];
      cp[1][j+2]=!cp[1][j+2];
      cp[2][j+1]=!cp[2][j+1];
      ans[1][j+1]=1;
    }
      }
      for(int j=2;j<=10;j++){
    for(int k=1;k<=10;k++){
      if(cp[j-1][k]){
        cp[j-1][k]=!cp[j-1][k];
        cp[j][k]=!cp[j][k];
        cp[j][k-1]=!cp[j][k-1];
        cp[j][k+1]=!cp[j][k+1];
        cp[j+1][k]=!cp[j+1][k];
        ans[j][k]=1;
      }
    }
      }
      int f=0;
      for(int j=1;j<=10;j++)
    for(int k=1;k<=10;k++)
      if(cp[j][k])f=1;
      if(!f)break;
    }
 
    for(int i=1;i<=10;i++){
      for(int j=1;j<=10;j++){
    if(j!=1)cout<<' ';
    cout<<ans[i][j];
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    long long n, m;
    cin >> n >> m;
    long long a, b;
    vector<pair<long long, long long>> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end());
    long long m_sum = 0, i;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (m_sum == m)
            break;
        else if (m_sum + p[i].second <= m)
        {
            m_sum += p[i].second;
            ans += p[i].first * p[i].second;
            //cout << m_sum << " " << ans << endl;
        }
        else
        {
            ans += p[i].first * (m - m_sum);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  int mx=0;
  pair<string,int> p();
  for(p:mp) mx=max(mx,p.second);
  pair<string,int> p();
  for(p:mp) {
    if(p.second!=mx) continue;
    cout<<p.first<<endl;
  }
  return 0;
}
  
  


Measured memory_bytes: 25216
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
struct node
{
    char data;
    struct node *next, *last;
};
char ch[100100];
int main()
{
    scanf("%s",ch);
   int len=strlen(ch);
   struct node *head,*tail;
   head=(struct node *)malloc(sizeof(struct node ));
   head->data='0';
   head->next=NULL;
   head->last=NULL;
   tail=head;
   struct node *p;
   for(int i=0;i<len;i++)
   {
       p=(struct node *)malloc(sizeof(struct node ));
       p->next=NULL;
       p->last=NULL;
       p->data=ch[i];
       tail->next=p;
       p->last=tail;
       tail=p;
   }
   p=head->next->next;
   int k=0;
   while(p->next&&p)
   {
       if(p==head)
       {
           p=p->next->next;
           if(p==tail)
           {
               break;
           }
       }
       if(p==head->next)
       {
           p=p->next;
           if(p==tail)
           {
               break;
           }
       }
       if(p->last->data!=p->next->data)
       {
           struct node *z=(struct node *)malloc(sizeof(struct node));
           z=p->next;
           struct node *zz=(struct node *)malloc(sizeof(struct node ));
           zz=p->last;
           zz->next=z;
           z->last=zz;
           p=zz->last;
           k++;
       }
       if(p==tail)
       {
           break;
       }
       p=p->next;
   }
   if(k%2==1)
   {
       printf("First\n");
   }
   else
   {
       printf("Second\n");
   }
    return 0;
}


Measured memory_bytes: 3328
let rec transpose = function
    | (_::_)::_ as M -> List.map List.head M :: transpose (List.map List.tail M)
    | _ -> []

let eightval lst = 
  let sgn = [1L;-1L]
  match lst with
    | [x;y;z] -> [ for i in sgn do for j in sgn do for k in sgn do yield i*x + j*y + k*z ]
    | _ -> failwith "omg"

// read N and M
let [|n;m|] = stdin.ReadLine().Split() |> Array.map int
// read Data with int64
let inline scanLongInts _ = stdin.ReadLine().Split() |> Array.map int64 |> Array.toList
let xs = [ for i in 1..n -> scanLongInts 0 ]
// do the work
xs
|> List.map eightval
|> transpose
|> List.map (List.toArray >> Array.sort >> Array.rev >> (fun a -> a.[0..m-1]) >> Array.sum)
|> Seq.max
|> printfn "%d"

Measured memory_bytes: 17500
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n;
vll v;

void func() {
    cin >> n;
    v.clear();
    for (ll i = 0, a; i < n; i++) {
        cin >> a;
        if (v.empty() || a <= v.back()) {
            v.push_back(a);
        } else {
            *upper_bound(v.begin(), v.end(), a, greater<ll>()) = a;
        }
    }
    cout << v.size() << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int p[20];

int f(int a, int b, int c)
{
  if(!b&&!c) return 0;
  int s = (a|b|c)>>1;
  int t = 0;
  while(s&1) {t++;s>>=1;}
  if(1&a) return f(a>>1,b>>1,c>>1);
  if(1&b) return f(c>>1,b>>1,a>>1)+p[t];
  if(1&c) return f(a>>1,b>>1,c>>1)+2*p[t];
}

int main()
{
  int n,m;
  REP(i,20)
  {
    p[i] = pow(3,i);
  }
  while(cin >> n >> m,n)
  {
    int a[3] = {0};
    REP(i,3)
    {
      int t,u; cin >> t;
      REP(j,t)
      {
        cin >> u;
        a[i] |= 1 << u-1;
      }
    }
    int ans = min(f(a[0],a[1],a[2]),f(a[2],a[1],a[0]));
    cout << (ans>m?-1:ans) << endl;
  }
}

Measured memory_bytes: 3292
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=Integer.parseInt(sc.next());
		int K=Integer.parseInt(sc.next());
		sc.close();
		System.out.println((int)Math.ceil((double)(N-K)/(K-1))+1);
	}
}
	


Measured memory_bytes: 21716
from collections import defaultdict as dd
N = int(input())
K = int(input())

s = str(N)

dp = dd(int)
dp[(True, 1)] = 1
dp[(False, 1)] = int(s[0])-1
dp[(False, 0)] = 1

for c in s[1:]:
    i = int(c)
    ndp = {}
    if i != 0:
        ndp[(True, 0)] = 0
        ndp[(True, 1)] = dp[(True, 0)]
        ndp[(True, 2)] = dp[(True, 1)]
        ndp[(True, 3)] = dp[(True, 2)]
        ndp[(False, 0)] = dp[(False, 0)] + dp[(True, 0)]
        ndp[(False, 1)] = dp[(False, 1)] + dp[(False, 0)]*9 + dp[(True, 0)]*(i-1) + dp[(True, 1)]
        ndp[(False, 2)] = dp[(False, 2)] + dp[(False, 1)]*9 + dp[(True, 1)]*(i-1) + dp[(True, 2)]
        ndp[(False, 3)] = dp[(False, 3)] + dp[(False, 2)]*9 + dp[(True, 2)]*(i-1) + dp[(True, 3)]
    else:
        ndp[(True, 0)] = dp[(True, 0)]
        ndp[(True, 1)] = dp[(True, 1)]
        ndp[(True, 2)] = dp[(True, 2)]
        ndp[(True, 3)] = dp[(True, 3)]
        ndp[(False, 0)] = dp[(False, 0)]
        ndp[(False, 1)] = dp[(False, 1)] + dp[(False, 0)]*9
        ndp[(False, 2)] = dp[(False, 2)] + dp[(False, 1)]*9
        ndp[(False, 3)] = dp[(False, 3)] + dp[(False, 2)]*9
    dp = ndp
print(dp[True, K] + dp[False, K])

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < c&&c < b)cout << "Yes" << endl;
	else if (b < c&&c < a)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

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

    int total = 0;
    for (int n=1; n<=N; ++n) {
        int r = n;
        int sub = 0;
        while (r != 0) {
            sub += r % 10;
            r /= 10;
        }
        if (((A <= sub) && (sub <= B))) {
            total += n;
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Utility;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var a = ReadInt();
            var b = ReadInt();
            var h = ReadInt();
            Console.WriteLine($"{(a + b) * h / 2}");
        }
    }

    public static class Utility
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(v => int.Parse(v));

        public static IEnumerable<int> EnumerateDigits(int value)
        {
            while (value > 0)
            {
                yield return value % 10;
                value /= 10;
            }
        }

    }

    public class Factorial
    {
        public static long Number(long term)
        {
            return term > 1 ? Number(term - 1) * term : 1;
        }

        public static long[] Cache(long term)
        {
            var cache = new long[term + 1];
            cache[0] = 1;
            for (int i = 1; i < cache.Length; i++)
            {
                cache[i] = cache[i - 1] * i;
            }
            return cache;
        }

        public static long[] CacheMod(long term, long mod)
        {
            var cache = new long[term + 1];
            cache[0] = 1;
            for (int i = 1; i < cache.Length; i++)
            {
                cache[i] = cache[i - 1] * i % mod;
            }
            return cache;
        }
    }
}


Measured memory_bytes: 13140
x, k, d= map(int, input().split())
x = abs(x)
if x - k * d >= 0:
    print(x - k * d)
else:
    ans1 = x % d
    check = x // d
    ans2 = ans1 - d
    if(ans1 + ans2 > 0 and(k - (check + 1))%2==0):
        print(abs(ans2))
    elif(ans1 + ans2 > 0 and (k - (check + 1))%2==1):
        print(ans1)
    elif(ans1 + ans2 < 0 and (k - check)%2==0):
        print(ans1)
    else:
        print(abs(ans2))


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

int main(){

    long long H, W;
    cin >> H >> W;
    long long res = 0;
    long long w=0, h=0;
    
    if(W%2 == 0){
        w = W/2;
        if(H%2 == 0){
            h = H/2;
            res = w*H;
        }else{
            h = (H+1)/2;
            res = w*H;
        }
    }else{
        w = (W+1)/2;
        if(H%2 == 0){
            h = H/2;
            res = w*h + (w-1)*h;    
        }else{
            h = (H+1)/2;
            res = w*h + (w-1)*(h-1);
       }
    }
    if(H==1 || W==1){
        cout << 1 << endl;
    }else{
        cout << res << endl;
    }
    

}

Measured memory_bytes: 3544
n,m,Q = map(int,input().split())
lr = [list(map(int,input().split())) for _ in range(m)]
lr.sort(key=lambda x:(x[0],x[1]))
ans = [[0]*(n+1) for _ in range(n+1)]
now = 0
for i in range(1,n+1):
  j = 1
  while True:
    if now < m:
      if lr[now][1] == j and lr[now][0] == i:
        ans[i][j] += (ans[i][j]==0)*(ans[i][j-1]) + 1
        now += 1
      else:
        j += 1
        if j <= n:
          ans[i][j] = ans[i][j-1]
        else:
          break
    else:
      j += 1
      if j <= n:
        ans[i][j] = ans[i][j-1]
      else:
        break
ans2 = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    if i == 1:
      ans2[i][j] = ans[i][j]
    else:
      ans2[i][j] = ans2[i-1][j] + ans[i][j]
for i in range(Q):
  p,q = map(int,input().split())
  print(ans2[q][q]-ans2[p-1][q])

Measured memory_bytes: 64992
#include<cstdio>
#include<cmath>
using namespace std;
int a, b, c, len;
int main() {
	scanf("%d%d", &a, &b);
	c=b;
	while(c>0) {
		c/=10;
		len++;
	}
	a=a*pow(10,len)+b;
	if(sqrt(a)==floor(sqrt(a))) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
// queue: first in first out
// stack: first in last out
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
const ll NUM = 1e5+1;
// ll dp[100005][13];
ll dp[10005];

ll Query[NUM];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(void) {
  ll K, N;
  cin >> K >> N;
  ll max = 0;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
    ll dist = 0;
    if (i == 0) {

    } else {
      dist = A[i] - A[i-1];
    }
    if (dist > max) {
      max = dist;
    }
  }

  if (K-A[N-1]+A[0] > max) {
    max = K-A[N-1]+A[0];
  }
  cout << K - max << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
    int a,a1;
	int b,b1;
	int c,c1;
	int d,d1;
	int e,e1;
	int f,f1;
	int g,g1;
	int j,k,l,m,n,p,o;
	scanf("%d %d",&a,&a1);
	scanf("%d %d",&b,&b1);
	scanf("%d %d",&c,&c1);
	scanf("%d %d",&d,&d1);
	scanf("%d %d",&e,&e1);
	scanf("%d %d",&f,&f1);
	scanf("%d %d",&g,&g1);
	j=a-a1;
	k=b-b1;
	l=c-c1;
	m=d-d1;
	n=e-e1;
	p=f-f1;
	o=g-g1;
	printf("%d\n",j);
	printf("%d\n",k);
	printf("%d\n",l);
	printf("%d\n",m);
	printf("%d\n",n);
	printf("%d\n",p);
	printf("%d\n",o);
	return 0;
}

Measured memory_bytes: 1028
import sys
input = sys.stdin.readline
n=int(input())
ab=[]
for _ in range(n):
    t,a=map(int,input().split())
    ab.append([t,a,t+a])
sorted_items = sorted(
  ab,
  key = lambda x: x[2],
  reverse=True
)
t=0
a=0
for i in range(n):
    if i%2==0:
        t+=sorted_items[i][0]
    else:
        a+=sorted_items[i][1]
print(t-a)

Measured memory_bytes: 25252
n, q = map(int, input().split())
s = input()
dic = {}
t_list = []
d_list = []

for i in range(q):
    t, d = input().split()
    t_list.append(t)
    if d == 'L':
        d_list.append(-1)
    else:
        d_list.append(1)


def find_pos(left, right):
    return left + (right - left - 1) // 2


def calc(sites, ts, ds, _n, _q):
    def check(idx):
        num = idx
        for j in range(_q):
            site = sites[num]
            if ts[j] == site:
                num += ds[j]
            if num < 0:
                return False
            if num > n - 1:
                return True
        return True

    def func(left, right):
        if right - left == 1:
            if check(left):
                return left
            else:
                return right
        pos = find_pos(left, right)
        if check(pos):
            return func(left, pos + 1)
        else:
            return func(pos + 1, right)
    return func


f1 = calc(s, t_list, d_list, n, q)
f2 = calc(s[::-1], t_list, [-i*1 for i in d_list], n, q)
print(n - f1(0, n) - f2(0, n))


Measured memory_bytes: 8556
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
#define int long long
#define mod 1000000007
using namespace std;

signed main(){
	int a; cin >> a;
	int s = 1;
	for (int b = 1; b <= a; b++) {
		s = s*b%mod;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
//	-*- mode: C++ -*-
//	Stack
//		Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free.
//
//		Write a program which reads an expression in the Reverse Polish notation and prints the computational result.
//
//		An expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations.
//
//	Input
//		An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.
//
//		You can assume that +, - and * are given as the operator and an operand is a positive integer less than 106
//
//	Output
//		Print the computational result in a line.
//
//	Constraints
//		2 ≤ the number of operands in the expression ≤ 100
//		1 ≤ the number of operators in the expression ≤ 99
//		-1 × 109 ≤ values in the stack ≤ 109
//	Sample Input 1
//		1 2 +
//	Sample Output 1
//		3
//	Sample Input 2
//		1 2 + 3 4 - *
//	Sample Output 2
//		-3

#include <iostream>
#include <stack>
#include <vector>
#include <sstream>

void	get2Elements(std::stack<long long>&	S,
					 long long&				a,
					 long long&				b)
{
	a	= S.top();
	S.pop();
	b	= S.top();
	S.pop();
}

void	plus(std::stack<long long>&	S)
{
	long long	a, b;
	get2Elements(S, a, b);

	S.push(b + a);
}

void	minus(std::stack<long long>&	S)
{
	long long	a, b;
	get2Elements(S, a, b);

	S.push(b - a);
}

void	mul(std::stack<long long>&	S)
{
	long long	a, b;
	get2Elements(S, a, b);

	S.push(b * a);
}

std::vector<std::string>	split(const std::string&	s,
								  char				 	d)
{
	std::vector<std::string>	r	{};
    size_t						c	{0};
	size_t						f	{0};
    while((f = s.find_first_of(d, c)) != std::string::npos){
        r.push_back(std::string(s, c, f - c));
        c	= f + 1;
    }

    r.push_back(std::string(s, c, s.size() - c));

    return	r;
}

int	main(int	argc,
		 char*	argv[])
{

	std::stack<long long>	S	{};
	std::string				str	{};

	std::getline(std::cin, str);

	std::vector<std::string>	v	= split(str, ' ');

	for(auto str : v){
		if(str == "+"){
			plus(S);
		}
		else if(str == "-"){
			minus(S);
		}
		else if(str == "*"){
			mul(S);
		}
		else{
			long long	value	= std::stoll(str);
			S.push(value);
		}
	}

	std::cout << S.top() << '\n';
    return 0;
}



Measured memory_bytes: 3164
/*
20 2 5
*/
fn main() {
    let vec = read_line();
    let n = vec[0];
    let a = vec[1];
    let b = vec[2];
    let mut sum = 0;
    for i in 1..n + 1 {
        let n5 = i / 10000;
        let n4 = i % 10000 / 1000;
        let n3 = i % 1000 / 100;
        let n2 = i % 100 / 10;
        let n1 = i % 10;

        let res = n1 + n2 + n3 + n4 + n5;
        if (res >= a) && (b >= res) {
            // println!("==debug====");
            // println!("i={}", i);
            // println!("res={}", res);
            // println!("{},{},{},{},{}", n5, n4, n3, n2, n1);
            sum += i;
        }
    }
    println!("{}", sum);
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v
}

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

#define M 1000001/* your task*/
#define L 14
#define FALSE -1

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
   long sum = 0, p = 1, i;
   for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return /* your task */key % M; }
int h2(int key){ return /* your task */1 + (key % (M-1)); }

int find(char str[]){

  /* your task */
  long long i,j,k;
  k = getKey(str);
  for(i=0; ;i++){
    j = (h1(k)+i*h2(k))%M;
    if(strcmp(H[j],str) == 0)return 1;
    else if(strlen(H[j]) == 0)return 0;
  }
  return 0;
}

int insert(char str[]){

  /* your task */
  long long i,j,k;
  k = getKey(str);
  for(i=0; ;i++){
    j = (h1(k)+i*h2(k))%M;
    if(strcmp(H[j],str) ==0)return 1;
    else if(strlen(H[j]) ==0){
      strcpy(H[j],str);
      return 0;
    }
  }
  
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if ( find(str) ==1 ){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

public class Main {

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

        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = scanner.nextInt();

        int q = partition(a, 0, n -1);

        String[] a_s = Arrays.stream(a)
            .mapToObj(String::valueOf)
            .toArray(String[]::new)
            ;
        a_s[q] = "[" + a_s[q] + "]";
        System.out.println(String.join(" ", a_s));

    }

    private static int partition(int[] a, int p, int r) {
        int x = a[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (a[j] <= x) {
                i++;
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        i++;
        int tmp = a[i];
        a[i] = a[r];
        a[r] = tmp;
        return i;
    }

}



Measured memory_bytes: 70652
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int32_t main()
{
    IOS;
    int k;
    cin>>k;
    if(k%2==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    int ans=0;
    map<int,int>mp;
    for(int i=1;i<=2000000;i++)
    {
        ans=ans*10+7;
        ans%=k;

        if(ans==0)
        {
            cout<<i<<endl;
            return 0;
        }
       
        if(mp[ans]>0)
        {
            cout<<-1<<endl;
            return 0;
        }
         mp[ans]++;
    }


}

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

using namespace std;




int main() {

 string S;
 cin >> S;

int modulos[200000];
long i,j;
char zero;

zero = '0';

long N;
int module;
N=S.length();
module = S[N-1]-zero;
//cout << module << endl;
modulos[0] = module;
int chiffre,puiss;
puiss = 10;

long collisions[2019];
for (i = 0;i<2019;i++)
  collisions[i] = 0;

collisions[module]++;

 for (i=N-2;i>=0;i--) {
   chiffre = S[i]-zero;
   module = (module+ chiffre*puiss) % 2019;
   puiss = (10*puiss) % 2019;
   modulos[N-2-i+1] = module;
   collisions[module]++;
 //cout << i << " " << module << endl;
  }



 long coll,total_coll,nb_zero;




 i = 0;
 int flag;
 nb_zero = collisions[0];

 for (i=0;i<2019;i++)
  if (collisions[i] > 1)
    nb_zero += (collisions[i]*(collisions[i]-1))/2;



  cout << nb_zero << endl;
  return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll n,ans=0,cnt=0,tmp;
	in(n);
	
	vll l(n);
	map<ll,ll> m;
	rep(i, 0, n) {
		in(l[i]);
	}

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

	rep(i, 0, n-2) {
		rep(j, i + 1, n-1) {
			if (l[j] >= l[i] + l[j+1]) {
				break;
			}
			rep(k, j + 1, n) {
				if (l[k] >= l[i] + l[j]) {
					break;
				}
				ans++;
			}
		}
	}

	outn(ans);

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S; cin >> S;
  string T; cin >> T;
  int res=0;
  for(int i=0;i<3;i++){
  	if(S[i] == T[i]) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

vll arr(100010, 0);

int main(){
    ll N, K;
    cin >> N >> K;
    vll a(N), b(N);
    rep(i, N){
        cin >> a[i] >> b[i];
        arr[a[i]] += b[i];
    }
    ll num = 0;
    rea(i, 1, 100001){
        num += arr[i];
        if(num >= K){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-


def main():
    from re import search

    s = input()
    pattern = r'^A?KIHA?BA?RA?$'
    is_match = search(pattern, s)

    if is_match:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long

using namespace std;

///Code starts from here
int main()
{
    int x,y,a,b;
    cin>>x>>y;
    for(int i=0;i<=x;i++)
    {
        a=i;
        b=x-i;
        if(2*a+4*b==y)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 100000;
int pre[N];
bool t[N];
int find(int x)
{
	if (x!=pre[x]) pre[x]=find(pre[x]);
	return pre[x];
}
 
void mix(int x,int y)
{
	int fx=find(x),fy=find(y);
	if(fx!=fy)
	{
		pre[fy]=fx;
	}
} 
 
int n,m;
int main()
{
    cin>>n>>m;
    for (int i=0;i<n;i++)
    {
        pre[i]=i;
    }
    for (int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        mix(x,y);
    }
    memset(t,0,sizeof(t));
    for (int i=0;i<n;i++)
    {
        t[find(i)]=1;
    }
    int ans=0;
    for (int i=0;i<n;i++)
    {
        if (t[i]) ans++;
    }
    cout<<ans-1;
    return 0;
}

Measured memory_bytes: 4124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ?????°?????????
		int cnt1 = 0;
		int cnt2 = 0;

		while(true) {

			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H == 0 && W == 0)
				break;

			for(cnt1 = 0; cnt1 < W; cnt1++ ) {

				System.out.print("#");

			}

			System.out.println("");

			for(cnt2 = 0; cnt2 < H-2; cnt2++) {

				System.out.print("#");

				for(cnt1 = 0; cnt1 < W-2; cnt1++ ) {

					System.out.print(".");

				}

				System.out.println("#");

			}

			for(cnt1 = 0; cnt1 < W; cnt1++ ) {

				System.out.print("#");

			}
			System.out.println("");
			System.out.println("");
		}
		sc.close();}
}

Measured memory_bytes: 35604
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(seq[n-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, a[MAXN];
map < int, int > cnt;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll res = 0ll;
	for(auto &to : cnt) {
		if(to.second >= to.first) res += to.second - to.first;
		else res += to.second;
	}
	cout << res << nxtl;
	
	return 0;
}

Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    vi abc(3);
    rep(i,3)cin >> abc[i];
    int k;
    cin >> k;

    sort(all(abc));
    rep(i,k)abc[2]*=2;
    int ans=0;
    rep(i,3)ans+=abc[i];

    cout << ans << endl;
}

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

using namespace std;

int N;
vector<int> d;

int main()
{
	int ans = 0;
	cin >> N;
	d = vector<int>(N);

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

	for (int i = 0; i < N-1; i++) {
		for (int j = i+1; j < N; j++) {
			ans += d.at(i)*d.at(j);
		}
	}



	cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool solve(const vector<int>& a){
    if(a.back() == 0) return true;
    if(a.size()%3 != 0) return false;
    int n = a.size()/3;
    for(int i=1;i<n;i++){
        for(int j=0;j<2;j++){
            int base = n*j;
            if(a[base] != a[base+i]) return false;
        }
    }
    return (a[0]^a[n]) == a[2*n];
}

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N);
        for(auto& t : a) cin >> t;
        sort(a.begin(), a.end());
        cout << (solve(a) ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>

#define r(a,b,c) for(int a=b;a<=c;++a)
#define INF 0x7fffffff

using namespace std;

inline int read()
{
    int a=0,b=1;
    char c=getchar();
    while(c<='0'||c>'9')
    {
        if(c=='-')
        {
            b=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        a=a*10+c-'0';
        c=getchar();
    }
    return a*b;
}

void write(int n)
{
    if(n<0)
    {
        n=-n;
        putchar('-');
    }
    if(n>10)
    {
        write(n/10);
    }
    putchar(n%10+'0');
}
char a[10001];
int main()
{
    cin>>a;
    cout<<a[0]<<strlen(a)-2<<a[strlen(a)-1]<<endl;
    return 0;
}

Measured memory_bytes: 256