akhauriyash/Code-Regression huggingface dataset:
//#############################################################################
//----------------------------Karma is Real------------------------------------
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void print_matrix(vector<vector<ll>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
void print_vector(vector<ll> vec){
    for(auto e : vec){cout<< e <<" ";}
    cout<<endl;
}
map<int,int> get_count(vector<ll> vec){
    map<int,int> count;
    for(auto e: vec){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    ll n; cin>>n;
    vector<vector<ll>> hap(n, vector<ll>(3));
    vector<vector<ll>> dp(n, vector<ll>(3,0));
    for(ll i = 0; i<n; i++){
        for(ll j = 0; j<3; j++){
            cin>>hap[i][j];
        }
    }
    dp[0][0] = hap[0][0]; dp[0][1] = hap[0][1]; dp[0][2] = hap[0][2];
    for(ll i = 1; i<n; i++){
        dp[i][0] = hap[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = hap[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = hap[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<*max_element(all(dp[n-1]))<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
    return 0;
}
//#############################################################################


Measured memory_bytes: 13312
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <map>
using namespace std;

map<string, int> d;

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

   for (int i = 0; i < n; i++)
   {
      string s;
      cin >> s;
      d[s]++;
   }

   cout << "AC" << " x " << d["AC"] << "\n";
   cout << "WA" << " x " << d["WA"] << "\n";
   cout << "TLE" << " x " << d["TLE"] << "\n";
   cout << "RE" << " x " << d["RE"] << "\n";

   return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vector<char>> s(h, vector<char>(w));
  for (ll i = 0; i < h; ++i) {
    string tmp;
    cin >> tmp;
    for (ll j = 0; j < tmp.size(); ++j) {
      s[i][j] = tmp[j];
    }
  }

  vector<vector<ll>> seen(h, vector<ll>(w, -1));
  queue<Pll> q;
  q.push(mkp(0, 0));
  seen[0][0] = 1;
  while (!q.empty()) {
    auto pos = q.front();
    q.pop();

    ll y = pos.first;
    ll x = pos.second;
    if (y == h-1 && x == w-1) break;

    vector<ll> dy = {1, -1, 0, 0};
    vector<ll> dx = {0, 0, 1, -1};
    for (ll i = 0; i < 4; ++i) {
      ll ny = y + dy[i];
      ll nx = x + dx[i];
      if (ny < 0 || ny >= h) continue;
      if (nx < 0 || nx >= w) continue;
      if (s[ny][nx] == '#') continue;
      if (seen[ny][nx] >= 0) continue;

      seen[ny][nx] = seen[y][x] + 1;
      q.push(mkp(ny, nx));
    }
  }

  if (seen[h-1][w-1] == -1) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = -1 * seen[h-1][w-1];
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      if (s[i][j] == '.') ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int tmp = s[0] - '0';
    string t = to_string(tmp);
    for (int i = 0; i < n - 1; i++)
    {
        t += '9';
    }
    // cout << t << endl;
    if (stoll(s) >= stoll(t))
    {
        cout << tmp + 9 * (n - 1) << endl;
    }
    else
    {
        cout << tmp - 1 + 9 * (n - 1) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	string s,t;
	cin >> s >> t;
	int n,m;
	n=s.length();
	m=t.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0||j==0)	dp[i][j]=0;
			else{
				if(s[i-1]==t[j-1]){
					dp[i][j]=1+dp[i-1][j-1];
				}
				else{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
	}
	int x,y;
	string ans;
	int sum=-1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(sum<dp[i][j]){
				sum=dp[i][j];
				x=i;
				y=j;
			}
		}
	}
	ans="";
	while(dp[x][y]!=0 && x>=0 && y>=0){
		if(s[x-1]==t[y-1]){
			ans.push_back(s[x-1]);
			x--;y--;
		}
		else{
			if(dp[x][y]==dp[x-1][y]){
				x--;
			}
			else{
				y--;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;



	return 0;
}

Measured memory_bytes: 73960
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>

using namespace std;

class two_value {
public:
  int num;
  int value;
  two_value(int n, int v) {
    num = n;
    value = v;
  }
  static bool cmp(const two_value &a, const two_value &b) {
    return a.value > b.value;
  }
};  

int main() {
  priority_queue<int,vector<int>, greater<int>> q;
  int N, M, B, C;
  cin >> N >> M;
  vector<two_value> tv;  
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    q.push(A);
  }
  for(int i = 0; i < M; i++) {
    cin >> B >> C;
    tv.push_back(two_value(B, C));
  }
  sort(tv.begin(),tv.end(), two_value::cmp);
  unsigned long long sum = 0;
  for(auto set : tv) {
    if(set.value <= q.top())
      break;
    for(int i = 0; i < set.num; i++) {
      if(q.top() < set.value) {
        q.pop();
        q.push(set.value);
      } else 
        break;
    }
  }
  while(!q.empty()) {
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	long long A[200000];
	rep(i, N) {
		cin >> A[i];
	}
	rep1(i, N - 1) {
		A[i] = A[i - 1] + A[i];
	}

	long long kotae = 1e18;

	for (int r2 = 1; r2 <= N - 3; r2++) {

		int l1 = 0;
		int r1 = r2 - 1;
		int l3 = r2 + 1;
		int r3 = N - 2;
		while (l1 != r1) {
			int mid1 = (l1 + r1) / 2 + 1;
			if (A[mid1] <= A[r2] - A[mid1]) l1 = mid1;
			else r1 = mid1 - 1;
		}
		if (abs(2 * A[r1] - A[r2]) > abs(2 * A[r1 + 1] - A[r2])) r1++;
		while (l3 != r3) {
			int mid3 = (l3 + r3) / 2 + 1;
			if (A[mid3] - A[r2] <= A[N - 1] - A[mid3]) l3 = mid3;
			else r3 = mid3 - 1;
		}
		if (abs(2 * A[r3] - A[r2] - A[N - 1]) > abs(2 * A[r3 + 1] - A[r2] - A[N - 1])) r3++;
		long long minimum = 1e18;
		long long maximum = 0;
		minimum = min(minimum, A[r1]);
		minimum = min(minimum, A[r2] - A[r1]);
		minimum = min(minimum, A[r3] - A[r2]);
		minimum = min(minimum, A[N - 1] - A[r3]);
		maximum = max(maximum, A[r1]);
		maximum = max(maximum, A[r2] - A[r1]);
		maximum = max(maximum, A[r3] - A[r2]);
		maximum = max(maximum, A[N - 1] - A[r3]);
		kotae = min(kotae, maximum - minimum);

	}

	cout << kotae << "\n";
	Would you please return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

namespace _0364
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] max = new int[x[0] + 10];
			for (int i = 0; i < x[2]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				if (a[0] > 0) max[a[0] - 1] = Math.Max(max[a[0] - 1], a[1]);
			}
			int n = 0;
			for (int i = x[0]; i >= 0; i--)
			{
				n = Math.Max(n, max[i]);
				max[i] = n;
			}
			int ret = int.MaxValue;
			for (int i = 0; i <= x[0]; i++)
			{
				ret = Math.Min(ret, i + max[i]);
			}
			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 24576
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

vector <int> prime;
bool isprime[300001];

void make_prime(void)
{
	fill(isprime, isprime + 300001, true);
	for (int i = 2; i < 300001; i++){
		if (((i % 7) != 1 && (i % 7) != 6) || isprime[i] == false){
			isprime[i] = false;
			continue;
		}
		else{
			prime.push_back(i);
			for (int j = i+i; j < 300001; j += i){
				isprime[j] = false;
			}
		}
	}
	return;
}

int main(void)
{
	make_prime();

	int n;
	while (cin >> n){
		if (n == 1){
			break;
		}
		vector <int> ret;
		for (int i = 0; i < prime.size(); i++){
			if (n % prime[i] == 0){
				ret.push_back(prime[i]);
			}
			if (n < prime[i]){
				break;
			}
		}
		sort(ret.begin(), ret.end());
		int prev = -1;
		cout << n << ":";
		for (int i = 0; i < ret.size(); i++){
			if (prev != ret[i]){
				cout << " " << ret[i];
				prev = ret[i];
			}
		}
		puts("");
	}

	return 0;
}

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

int main() {
	int X, Y;
	cin >> X >> Y;
	int ans;
	ans = X + Y/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=0;i<=n;i++) cin>>a[i];
    vector<int> b(n);
    for(int i=0;i<n;i++) cin>>b[i];

    ll res=0;
    for(int i=0;i<n;i++){
        int tmp=min(a[i],b[i]);
        res+=tmp;
        b[i]-=tmp;
        a[i]-=tmp;
        tmp=min(a[i+1],b[i]);
        res+=tmp;
        b[i]-=tmp;
        a[i+1]-=tmp;
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while (true) {
			int x = sc.nextInt();
			count++;
			if (x == 0) {
				break;
			}
			System.out.println("Case " + count + ": " + x);
		}
	}
}

Measured memory_bytes: 41492
# Collatz Problem

s = int(input().strip())

ai = [s]
for i in range(2, 10**9):
	if ai[-1] % 2 == 0:
		am = int(ai[-1]/2)
	else:
		am = int(3*ai[-1]+1)
	
	if am in ai:
		print(i)
		break
	else:
		ai.append(am)

Measured memory_bytes: 3060
N, X = list(map(int, input().split()))
mem = []
pt = []
mem.append(1)
pt.append(1)
for i in range(50):
    mem.append(mem[i] * 2 + 3)
    pt.append(pt[i] * 2 + 1)


def check_pt(n, layer, nowpt):
    if n == 0:
        return nowpt + 1
    elif layer == 1:
        return nowpt
    elif layer == mem[n]:
        return nowpt + pt[n]
    elif layer < mem[n - 1] + 2:
        return check_pt(n - 1, layer - 1, nowpt)
    elif layer == mem[n - 1] + 2:
        return check_pt(n - 1, layer - 2, nowpt + 1)
    else:
        return check_pt(n - 1, layer - (mem[n - 1] + 2), nowpt + pt[n - 1] + 1)


print(check_pt(N, X, 0))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    {
        cout<<"1"<<endl;
    }
    else if(b==0)
    {
        cout<<"2"<<endl;
    }
    else if(c==0)
    {
        cout<<"3"<<endl;
    }
    else if(d==0)
    {
        cout<<"4"<<endl;
    }
    else
    {
        cout<<"5"<<endl;
    }

    return 0;
}




Measured memory_bytes: 3588
"use strict";

function main(arg) {
    //    console.log(arg.trim().split("\n"));
    let ary = arg.trim().split(" ").map(n => Number(n));
    let sheep = ary.shift();
    let wolf = ary.shift();
    console.log(wolf >= sheep ? 'unsafe' : 'safe');

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

  int ans=1;
  string sub=s.substr(0, 1);

  for(int i=1; i<s.size(); ++i){
    if(sub==s.substr(i, 1)){
      if(i+1<s.size()){sub=s.substr(i, 2); ++ans; ++i;}
    }else{
      sub=s.substr(i, 1); ++ans;
    }
  }
  

  cout<<ans<<endl;
}

Measured memory_bytes: 640
#coding:utf-8
n = int(input())
A = list(map(int, input().split()))
B = A[:]
B.sort()
C = [True for i in range(n)]
minA = min(A)

j = 0
a = []
total = 0
for i in range(n):
    circle = []
    j = i
    while C[j]:
        C[j] = False
        j = B.index(A[j])
        circle.append(A[j])
    n_c = len(circle)
    if n_c == 2:
        total += (circle[0]+circle[1])
    if n_c > 2:
        minc = min(circle)
        cirSum = sum(circle)
        total += min( cirSum + (n_c-2) * minc , cirSum + minc + (n_c+1)*minA)
    a.append(circle)
    

print(total)



Measured memory_bytes: 5724
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(int x, int y) { ll ans = 1; for (; y; y >= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll comb(int n, int m) {
	if(n<m)return 0;
	ll ans = 1;
	if (m > n - m)m = n - m;
	_for(i, n - m + 1, n + 1)ans *= i;
	_for(i, 1, m + 1)ans = ans /i;
	return ans;
}
int main(){
	FIO;
	int n,m;cin>>n>>m;
	cout<<comb(n,2)+comb(m,2);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

        // input
        char[] input = scan.next().toCharArray();

        // search
        char temp1 = input[0];
        char temp2 ='t';
        int count = 1;
        String answer = "Yes";
        for(int i = 1; i < input.length; i++){
            if(temp1 != input[i] && count == 1){
                temp2 = input[i];
                count++;
            } else if(count == 2 && temp1 != input[i] && temp2 != input[i]){
                answer = "No";
            }
        }
        if(count == 1){
            answer = "No";
        }

        // answer
        System.out.println(answer);

    }
}

Measured memory_bytes: 23892
#include <stdio.h>

int func(int x) {
	return x * x;
}

int main() {
	int d;
	int ans;
	int i;

	while(scanf("%d", &d) != EOF) {
		ans = 0;

		for(i = 0; i < 600 / d; i++)
			ans += d * func(i * d);

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> V;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        V.push_back(tmp);
    }
    sort(V.begin(), V.end());
    double ans=V[0]+V[1];
    ans=ans/2;
    for(int i=2;i<N;i++){
        ans=(ans+V[i])/2;
    }
    cout << ans << endl;
    return 0;
}

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

int main (){
    set<pair<int,int> >s1,s2;
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;scanf("%d %d",&x,&y);
        s1.insert(make_pair(x,y));
    }
    for(int i=0;i<n;i++){
        int x,y;scanf("%d %d",&x,&y);
        s2.insert(make_pair(x,y));
    }
    int ans=0;
    /*set<pair<int,int> >::iterator it;
    for(it=s1.begin();it!=s1.end();it++){

        set<pair<int,int> >::iterator jt=s2.begin(),x=s2.end();

        for(;jt!=s2.end()&&(it->first<jt->first);jt++){
            if(( it->first < jt->first) && it->second < jt->second){
                 if(x==s2.end()||(x->first==jt->first&&x->second>jt->second)) x=jt;
            }

        }
        if(x!=s2.end()) {
            ans++;
            s2.erase(x);
        }
    }*/
    for(set<pair<int,int> >::iterator it=s2.begin();it!=s2.end();it++){
		set<pair<int,int > >::iterator jt=s1.begin(),x;
		x=s1.end();
		for(;jt!=s1.end()&&jt->first<it->first;jt++){
			if(jt->first<it->first&&jt->second<it->second){
				if(x==s1.end()||x->second<jt->second){
					x=jt;
				}
			}
		}
		if(x!=s1.end()){
			ans++;
			s1.erase(x);
		}
	}
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

inp = input().split(' ')
N = int(inp[0])
T = int(inp[1])
flag = False
ans_cost = 1001

for i in range(N):
    inp = input().split(' ')
    c = int(inp[0])
    t = int(inp[1])
    
    if t <= T:
        if ans_cost >= c:
            flag = True
            ans_cost = c

if flag == True:
    print(ans_cost)
else:
    print('TLE')


Measured memory_bytes: 3064
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for(int i=0;i<n;i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	int cnt = 0;
	int ptr = 1;
	cin >> n;
	vector<int>a(n);
	vector<bool>b(n);
	loop(n) {
		cin >> a[i];
		b[i] = false;
	}
	while(true) {
		cnt++;
		if (b[ptr-1] == true) {
			cout << -1 << endl;
			return 0;
		}
		b[ptr-1] = true;
		ptr = a[ptr - 1];
		if (ptr == 2) {
			cout << cnt << endl;
			return 0;
		}
	}
	return 0;
}

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

template<typename T> void print(const T & v);


int main() {
    vector<int> dishes(5);
    rep(i, 5) cin >> dishes[i];
    int mini = 10;
    int total = 0;
    rep(i, 5){
        total += ((dishes[i] + 9) / 10) * 10;
        int amari = dishes[i] % 10;
        if(amari){
            mini = min(mini, amari);
        }
    }
    total = total - 10 + mini;
    cout << total << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int a;
	cin >> a;
	
	cout << a + (a*a) + (a*a*a);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M, Q;
int val[100050];
int num[100050];
int inv[100050];
bool canignore[100050];
int a[100050];
int allappeared = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    int index = 0;
    for(int i = Q; i >= 1; i--) cin >> a[i];
    for(int i = 1; i <= Q; i++) {
        if(inv[a[i]] != 0) continue;
        index++;
        inv[a[i]] = index;
        val[index] = a[i];
        if(allappeared == a[i] - 1) canignore[a[i]] = true;
        while(inv[allappeared+1] != 0) allappeared++;
    }
    /*
    while(index >= 1 && allappeared[val[index]]) {
        inv[val[index]] = 0;
        val[index] = 0;
        index--;
    }
    */
    cerr << index << endl;
    for(int i = 1; i <= index; i++) {
        //cerr << val[i] << " " << canignore[val[i]] << endl;
    }
    num[0] = N;
    for(int i = 1; i <= Q; i++) {
        int nowindex = inv[a[i]];
        if(nowindex == 0) continue;
        num[nowindex]++;
        chmin(num[nowindex], num[nowindex-1]);
        /*
        if(num[nowindex] > num[nowindex-1]) {
            cout << "No" << endl;
            return 0;
        }
        */
    }
    for(int i = 1; i <= index; i++) {
        if(!canignore[val[i]] && num[i] != N) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S>
void print(vector<S> &v){
	for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}


int main(){
	int n,m; cin >> n >> m;
	vector<vector<int>> adj(n);
	Rep(m){
		int a,b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
	}
	queue<int> q;
	vector<int> ans(n,-1);
	int able = 1;
	q.push(0);
	while(!q.empty()){
		int a=q.front();
		q.pop();
		for(int ad: adj[a]){
			if(ans[ad] == -1){
				ans[ad]=a;
				q.push(ad);
				able++;
			}
		}
	}
	if(able <  n) cout << "No\n";
	else{
		cout << "Yes\n";
		for(int i=1; i<n; i++){
			cout << ans[i]+1 << endl;
		}
	}
}

Measured memory_bytes: 10048
import time
import  random
def main():
    start = time.time()
    for d in range(D):
        res[d] = d%26
    ma = check(res)
    
    while 1:
        idx1 = random.randint(0,D-1)
        idx2 = random.randint(0,D-1)
        if idx1==idx2:
            continue
        taihi = res[idx1]
        res[idx1] = res[idx2]
        res[idx2] = taihi
        tmp = check(res)
        if tmp > ma:
            ma = tmp
        else:
            res[idx2] = res[idx1]
            res[idx1] = taihi
        if time.time() - start > 1.75:
            break
    return res

def check(res):
    last = [0] * 26
    score = 0
    for d in range(D):
        sd = s[d]
        score += sd[res[d]]
        last[res[d]] = d+1
        for i in range(26):
            score -= c[i]*(d+1-last[i])
    return score

if __name__ == '__main__':
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    res = [0] * D
    ans = main()
    for val in ans:
        print(val+1)

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

typedef struct {
    int m;
    int t;
    int p;
    int j;
} LOG;

typedef struct {
    int team;
    int score;  // 問題数*10000 + 5000 - 合計(提出時間 + ペナルティ) 
} TEAM;




int comp(const void *a, const void *b)
{
    int score;
    
    score = (*(TEAM *)b).score - (*(TEAM *)a).score;

    if (score != 0){
        return (score);
    }
    return ((*(TEAM *)b).team - (*(TEAM *)a).team);
}


int main(void)
{
    int M, T, P, R;
    LOG log[2000];
    TEAM team[50];
    int i, k;
    
    while (1){
        scanf("%d%d%d%d", &M, &T, &P, &R);
        if (M == 0 && T == 0 && P == 0 && R == 0){
            break;
        }
        
        for (i = 0; i < T; i++){
            team[i].team = i + 1;
            team[i].score = 90000;
        }
        
        for (i = 0; i < R; i++){
            scanf("%d%d%d%d", &log[i].m, &log[i].t, &log[i].p, &log[i].j);
            if (log[i].j == 0){
                team[log[i].t - 1].score += 100000;
                team[log[i].t - 1].score -= log[i].m;
                for (k = i - 1; k >= 0; k--){
                    if (log[k].t == log[i].t && log[k].p == log[i].p && log[k].j != 0){
                        team[log[i].t - 1].score -= 20;
                    }
                }
            }
        }
        
        qsort(team, T, sizeof(TEAM), comp);
        
        for (i = 0; i < T; i++){
            printf("%d", team[i].team);
            if (i < T - 1){
                if (team[i].score > team[i + 1].score){
                    printf(",");
                }
                else {
                    printf("=");
                }
            }
        }
        printf("\n");
    }
    return (0);
}



Measured memory_bytes: 2064
N, M = map(int, input().split())

s = []
c = []
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  s.append(tmp1-1)
  c.append(tmp2)

digit = [-1, -1, -1]

for i in range(M):
  if digit[s[i]] < 0:
    digit[s[i]] = c[i]
  else:
    if not(digit[s[i]] == c[i]):
      print("-1")
      exit()

if M==0:
  if N==1:
    print("0")
    exit()
  print(str(10**(N-1)))
  exit()
      
if ((N == 1) and (digit[0] == 0)):
  print("0")
  exit()
    
if digit[0] == 0:
  print("-1")
  exit()

if digit[0] < 0:
  digit[0] = 1
  
output = ""
  
for i in range(N):
  if digit[i] < 0:
    output += "0"
    continue
  output += str(digit[i])
  
print(output)
  

Measured memory_bytes: 3064
from math import log2, ceil

N, K = map(int, input().split())

ans = 0.

for k in range(1, N+1):
    if k >= K:
        ans += 1. / float(N)
        continue
    tmp1 = float(ceil(log2(K / k)))
    tmp = 0.5**tmp1
    ans += tmp / float(N)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define MAX 100000
#define NIL -1

struct Node {
  int p, l, r;
};

Node T[MAX+1];

int getDepth(int u){
  int c = 0;
  while(T[u].p != NIL){
    u = T[u].p;
    c ++;
  }
  return c;
}

void printChildren(int u){
  int c = T[u].l;
  int cnt = 0;
  while(c != NIL){
    if ( cnt ){ cout << ", "; }
    cout << c;
    c = T[c].r;
    cnt ++;
  }
}

string getType(int u){
  if ( T[u].p == NIL){ return "root";}
  else if ( T[u].l == NIL){ return "leaf";}
  else {return "internal node";}
}

int main() {
  int n;
  cin >> n;
  int id, k, c, l;

  for ( int i = 0; i < n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for ( int i = 0; i < n; i++){
    cin >> id >> k;
    for ( int j = 0; j < k; j++){
      cin >> c;
      T[c].p = id;
      if(j == 0){T[id].l = c;}
      else {T[l].r = c;}
      l = c;
    }
  }

  for ( int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << T[i].p << ", " << "depth = " << getDepth(i) << ", " << getType(i) << ", " << "[";
    printChildren(i);
   cout  << "]" << endl;
  }


  return 0;
}


Measured memory_bytes: 4400
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}
	// fmt.Println(n, k, xs)

	var ans int
	for _, x := range xs {
		ans += min(abs(x-k), x) * 2
	}
	fmt.Println(ans)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
ll lookup[101][501];

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

 

int main()
{
    fast;
    ll n;
    ld m;
    cin>>n>>m;
    ld a[n];
    ld sum=0;
    for(ll i=0;i<n;i++) 
    {
        cin>>a[i];
        sum+=a[i];
    }
    ll c=0;
    for(ll i=0;i<n;i++)
    {
       if(a[i] >= sum/(4*m))
       {
          c++;
       }
    }
    if(c>=m) cout<<"Yes";
    else cout<<"No";


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int i, n, *a;
    cin >> n;
    a = new int[n];
    for (i = 0; i < n; i++)
        cin >> a[i];

    int min = a[0], max = a[0];

    for (i = 1; i < n; i++) {
        if (min > a[i])
            min = a[i];
        if (max < a[i])
            max = a[i];
    }
    cout << max - min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n; cin>>n;
    n=(n-2LL)*(180LL);
    cout<<n;

      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 

    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1] = tolower(s[k-1]);
    cout<<s<<"\n";
}


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

namespace Matrix_Multiplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int l = int.Parse(input[2]);

            List<long> nm = new List<long>();
            List<long> ml = new List<long>();

            for (int i = 0; i < n; i++)
            { 
                string[] temp = Console.ReadLine().Split(' ');

                for (int j = 0; j < temp.Length; j++)
                {
                    nm.Add(long.Parse(temp[j]));
                }
            }

            for (int i = 0; i < m; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');

                for (int j = 0; j < temp.Length; j++)
                {
                    ml.Add(long.Parse(temp[j]));
                }
            }

            List<long> nl = new List<long>();

            


            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < l; ++j)
                {
                    long sum = 0;
                    for (int k = 0; k < m; ++k)
                    {
                        sum += nm[k + i * m] * ml[k * l + j];
                    }
                    nl.Add(sum);
                }
            }   


            int count = 0;

            foreach (long item in nl)
            {
                Console.Write(item);
                if ((count + 1) % l == 0)
                {
                    Console.WriteLine();
                }
                else
                {
                    Console.Write(" ");
                }

                ++count;
            }


        }
    }
}



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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int Alice = 0, Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i == 0 || i % 2 == 0) {
            Alice += vec.at(i);
        }else{
            Bob += vec.at(i);
        }
    }
    cout << Alice - Bob << endl;

}


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

