akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

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

typedef long long ll;

ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll GCD=gcd(a[0],a[1]);
    ll MAX=max(a[0],a[1]);
    for(int i=0;i<n;i++){
        cin>>a[i];
        GCD=gcd(GCD,a[i]);
        MAX=max(a[i],MAX);
    }
    if(k>MAX){cout<<"IMPOSSIBLE"<<endl;}
    else if(GCD==1||k%GCD==0){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val in = new Scanner(System.in)
    val N = in.nextInt()
    val X = in.nextInt()
    val Y = in.nextInt()
    val foods = (for (_ <- 0 until N) yield {
      val K = in.nextInt()
      (for (_ <- 0 until K) yield {
        val a = in.nextInt()
        val b = in.nextInt()
        val c = in.nextInt()
        (a, b, c)
      }).toArray
    }).toArray

    val dist = (for (_ <- 0 until N) yield (for (_ <- 0 until N) yield in.nextInt()).toArray).toArray
    for {
      k <- 0 until N
      i <- 0 until N
      j <- 0 until N
    } dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))

    val cost = Array.fill(1 << (N + 1), N + 1)(Int.MaxValue / 2)
    cost(1)(0) = 0
    for {
      mask <- 0 until (1 << N)
      current <- 0 until N
      next <- 1 until (N + 1)
      if (mask & (1 << current)) != 0
      if (mask & (1 << next)) == 0
    } {
      val nextMask = mask | (1 << next)
      cost(nextMask)(next) = math.min(cost(nextMask)(next), cost(mask)(current) + dist(current)(next % N))
    }

    val bottom = N / 2
    val top = N - bottom

    val deq = new Array[Int](1000000)
    val deqv = new Array[Int](1000000)

    def knapsack(mask: Int, dp: Array[Int]): Unit = {
      dp(0) = 0
      for {
        i <- 0 until N
        if (mask & (1 << i)) != 0
        (price, value, remain) <- foods(i)
        a <- 0 until price
      } {
        var s = 0
        var t = 0

        var num = 0
        while (num * price <= (Y - a)) {
          val v = dp(num * price + a) - num * value
          while (s < t && deqv(t - 1) <= v) {
            t -= 1
          }
          deq(t) = num
          deqv(t) = v
          t += 1

          dp(num * price + a) = deqv(s) + num * value
          if (deq(s) == num - remain) {
            s += 1
          }

          num += 1
        }

      }

      for {
        i <- 1 to Y
      } {
        dp(i) = math.max(dp(i), dp(i - 1))
      }
    }

    val bottomDp = Array.fill[Int](1 << bottom, Y + 1)(-1)
    val topDp = Array.fill[Int](1 << top, Y + 1)(-1)
    for (mask <- 0 until (1 << bottom)) {
      knapsack(mask, bottomDp(mask))
    }
    for (mask <- 0 until (1 << top)) {
      knapsack(mask << bottom, topDp(mask))
    }

    var max = 0
    for {
      mask <- 0 until (1 << N)
    } {
      val moveCost = cost(mask | (1 << N))(N)
      val budget = math.min(Y, X - moveCost)
      val bottomMask = mask & ((1 << bottom) - 1)
      val topMask = mask >> bottom

      if (budget > 0) {

        for {
          bottomBudget <- 0 to budget
        } {
          max = math.max(max, bottomDp(bottomMask)(bottomBudget) + topDp(topMask)(budget - bottomBudget))
        }
      }
    }
    println(max)
  }
}

Measured memory_bytes: 120312
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String[] __){
		int n;
		while(true){
			n=s.nextInt();
			if(n==0)return;
			final int q=s.nextInt();
			HashMap<Integer,Integer> hm=new HashMap<>(51);
			for(int i=0;i<n;i++) {
				for(int j=s.nextInt();j>0;j--) {
					hm.merge(s.nextInt(),1,Integer::sum);
				}
			}
			System.out.println(
					hm.entrySet().parallelStream()
					.filter(o->o.getValue()>=q)
					.max(Entry
							.<Integer,Integer>comparingByValue()
							.thenComparing(Entry.<Integer,Integer>comparingByKey().reversed()))
					.map(Entry::getKey)
					.orElse(0)
					);
		}
	}
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;
ll a,b;

