akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;



map<int,int> prime(int n ){
    map<int,int> ret;
    while(n%2 == 0){
        n/=2;
        ret[2]++;
    }
    for(int i = 3; i*i <= n; i = i + 2){
        while(n%i == 0){
            n/=i;
            ret[i]++;
        }
    }
    if (n>2) ret[n]++;
    return ret;
}

bool ok;

void dfs(vector<int>& ps, vector<int>& pw, int i, int v,map<int,int>& seen){
    if (i == pw.size()){
        if (v==1) return;
        ok |= seen[v];
        //cout << v << endl;
        return;
    }
    for(int j = 0; j <= pw[i]; j++){
        dfs(ps,pw,i+1,v*pow(ps[i],j),seen);
    }
}

bool check(map<int,int>& p, map<int,int>& seen){
    ok = false;
    vector<int> ps,pw;
    for(auto e:p){
        ps.push_back(e.first);
        pw.push_back(e.second);
    }
    dfs(ps,pw,0,1,seen);
    return ok;
}

void solve(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    if (n==1){
        cout << 1;
        return;
    }
    SORT(a);
    if (a[0] == a[n-1]){
        cout << 0;
        return;
    }
    int ans = 0;
    map<int,int> seen;
    map<int,int> count;
    rep(i,n){
        count[a[i]]++;
    }
    for(int i = 0; i < n; i++){
        if (a[i] == 1){
            if (count[1] == 1){
                cout << 1;
                return;
            }
            cout << 0;
            return;
        }
        if (count[a[i]] > 1){
            ans++;
            seen[a[i]] = 1; 
            continue;
        }
        auto p = prime(a[i]);
        
        if (check(p,seen)) ans++;
        seen[a[i]] = 1;
    }
    
    cout << n - ans;
}


int main(){
    int T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}


