akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())

counter = [[0 for _ in range(10)] for _ in range(10)]

for i in range(N):
    i += 1
    top = int(str(i)[0])
    bottom = int(str(i)[-1])
    counter[top][bottom] += 1

c = 0
for i in range(10):
    for j in range(10):
        if i == j:
            t = counter[i][j]
            # iとjを入れ替えてダブルカウントするので1/2する
            c += t**2
        else:
            c += counter[i][j] * counter[j][i]

print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    ll H, N;
    cin >> H >> N;
    ll A[N];
    ll sum =0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    if (sum < H) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }




}

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

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 500;
static const uint mod = 1000000007;

bool m[m_max+2][m_max+2];
uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

uint h, w;

int main(int, char**)
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n, 0);
	vector<int> c(n, 0);

	for (int i = 0; i < n; i++)
		cin >> h[i];

	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		c[i] = INT_MAX;
		for (int j = 1; j <= k; j++) {
			if (i < j) break;
			c[i] = min(c[i], c[i-j]+abs(h[i]-h[i-j])); 
		}
	}

	cout << c[n-1] << endl;


	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, c, i;
    vector <int> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        v.push_back(x);
    }
    
    sort(v.begin(), v.end());
    
    c = v[0];
    
    for (i = 1; i < n - 1; i++) {
        if (abs(v[n - 1] / 2.0 - v[i]) < abs(v[n - 1] / 2.0 - c)) c = v[i];
    }
    
    printf("%d %d\n", v[n - 1], c);
    
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> *edges,int i,int *dp){
    if(dp[i]!=-1){
        return dp[i];
    }
    int leaf=1;
    int ans=0;
    for(auto x:edges[i]){
        leaf=0;
        ans=max(ans,solve(edges,x,dp));
    }
    if(leaf==1){
        return dp[i]=0;
    }
    return dp[i]=1+ans;
}
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> edges[n+1];
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        edges[u].push_back(v);
    }
    int ans=INT_MIN;
    int dp[n+1];
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++){
        ans=max(ans,solve(edges,i,dp));
    }
    cout<<ans<<endl;
	return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), wa(N), sa(N);
    for(int i=0; i<N; i++){
      cin >> A[i];
      wa[i] = A[i] + i;
      sa[i] = A[i] - i;
    }

    sort(wa.begin(), wa.end());
    sort(sa.begin(), sa.end());

    ll ans = 0;
    for(int i=0; i<N; i++){
      auto iter1 = lower_bound(wa.begin(), wa.end(), -sa[i]);
      //auto index1 = iter1 - wa.begin();
      auto iter2 = upper_bound(wa.begin(), wa.end(), -sa[i]);
      //auto index2 = iter2 - wa.begin();

      ans += iter2 - iter1;
    }

    cout << ans << endl;

}