/*
l > r
a>b
b += r-b%r
a = b*l/r;

a<b

*/
ll gcd( ll m, ll n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main(){
  cin >> n;
  cin >> a >> b;
  REP(i,n-1){
    ll l,r;
    cin >> l >> r;
    ll d = gcd(a,b);
    ll a2 = a/d,b2 = b/d;
    if(a2*r == b2*l){
      continue;
    }
    if(a2*r < b2*l){
      b += (r-(b%r)) % r;
      a = b/r*l;
    }else{
      a += (l-(a%l))%l;
      b = a/l*r;
    }
  }
  cout << a+b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,m; cin >> n >> m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];

  for(int i = 0; i < n; i++){
    int mn = 1<<29, ans = 0;
    for(int j = 0; j < m; j++){
      int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(dist < mn){
        mn = dist;
        ans = j;
      }
    }
    cout << ans+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	string s,k;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'B') {
			k += s[i];
		}
		else {
			for (int j = k.size() - 1; j >= 0; j--) {
				if (k[j] != ' ') {
					k[j] = ' ';
					break;
				}
			}
		}

	}
	for (int i = 0; i < k.size(); i++) {
		if (k[i] != ' ') {
			cout << k[i];
		}
	}
	cout << endl;
    return 0;
}

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

int main() {
  int m1, d1;
  int m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if (m1 != m2) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}

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

int main() {
    ll A, B;
    cin >> A >> B;
    ll d = (A * A) - (B * B);
    ll n = (A - B) * 2;

    if (n == 0 || d % n != 0) {
        cout << "IMPOSSIBLE";
        return 0;
    }

    int k = d / n;
    cout << k;

    return 0;
}


Measured memory_bytes: 384
# coding: utf-8
# Here your code !
import sys
from collections import deque

class CPU():
    def __init__(self, in_quantum):
        self.quantum = in_quantum
        self.total_time = 0
        
    def deal(self, in_process, in_time):
        this_process_time = 0

        if in_time[0] > self.quantum:
            remain_time = in_time[0] - self.quantum
            this_process_time = in_time[0] - remain_time

            in_process.append(in_process[0])
            in_time.append(remain_time)
            
            self.total_time += this_process_time
        else:
            this_process_time = in_time[0]
            self.total_time += this_process_time
            #make log
            self.makeLog(in_process[0])

        in_process.popleft()
        in_time.popleft()
        
        return in_process, in_time

    def makeLog(self, in_process):
        print(in_process, self.total_time)

    
processes = deque()
times = deque()
    
data_cnt, quantum =  list(map(int,input().split(" ")))  

for i in range(data_cnt):
    tmp_process, tmp_time = input().split(" ")
    processes.append(tmp_process)
    times.append(int(tmp_time))

objCPU = CPU(quantum)

while True:
    processes, times = objCPU.deal(processes, times)
    if len(processes) == 0:
        break

Measured memory_bytes: 11872
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

x,k,d=nii()

dist=abs(x)
num=dist//d

if num>k:
  print(abs(dist-d*k))
  exit()
else:
  k-=num
  dist-=d*num

if k%2==0:
  print(dist)
else:
  print(min(abs(dist+d),abs(dist-d)))

Measured memory_bytes: 9104
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int getmin(int val1, int val2) {
	if (val1 < val2) {
		return val1;
	}
	else {
		return val2;
	}
}

int getmax(int val1, int val2) {
	if (val1 > val2) {
		return val1;
	}
	else {
		return val2;
	}
}

typedef struct data {
	char c;
	int cnt;
} data;

int h, w;
char mass[2000][2005];
int xcnt[2000][2005];
int ycnt[2000][2005];

