akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;

typedef pair<long long,long long> P;

int v,e,r;
bool f[1010];

struct edge{
    int to;
    long long cost;
    edge(int _to,long long _cost):to(_to),cost(_cost){}
};

vector<edge> G[1010];
long long d[1010];

bool bellman_ford(int start){
    for(int i=0;i<v;i++){
        d[i]=1e12;
    }
    d[start]=0;
    f[start]=1;
    
    for(int i=0;i<v;i++){
        bool update=false;
        
        for(int j=0;j<v;j++){
            int from=j;
            
            if(!f[from])continue;
            
            for(int k=0;k<G[from].size();k++){
                edge e=G[j][k];
                
                if(d[from]!=1e12&&d[e.to]>d[from]+e.cost){
                    f[e.to]=1;
                    d[e.to]=d[from]+e.cost;
                    update=true;
                }
            }
        }
        if(update==false)break;
        if(i==v-1)return true;
    }
    return false;
}

int main(void){
    cin>>v>>e>>r;
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        G[s].push_back(edge(t,d));
    }
    
    if(bellman_ford(r)){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    
    for(int i=0;i<v;i++){
        if(d[i]!=1e12)cout<<d[i]<<endl;
        else cout<<"INF"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
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 (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 200001

void Main() {
  //自動整形防止用コメント
  ll n;
  ll a[MAX_NUM];
  deque<ll> d;

  cin >> n;
  rep(i, n){
    cin >> a[i];
  }

  rep(i, n){
    if (n % 2 == 1)
    {
      if (i % 2 == 0)
      {
        d.push_front(a[i]);
      }
      else
      {
        d.push_back(a[i]);
      }
    }
    else
    {
      if (i % 2 == 0)
      {
        d.push_back(a[i]);
      }
      else
      {
        d.push_front(a[i]);
      }
    }
  }

  for (auto &&i : d)
  {
    std::cout << i << " ";
  }
  
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int N;
ll A[101010];
ll ans = 0;

void solve() {
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) {
        if (i > 0) {
            ans += min(A[i-1], A[i]);
            A[i] -= min(A[i-1], A[i]);
        }
        ans += A[i] / 2;
        A[i] -= (A[i] / 2) * 2;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

int main(){
	string st;
	getline(cin,st);
	//st.upper(st.begin(), st.end());
	for( int i = 0; i < st.size(); i++ ){
		cout << (char)toupper(st[i]);
	}
	cout << endl;
}

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

set<int> t;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    for(int i=0;i<=5;i++)t.insert(i);
    for(int i=0;i<5;i++){
        int a;
        cin>>a;
        t.erase(a);
    }
    cout<<*t.begin()<<endl;

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define fir first
#define sec second
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,m,tim[1010][1010];
char s[1010];
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
struct node{
	int x,y;
};
bool operator<(const node &p,const node &q)
{
	return tim[p.x][p.y]>tim[q.x][q.y];
}
priority_queue<node> q;

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();m=read();
	rep(i,1,n)
	{
		rep(j,1,m) tim[i][j]=maxd;
	}
	rep(i,1,n)
	{
		scanf("%s",s+1);
		rep(j,1,m)
		{
			if (s[j]=='#')
			{
				q.push((node){i,j});
				tim[i][j]=0;
			}
		}
	}
	int ans=0;
	while (!q.empty())
	{
		node now=q.top();q.pop();
		rep(i,0,3)
		{
			int nx=now.x+dx[i],ny=now.y+dy[i];
			if ((nx<0) || (nx>n) || (ny<0) || (ny>m)) continue;
			if (tim[nx][ny]==maxd) q.push((node){nx,ny});
			tim[nx][ny]=min(tim[nx][ny],tim[now.x][now.y]+1);
		}
	}
	rep(i,1,n)
	{
		rep(j,1,m) ans=max(ans,tim[i][j]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 13292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		
		Set<String> s = new HashSet<>();
		
		for(int i=0; i<N; i++) {
			s.add(br.readLine());
		}
		
		System.out.println(s.size());
	}

}

Measured memory_bytes: 66784
#include <stdio.h>

int main()
{
	int i, N, d, flag[101] = {}, sum = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &d);
		if (flag[d] == 0) {
			sum++;
			flag[d] = 1;
		}
	}
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n ,a, b;
    cin>>n>>a>>b;
    vector<int>h(n);
    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    int l=0;
    int r=INF;
    while(l+1<r){
        int c=(l+r)>>1;
        int cnt=0;
        for (int i = 0; i < n; i++)
        {
            int x=max(h[i]-b*c , 0LL);
            
                cnt+=(x+a-b-1) /(a-b);
            
        }
      //  cerr<<cnt<<endl;
        if(cnt<=c){
            r=c;
        }
        else{
            l=c;
        }
    }
    cout<<r<<endl;
    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
vpii v;
int n;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(int i=1;i<=n;i++){
        int x; cin>>x;
        v.pb(mp(x,i));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        cout<<v[i].se;
        if(i<v.size()-1)cout<<" ";
        else cout<<newl;
    }
}


Measured memory_bytes: 1780
(defun odd (s)
  (if (null s)
      "Yes"
      (let ((c (car s)))
        (if (char= c #\L)
            "No"
            (even (cdr s))))))

(defun even (s)
  (if (null s)
      "Yes"
      (let ((c (car s)))
        (if (char= c #\R)
            "No"
            (odd (cdr s))))))

(defun main ()
  (let ((s (concatenate 'list (read-line))))
    (format t "~A~%" (odd s))))

(main)


Measured memory_bytes: 11876
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

P.sort()

result = 0
for i in range(0, 101):
    if X - i not in P:
        result = X - i
        break
    if X + i not in P:
        result = X + i
        break

print(result)


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

string S;
vector<int> v(4);

int main() {
  cin >> S;

  for(int i = 0; i < 4; ++i) {
    v[i] = S[i] - '0';
  }

  for(int bit = 0; bit < (1<<3); ++bit) {
      int tmp = v[0];
    for(int i = 0; i < 3; ++i) {
      if(bit & (1 << i)) {
        tmp += v[i + 1];
      } else {
        tmp -= v[i + 1];
      }
    }
    if(tmp == 7) {
      cout << v[0];
      for(int i = 0; i < 3; ++i) {
        if(bit & (1 << i)) {
          cout << '+';
        } else {
          cout << '-';
        }
        cout << v[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j+M] for k in A[i:i+M]]
        if t==B:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int e = 0;
			int o = 0;
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				if (x % 2 == 0) {
					++e;
				} else {
					++o;
				}
			}
			e += o / 2;
			o %= 2;
			while (e > 1) {
				int ne = e / 2;
				if (e % 2 == 1) {
					++ne;
				}
				e = ne;
			}
			out.println(e + o == 1 ? "YES" : "NO");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



Measured memory_bytes: 23176
#include <iostream>
#include <tuple>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

typedef tuple<string, int> P;

int main(){
	vector<P> vec;
	int D, x, y;
	cin >> D;
	cin >> x;
	for(int i=0;i<x;i++){
		string a;
		int b;
		cin >> a >> b;
		if(a == "D"){
			vec.push_back(P(a, b));
		}
	}
	cin >> y;
	for(int i=0;i<y;i++){
		string a;
		int b;
		cin >> a >> b;
		if(a == "DD"){
			vec.push_back(P(a, b));
		}
	}
	array<int, 14> dp;
	fill(dp.begin(), dp.end(), -1);
	dp[0] = 0;
	for(int k=0;k<vec.size();k++){
		for(int i=D-get<0>(vec[k]).size();i>=0;i--){
			if(dp[i] == -1) continue;
			int a = get<0>(vec[k]).size();
			int b = get<1>(vec[k]);
			if(dp[i+a] == -1){
				dp[i+a] = dp[i] + b;
			}else{
				dp[i+a] = max(dp[i+a], dp[i] + b);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<=D;i++){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;


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

    int t[N];
    string s[N];
    rep(i,N){
        cin>>s[i]>>t[i];
    }

    string x;
    cin>>x;
    long long ans=0;
    bool start=false;
    rep(i,N){
        int p=0;
        if(!start){
            rep(j,s[i].size()){
                if(s[i].size()!=x.size()){
                break;
                }
                if(s[i][j]==x[p]){
                p++;
                }

                if(p==x.size())start=true;
            }
        }
        else{
            ans+=t[i];
        }
    }
    cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())


def ans():
    for i in range(100000):
        if i * i > N:
            return (i - 1) * (i -1)


print(ans())


Measured memory_bytes: 9656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

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

  REP(i, n) { cin >> p[i]; }

  sort(ALL(p));

  int ans = 0;
  REP(i, k) { ans += p[i]; }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#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;

int main(){
    int n;
    cin >> n;
    int odd = n/2+n%2;
    double ans = (double)odd/n;
    printf("%.10f\n",ans);
}

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

using namespace std;

int main(){
        int N, M;
        cin>>N;
        vector <int> D(N);
        for(int i=0;i<N;i++){
                cin>>D[i];
        }
        sort(D.begin(), D.end());
        cin>>M;
        int T;
        bool res=true;
        for(int i=0;i<M;i++){
                cin>>T;
                bool flag=false;
                int lef=0, rigt=N-1;
                int mid;
                while(rigt-lef>1){
                        mid=(lef+rigt)/2;
                        if(T==D[mid]){
                                break;
                        }
                        else if(T>D[mid]){
                                lef=mid;
                        }
                        else{
                                rigt=mid;
                        }
                }
                if(T==D[mid]){
                        N--;
                        flag=true;
                        D.erase(D.begin()+mid);
                }
                else if(T==D[lef]){
                        N--;
                        flag=true;
                        D.erase(D.begin()+lef);
                }
                else if(T==D[rigt]){
                        N--;
                        flag=true;
                        D.erase(D.begin()+rigt);
                }
                if(!flag){
                        res=false;
                        break;
                }
        }
        if(res){
                cout<<"YES"<<endl;
        }
        else{
                cout<<"NO"<<endl;
        }
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long x;
	scanf("%lld", &x);
	
	long long ans = (x - 1) / 11 * 2;
	if ((x - 1) % 11 < 6) ans += 1;
	else ans += 2;
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const INAN = 1e9+5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int Q, t, a, b; std::cin >> Q >> t >> a >> b;
  std::priority_queue<int> L;
  std::priority_queue<int, std::vector<int>, std::greater<int>> R;
  int mid = a;
  int64_t bsum = b, amin = 0;
  for(int i = 1; i < Q; ++i) {
    std::cin >> t;
    if(t == 2) {
      std::cout << ((mid != INAN)? mid: L.top()) << " " << amin+bsum << "\n";
      continue;
    }
    std::cin >> a >> b;
    bsum += b;
    if(mid == INAN) {
      if(L.top() <= a && a <= R.top()) mid = a;
      else if(a > R.top()) {
        mid = R.top(); R.pop();
        amin += a - mid;
        R.push(a);
      } else {
        mid = L.top(); L.pop();
        amin += mid - a;
        L.push(a);
      }
    } else {
      if(a >= mid) {
        amin += a - mid;
        L.push(mid);
        R.push(a);
      } else {
        amin += mid - a;
        L.push(a);
        R.push(mid);
      }
      mid = INAN;
    }
  }
  return 0;
}


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

const int maxn = 1e6+1000;
typedef long long LL;
struct Node
{
    int v;
    LL w;
    Node(int v = 0,LL w = 0):v(v),w(w) {}
};


vector<Node> G[maxn];


int R,C;
int n;


LL A[maxn];
bool vis[maxn];



const LL INF = 0x3f3f3f3f3f3f3f3f;

int seq[maxn];
int cur;

bool dfs(int u)
{
    seq[cur++] = u;
    for(int i = 0;i < G[u].size();++i)
    {
        int v = G[u][i].v;
        LL w = G[u][i].w;

        if(!vis[v])
        {
            vis[v] = 1;
            A[v] = w-A[u];
            if(!dfs(v)) return false;
        }
        else
        {
            if(A[v] + A[u] != w) return false;

        }
    }
    return true;

}


bool bfs(int s)
{
    int b = 0, e = 1;
    seq[0] = s;
    vis[s] = true;
    A[s] = 0;
    while (b < e) {
      for (int j = 0; j < (int) G[seq[b]].size(); j++) {
        int u = G[seq[b]][j].v;
        int w = G[seq[b]][j].w;
        if (vis[u]) {
          if (A[seq[b]] + A[u] != w) {
            return false;
            }
          continue;
        }
        seq[e] = u;
        A[u] = w - A[seq[b]];
        vis[u] = true;
        e++;
      }
      b++;
    }
    cur = e;

    return true;
}

bool judge()
{

    memset(vis,0,sizeof(vis));
    for(int i = 1;i <= R+C;++i)
        if(!vis[i])
        {
            vis[i] = 1;
            A[i] = 0;

            cur = 0;
            if(!bfs(i)) return false;

            long long m1 = INF, m2 = INF;
    for (int j = 0; j < cur; j++) {
      if (seq[j] <= R) {
        m1 = min(m1, A[seq[j]]);
      } else {
        m2 = min(m2, A[seq[j]]);
      }
    }
    if (m1 + m2 < 0) {
      return false;
    }
//            LL Minr = INF;
//            LL Minc = INF;
//
//            for(int j = 0;j < cur;++j)
//            {
//                int t = seq[i];
//                if(t <= R)
//                    Minr = min(Minr,A[t]);
//                else
//                    Minc = min(Minc,A[t]);
//
//            }
//            if(Minr + Minc < 0) return false;

        }
    return true;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)
    {
        int a,b;
        LL w;
        scanf("%d %d %lld",&a,&b,&w);
        b += R;
        G[a].push_back(Node(b,w));
        G[b].push_back(Node(a,w));
    }
    if(judge())
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 32512
#include <stdio.h>

int n, r[100], c[100];
int DP[100][100];

int min(int a, int b){
  if (a > b) {
    return b;
  } else {
    return a;
  }
}

int main(){
  int a, b, i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &r[i], &c[i]);
    DP[i][i] = 0;
  }
  
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      DP[i][j] = 0;
    }
  }
  
  for (i = 1; i < n; i++) {
    for (j = 0; j < n - i; j++) {
      a = r[j] * c[i + j] * c[j] + DP[j][j] + DP[j + 1][i + j];
      for (k = j + 1; k < i + j; k++) {
        b = r[j] * c[i + j] * c[k] + DP[j][k] + DP[k + 1][i + j];
        a = min(a, b);
      }
      DP[j][i + j] = a;
    }
  }
  
  printf("%d\n", DP[0][n - 1]);
  return 0;
}

Measured memory_bytes: 632
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()
	var a = make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Fscanf(bufin, "%d\n", &a[i])
	}
	sort.Ints(a)
	if a[0]+a[1] == a[2] {
		fmt.Fprintf(bufout, "Yes\n")
	} else {
		fmt.Fprintf(bufout, "No\n")
	}
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#endif

const int MAX = 36;
long long pow2[40];

void init() {
    pow2[0] = 1;
    for (int i=1; i<=MAX; ++i) {
        pow2[i] = pow2[i-1] * 2;
    }
}

string solve(long long X, long long Y, bool odd) {
    string s = "";
    for (int i=MAX; i>=0; --i) {
        long long parm = odd ? pow2[i] : pow2[max(0, i-1)];
        long long ph = odd ? parm-1 : (i == 0 ? 0 : parm);

        if (abs(X+parm) + abs(Y) <= ph) {
            X += parm;
            s = "L" + s;
        } else if (abs(X-parm) + abs(Y) <= ph) {
            X -= parm;
            s = "R" + s;
        } else if (abs(X) + abs(Y+parm) <= ph) {
            Y += parm;
            s = "D" + s;
        } else if (abs(X) + abs(Y-parm) <= ph) {
            Y -= parm;
            s = "U" + s;
        }
    }
    return s;
}

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

    init();

    int N;
    cin >> N;

    vector<int> X(N), Y(N);
    int odd = 0, even = 0;
    for (int i=0; i<N; ++i) {
        cin >> X[i] >> Y[i];
        if (abs(X[i]+Y[i]) % 2 == 0) {
            even ++;
        } else {
            odd ++;
        }
    }
    if (even > 0 && odd > 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << MAX+1 << endl;
    for (int i=0; i<=MAX; ++i) {
        cout << (odd > 0 ? pow2[i] : pow2[max(0, i-1)]) << endl;
    }

    for (int i=0; i<N; ++i) {
        cout << solve(X[i], Y[i], odd > 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

#define M_PI 6.28318530717958623200;

using namespace std;

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

	long double ans;

	ans = (long double)a* M_PI;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;

}

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

import sys
from itertools import accumulate
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

def popcount(i):
    return bin(i).count('1')

H, W, K = MAP()
grid = build_grid(H, W, 0, int, space=0)

ans = INF
for S in range(1<<(H-1)):
    N = popcount(S) + 1
    A = list2d(N, W, 0)
    for w in range(W):
        A[0][w] = grid[0][w]
    h = 0
    for k in range(H-1):
        if S & 1<<k:
            h += 1
        for w in range(W):
            A[h][w] += grid[k+1][w]
    for i in range(N):
        A[i] = [0] + list(accumulate(A[i]))
    cnt = 0
    idx = 1
    while 1:
        nxt = INF
        for i in range(N):
            nxt = min(nxt, bisect_right(A[i], K+A[i][idx-1], lo=idx))
        if idx == nxt:
            cnt = INF
            break
        idx = nxt
        if idx == W+1:
            break
        cnt += 1
    ans = min(ans, N-1+cnt)
print(ans)


Measured memory_bytes: 51420
n = int(input())
w = [int(i) for i in input().split()]
min_diff = 10 ** 100
for t in range(0, n - 1):
    diff_abs = abs(sum(w[:t + 1]) - sum(w[t + 1:]))
    if min_diff > diff_abs:
        min_diff = diff_abs
print(min_diff)

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

int main() {
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        if(i == 0 && S[i] == '?') {
            S[0] = 'D';
            continue;
        }
        if(S[i] == '?' && S[i-1] == 'P') {
            S[i] = 'D';
        }
        if(S[i] == '?' && S[i-1] == 'D') {
            S[i] = 'D';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3756
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		int a = 0;
		int b = 0;
		HashSet<Integer> m1 = new HashSet<>();
		HashSet<Integer> m2 = new HashSet<>();
		for(i=0;i<m;i++) {
			a = parseInt(sc.next());
			b = parseInt(sc.next());
			if(a==1) m1.add(b);
			if(b==n) m2.add(a);
		}
		sc.close();
		boolean f=false;
		for (Integer ii:m1) {
			if(m2.contains(ii)) {
				f = true;
				break;
			}
		}
		out.println(f?"POSSIBLE":"IMPOSSIBLE");
	}
}


Measured memory_bytes: 80664
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long i,n,d;
  cin >> n >> d;
  long long sum=0;
  for(i=0;i<n;i++){
    long long x,y;
    cin >> x >> y;
    if(x*x+y*y<=d*d){
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    string s;
    long long k;
    cin >> s >> k;
    int n = s.size();

    for (int i=0; i<n; i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
        if (i+1 >= k) break;
    }
    cout << '1' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;

ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    string S, T;
    cin >> S;
    cin >> T;

    S = S + T[T.size()-1];
    // cout << S << " " << T <<endl;
    if (S == T){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3632
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
 
int32_t main()
{
	int n,m;
	cin >> n >> m;
	int l[m],r[m];
	int minl = 0,maxr = INT_MAX;
	for(int i = 0 ;i<m;i++)
	{
		cin >> l[i] >> r[i];
		minl = max(minl,l[i]);
		maxr = min(maxr,r[i]);
	}
	//cout << minl << " " << maxr<<endl;
	int ans = 0;
	for(int i = 1;i<=n;i++)
		if(i >= minl && i <= maxr)
		{
			ans++;
		}
	cout << ans << endl;
}

Measured memory_bytes: 4308
from collections import deque

n = int(input())
q = deque()

for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

ll square(ll x)
{
    return x * x;
}

ll power(ll b, ll p, ll m)
{
    if (p == 0)
        return 1;

    if (p % 2 == 0)
        return square(power(b, p/2, m)) % m;

    return (b * power(b, p-1, m)) % m;
}

ll solve(ll n, ll k)
{
    ll c[n+1];
    ll ans = 0;

    c[0] = 1;
    c[1] = n;

    for (int i = 2; i <= n; i++)
    {
        c[i] = ((n+1-i) * (c[i-1])) % mod;
        c[i] = c[i] * power(i, mod-2, mod);
        c[i] = c[i] % mod;
        cout << c[i] << "\n";
        if (i >= k)
        {
            ans = ans + c[i];
            ans = ans % mod;
        }
    }

    return ans;
}

int main()
{
    ll n, k;

    cin >> n >> k;

    ll ans = 0;

    for (int i = k; i <= n+1; i++)
    {
        ans = ans + ((i * (n+1-i)) % mod);
        ans = (ans + 1) % mod;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   string s;
    cin>>k>>s;
    n=s.size();
    if(n<=k)cout<<s;
    else
    {
        cout<<string(s.begin(),s.begin()+k)+"...";
    }
    
    
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;
double pai = 3.141592653589793;

signed main(){
	double A,B,X;
	cin>>A>>B>>X;
	if(A*A*B<X*2){
		auto f =[&](double x)->bool{
			return (double)A*A*B-A*A*x/2.0>=X;
		};
		double l = -1, r = B;
		REP(_,100){
			double c = (l + r) / 2.0;
			if(f(c)) l = c;
			else r = c;
		}
		printf("%.20lf\n",atan2(r,A)*180.0/pai);
	}else{
		auto f =[&](double x)->bool{
			return (double)B*A*x/2.0>=X;
		};
		double l = -1, r = A;
		REP(_,100){
			double c = (l + r) / 2.0;
			if(f(c)) r = c;
			else l = c;
		}
		printf("%.20lf\n",90.0-atan2(r,B)*180.0/pai);
	}
}

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

class Program
{
    static void Main(string[] args)
    {/*
        var input = Console.ReadLine().Split();
        int W = int.Parse(input[0]);
        int H = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        int y = int.Parse(input[3]);*/
        var input = Console.ReadLine().Split();
        int n = int.Parse(input[0]);
        int x = int.Parse(input[1]);
        var input2 = Console.ReadLine().Split();
        var l = new int[n];
        for (int i = 0; i < n; i++)
        {
            l[i] = int.Parse(input2[i]);
        }
        int count = 0;
        int ball = 0;
        for (int i = 0; ball <= x&&i<n+1; i++)
        {
            if(i<n)ball += l[i];
            count++;
        }
        Console.WriteLine(count);
    }
}


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

int main()
{
    int N;
    cin >> N;
    int t = N;
    int d = 0;
    while (t != 0)
    {
        d += t % 10;
        t /= 10;
    }

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

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>

int main()
{
  long int  n, a, b;
  int  f, min;

  scanf("%ld", &n);

  min = 100;
  for(a = 1; a <= sqrt(n); a++){ 
    b = n / a;
    if( n % a == 0){ 
      for(f = 0; b > 0; f++){
        b /= 10;
      } 
      if( f < min){
        min = f;
      }
    }
  }

  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    ll ans = 0;
    vector<ll> v(2019);
    v[0] = 1;//余りが0のものは1個で用を足すので、見つけたらすぐansに足せるように1を入れておく.
    ll d = 1, now = 0;
    rep(i, s.size()){
        now = (now + (s[i] - '0') * d) % 2019;
        ans += v[now];//順次足せば、総和の公式で集計しなくても良い(同じ事).
        v[now]++;
        d = (d*10) % 2019;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxn 200005
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
using namespace std;

int n;
int a[maxn], b[maxn];
int main(){
	//freopen("bbu.in", "r", stdin);
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + 1 + n);
	rep(i, 1, n) a[i] = lower_bound(b + 1, b + 1 + n, a[i]) - a;
	int ans = 0;
	for (register int i = 1; i <= n; i += 2) ans += !(a[i] & 1); 
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL X;cin >> X;

    rep(i,X+1){
        if(i*(i+1)/2 >= X){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#!/usr/local/gnu/bin/bash
read n
x=$((n*100/108))
i=0
while(((x+i)*108/100<=n))
do
    if(((x+i)*108/100==n))
    then
        echo $((x+i))
        exit
    else
        i=$((i+1))
    fi
done
echo ":("

Measured memory_bytes: 376
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	int n, k, sum = 0;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	for (int i = 0; i < k; i++) {
		sum += arr[i];
	}

	cout << sum << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

using namespace std;

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

  if (n % k == 0) {
    cout << 0 << endl;
  } else if (n < k) {
    cout << min(n, abs(n - k)) << endl;
  } else {
    cout << min(n % k, abs(n % k - k)) << endl;
  }

  return 0;
}

Measured memory_bytes: 256