Measured memory_bytes: 8012
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(long long N, long long R) {
  if (N >= 10) {
    ANS(R);
  } else {
    ANS(R + (100 * (10 - N)));
  }
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long R;
  scanf("%lld",&R);
  solve(N, R);
  return 0;
}


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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<long long> v(n);
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    v[i] = a - (i + 1);
  }
  sort(v.begin(), v.end());
  ll ans = 0, b = v[n/2];
  for (ll i = 0; i < n; i++) {
    ans += llabs(v[i] - b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	Scanner sc;
	int a;
	String s;

	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		a = sc.nextInt();
		s = sc.next();
		
		if (a < 3200) System.out.println("red");
		else System.out.println(s);
		System.out.flush();
	}

	public static void main(String[] args) {
		new Main().calc();
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
int main()
{
   string s;
   cin>>s;
   if(s[2]==s[3]&&s[4]==s[5])
   puts("Yes");
   else puts("No");
   //system("pause");
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>

using namespace std;

#define INF 999999999

string revstr(string st){
	/*
	cout << st << endl;
	*/
	
	for(int i=0;i < st.size() / 2; i++){
		swap( st[i], st[st.size() - i - 1]);
	}
	return st;
}

int main(){
	int ans, m, i, j, k,q;
	string in, s;
	vector<string> mat;
	
	cin >> m;
	for(i = 0; i < m; i++){
		ans = 0;
		mat.clear();
		
		cin >> in;
		/*
		cout << in << endl;
		*/
		
		for(j=1; j<in.size();j++){
			for(q=0;q<8;q++){
				/*
				cout << in.substr(0,j) << " " << in.substr(j) << endl;
				*/
				if(q==0)s = in.substr(0,j) + in.substr(j);
				else if(q==1)s = revstr(in.substr(0,j)) + in.substr(j);
				else if(q==2)s = in.substr(0,j) + revstr(in.substr(j));
				else if(q==3)s = revstr(in.substr(0,j)) + revstr(in.substr(j));
				else if(q==4)s = in.substr(j) + in.substr(0,j);
				else if(q==5)s = revstr(in.substr(j)) + in.substr(0,j);
				else if(q==6)s = in.substr(j) + revstr(in.substr(0,j));
				else if(q==7)s = revstr(in.substr(j)) + revstr(in.substr(0,j));
				
				/*
				cout << q << " " << s << endl;
				*/
				
				int flag = 0;
				for(k=0;k<ans;k++){
					if(s == mat[k]){
						flag++;
						break;
					}
				}
				if(!flag){
					mat.push_back(s);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

struct UnionFind{
    vector<int> data;

    UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
      return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  ll n, m;
  cin >> n >> m;
  vector<P> edge;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    edge.push_back({a,b});
  }
  reverse(edge.begin(), edge.end());
  UnionFind uf(n+1);
  vector<ll> res;
  res.push_back(n*(n-1)/2); //完全グラフの辺の数
  
  rep(i,m) {
    if (!uf.same(edge[i].first, edge[i].second)) {
      ll asize = uf.size(edge[i].first);
      ll bsize = uf.size(edge[i].second);
      res.push_back({res.back() - asize * bsize});
      uf.unite(edge[i].first, edge[i].second);
    } else res.push_back(res.back());
  }
  reverse(res.begin(), res.end());
  rep(i,res.size()-1) {
    cout << res[i+1] << endl;
  }
  return 0;
} 

Measured memory_bytes: 3444
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int s;
	int w;
	cin >> s >> w;
  	string ans;
  	if(w >= s) ans = "unsafe";
  	else ans = "safe";
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

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

int min_v(int a,int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main()
{
	int n;
	scanf("%d",&n);

	int arr[n];
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}

	int ans = 0;
	
	int min = arr[0];
	int max = -1000000000;
	for(int i=1;i<n;i++){
		max = max_v(max,arr[i] - min);
		min = min_v(min,arr[i]);
	}

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

	return 0;
}



Measured memory_bytes: 2584
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            Console.WriteLine(cin.Read.Where(c => c == '1').Count());

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int
int main()
{
   char S[200002]={'\0'};
   char T[200002]={'\0'};

   scanf("%s %s",&S,&T);

    int count = 0;
   for (int i = 0 ; i<strlen(S);i++)
   {
   	if (S[i]!=T[i])count++;
   }


   printf("%d",count);

    return 0;
}


Measured memory_bytes: 2128
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#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 go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline 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;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n;
ll f[100100][3];

int main()
{
	n=read();
	f[0][1]=f[0][2]=-1e18;
	rep(i,1,n)
	{
		int x=read();
		f[i][0]=max(f[i-1][0],f[i-1][1]);
		f[i][1]=max(f[i-1][1],f[i-1][2]);
		f[i][2]=f[i-1][2];
		f[i][0]+=x;f[i][1]-=x;f[i][2]+=x;
		if (x<0)
		{
			f[i][2]=max(f[i][2],f[i][1]);
			f[i][1]=max(f[i][1],f[i][0]);
		}
	}
	ll ans=max(max(f[n][0],f[n][1]),f[n][2]);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    int count=0;
    for(int i=0;i<s.length();i++)
    {
      char c1=s.charAt(i);
      char c2=t.charAt(i);
      if(c1!=c2)
        count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 41272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end();
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans;
    for (int i = 0; i < n; i++)
    {
        if(i >= k) {
            if(a[i] > a[i-k]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 4028
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H, i, A[MAX+1];

  cin >> H;
  for(i=1; i<= H; i++) cin >> A[i];

  for(i=1; i<=H; i++){
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
const MOD: usize = 1e9 as usize + 7;
const MAX: usize = 1e5 as usize * 2 + 1;

fn init_fact() -> (Vec<usize>, Vec<usize>, Vec<usize>) {
  let mut fac = vec![0; MAX]; // 階乗
  let mut inv = vec![0; MAX]; // 逆元
  let mut finv = vec![0; MAX]; // 階乗の逆元
  fac[0] = 1;
  fac[1] = 1;
  finv[0] = 1;
  finv[1] = 1;
  inv[1] = 1;
  for i in 2..MAX {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
  return (fac, inv, finv)
}

fn mod_combination(n: usize, k: usize) -> usize {
    let (fac, _, finv) = init_fact();
    let mut ret = fac[n];
    ret *= finv[n-k];
    ret %= MOD;
    ret *= finv[k];
    ret %= MOD;
    ret
}

fn main() {
    input!{
      n: usize,
      m: usize,
      k: usize,
    }
    let mut ans = 0;
    let pair = mod_combination(n*m-2, k-2);
    for d in 1..m {
        ans += n*n*(m-d)*d%MOD *pair%MOD;
        ans %= MOD;
    }
    for d in 1..n {
        ans += m*m*(n-d)*d%MOD *pair%MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}


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

int main()
{
    int i,n,arr[100010],x;
    long long int count=0;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=1;i<n;i++)
    {
        if(arr[i]+arr[i-1]>x)
        {
            if(arr[i]+arr[i-1]-x<=arr[i])
            {
                count+=arr[i]+arr[i-1]-x;
                arr[i]-=(arr[i]+arr[i-1]-x);
            }
            else if(arr[i]+arr[i-1]-x>arr[i])
            {
                count+=arr[i]+arr[i-1]-x;
                arr[i]=0;
                arr[i-1]-=arr[i-1]-x;
            }
        }
    }
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n; cin>>n;
    int a,b,c,x,y,z;
    cin>>x>>y>>z;
    a=x; b=y; c=z;
    for(int i=1;i<n;i++){
        cin>>x; cin>>y; cin>>z;
        x+=max(b,c); y+=max(a,c); z+=max(a,b);
        a=x; b=y; c=z;
        //cout<<"a is "<<a<<", b is "<<b<<", c is "<<c<<"\n";
    }
    int ans=max(a,max(b,c));
    cout<<ans;
}

Measured memory_bytes: 3620
Scanf.scanf "%d" (fun d ->
    let c = Array.init 26 (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    let s = Array.init d (fun _ ->
        Array.init 26 (fun _ ->
            Scanf.scanf " %d" (fun s -> s)))
    in
    let t = Array.init d (fun _ -> Scanf.scanf " %d" (fun t -> t - 1)) in
    let last = Array.make 26 (-1) in
    let rec loop i sat =
        if i < d then (
            let sat = sat + s.(i).(t.(i)) in
            last.(t.(i)) <- i;
            let rec loop2 j sat =
                if j = 26 then sat else
                    loop2 (j + 1) (sat - c.(j) * (i - last.(j)))
            in
            let sat = loop2 0 sat in
            Printf.printf "%d\n" sat;
            loop (i + 1) sat
        )
    in
    loop 0 0
)


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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
    // vector<pair<int, int> > A;
    rd2(ll, a, v);
    rd2(ll, b, w);
    rd1(ll, t);
    
    ll dist = abs(a - b);
    if(dist == 0) {
        cout << "YES";
        return;
    }
    ll sp = w - v;
    
    if(sp >= 0) {
        cout << "NO";
        return;
    }
    
    sp = abs(sp);
    
    ll cd = sp * t;
    
    if(cd >= dist) {
        cout << "YES";
        return;
    }
    
    cout << "NO";
    
    // ll dc = sp * t;
    // if()
    
    
	
}

int main() {
	
	fastio;

//  	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3648
N, A, B = map(int, input().split())
X = [int(_) for _ in input().split()]
ans = 0
for i in range(1, N):
    walk = (X[i]-X[i-1])*A
    teleport = B
    if walk < teleport:
        ans += walk
    else:
        ans += teleport

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    ll k;
    cin >> k;
    cout << a[k-1] << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, v[i]);
    cs.build();

    vector<ll> sums;

    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            ll sum = cs.getSectionSum(i, j);
            sums.push_back(sum);
        }
    }

    vector<ll> prev = sums;

    auto is_bit_k = [&](int i) -> bool {
        int count = 0;
        for (ll l : prev) {
            bool b = (l >> i) & 1;
            if (b)count++;
        }
        return count >= k;
    };

    auto filter_bit = [&](int i) -> vector<ll> {
        vector<ll> ans;
        for (ll l : prev) {
            bool b = (l >> i) & 1;
            if (b)ans.push_back(l);
        }
        return ans;
    };


    for (int i = 63; i >= 0; i--) {
        bool ok = is_bit_k(i);
        if (!ok) continue;
        prev = filter_bit(i);
    }

    assert(prev.size() >= k);

    ll ans = prev[0];
    rep(i, k) ans &= prev[i];
    cout << ans << endl;

}


Measured memory_bytes: 12996
#include <iostream>

using namespace std;

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

	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (true) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
				if (x) {
					continue;
				}
				else {
					break;
				}
			}
		}
	}

	cout << endl;

	return 0;
	
}

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

typedef pair<int,int> PII;
int main(void){
  int n,t;
  vector<PII> vec;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> t;
    vec.push_back(make_pair(-t,i));
  }
  sort(vec.begin(), vec.end());
  for (int i=0; i<n; i++){
    if (i==vec[0].second) cout << -vec[1].first << endl;
    else cout << -vec[0].first << endl;
  }
  return 0;
}


Measured memory_bytes: 3312
#include<cstdio>

using namespace std;

void solve(int a,int b){
	for(int i = 0;i < a;i++){
		printf("%d",b);
	}
	printf("\n");
}

int main(){
	//freopen("in","r",stdin);
	int a,b;
	scanf("%d%d",&a,&b);
	if(a > b) solve(a,b);
	else solve(b,a);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char const *argv[]) {
  ll N;
  cin >> N;

  vector<vector<string>> vector_of_string(5);

  char march[6] = "MARCH";
  for (int i = 0; i < N; i++) {
    string temp;
    cin >> temp;
    for (int j = 0; j < 5; j++) {
      if (march[j] == temp[0]) {
        vector_of_string[j].push_back(temp);
      }
    }
  }
  size_t size_of_each_name_vector[6];
  for (int i = 0; i < 5; i++) {
    size_of_each_name_vector[i] = vector_of_string[i].size();
  }
  ll ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += size_of_each_name_vector[i] * size_of_each_name_vector[j] *
               size_of_each_name_vector[k];
      }
    }
  }

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


Measured memory_bytes: 5748
n=int(input())
c1=0
c2=0
for i in range(n):
    t,h=map(str,input().split())
    if t>h:
        c1+=3
    elif t<h:
        c2+=3
    else:
        c1+=1
        c2+=1

print("{0} {1}".format(c1,c2))



Measured memory_bytes: 5600
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>


using namespace std;


typedef long long ll;


int main() {

	int N, L;
	scanf("%d %d", &N, &L);

	vector<string> S;
	for (int i = 1; i <= N; i++) {
		string s;
		cin >> s;
		S.push_back(s);
	}

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

	for (auto itr = S.begin(); itr != S.end(); ++itr) {
		cout << (*itr);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

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

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    int k = S.size();

    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());

    int l = S.size();

    if (k == l) { cout<<"yes"<<endl; }
    else { cout<<"no"<<endl; }

}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


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

int main() {
  int S;
  cin >> S;
  int bef = S / 100;
  int aft = S - bef * 100;

  int isYYMM = false;
  if (bef >= 0 && bef <= 99 && aft >= 1 && aft <= 12) isYYMM = true;
  int isMMYY = false;
  if (aft >= 0 && aft <= 99 && bef >= 1 && bef <= 12) isMMYY = true;

  if (isYYMM && isMMYY)
    cout << "AMBIGUOUS" << endl;
  else if (isYYMM)
    cout << "YYMM" << endl;
  else if (isMMYY)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 1000000007
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define vit vector<int>::iterator
typedef pair<int,int> pii;
vector<pii> V[MAX];
int pos[MAX],flg,visited[MAX];
void dfs(int u){
    visited[u]=1;
    for(auto v:V[u]){
        if(v.second){
            if(!pos[v.first]){
                pos[v.first]=1;
                dfs(v.first);
            }
            else if(pos[v.first]==1){
                if(!visited[v.first])
                    dfs(v.first);
            }
            else flg=1;
        }
        else{
            if(!pos[v.first]) pos[v.first]=2;
            else if(pos[v.first]==1) flg=1;
        }
    }
}
int possible(int k,int n){
    vector<int>vec;
    for(int i=0;i<(n-k);i++) vec.pb(0);
    for(int i=0;i<k;i++) vec.pb(1);
    do{
        flg=0;
        for(int i=1;i<=n;i++){
            visited[i]=0;
            pos[i]=vec[i-1];
        }
        for(int i=1;i<=n;i++){
            if(!visited[i] && vec[i-1]){
                dfs(i);
            }
        }
        if(!flg)
            return 1;

    }while(next_permutation(vec.begin(),vec.end()));
    return 0;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        for(int j=0;j<a;j++){
            int x,y;
            cin>>x>>y;
            V[i+1].pb(mp(x,y));
        }
    }
    int lo,hi,mid;
    lo=0;
    hi=n;
    while(hi>lo){
        mid=(lo+hi+1)/2;
        if(possible(mid,n)) lo=mid;
        else hi=mid-1;
    }
    cout<<lo;
}


Measured memory_bytes: 5988
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	
	int ans = a+b;
	if(ans > b+c) ans = b+c;
	if (ans > c+a)	ans = c+a;

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

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int p,q;
    cin>>p>>q;
    cout<<p*q<<" "<<2*(p+q)<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pill;

int modCount[100005];
int pairs[100005];
void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> dp;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    modCount[t%m]++;
    dp[t]++;
  }
  for(auto x: dp) {
    pairs[(x.first%m)] += x.second / 2;
  }
  int ret = 0;
  {
    int zero = modCount[0]/2;
    ret += zero;
    modCount[0] -= 2 * zero;
  }
  {
    if(m%2 == 0) {
      int zero = modCount[m/2]/2;
      ret += zero;
      modCount[m/2] -= 2 * zero;
    }
  }
  for(int i = 1; i < m-i; i++) {
    int j = m-i;
    int take = min(modCount[i], modCount[j]);
    modCount[i] -= take;
    modCount[j] -= take;
    ret += take;
  }
  for(int i = 0; i < m; i++) {
    ret += min(pairs[i], modCount[i]/2);
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 5760
def resolve():
    N, K = map(int, input().split())
    targets = list(map(str, input().split()))
    targets_dict = {}

    for i in range(N):
        if targets[i] not in targets_dict:
            targets_dict[targets[i]] = 1
        else:
            targets_dict[targets[i]] += 1

    need_reduce = len(targets_dict) - K

    if need_reduce <= 0:
        print(0)
    else:
        ans = 0
        targets_dict = sorted(targets_dict.items(), key=lambda x: x[1])
        for i in range(need_reduce):
            ans += targets_dict[i][1]
        print(ans)
       
resolve()

Measured memory_bytes: 98772
#include <stdio.h>
int main(void){
    int A, B, C, D, s;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &D);
    s=0;
    if (A<B) s+=A;
    else s+=B;
    if (C<D) s+=C;
    else s+=D;
    printf("%d", s);
    return 0;
}


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

int main()
{
  int d;
  int i,j;
  int h;

  while(scanf("%d", &d)!=EOF){
    int  sum=0;
    for(i=1;i<600/d;i++)
      sum+=d*d*d*i*i;
    cout<<sum<<endl;
  }
}

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

int A,B,C;

int main()
{
	cin>>A>>B>>C;
	int cnt=0;
	while(1)
	{
		if(A&1||B&1||C&1) break;
		int a,b,c;
		a=(B+C)/2;
		b=(A+C)/2;
		c=(A+B)/2;
		A=a;
		B=b;
		C=c;
		cnt++;
		if(cnt==1e7) break;
	}
	if(cnt==1e7) puts("-1");
	else cout<<cnt<<endl;
}

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

int judge(char p[], int a){
    int i;
    char t[100];
    for(i=0;i<a;i++){
        t[i] = p[a-1-i];
    }
    t[a] = 0;
    //printf("%d; %s\n%s\n",a,p,t);
    if(strncmp(p,t,a)==0){ return 1; }
    else { return 0; }
}

int main(){
    char s[100], ss[100], sss[100]={};
    scanf("%s", s);
    int n=strlen(s) , c=0, i;
    for(i=0;i<(n-1)/2;i++){
        ss[i] = s[i];
    }
    for(i=0;i<(n-1)/2;i++){
        sss[i] = s[(n+3)/2 + i -1];
    }
    //printf("%s----\n",sss);
    c = judge(s,n) + judge(ss,(n-1)/2) + judge(sss,(n-1)/2);
    //printf("%d; %d %d %d",n,judge(s,n),judge(ss,(n-1)/2),judge(sss,(n-1)/2));
    if(c==3){ printf("Yes"); } else { printf("No"); }
    return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#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>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;

int a[10];
int main(){
	REP(i,10)cin>>a[i];
	sort(a,a+10,greater<int>());
	REP(i,3)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    
        ll n,a,b;
    cin>>n>>a>>b;
    
        if((b-a)%2==0)
        cout<<(b-a)/2;
        else
        {
            ll ans=(a-1<n-b)?a-1:n-b;
            cout<<ans+1+((b-a)/2);
        }
        
    
    
    
}

Measured memory_bytes: 3636
import qualified Data.ByteString.Char8 as C
import Data.List(unfoldr)


r' :: IO [Int]
r' = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [x,a] <- r'
    let r = if x<a then 0 else 10
    print r


Measured memory_bytes: 380
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long
#define f first
#define s second     
using namespace std;
 
void scan()
{
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
 
}
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
int ans[N];
int main() 
{
    scan();                 
    int n;
    cin >> n;
    pair<string, pair<int,int>> a[n + 1];
    for (int i = 1; i <= n; i++)
    {
    	cin >> a[i].f >> a[i].s.f;
    	a[i].s.s = i;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
    {
    	ans[a[i].s.s] = i;
    //	cout << a[i].f << " " << a[i].s.f << " " << a[i].s.s << '\n';
    }
    stack<int> q;
    q.push(a[1].s.s);
    for (int i = 2; i <= n; i++)
    {
    	if (a[i].f != a[i - 1].f)
    	{
    		while (q.size() > 0)
    		{
    			cout << q.top() << '\n';
    			q.pop();
    		}
    	} 	
    	q.push(a[i].s.s);
    }
    while (q.size() > 0)
    		{
    			cout << q.top() << '\n';
    			q.pop();
    		}

}     
//JUDGE_ID: 295965SY
//Tis I

Measured memory_bytes: 3652
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();

    if (2 * k <= b-a) {
      for (int i = 0; i < k; i++) {
        System.out.println(a);
        a++;
      }
      b -= k-1;
      for (int i = 0; i < k; i++) {
        System.out.println(b);
        b++;
      }
    } else if (2 * k > b-a) {
      for (; a <= b; a++) {
        System.out.println(a);
      }
    }

  }

}


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

void b()
{
	int n;
	std::cin >> n;
	int l[100];
	for (int i = 0; i < n; i++) {
		std::cin >> l[i];
	}

	std::sort(l, l+n);
	int sum = 0;
	for (int i = 0; i < n-1; i++) {
		sum += l[i];
	}
	std::cout << (sum > l[n - 1] ? "Yes" : "No") << std::endl;
}

int main()
{
	b();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	string s;
	int no=0;
	cin>>s;
	no=15-s.size();
	int kati=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='o')
			kati++;
	}
	if(kati+no>=8)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

lis = [4, 6, 9, 11]
lis2 = [1, 3, 5, 7, 8, 10, 12]

if a == b == 2:
    print('Yes')
elif a in lis and b in lis:
    print('Yes')
elif a in lis2 and b in lis2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(a-b>=0){
        printf("delicious\n");
    }else if((b-a)<=x){
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  string s;
  cin >> s;
  int count=0, ans=0;
  rep(i,s.size()) {
    if(s.at(i)=='A' || s.at(i)=='C' || s.at(i)=='G' || s.at(i)=='T') 
      count++;
    else 
      count = 0;
    ans = max(ans,count);
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		String line = input.nextLine();
		Scanner lineReader = new Scanner(line);
	
		ArrayList<Integer> values = new ArrayList<>();
		ArrayList<String> operations = new ArrayList<>();
		while (lineReader.hasNext()) {
			if (lineReader.hasNextInt()) {
				int val = lineReader.nextInt();
				values.add(val);
			} else {
				
				String operator = lineReader.next();
				int a = values.remove(values.size() - 1);
				int b = values.remove(values.size() - 1);
				
				int c;
				switch (operator) {
				case "+":
					c = a + b;
					break;
				case "-":
					c = b - a;
					break;
				case "*":
					c = a * b;
					break;
				default:
						c = -1;
					
				}
				values.add(c);
			}
		}
		
		System.out.println(values.get(0));
	}
}



Measured memory_bytes: 27044
import heapq
import queue
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Info:
    def __init__(self,arg_name,arg_rest_time):
        self.name = arg_name
        self.rest_time = arg_rest_time


N,LIMIT = map(int,input().split())
Q = deque()


for _ in range(N):
    tmp = input().split()
    Q.append(Info(tmp[0],int(tmp[1])))

current_time = 0

while len(Q) > 0:
    info = Q.popleft()
    if info.rest_time > LIMIT:
        info.rest_time -= LIMIT
        current_time += LIMIT
        Q.append(info)
    else:
        current_time += info.rest_time
        print("%s %d"%(info.name,current_time))



Measured memory_bytes: 18684
#include<stdio.h>
#include<math.h>


int main(void){

  double x[3], y[3];
  double xp, yp;
  double r[3];
  int i;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &xp, &yp)!=EOF){
    
    for(i=0; i<3; i++){
      r[i]=(x[(i+1)%3]-x[i])*(yp-y[i])-(y[(i+1)%3]-y[i])*(xp-x[i]);
    }
    if((r[0]>0 && r[1]>0 && r[2]>0) || (r[0]<0 && r[1]<0 && r[2]<0)){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    
  }

  return(0);
}



Measured memory_bytes: 2024