int fnc2() {
	int i, j, k;
	int h = geti();
	int w = geti();
	for (i = 0; i < h; i++) {
		getstr(mass[i]);
	}

	for (i = 0; i < h; i++) {
		int no = 0;
		int sno = -1;
		int eno;
		for (j = 0; j < w; j++) {
			if (mass[i][j] == '.') {
				if (sno < 0) {
					sno = j;
				}
				eno = j;
			}
			else {
				if (sno >= 0) {
					for (k = sno; k <= eno; k++) {
						xcnt[i][k] = eno - sno;
					}
					sno = -1;
				}
			}
		}
		if (sno >= 0) {
			for (k = sno; k <= eno; k++) {
				xcnt[i][k] = eno - sno;
			}
			sno = -1;
		}
	}

	for (i = 0; i < w; i++) {
		int no = 0;
		int sno = -1;
		int eno;
		for (j = 0; j < h; j++) {
			if (mass[j][i] == '.') {
				if (sno < 0) {
					sno = j;
				}
				eno = j;
			}
			else {
				if (sno >= 0) {
					for (k = sno; k <= eno; k++) {
						ycnt[k][i] = eno - sno;
					}
					sno = -1;
				}
			}
		}
		if (sno >= 0) {
			for (k = sno; k <= eno; k++) {
				ycnt[k][i] = eno - sno;
			}
			sno = -1;
		}
	}

	int max = 0;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			max = getmax(max, xcnt[i][j] + ycnt[i][j]);
		}
	}

	return max + 1;
}

int fnc1() {
	int ret = fnc2();
	outi(ret);
	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc1();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc1();
#endif

	return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vi B(N-1);
  rep(i,N-1) cin >> B[i];
  
  int ans=B[0]+B[N-2];
  rep(i,N-2) ans+=min(B[i],B[i+1]);
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {


	char a;

	cin >> a;

	printf("%c", a + 1);

	return 0;
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int A[5];
    int ans;
    for(int i=0;i<5;i++)
    {
        cin>>A[i];
        if(!A[i])
        ans=i+1;
    }
    cout<<ans;

return 0;
}

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

using namespace std;

#define mod 1000000007
#define inf 1e18
#define ll long long
#define PI 3.1415926536


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll no1, no2;
	cin >> no1 >> no2;
	cout << (no1 * no2) << endl;
	return 0;
}

Measured memory_bytes: 3684
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  string s;
	cin >> s;
	ll x = 0, y = 0, z = 0, w = 0;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] == 'N') x++;
		if (s[i] == 'S') y++;
		if (s[i] == 'W') z++;
		if (s[i] == 'E') w++;
	}
	bool ans = true;
	if (x > 0 && y == 0) ans = false;
	if (x == 0 && y > 0) ans = false;
	if (z > 0 && w == 0) ans = false;
	if (z == 0 && w > 0) ans = false;
	if (ans) Yes();
	else No();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
  static void Main (string[] args) {
    long N = long.Parse (Console.ReadLine ());
    var p = Console.ReadLine ().Split (' ');
    long[] a = new long[100000];
    for (int i = 0; i < N; i++) {
      a[i] = int.Parse (p[i]);
    }

    long num = 0;
    while (true) {
      bool f=false;
      for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 0) {
          num++;
          a[i] /= 2;
          f=true;
        }
      }
      if (f==false)break;
    }

    Console.WriteLine (num);

  }
}

Measured memory_bytes: 14560
#include <bits/stdc++.h>
using namespace std;
int dp[1 << 26];
int main()
{
    int bit = 0;
    string S;
    
    fill_n(dp, 1 << 26, 1 << 27);
    dp[0] = 0;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        bit ^= (1 << (S[i] - 'a'));
        for(int j = 0; j < 26; j++) {
            dp[bit] = min(dp[bit], dp[bit ^ (1 << j)] + 1);
        }
    }

    cout << dp[bit] + (dp[bit] == 0) << endl;
            
    return (0);
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort(a) sort(a.begin(),a.end());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,n,p) for(lli i = 0;i<n;i= i +p)
#define endl "\n"

//Written By GHATAK...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