string S;
int main() {
    cin >> S;

    bool f = false;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S.substr(i, 2) == "AC") {
            f = true;
            break;
        }
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string s; cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i += 2) {
    ans += s.at(i);
  }
  cout << ans << endl;
}

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

#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m,s,t;
vi adj[100005];
bool vis[100005][3];
int ans[100005][3];

void bfs(int so)
{
	
	queue<pii> Q;Q.push({so,0});vis[so][0]=true;
	ans[so][0]=0;
	while(!Q.empty())
	{
		auto te=Q.front();Q.pop();
		int next=(te.ss+1)%3;
		
		for (auto x:adj[te.ff])
		{
			if (vis[x][next])continue;
			vis[x][next]=true;
			if (next!=1)ans[x][next]=ans[te.ff][te.ss];
			else ans[x][next]=ans[te.ff][te.ss]+1;
			Q.push({x,next});
		}

	}

}



void solve()
{
	cin>>n>>m;int u,v;rep(i,0,m)cin>>u>>v,adj[u-1].pb(v-1);cin>>s>>t;s--;t--;


	memset(vis,0,sizeof vis);
	rep(i,0,n)rep(j,0,3)ans[i][j]=MOD;
	bfs(s);
	if (!vis[t][0])cout<<"-1";
	else cout<<ans[t][0];
	cout<<"\n";
	/*rep(i,0,n)cout<<ans[i][0]<<" ";
	cout<<"\n";
	rep(i,0,n)cout<<ans[i][1]<<" ";
	cout<<"\n";
	rep(i,0,n)cout<<ans[i][2]<<" ";*/


}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif


    int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


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

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    
    int ans = 0;
    rep(i,n) {
        if((i+1)%2 == 0) continue;
        if(a.at(i)%2 == 0) continue;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 2005;

int c[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int mod = 1e9 + 7;
    rep(i, 0, (int)N) {
        c[i][0] = 1;
        rep(j, 1, i + 1) {
            c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
            if(c[i][j] >= mod) {
                c[i][j] -= mod;
            }
        }
    }
    int n, k;
    cin >> n >> k;
    rep(i, 1, k + 1) {
        int ans = int(c[n - k + 1][i] * (ll)c[k - 1][i - 1] % mod);
        cout << ans << endl;
    }
}

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

using namespace std;

typedef long long lli;

const int N = 200000 + 10;
const lli inf = 1000000000LL * 1000000000LL;

lli a[N], b[N];
int n, s, t;
lli k;

bool check1(lli x)
{
	lli c;
	int i;
	c = 0;
	for (i=0; i<s; i++)
		if (x % a[i] == 0) c += b + t - lower_bound(b, b + t, x / a[i]);
		else c += b + t - upper_bound(b, b + t, x / a[i]);
	return c >= k;	
}

bool check2(lli x)
{
	lli c;
	int i;
	c = 0;
	for (i=0; i<s-1; i++) 
		if (x / a[i] >= a[i]) c += a + s - lower_bound(a + i + 1, a + s, x / a[i]);
		else c += s - i - 1;
	for (i=0; i<t-1; i++) 
		if (b[i] == 0) c += t - i - 1;
		else c += max(0, (int)(upper_bound(b, b + t, x / b[i]) - b - i - 1));
//	cout<<x<<" "<<c<<endl;	
	return c >= k;
}

int main()
{
	lli low, high, mid;
	int x, i;
	cin>>n>>k;
	s = t = 0;
	for (i=0; i<n; i++) 
	{
		cin>>x;
		if (x < 0) a[s++] = x; else b[t++] = x;
	}
	sort(a, a + s);
	sort(b, b + t);
	if (k <= 1LL * s * t)
	{
		low = a[0] * b[t-1];
		high = a[s-1] * b[0];
		while (low <= high)
		{
			mid = (low + high) / 2;
			if (check1(mid)) high = mid - 1;
			else low = mid + 1;
		}
		cout<<low<<endl;
	}
	else
	{
		k -= 1LL * s * t;
		low = 0;
		high = inf;
		while (low <= high)
		{
			mid = (low + high) / 2;
			if (check2(mid)) high = mid - 1;
			else low = mid + 1;
		}
		cout<<low<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
use std::vec::Vec;
use std::cmp::min;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, k) = read_touple::<i64>();
    let x = (n - (n / k) * k).abs();
    let y = (n - ((n + k - 1) / k) * k).abs();
    let ans = min(x, y);
    println!("{}", ans);
}


Measured memory_bytes: 4352
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int x, y, z;
  x = A + B;
  y = A - B;
  z = A * B;
  int ans;
  ans = max({x, y, z});
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    long long a[n],sum=1;
    for(i=0;i<n;i++) scanf("%lld",&a[i]);
    for(i=0;i<n;i++){
        if(a[i]==0){
            printf("0");
            return 0;
        }
    }
    for(i=0;i<n;i++){
        if(a[i]>1000000000000000000/sum){
            printf("-1");
            return 0;
        }
        else sum*=a[i];
    }
    printf("%lld",sum);
}