Measured memory_bytes: 42516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int ans = 1000 - N % 1000;
		if(ans == 1000) {
			System.out.println(0);
		}else {
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 35584
# ABC123A - Five Antennas
lst = list(map(int, [input() for _ in range(5)]))
k = int(input())
answer = "Yay!"
count = 0

for i in range(4, 0, -1):
    count += 1
    for j in range(4 - count):
        if lst[i] - lst[j] > k:
            answer = ":("

print(answer)

Measured memory_bytes: 3060
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string t;
    cin>>t;
    ll res = 0;
    rep(i,1000){
     //   cout<<i<<endl;
        vector<int> vec(3);
        string s = to_string(i);
        int temp = 2;
       // cout<<s<<endl;
        for (int j = s.size() - 1; j >= 0;j--)
        {
            vec[temp] = s[j]-'0';
        //    cout<<s[j]<<" "<<temp<<endl;
            temp--;
            
        }
        //cout<<vec
        //cout<<"h"<<vec[3]<<endl;
        //rep(j,4)cout<<vec[j];
        //cout<<endl;
        int temp2 = 0;
        rep(j,t.size()){
         //   if(i==24)cout<<temp2<<endl;
            if(t[j]-'0'==vec[temp2]){
           //     if(i==24)cout<<" "<<t[j]<<endl;
                temp2++;
            }
            if(temp2==3){
               // cout<<i<<endl;
                res++;
                break;
            }
                
        }
     //   if(i==24)cout<<endl;
        
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010



int main(){
  int n;
  int a, t[11];
  
  scanf("%d",&n);

  ll ans = 1;

  for(int i=0;i<n;i++){
    scanf("%d",&a);

    if(a%2 == 0){
      t[i] = 2;
    }else{
      t[i] = 1;
    }
    
    ans *= 3;
  }

  ll p = 1;

  for(int i=0;i<n;i++){
    p *= t[i];
  }

  cout << ans - p<< endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   vector<int> a(200010,0);
   ll syurui=0;
   rep(i,n){
      int x;
      cin>>x;
      if(a[x]==0) {
         syurui++;
         a[x]++;
      }
      else{
         a[x]++;
      }
   }
   int p=syurui-k;

   vector<int> b;
   rep(i,200010){
      if(a[i]!=0){
         b.push_back(a[i]);
      }
   }
   sort(b.begin(),b.end());
   int ans=0;
   rep(i,p){
      ans+=b[i];
   }
   cout<<ans;
   return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  string s, t;
  cin >> s >> t;

  if (s.length() < t.length()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  string ans = "~";
  rep(i, 1 + s.length() - t.length()) {
    string cand = s;
    bool match = true;
    rep(j, t.length()) {
      if (s[i + j] != '?' && s[i + j] != t[j]) {
        match = false;
        break;
      }
      cand[i + j] = t[j];
    }
    if (match) {
      rep(j, cand.size()) {
        if (cand[j] == '?') {
          cand[j] = 'a';
        }
      }
      chmin(ans, cand);
    }
  }

  if (ans == "~") {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,h; cin>>n>>h; 
    int mx=0;
    priority_queue <int> pq;
    while (n--){
        int a,b; cin>>a>>b;
        mx = max(mx,a);
        pq.push(b);
    }
    int ans=0,cur=0;
    while (pq.size() && pq.top()>mx and h>0){
        h -= pq.top();
        ans++;
        pq.pop();
    }
    if (h>0) ans += (h+mx-1)/mx;
    printf("%lld\n",max(1LL,ans));
}

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


Measured memory_bytes: 4208
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int a, b, cnt = 0, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
            if (cnt == k) {
                cout << i << "\n";
                return;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
h, n = map(int, input().split())
magics = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a, b in magics)
dp = [0] * (h + max_a)
for i in range(1, h + max_a):
    dp[i] = min(dp[i - a] + b for a, b in magics)
print(dp[h])

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 200000+10;
const int dem = 2; 
const double INF = (1e200);

struct Point{
    double x[dem];
}p[maxn];

int n;
double minx[1<<dem], maxx[1<<dem];

double solve() {
    int tmp = 1<<dem;

    for(int i=0; i<tmp; i++) {
        minx[i] = INF;
        maxx[i] = -INF;
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<tmp; j++) {
            int t = j;
            double s = 0;
            for(int k=0; k<dem; k++) {
                if(t & 1) s += p[i].x[k];
                else s -= p[i].x[k];
                t >>= 1;
            }
            if(maxx[j] < s) maxx[j] = s;
            if(minx[j] > s) minx[j] = s;
        }
    }

    double ans = -INF;
    for(int i=0; i<tmp; i++) {
        if(maxx[i] - minx[i] > ans)
            ans = maxx[i] - minx[i];
    }

    return ans;
}

int main(){

    while(scanf("%d", &n) != EOF) {
        for(int i=0; i<n; i++) {
            for(int j=0; j<dem; j++) {
                scanf("%lf", &p[i].x[j]);
            }
        }
        printf("%.0f\n", solve());
    }

    return 0;
}

Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int main() {
	int64_t N;
	cin >> N;
	int64_t a=0, b=0, c=0, x, y, z;
	double m = sqrt(N);
	if (N == 1) {
		std::cout << "1" << '\n';
		return 0;
	} else {
		a = N*(1+N)/2;
		for (int64_t i = 2; i <= N; i++) {
			a += (N/i)*(i+(N-N%i))/2;
		}
	}
	std::cout << a << '\n';
}


Measured memory_bytes: 3668
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)



int main() {
	int x;
	cin >> x;
	int i = 1;
	while (true) {
		if (i*(i + 1) / 2 >= x) {
			cout << i << endl;
			break;
		}
		i++;
	}

	
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int d,n;
  cin >> d >> n;
  
  int cnt = n;int ans = 0;
  while(cnt != 0){
    ans++;
    int A = ans,c=0;
    while(A%100 == 0){
      c++;
      A /= 100;
    }
    if(c == d) cnt--;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int ans[100001];
int arr[100001];
int func(int n)
{
    if(ans[n]!=-1)
    return ans[n];
    
    
    
    int a = func(n-1)+abs(arr[n]-arr[n-1]);
    int b = func(n-2)+abs(arr[n]-arr[n-2]);
    ans[n] = min(a,b);
    return ans[n];
}
int main()
{
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>arr[i];
    for(i=1;i<=n;++i)
    ans[i]=-1;
    ans[0] = 1e9;
    ans[1] = 0;

    int final = func(n);
    cout<<final<<endl;
}

Measured memory_bytes: 4096
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val sn = Math.sqrt(n.toDouble())
    var sum = 0L
    for (i in 1..sn.toLong()) {
        if ((n - i) % i == 0L) {
            var x=(n - i) / i
            if (x>i) {
                sum += x
            }
        }
    }
    println(sum)
}


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

int main() {
    int N;
    cin >> N;
    vector<vector<vector<int> > > vec(4, vector<vector<int> >(3, vector<int>(10, 0)));
    
    for (int i = 0; i < N; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        vec.at(b-1).at(f-1).at(r-1) += v;
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << ' ' << vec.at(i).at(j).at(k);
                if (k == 9) {
                    cout << endl;
                }
            }
        }
        if (i != 3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3168
#include <stdio.h>
#define MAX_NUM 200000
int main (void){
    int R[MAX_NUM];
    int ans;
    int i,n;
    int R_min;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&R[i]);
    }
    R_min=R[0];
    ans = R[1]-R[0];
    for(i=1;i<n;i++){
        if(R[i]-R_min>ans) ans=R[i]-R_min;
        if(R_min>R[i]) R_min=R[i];
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1376
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
        int ans = 1;
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
        }
        for(int i = 1; i < n; i++){
            int count = 0;
        	for(int j = 0; j < i; j++){
            	if(num[i] >= num[j]){
                	count++;
                }else{
                	break;
                }
            }
            if(count == i){
            	ans++;
            }
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "YES";
const string NO = "NO";
#define pb push_back
#define mp make_pair

set<string> dic;
string s;
int N;

bool dfs(int pos)
{
	if(pos == N) return true;
	bool res = false;
	for(auto ss : dic){
		if(pos + ss.length() <= N && s.substr(pos, ss.length()) == ss){
			res |= dfs(pos + ss.length());
			if(res) return true;
		}
	}
	return false;
}

void solve()
{
	dic.emplace("dream"); dic.emplace("dreamer");
	dic.emplace("erase"); dic.emplace("eraser");
	N = s.length();
	if(dfs(0)) cout << YES << endl;
	else cout << NO << endl;
}

int main()
{
	cin >> s;
	solve();
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int N; cin >> N;
    vi x(N), y(N), h(N);
    rep (i, N) cin >> x[i] >> y[i] >> h[i];

    int MAX = 100;
    rep (posY, MAX + 1) {
        rep (posX, MAX + 1) {

            int needH = -1;

            rep (i, N) {
                if (h[i] > 0) {
                    int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                    if (needH == -1)  needH = tmp;
                    else {
                        if (needH != tmp) {
                            needH = -2;
                            break;
                        }
                    }
                }
            }

            if (needH == -2) continue;

            rep (i, N) {
                if (h[i] == 0) {
                    int dist = abs(posY - y[i]) + abs(posX - x[i]);
                    if (needH > dist) {
                        needH = -2;
                        break;
                    }
                }
            }

            if (needH == -2) continue;

            cout << posX << " " << posY << " " << needH << endl;
            return 0;
        }
    } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll a,b,n;

ll check(ll x){
	return (a*x)/b-a*(x/b);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>n;
	ll L=1,R=n;
	while(R>L){
		ll m1=L+(R-L)/3;
		ll m2=R-(R-L)/3;
		if(check(m1)>check(m2))
			R=m2-1;
		else
			L=m1+1;
	}
	cout<<check(L)<<'\n';
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main() {
	int p, q, r, max = 0;

	scanf("%d %d %d", &p, &q, &r);

	if (p >= max) max = p;
	if (q >= max) max = q;
	if (r >= max) max = r;

	printf("%d\n", p + q + r - max);

	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n, t, o;
    stack<char> ans;
    cin >> n;
    while (n)
    {
        n -= 1;
        o = n % 26;
        n /= 26;
        ans.push('a' + o);
    }
    while (!ans.empty())
    {
        cout << ans.top();
        ans.pop();
    }

    return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

using int64 = long long;

struct bug
{
	int64 release, capture;
	bool operator<(const bug&other)const
	{
		return release < other.release;
	}
};
int64 n;
bug bg[345678];

bool cond(int x)
{
	priority_queue<bug>heap;
	int64 sum = 0;
	for (int i = 0; i < x; ++i)
	{
		heap.push(bg[i]);
		sum += bg[i].release;
	}
	if (bg[x - 1].capture * x >= sum)
	{
		return true;
	}
	for (int i = x; i < n; ++i)
	{
		heap.push(bg[i]);
		sum += bg[i].release;
		sum -= heap.top().release;
		heap.pop();
		if (bg[i].capture * x >= sum)
		{
			return true;
		}
	}
	return false;
}

int main(void)
{
	scanf("%lld", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld %lld", &bg[i].release, &bg[i].capture);
	}
	sort(bg, bg + n, [](const bug&b1, const bug&b2) {return b1.capture > b2.capture; });
	int64 big = n;
	int64 small = 0;
	if (cond(n))return 0 * printf("%lld\n", n);
	while (big - small > 1)
	{
		int64 middle = (big + small) / 2;
		if (cond(middle))
		{
			small = middle;
		}
		else
		{
			big = middle;
		}
	}
	printf("%lld\n", small);
	return 0;
}

Measured memory_bytes: 20440
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	string S;cin>>S;
    
	//出力
	if (S=="ABC") printf("ARC\n");
	else printf("ABC\n");
}


Measured memory_bytes: 3596
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

const int M = 3000;
ll tim[52][M];
bool visited[52][M];
vector < pair <int, pll> > graph[52];
ll C[52], D[52];

void dijkstra(int s) {
	priority_queue < pair <ll, pii>, vector < pair <ll, pii> >, greater < pair <ll, pii> > > pq;
	pq.push({0, {1, s}});
	while (!pq.empty()) {
		ll t = pq.top().F;
		int source = pq.top().S.F;
		int coins = pq.top().S.S;
		pq.pop();
		if (visited[source][coins]) {
			continue;
		}
		visited[source][coins] = 1;
		for (auto a : graph[source]) {
			int left = coins - a.S.F;
			ll next = t + a.S.S;
			if (left >= 0 and tim[a.F][left] > next) {
				tim[a.F][left] = next;
				pq.push({next, {a.F, left}});
			}
		}
		if (tim[source][min(M-1,coins + C[source])] > t + D[source]) {
			pq.push({t+D[source],{source,min(M-1,coins + C[source])}});
			tim[source][min(M-1,coins + C[source])] = t + D[source];
		}
	}
}

void solve() {
	int n,m;
	ll s;
	cin >> n >> m >> s;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < M; ++j) {
			tim[i][j] = LLONG_MAX;
		}
	}
	memset(visited, 0, sizeof(visited));
	for (int i = 0; i < m; ++i) {
		int u,v;
		ll a,b;
		cin >> u >> v >> a >> b;
		graph[u].pb({v, {a,b}});
		graph[v].pb({u, {a,b}});
	}
	for (int i = 1; i <= n; ++i) {
		cin >> C[i] >> D[i];
	}
	s = min(s, M-1);
	dijkstra(s);
	for (int i = 2; i <= n; ++i) {
		ll ans = LLONG_MAX;
		for (int j = 0; j < M; ++j) {
			ans = min(ans, tim[i][j]);
		}
		cout << ans << endl;
	}
}

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


Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    ll n,ans=INF;
    cin >> n;
    rep(i,sqrt(n)+1){
        if (n%(i+1)==0){
            ans=min(ans,(i+1)+(n/(i+1))-2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = next.Int()
	}
	if n == 1 {
		fmt.Println(t[0])
		return
	}
	ans := lcm(t[0], t[1])
	for i := 2; i < n; i++ {
		ans = lcm(ans, t[i])
		// log.Println(ans)
	}
	fmt.Println(ans)
}

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

func lcm(a, b int) int {
	g := gcd(a, b)
	return a / g * b
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

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

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
function Main(input) {
  input = input.trim();
  input = input.split("\n")
  var arr = input[1].split(" ")
  var sum = 0;
  var count = 1;
  for(var i=0;i<input[0];i++){
  if(arr[i]==count){
  count++;
  }else{
  sum++;
  }
  }
  if(count ==1){
  console.log(-1)
  }else{
  console.log(sum)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21236
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int x = scanner.nextInt();
        int[] a = new int[100000];
        long ans = 0;

        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
            if(a[i] > x){
                ans += a[i] - x;
                a[i] = x;
            }
        }

        for (int i = 0; i < N - 1; i++) {
            int temp = a[i] + a[i + 1];
            if(temp > x){
                int sa = temp - x;
                ans += sa;
                a[i + 1] = a[i + 1]  - sa;
            }

        }
        System.out.println(ans);

    }
}




Measured memory_bytes: 33912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for(int i=0; i<N; ++i) cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[N/2]-d[N/2-1] << endl;
	return 0;
}


Measured memory_bytes: 640
date = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
t = 0
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    date[b-1][f-1][r-1] += v

for tou in date:
    for floor in tou:
        for room in floor:
            print("", room, end = "")
        print()
    if t != 3:
        t += 1
        print("####################")


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

int count(map<pair<long long, long long>, bool> &x, int start_idx_h, int start_idx_w, long long H, long long W)
{
    if (start_idx_h < 0 || H <= start_idx_h + 2)
    {
        return -1;
    }

    if (start_idx_w < 0 || W <= start_idx_w + 2)
    {
        return -1;
    }

    int ret = 0;
    for (long long i = start_idx_h; i < start_idx_h + 3; i++)
    {
        for (long long j = start_idx_w; j < start_idx_w + 3; j++)
        {
            if (x[make_pair(i, j)])
            {
                ret++;
            }
        }
    }
    return ret;
}

int main()
{
    long long H, W;
    cin >> H >> W;

    int N;
    cin >> N;

    map<pair<long long, long long>, bool> x;
    long long a, b;
    vector<long long> ans(10, 0);
    ans[0] = (H - 3 + 1) * (W - 3 + 1);
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        x[make_pair(a, b)] = true;
        for (int j = a - 2; j <= a; j++)
        {
            for (int k = b - 2; k <= b; k++)
            {
                int num = count(x, j, k, H, W);
                if (num > 0)
                {
                    ans[num]++;
                    ans[num - 1]--;
                }
            }
        }
    }
    for (int i = 0; i < 10; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 156544
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc149/tasks/abc149_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S,T; cin >> S >> T;
    res = T+S;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

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


    int a, b, c, k;

    cin >> a >> b >> c >> k;

    for(int i=0; i<=k; i++)
    {
        for(int j=0; j+i<=k; j++)
        {
            int l = k-i-j;
            int A = a*(1<<i);
            int B = b*(1<<j);
            int C = c*(1<<l);
            if(C>B && B>A)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;



    return 0;

}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define task "atcoder"
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define lla(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ar array
#define endl '\n'
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

void solved()
{
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solved();
}










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

namespace ABC114__A_753
{
    class Program
    {
        static void Main(string[] args)
        {int x = int.Parse(Console.ReadLine());
         if (x == 3 || x == 5 || x == 7)
         Console.WriteLine("YES");
         else
         Console.WriteLine("NO");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin>>n>>m;
	map<ll,int> Map;
	REP(i,n){
		int x;
		cin>>x;
		Map[x]++;
	}
	REP(i,m){
		int b,c;
		cin>>b>>c;
		Map[c]+=b;
	}
	int t=n;
	ll res=0;
	auto it=Map.end();
	it--;
	while(t){
		int k=min(t,it->second);
		res+=k*it->first;
		t-=k;
		it--;
	}
	cout<<res<<'\n';
}



Measured memory_bytes: 16148
#include <iostream>
 int main() {
  int H, W;
  while (1) {
   std::cin >> H >> W;
   if (H == 0 && W == 0) break;
   for (int i = 0; i < H; i++) {
     for (int j = 0; j < W; j++) {
       std::cout << "#";
     }
     std::cout <<std::endl; 
   }
   std::cout <<std::endl;
  }


return 0;


}



Measured memory_bytes: 3068
#include<bits/stdc++.h> 
using namespace std;
using ll = long long;
using ull = unsigned long long;


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


Measured memory_bytes: 256
// :)
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

std::random_device rd_device;
std::mt19937 rng(rd_device());

int main() {
    ios::sync_with_stdio(false);
    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    int x, y, z, k;
    cin>>x>>y>>z>>k;
    vector<ll> xx(x), yy(y), zz(z);
    for (int i=0;i<x;i++) cin>>xx[i];
    for (int i=0;i<y;i++) cin>>yy[i];
    for (int i=0;i<z;i++) cin>>zz[i];

    sort(xx.begin(), xx.end(), greater<ll>());
    sort(yy.begin(), yy.end(), greater<ll>());
    sort(zz.begin(), zz.end(), greater<ll>());

    priority_queue<ll> q;

    for (int a=0;a<x;a++) {
        for (int b=0;b<y;b++) {
            for (int c=0;c<z;c++) {
                if ((a+1)*(b+1)*(c+1) <= k) q.push(xx[a]+yy[b]+zz[c]);
                else break;
            }
        }
    }

    while (k>0 && q.size() > 0) {
        cout<<q.top()<<endl;
        q.pop();
        k--;
    }

    return 0;
}


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

int main(){
  int a,b,q; cin>>a>>b>>q;
  vector<ll> s(a),t(b);
  for(int i=0;i<a;i++){
    cin>>s[i];
  }
  for(int i=0;i<b;i++){
    cin>>t[i];
  }
  for(int i=0;i<q;i++){
    ll x; cin>>x;
    ll ans=30000000000;
    bool f1=false,f2=true,f3=false,f4=true;
    auto itrs2=lower_bound(s.begin(),s.end(),x);
    auto itrt4=lower_bound(t.begin(),t.end(),x);
    if(itrs2==s.end()) f2=false;
    if(itrt4==t.end()) f4=false;
    if(itrs2!=s.begin()){
      f1=true;
    }auto itrs1=itrs2; itrs1--;
    if(itrt4!=t.begin()){
      f3=true;
    }auto itrt3=itrt4; itrt3--;
    if(f1 && f3){
      ans=min(ans,x-min(*itrs1,*itrt3));
    }
    if(f2 && f4){
      ans=min(ans,abs(max(*itrs2,*itrt4)-x));
    }
    if(f1 && f4){
      ans=min(ans,abs(*itrt4-*itrs1)+min(*itrt4-x,x-*itrs1));
    }
    if(f2 && f3){
      ans=min(ans,abs(*itrs2-*itrt3)+min(x-*itrt3,*itrs2-x));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2944
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
#define MAXN 1000100
#define ll long long
ll n, m, ans;
int main()
{
	scanf("%lld%lld",&n,&m);
	ans = min(n%m, m-n%m);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll int
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+3;
const ll mod=1e9+7;
int main()
{
   FASTIO
   int t=1;
  // cin>>t;
   while(t--)
  {
        ll n,k;
        cin>>n>>k;
        vi v(n);
        rep(i,0,n)
        cin>>v[i];
        vi cost(n);

        fill(all(cost),INT_MAX);
        cost[0]=0;
        rep(i,1,n)
        {
            for(ll j=i-1;j>=i-k && j>=0;j--){

                cost[i]=min(cost[i],cost[j]+abs(v[i]-v[j]));
        }
        }
      /*  rep(i,0,n)
        cout<<cost[i]<<" ";
        cout<<endl;*/
        cout<<cost[n-1];
   }
 return 0;
}


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

string s;
int i;

/*
 * expr   ::= term [ "-" term]*
 * term   ::= number | "S<" expr ">"
 * number ::= [0-9]+
 */

ll expr();
ll term();
ll number();

ll expr(){
    ll val=term();
    while(s[i]=='-'){
        i++;
        val=val>>min(term(),32ll);
    }
    return val;
}
ll term(){
    if(isdigit(s[i])) return number();
    i+=2;
    ll val=expr();
    val=val*val%1'000'000'007;
    i++;
    return val;
}
ll number(){
    ll val=0;
    while(isdigit(s[i])){
        val=val*10+s[i++]-'0';
    }
    return val;
}

bool input(){return getline(cin,s) and s!="#";}

ll solve(){
    string t="";
    for(auto c:s) if(c!=' ') t+=c;
    s=t;
    for(int i=2;i<s.size();i++){
        if(isdigit(s[i]) or s[i]=='S'){
            if(s[i-1]=='>' and s[i-2]=='>'){
                s[i-1]='-';
                s.erase(s.begin()+i-2);
            }
        }
    }
    i=0;
    return expr();
}


int main(void){
    while(input()){
        cout<<solve()<<endl;
    }
    return 0;
}



Measured memory_bytes: 4932
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  
  string input_s,input_t;
  
  cin >> input_s >> input_t;
  
  cout << ((input_t.substr(0,input_s.size()) == input_s) ? string("Yes") : string("No")) << endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
   
    int a[5],i;
    for(i=1;i<=5;i++){
        cin>>a[i];
    } 
    for(i=1;i<=5;i++){
     if(a[i]==0){
            cout<<i;
        }
   }
     return 0;   
}

Measured memory_bytes: 3144
#include<iostream>
#include <cstdio>

using namespace std;

int main() {

	int a, b, c, count = 0;
		while (cin >> a >> b) {
			c = a + b;
			while (c) {
				c = c / 10;
				count++;
			}
			cout << count << endl;
			count = 0;
		}

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int F(long a, long b){
    string sa = to_string(a);
    string sb = to_string(b);
    return max(sa.length(), sb.length());
}

int main(){
    long N;
    cin >> N;
    
    string sn = to_string(N);
    long a,b;
    long ma = pow(10, (sn.length()%2 == 1)? sn.length()/2+1: sn.length()/2);  
    for(int i=1; i<ma; i++){
       if(N%i == 0){
           a = i;
           b = N/i;
       }
    }

    cout << F(a, b) << endl;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s,tmp;
    cin>>s;
    tmp=s;
    reverse(tmp.begin(),tmp.end());
    if(s==tmp){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;



int main(){
  int A[3][3];
  for(int i = 0;i < 3;++i)
    for(int j = 0;j < 3;++j)
      cin >> A[i][j];
  int N, b;
  cin >> N;
  for(int i = 0;i < N;++i){
    cin >> b;
    for(int i = 0;i < 3;++i)
      for(int j = 0;j < 3;++j)
        if(A[i][j] == b)
          A[i][j] = 0;

  }
  bool flg = false;
  for(int i = 0;i < 3;++i){
    if((A[i][0] == A[i][1] && A[i][1] == A[i][2])||(A[0][i] == A[1][i] && A[1][i] == A[2][i]))
      flg = true;
  }
  if(A[0][0] == A[1][1] && A[1][1] == A[2][2] || A[0][2] == A[1][1] && A[1][1] == A[2][0])
    flg = true;
  cout << ((flg) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    ll ans = 1000;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    for (int i = 0; i < N - 1; i++) {
        if (A[i + 1] > A[i])
            ans = (ans / A[i]) * A[i + 1] + (ans % A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
  long n;
  cin >> n;
  
  long dmax = sqrt(n)+1;
  while (dmax--)
    if (n % dmax == 0)
      break;
   cout << dmax + n / dmax - 2 << endl;
}


Measured memory_bytes: 384