int main()
{
    ios
    lli T=1;
    //cin>>T;
    while(T--)
    {
        //start from here
        lli n;
        cin>>n;
        for(lli i = 1;i<10;i++)
        {
            if(n%i == 0)
            {
                lli k = n/i;
                if((k>=1)&&(k<=9))
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
        cout<<"No";
    }
    return 0;
}
/*-----------------------------------------------------------------------*/
/*
--->  reverse(vec.begin(),vec().end());
*/


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<vector<int> > neta(n+1);
  REP(i, n) {
    int t, d; cin >> t >> d;
    neta[t].push_back(d);
  }
  vector<int> top, hebo;
  FOR(i, 1, n+1) {
    if (neta[i].size() == 0) continue;
    sort(ALL(neta[i]), greater<int>());
    top.push_back(neta[i].front());
    int sz = neta[i].size();
    FOR(j, 1, sz) hebo.push_back(neta[i][j]);
  }
  int top_sz = top.size(), hebo_sz = hebo.size();
  vector<long long> top_sum(top_sz+1, 0), hebo_sum(hebo_sz+1, 0);
  sort(ALL(top), greater<int>());
  REP(i, top_sz) top_sum[i+1] = top_sum[i] + top[i];
  sort(ALL(hebo), greater<int>());
  REP(i, hebo_sz) hebo_sum[i+1] = hebo_sum[i] + hebo[i];
  long long ans = 0;
  FOR(i, 1, k+1) {
    if (i > top_sz) break;
    if (k - i > hebo_sz) continue;
    ans = max(ans, top_sum[i] + hebo_sum[k-i] + (long long)i * i);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7032
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	if (N < 1200) cout << "ABC" << endl;
	else if (N < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

    return 0;
}


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

int main(){
  int set;
  int i,j;
  int x,y,w,h;
  int xc,yc;
  int n;
  int s;

  cin >> set;

  for(i=0;i<set;i++){
    cin >> x >> y >> w >> h;
    cin >> n;
    s = 0;
    for(j=0;j<n;j++){
      cin >> xc >> yc;
      if(x<=xc && xc<=x+w && y<=yc && yc<=y+h)s++;
    }

    cout << s << endl;
  }
}

Measured memory_bytes: 0
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(n m)
  (labels ((g(a)
             (/ (* a (1+ a)) 2)))
  (+ (g (1- n)) (g (1- m)))))

(let ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
  (format t "~A~%" (f (car line) (cadr line))))


Measured memory_bytes: 13284
#include <stdio.h>

#define N 8
#define F -1
#define NF -2

int board[N][N],col[N],row[N],dpos[2*N-1],dneg[2*N-1];
 
void p(){

  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(board[i][j]==1 && row[i]!=j)return;
    }
  }

   for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){

  int j;

  if(i==N){
  p();
  return ;
  }
  
  for(j=0;j<N;j++){

    if(col[j]==NF || dpos[i+j]==NF || dneg[i-j+N-1]==NF) continue;

    row[i]=j;
    col[j]=NF;
    dpos[i+j]=NF;
    dneg[i-j+N-1]=NF;

    recursive(i+1);

    row[i]=F;
    col[j]=F;
    dpos[i+j]=F;
    dneg[i-j+N-1]=F;

  } 
}



  
 
int main()
{

int i,j,k;
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      board[i][j]=-1;
    }
  }
	
  for(i=0;i<N;i++){
    col[i]=F;
    row[i]=F;
  }
  for(i=0;i<N;i++){
    dpos[i]=F;
    dneg[i]=F;
  }
  
  scanf("%d",&k);
  
  int x[k],y[k];
  
  for(i=0;i<k;i++){
    scanf("%d%d",&x[i],&y[i]);
    board[x[i]][y[i]]=1;
  }

 
  recursive(0);

 
  return 0;
}

  
      







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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#ifdef OJ
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)


int main() {
  int n; cin >> n;
  vector<int> a(n);
  int x = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    x ^= a[i];
  }
  
  for(int i = 0; i < n; i++) {
    cout << (a[i]^x) << ' ';
  }
  cout << endl;
  return 0;
}


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