Measured memory_bytes: 2500
n,k = gets.split.map(&:to_i)
ab = n.times.map{gets.split.map(&:to_i)}
ab.sort!{|a,b| a[0]<=>b[0]}
ab.each{|a,b|
  k-=b
  if k<=0 then
    puts a
    exit
  end
}


Measured memory_bytes: 10512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0) {
            if (tmp % 3 != 0 && tmp % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}


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

int main(void){
	string S;
	cin >> S;
	int a=0,b=0;
	//0101のパタン
	for(int i=0;i<S.size();i++){
		if(i%2==0){
			if(S[i]=='1'){
				a++;
			}
		}else{
			if(S[i]=='0'){
				a++;
			}
		}
	}
	for(int i=0;i<S.size();i++){
		if(i%2==0){
			if(S[i]=='0'){
				b++;
			}
		}else{
			if(S[i]=='1'){
				b++;
			}
		}
	}
	cout << min(a,b) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){

  int in;
  int h,m,s;
  scanf("%d",&in);

  h = in / 3600;
  in %= 3600;

  m = in / 60;
  in %= 60;

  s = in;

  printf("%d:%d:%d\n",h,m,s);
}

Measured memory_bytes: 1808
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n,-1);
    vector<int> prev(n);
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(int u:to[v]){
            if(dist[u]!=-1)continue;
            dist[u]=dist[v]+1;
            prev[u]=v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0)continue;
        cout << prev[i] + 1 << endl;
    }
}

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

int main(){
  string n;
  cin >> n;
  if(n.at(0) == '9' || n.at(1) == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int d, r;
	double a, b, f;
	scanf("%lf %lf", &a, &b);
	d = a / b;
	r = (int)a % (int)b;
	f = a / b;
	printf("%d %d %.5f\n", d, r, f);
	return 0;
}

Measured memory_bytes: 652
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll a, b; cin >> a >> b;

    cout << (b - 1 + a - 2) / (a - 1) << endl;
    
}

Measured memory_bytes: 256
/*author @dhanush*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first

int main()
{



  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int>red;
  vector<int>white;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'R')
      red.pb(i);
    else
      white.pb(i);
  }
  int r = red.size() - 1;
  int l = 0;
  int cnt = 0;
  while (l < white.size() && r >= 0 && white[l] < red[r])
  {
    cnt++;
    l++;
    r--;
  }
  cout << cnt << endl;
  return 0;

}





Measured memory_bytes: 4696