int main(void){
	string s;
	int K;
	cin>>s>>K;
	rep(i,(int)s.size()){
		if('z'-s[i]<K && s[i]!='a'){
			K-='z'-s[i]+1;
			s[i]='a';
		}
	}
	s[(int)s.size()-1]+=K%26;
	cout<<s<<endl;

	return 0;
}


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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    char ch; cin >> ch;
    if(ch >= 'A' && ch <= 'Z')
        cout << "A";
    else
        cout << "a";
    
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		solve();
	}
	return 0;
}

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


int main() {
	string S,T;cin>>S>>T;
	long long count=0,M=0;
	
	for(int i=0;i<=S.size()-T.size();i++)
	{  int k=0;
	    for(int j=i;j<i+T.size();j++)
	    {   
	        if(S[j]==T[k++])
	        count++;
	    }
	    M=max(M,count);
	    count=0;
	}
	cout<<T.size()-M;
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)
#define N 202020

ll p[N] = {1}, pinv[N];
ll modpow(ll x, int a){
  if(a == 0)return 1;
  else if(a == 1)return x;
  else {
    ll res = modpow(x, a / 2);
    res = res * res % mod;
    if(a % 2 == 0)return res;
    else return res * x % mod;
  }
}

void use(void){
  int i;
  rep1(i, N)p[i] = p[i - 1] * i % mod;
  rep(i, N)pinv[i] = modpow(p[i], mod - 2);
  return;
}

ll getC(int n, int r){
  return (p[n] * pinv[r] % mod) * pinv[n - r] % mod;
}

signed main(void){
  int i, j, k;
  use();
  for(int testcase = 0;testcase >= 0;testcase++){
    int4(h, w, a, b);

    ll res = 0;
    rep(i, h - a){
      ll tmp = 1;
      //(tate : i, yoko : b) wo keiyu
      tmp = getC(i + b - 1, b - 1) * getC(h - i + w - b - 2, h - i - 1) % mod;
      res = (res + tmp) % mod;
    }
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// change max/min
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;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  ll n = 0;          \
  cin >> n;          \
  vector<ll> a(n);   \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  // INPUT2(A, B);
  // INPUT3(A, B, C);
  // INPUTS(S);
  INPUTA(N, A);
  // INPUTB(X, Y, B);

  ll _max = 0;
  ll c = 0;
  ll _min = 0;

  FOR(i, 1, N)
  {
    _max = max(_max, A[i - 1]);
    c += max(_max - A[i], _min);
  }

  cout << c;
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    lint A;
    cin >> A;
    lint B;
    cin >> B;
    lint G = __gcd(A,B);
    int ret = 0;
    FOR(i,2,1e6 + 10){                 //prime factors starting from 2;
        if(G%i == 0) ++ret;
        while(G%i == 0) G/=i;          //prime factorization technique;
    }
    if(G != 1) ++ret;   
    cout << ret + 1 << endl;          //1 added for considering the number 1;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 2*1e5 + 5;
const int N = 2020;
const int MOD = 2019;
char s[M];
ll ret[N];
ll n, p;

int main( ){
    while( scanf( "%s", s ) != EOF ){
        ll x = 1, y = 0;
        mem( ret, 0 );
        ret[0] = 1;
        n = strlen( s );
        if( n < 4 ){
            printf( "0\n" );
            continue;
        }

        for( int i = n - 1; i >= 0; i-- ){
            y = ( ( s[i]-'0')*x + y ) % MOD;
            x = x*10%MOD;
            ret[y]++;
        }
        /*ll tmp = 0;
        for( int i = n-1; i >=n-4; i-- ){
            tmp = tmp*10+(s[i]-'0');
            ret[tmp%MOD]--;
        }

        if( n == 4 ){
            if( tmp%MOD )
                printf( "0\n" );
            else{
                ret[0]++;
                printf( "1\n" );
            }
            continue;
        }*/
        ll sum = 0;
        for( int i = 0; i < MOD; i++ )
            sum += ret[i]*(ret[i]-1)/2;
        printf( "%lld\n", sum );
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

int main()
{
	REP(i, 10001){
		int x;
		cin >> x;
		if(x == 0)
			break;

		printf("Case %d: %d\n", i+1, x);
	}

	return 0;
}




Measured memory_bytes: 3120
#include<stdio.h>
#define MAX 100
#define INFTY (2<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX];
int d[MAX];
int color[MAX];

void dijkstra(int n) {
    int u, mincost;
    d[0] = 0;
    color[0] = GRAY;

    while (true) {
        mincost = INFTY;
        u = -1;

        for (int i=0; i<n; i++) {
            if (color[i]!=BLACK && d[i]<mincost) {
                u = i;
                mincost = d[i];
            }
        }

        if (u==-1) break;
        color[u] = BLACK;

        for (int i=0; i<n; i++) {
            if (color[i]!=BLACK && M[u][i]<INFTY) {
                color[i] = GRAY;
                if (d[u]+M[u][i]<d[i]) {
                    d[i] = d[u] + M[u][i];
                }
            }
        }
    }
}

int main() {
    int n, k, v, c, u;
    scanf("%d", &n);

    for (int i=0; i<n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
        for (int j=0; j<n; j++) {
            M[i][j] = INFTY;
        }
    }

    for (int i=0; i<n; i++) {
        scanf("%d %d", &u, &k);
        for (int j=0; j<k; j++) {
            scanf("%d %d", &v, &c);
            M[u][v] = c;
        }
    }

    dijkstra(n);

    for (int i=0; i<n; i++) {
        printf("%d %d\n", i, d[i]);
    }

    return 0;
}


Measured memory_bytes: 2724
#include<stdio.h>

#define N 500000

int MaxH[N];

void MaxHeap(int,int );


int main(){
  int loop;
  int i;

  scanf("%d",&loop);
  for(i=1;i<loop+1;i++){
    scanf(" %d",&MaxH[i]);
  }

  for(i=(loop/2);i>=1;i--){
    MaxHeap(i,loop);
  }

  for(i=1;i<loop+1;i++){
    printf(" %d",MaxH[i]);
  }

  printf("\n");
  
  return 0;
}

void MaxHeap(int Heapn,int loop){
  int left,right,temp;
  int Bscale;

  
  left=2*Heapn;
  right=(2*Heapn)+1;

  if((loop>=left) && (MaxH[Heapn]<MaxH[left])){
    Bscale=left;
  }

  else{
    Bscale=Heapn;
  }

  if((loop>=right) && (MaxH[Bscale]<MaxH[right])){
    Bscale=right;
  }

  if(Heapn!=Bscale){
    temp=MaxH[Heapn];
    MaxH[Heapn]=MaxH[Bscale];
    MaxH[Bscale]=temp;

    MaxHeap(Bscale,loop);
  }
     
}



Measured memory_bytes: 3648
//============================================================================
// Name        : abc124B.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	int count = 0;
	int maxHeight = 0;
	cin >> N;
	for(int i = 0; i < N; ++i){
		int H;
		cin >> H;
		if(maxHeight <= H)++count;
		maxHeight = max(maxHeight, H);
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;
set<string>s;
set<string>visit;
map<string,vector<string> >m;
void S(string&key){
	vector<string>&z=m[key];
	for(int i=0;i<z.size();i++)
		if(m.find(z[i])==m.end())s.insert(z[i]);
		else if(visit.find(z[i])==visit.end())
			visit.insert(z[i]),S(z[i]);
}
main(){
	string str,group,g1,arg;
	for(int n,i,j;cin>>n,n;visit.insert(g1),S(g1),cout<<s.size()<<endl)
		for(m.clear(),s.clear(),visit.clear(),i=0;i<n;i++){
			for(cin>>str,j=0;j<str.length();j++)if(str[j]==':'||str[j]==','||str[j]=='.')str[j]=' ';
			istringstream is(str);
			vector<string>v;
			is>>group;
			if(!i)g1=group;
			for(;is>>arg;)v.push_back(arg);
			m[group]=v;
		}
}

Measured memory_bytes: 1372
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	S := readBytes()
	N := len(S) + 1

	a := make([]int, N)

	for i := 0; i < N-1; i++ {
		if S[i] == '<' {
			a[i+1] = a[i] + 1
		}
	}

	for i := N - 1; 0 < i; i-- {
		if S[i-1] == '>' {
			a[i-1] = max(a[i]+1, a[i-1])
		}
	}

	var ans int
	for i := range a {
		ans += a[i]
	}
	println(ans)
}

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


Measured memory_bytes: 6784
$n = gets.to_i

def dfs(x)
  return 0 if x > $n
  total = 0
  tmp = x.to_s.chars
  if tmp.include?("3") && tmp.include?("5") && tmp.include?("7") && tmp.all?{|a| a == "3" || a == "5" || a == "7"}
    total += 1
  end
  total += dfs(10 * x + 3)
  total += dfs(10 * x + 5)
  total += dfs(10 * x + 7)
  total
end

puts dfs(0)

Measured memory_bytes: 1788
//file_name:ABC68_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    ll x[50] = {};
    ll p = k%50;
    k = k/50;

    rep(i,50-p){
        x[i] = 49 - p - i;
    }
    srep(i,50-p,50){
        x[i] = 50-(i-50+p);
    }
    rep(i,50){
        x[i] += k;
    }

    int g = 50;
    cout << g << endl;
    rep(i,50){
        cout << x[i] << ' ';
    }

    return 0;
}



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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    println!("{}", a.iter().map(|&ai| ai.trailing_zeros()).min().unwrap())
}


Measured memory_bytes: 4352
def d_lamp(H, W, Grid):
    num_left = [[0] * W for _ in range(H)]
    num_right = [[0] * W for _ in range(H)]
    num_down = [[0] * W for _ in range(H)]
    num_up = [[0] * W for _ in range(H)]

    for row in range(H):
        for col in range(W):
            if Grid[row][col] == '.':
                num_left[row][col] = 1 if col == 0 else (num_left[row][col - 1] + 1)

    for row in range(H):
        for col in range(W - 1, -1, -1):
            if Grid[row][col] == '.':
                num_right[row][col] = 1 if col == W - 1 else (num_right[row][col + 1] + 1)

    for col in range(W):
        for row in range(H):
            if Grid[row][col] == '.':
                num_up[row][col] = 1 if row == 0 else (num_up[row - 1][col] + 1)

    for col in range(W):
        for row in range(H - 1, -1, -1):
            if Grid[row][col] == '.':
                num_down[row][col] = 1 if row == H - 1 else (num_down[row + 1][col] + 1)

    ans = max(num_left[row][col] + num_right[row][col] + num_up[row][col]
              + num_down[row][col] - 3 for row in range(H) for col in range(W))
    return ans

H, W = [int(i) for i in input().split()]
Grid = [input() for _ in range(H)]
print(d_lamp(H, W, Grid))

Measured memory_bytes: 178948
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	r := []rune(s)
	ans := 0
	for i:=0; i<n-2; i++ {
		if string(r[i:i+3]) == "ABC" {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,e=0,f=0;
  string c[100],d[100];
  cin>>a;
  for(int i=0;i<a;i++) cin>>c[i];
  cin>>b;
  for(int i=0;i<b;i++) cin>>d[i];
  for(int i=0;i<a;i++){
    e=0;
    for(int j=0;j<a;j++){
      if(c[i]==c[j]) e++;
    }
    for(int j=0;j<b;j++){
      if(c[i]==d[j]) e--;
    }
    f=max(f,e);
  }
  cout<<f<<"\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long s,c;
    while(cin>>s>>c)
    {
        if(c<=s*2)
            cout<<c/2<<endl;
        else
        {
            c+=s*2;
            cout<<c/4<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#min関数は計算量食うので使わない
N=int(input())
A=list(map(int,input().split()))
a=0
m=A[0]
for i in range(N):
    if A[i]<=m:
        a+=1
        m=A[i]#今のA[i]より前に小さい値がある場合に現時点の最小値としてmに記録する
print(a)

Measured memory_bytes: 24872