akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int n=read(),m=read(),x=read(),y=read(),ans=0;
ans+=x*min(n,m);
if (n>m) ans+=(n-m)*y;
write(ans);
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B;
    int R = C + D;
    if (L > R) cout << "Left" << endl;
    else if (R > L) cout << "Right" << endl;
    else cout << "Balanced" << endl;

    return 0;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < (int)(N); ++i) cin >> v[i] >> w[i];

  vector<int> dp(W + 1, 0);
  for (int i = 0; i < (int)(N); ++i) for (int j = W; j >= 0; --j) {
    if (j - w[i] >= 0) chmax(dp[j], dp[j - w[i]] + v[i]);
  }

  cout << dp[W] << endl;

  return 0;
}



Measured memory_bytes: 3152
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var n = len(s)
	var t = []byte{'A', 'G', 'C', 'T'}
	var cnt = 0
	var ans = 0
	for i := 0; i < n; i++ {
		if contains(s[i], t) {
			cnt++
		} else {
			ans = max(ans, cnt)
			cnt = 0
		}
	}
	ans = max(ans, cnt)
	fmt.Print(ans)
}

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

func contains(b byte, t []byte) bool {
	for i := range t {
		if b == t[i] {
			return true
		}
	}
	return false
}


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

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

  string s;
  cin >> s;

  int ans = 0;
  stack<char> st;
  rep(i, s.size()) {
    if (st.empty() || s[i] == st.top()) {
      st.push(s[i]);
    } else {
      st.pop();
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
 
#define ELEMENT_CNT_MIN (1)
#define ELEMENT_CNT_MAX (100)
#define ELEMENT_MIN (0)
#define ELEMENT_MAX (100)
#define SUCCESS     (0)
#define FAILURE     (-1)
 
int selection_sort(int *p_arr, int size);
void swap(int *px, int *py);
void put_arr(const int *p_arr, int size);
int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
 
 
int main(void){
     
    int element_num;
    int element[ELEMENT_CNT_MAX];
    int cnt_exchange;
     
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == FAILURE)
    {
        return FAILURE;
    }
     
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == FAILURE)
    {
        return FAILURE;
    }
     
    cnt_exchange = selection_sort(&element[0], element_num);
     
    put_arr(&element[0], element_num);
    printf("%d\n", cnt_exchange);
     
    return SUCCESS;
}
 
int selection_sort(int *p_arr, int size)
{
    int i;
    int j;
    int min_idx;
    int cnt = 0;    /* exchange count */
     
    for(i = 0; i < size - 1; i++)
    {
        min_idx = i;
        for(j = i + 1; j < size; j++)
        {
            if(p_arr[j] < p_arr[min_idx])   
            {
                min_idx = j;        /* minimum value [i,size - 1] */
            }
        }
        if(p_arr[i] != p_arr[min_idx])
        {
            swap(&p_arr[i], &p_arr[min_idx]);
            cnt++;
        }
    }
     
    return cnt;
}
 
void swap(int *px, int *py)
{
    int tmp = *px;
    *px = *py;
    *py = tmp;
     
    return;
}
 
void put_arr(const int *p_arr, int size)
{
    int i;
     
    for(i = 0; i < size - 1; i++)
    {
        printf("%d ", p_arr[i]);
    }
    printf("%d\n", p_arr[size - 1]);
}
 
int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
     
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == FAILURE)
        {
            return FAILURE;
        }
    }
     
    return SUCCESS;
}
 
int get_int(int *p_num, int min, int max)
{
    scanf("%d", p_num);
     
    if(judge_constraint(*p_num, min, max) == FAILURE)
    {
        return FAILURE;
    }
     
    return SUCCESS;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return FAILURE;
    }
     
    return SUCCESS;
}

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

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

  // ここにプログラムを追記
  int sum = 0;
  for(int i = 0; i< N ; i++){
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = Integer.parseInt(sc.next());
			B[i] = i+1;
		}
		int[][] ans = combSort(A,B);

		for(int i=0;i<N;i++) {
			if(i<N-1) {
				System.out.print(ans[1][i]+" ");
			} else {
				System.out.println(ans[1][i]);
			}
		}


	}
	public static int[][] combSort(int[] data,int[] index) {
		if(data.length>1) {
			int h = data.length * 10 / 13;

		    while (true) {
		        int swaps = 0;
		        for (int i = 0; i + h < data.length; ++i) {
		            if (data[i] > data[i + h]) {
		                swap(data, i, i + h);
		                swap(index,i,i+h);
		                ++swaps;
		            }
		        }
		        if (h == 1) {
		            if (swaps == 0) {
		                break;
		            }
		        } else {
		            h = h * 10 / 13;
		        }
		    }
		}
	    int[][] ans = new int[2][data.length];
	    ans[0] = data;
	    ans[1] = index;
	    return ans;
	}

	private static void swap(int[] a, int i, int j) {
	    int t = a[i];
	    a[i] = a[j];
	    a[j] = t;
	}
}

Measured memory_bytes: 48856
main(h,m,s,t){for(;scanf("%d%d%d",&h,&m,&s)*-~h;)for(t=7200-h*3600-m*60-s,h=2;h--;t*=3)printf("%02d:%02d:%02d\n",t/3600,t/60%60,t%60);}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  if(N==1||N==2||N==3||N==4||N==5||N==6||N==7||N==8||N==9||N==10||N==12||N==14||N==15||N==16||N==18||N==20||N==21||N==24||N==25||N==27||N==28||N==30||N==32||N==35||N==36||N==40||N==42||N==45||N==48||N==49||N==54||N==56||N==63||N==64||N==72||N==81){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int n;
int a[100];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  int sum = 0;
  for (int i = 1; i < n - 1; ++i) {
    int mx = 0;
    int mn = 1e9;
    for (int k = i - 1; k <= i + 1; ++k) {
      mx = max(mx, a[k]);
      mn = min(mn, a[k]);
    }
    if (a[i] != mx && a[i] != mn) {
      ++sum;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;

vector<int> Ss;

int from[50],nid[50],d[50][50],d2[50][50],inf=1e8;
bool vis[50];
vector<int> cycle;

int N,M;
vector<P> G[10000];
int indeg[10000],dd[10000];
int H[50][50];

void init(){
	cycle.clear();
	rep(i,50) from[i]=nid[i]=vis[i]=0;
	rep(i,50) rep(j,50) d[i][j]=d2[i][j]=0;
	rep(i,Ss.size()) rep(j,Ss.size()) d[i][j]=H[i][j];
}
bool visit(int v,int s,int r){
	if(v==r) return 0;
	if(vis[v]) return v==s;
	cycle.pb(v);
	vis[v]=1;
	return visit(from[v],s,r);
}
int dir_mst(int r){
	int S=Ss.size();
	bool update=1;
	while(update){
		update=0;
		int sco=0;
		rep(i,S){
			if(i==r) continue;
			P mn=P(inf,-1);
			rep(j,S) if(i!=j) chmin(mn,P(d[j][i],j));
			if(mn.fs==inf) return inf;
			from[i]=mn.sc;
			sco+=mn.fs;
		}
		rep(i,S){
			if(i==r) continue;
			rep(j,S) vis[j]=0;
			cycle.clear();
			if(!visit(i,i,r)) continue;
			update=1;
			int len=cycle.size();
			cycle.pb(cycle[0]);
			int S2=S-len+1,it=0;
			rep(j,S){
				if(!vis[j]) nid[j]=it++;
				else nid[j]=-1;
			}
			r=nid[r];
			rep(j,S) if(nid[j]!=-1){
				rep(k,S) if(nid[k]!=-1){
					d2[nid[j]][nid[k]]=d[j][k];
				}
			}
			rep(j,S) if(nid[j]!=-1){
				int mn=inf;
				rep(k,S) if(nid[k]==-1) chmin(mn,d[k][j]);
				d2[S2-1][nid[j]]=mn;
			}
			int csum=0;
			rep(j,len) csum+=d[cycle[j+1]][cycle[j]];
			rep(j,S) if(nid[j]!=-1){
				int mn=inf;
				rep(k,len) chmin(mn,d[j][cycle[k]]+csum-d[cycle[k+1]][cycle[k]]);
				d2[nid[j]][S2-1]=mn;
			}
			S=S2;
			rep(j,S) rep(k,S) d[j][k]=d2[j][k];
			break;
		}
		if(!update) return sco;
	}
}
int main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		G[a].pb(P(b,0));
		G[b].pb(P(a,1));
		indeg[b]++;
	}
	rep(i,N){
		if(indeg[i]==0) Ss.pb(i);
	}
	rep(i,Ss.size()){
		int s=Ss[i];
		deque<P> que;
		rep(j,N) dd[j]=inf;
		que.push_front(P(0,s));
		dd[s]=0;
		while(!que.empty()){
			P p=que.front();
			que.pop_front();
			int v=p.sc;
			if(p.fs!=dd[v]) continue;
			for(P e:G[v]){
				int u=e.fs;
				int nd=dd[v]+e.sc;
				if(nd<dd[u]){
					dd[u]=nd;
					if(e.sc==0) que.push_front(P(nd,u));
					else que.pb(P(nd,u));
				}
			}
		}
		rep(j,Ss.size()) H[i][j]=dd[Ss[j]];
	}
	vector<int> costs;
	rep(i,Ss.size()){
		init();
		int cost=dir_mst(i);
		costs.pb(cost);
	}
	int mn=inf;
	rep(i,Ss.size()) chmin(mn,costs[i]);
	vector<int> ans;
	rep(i,Ss.size()) if(mn==costs[i]) ans.pb(Ss[i]);
	cout<<ans.size()<<" "<<mn<<endl;
	rep(i,ans.size()) cout<<ans[i]<<(ans.size()==i+1 ? "\n" : " ");
}

Measured memory_bytes: 4060
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		int[] A = new int[N];

		int[] B = new int[M];

		int[] C = new int[N];

		for(int i=0;i<N;i++) {

			A[i] = sc.nextInt();
		}

		for(int i=0;i<M;i++) {

			B[i] = sc.nextInt();
		}

		Arrays.fill(C, 0);

		int a,b;

		for(int i=0;i<M;i++) {

			b = B[i];

			for(int j=0;j<N;j++) {

				a = A[j];

				if(a<=b) {

					C[j]++;

					break;
				}
			}
		}

		int r = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			if(C[i]>r) {

				r = C[i];

				ans = i;
			}
		}

		System.out.println(ans+1);
	}

}



Measured memory_bytes: 33196
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r= 0;
    rep(i,s.size()){
        if(s[i]=='R'){r++;}
    }
    int ans = 0;
    rep(i,r){
        if(s[i]=='W')ans++;
    }    
    cout<<ans<<endl;
    
    
    
    
return 0;
}


Measured memory_bytes: 3732
H, W = map(int,input().split())
MAP = []
for _ in range(H):
    MAP.append(list(input()))
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if MAP[i][j] == ".":
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        if MAP[H-1-i][W-1-j] == ".":
            if i == 0:
                D[H-1-i][W-1-j] = 1
            else:
                D[H-1-i][W-1-j] = D[H-i][W-1-j] + 1
            if j == 0:
                R[H-1-i][W-1-j] = 1
            else:
                R[H-1-i][W-1-j] = R[H-1-i][W-j] + 1

MAX = 0

for i in range(H):
    for j in range(W):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if MAX < tmp:
            MAX = tmp

print(MAX)

Measured memory_bytes: 313992
#include <stdio.h>

#include <iostream>

using namespace std;

int main() {
    int H, A;
    cin >> H >> A;

    if (H % A == 0) {
        cout << (H / A) << endl;
    } else {
        cout << (H / A) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
x = gets.to_i
a = 0
loop do
  a5 = a**5
  if a5 < x
    b5 = x - a5
    b = b5 ** (1.0/5)
    bf = b.floor
    bc = b.ceil
    if bf**5 == b5
      puts "#{a} #{-bf}"
      exit
    elsif bc**5 == b5
      puts "#{a} #{-bc}"
      exit
    end
  else
    b5 = a5 - x
    b = b5 ** (1.0/5)
    bf = b.floor
    bc = b.ceil
    if bf**5 == b5
      puts "#{a} #{bf}"
      exit
    elsif bc**5 == b5
      puts "#{a} #{bc}"
      exit
    end
  end
  a += 1
end



Measured memory_bytes: 14676
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function heap(a::Array{Int,1})
	h = [a[1]]
	for i in 2:length(a)
		hpush(h,a[i])
	end
	h
end

function hpush(h::Array{Int,1},x)
	push!(h,x)
	l = length(h)
	if l>1
		k = div(l,2)
		while h[k]>x&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Int,1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k < l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k]>z
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k]>=z&&h[2*k+1]>=z
					break
				else
					t = h[2*k]<h[2*k+1]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function heapl(a::Array{Int,1})
	h = [a[1]]
	for i in 2:length(a)
		hpushl(h,a[i])
	end
	h
end

function hpushl(h::Array{Int,1},x)
	push!(h,x)
	l = length(h)
	if l>1
		k = div(l,2)
		while h[k]<x&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpopl(h::Array{Int,1})
	x = h[1]
	z = pop!(h)
	if length(h)>0
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k]<=z
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k]<=z&&h[2*k+1]<=z
					break
				else
					t = h[2*k]<h[2*k+1]?2*k+1:2*k
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = heap(a[1:n])
	c = heapl(a[2n+1:3n])
	l = zeros(Int,n+1)
	r = zeros(Int,n+1)
	l[1] = sum(b)
	r[n+1] = sum(c)
	for i in 1:n
		if b[1] < a[n+i]
			p=hpop(b)
			hpush(b,a[n+i])
			l[i+1] = l[i]-p+a[n+i]
		else
			l[i+1] = l[i]
		end
		if c[1] > a[2n+1-i]
			q = hpopl(c)
			hpushl(c,a[2n+1-i])
			r[n+1-i] = r[n+2-i]-q+a[2n+1-i]
		else
			r[n+1-i] = r[n+2-i]
		end
	end
	s = -10^18
	for i in 1:n+1
		s = max(s,l[i]-r[i])
	end
	println(s)
end

main()

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


int main(){
  string s;
  cin >> s;
  
  int maxl=0,count=0;
  vector<char> sl={'A','C','G','T'};
  
  // for(int i=0;i<s.size();i++){
  //   for(int j=i;j<s.size();j++){
  //     bool flag=false;
  //     for(int k=0;k<4;k++){
  //       if(sl.at(k)==s.at(j)){
  //         flag=true;
  //         break;
  //       }
  //     }
  //     if(flag) count++;
  //     else{
  //       maxl=max(maxl,count);
  //       break;
  //     }
  //   }
  // }
  
  for(int i=0;i<s.size();i++){
    bool flag=false;
    for(int k=0;k<4;k++){
      if(sl.at(k)==s.at(i)){
        flag=true;
        break;
      }
    }
    if(flag){
      count++;
      if(i==s.size()-1) maxl=max(maxl,count);
    }else{
      maxl=max(maxl,count);
      count=0;
    }
  }
  
  cout << maxl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int frog(std::vector<int> v,int n)
{
    int dp[100001] = {0};
    dp[0] = 0;
    dp[1] = abs(v[0]-v[1]);
    int ans1 = abs(v[0]-v[1]) + abs(v[1]-v[2]);
    int ans2 = abs(v[0] - v[2]);
    dp[2] = min(ans1,ans2);

    for(int i=3;i<=n;i++)
    {
        int a2 = dp[i-2] + abs(v[i-2]-v[i]);
        int a4 = dp[i-1] + abs(v[i]-v[i-1]);

        dp[i] = min(a2,a4);
    }

    return dp[n-1];

}
int main()
{
    int n;
    cin>>n;
    std::vector<int> v;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }

    int ans = frog(v,n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4496
s = list(input()) 
l = len(s) # l = 29
j = l - 1 # j = 28

for i in range(l // 2):
    if s[i] != s[j]:
        print('No')
        exit(0)
    j -= 1


h = (l + 3) // 2 - 1 # h = 15
j = h - 2

for h in range(l // 2):
    if s[h] != s[j]:
        print('No')
        exit(0)
    j -= 1

print('Yes')

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

int main(){

int w,h,x,y,r;
cin>>w>>h>>x>>y>>r;
if(x>=r&&w-r>=x){
    if(y>=r&&h-r>=y){
        cout<<"Yes"<<endl;
        return 0;
    }
}
cout<<"No"<<endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  char a;
  cin >> a;
  if ('a' <= a && a <= 'z') cout << 'a' << endl;
  else cout << "A" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

string s;
int l,r,cnt;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    int l=0,r=s.lg-1;
    while(l<r){
        if(s[l]!='x' && s[r]!='x'){
            if(s[l]!=s[r]){
                cout << -1;
                return 0;
            }
            l++; r--;
        }
        else if(s[l]=='x' && s[r]=='x'){
            l++; r--;
        }
        else if(s[l]=='x') cnt++,l++;
        else cnt++,r--;
    }
    cout << cnt;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    string s;
    cin >> s;

    ll m = 1e15;
    for(ll i=0; i<sz(s)-2; i++)
    {
        ll cur = 100*((ll)(s[i]-48));
        cur+=10*((ll)(s[i+1]-48));
        cur+=((ll)(s[i+2]-48));
        
        m = min(m, abs(753-cur));
    }

    cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrA = new int[n];
		int[] arrB = new int[n];
		for (int i = 0; i < n; i++) {
		    arrA[i] = sc.nextInt();
		    arrB[i] = sc.nextInt();
		}
		Arrays.sort(arrA);
		Arrays.sort(arrB);
		int count;
		if (n % 2 == 0) {
		    int left = arrA[(n - 1) / 2] + arrA[(n - 1) / 2 + 1];
		    int right = arrB[(n - 1) / 2] + arrB[(n - 1) / 2 + 1];
		    count = Math.max(right - left + 1, 0);
		} else {
		    int left = arrA[n / 2];
		    int right = arrB[n / 2];
		    count = Math.max(right - left + 1, 0);
		}
	    System.out.println(count);
	}
}


Measured memory_bytes: 61452
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define forr(i, n) for(ll i = 0;i < n; ++i)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define test ll testcase; cin>>testcase; while(testcase--)
#define time printf("\n\nTime taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC)
const int INF = 1e9;
int main()
{
	//clock_t tStart = clock();
	cr7
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ll a,b;
	cin >>a>>b;
	cout << (ll)(a*b);
	//time;
	return 0;
}


Measured memory_bytes: 3640
N, K = map(int, input().split())
D = list(map(int, input().split()))
ans = N - 1

while True:
  ans += 1
  str_ans = list(map(int, str(ans)))
  ans_len = len(str(ans))
  ans_check = 0
  for i in range(ans_len):
    if str_ans[i] not in D:
      ans_check += 1
  if ans_len == ans_check:
    print(ans)
    break
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,k,d[110],ans=0,a[200][200];
    map<llong, llong> mp;
    cin >> n >> k;
    for(llong i=1;i<=k;i++){
        cin >> d[i];
        rep(j,d[i]){
            cin >> a[i][j];
            mp[a[i][j]]++;
        }
    }
    for(llong i=1;i<=n;i++){
        if(!(mp[i] >= 1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3804
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s;
	cin>>s;
	cout<<"2018/01/"<<s[8]<<s[9]<<endl;
}

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

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.


int main(){
    
  int W, H, x, y, r;
 
  cin >> W >> H >> x >> y >> r;
  
  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H)
    
    {
    
    cout << "No" << endl;
    
    }
  
  else
  
  {
        
    cout << "Yes" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	
	int ans = 0;
	REP(i, n) {
		int cnt = 0;
		while (v[i]%2==0) {
			v[i] /= 2;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans << endl;

}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  if(s.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	int t[n],x[n],y[n];
	for(int i=0; i<n; i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	int px=0,py=0,pt=0;
	for(int i=0; i<n; i++){
		ll tmp=abs(x[i]-px) + abs(y[i]-py);
		ll time=abs(t[i]-pt);
		if(tmp > time){
			cout << "No" << endl;
			return 0;
		}else if(tmp < time && (tmp-pt)%2){
			cout << "No" << endl;
			return 0;
		}
		px = x[i];
		py = y[i];
		pt = t[i];
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int N;
        int M;
        int[] am;
        int[] bm;
        int[][] cibi;

        try (InputScanner is = new InputScanner(System.in)) {
            N = is.ni();
            M = is.ni();
            am = new int[M];
            bm = new int[M];
            cibi = new int[M][];
            for(int i =0;i < M;i++){
                am[i] = is.ni();
                bm[i] = is.ni();
                cibi[i] = is.nia(bm[i]);
            }
        }


        long dp[] = new long[1 << N];
        for (int i = 0; i < dp.length; i++) {
            dp[i] = 1000000009;
        }
        dp[0] =0;
        //鍵 1→Mまで
        for(int i=1;i<=M;i++){
            //i番目を使って移動する集合
            int set = 0;
            for(int j = 0;j < cibi[i-1].length;j++){
                set = set | (1 << (cibi[i-1][j] -1));
            }
            for(int s = 0;s < (1<<N);s++){
                if(dp[s|set] > dp[s]+am[i-1]){
                    dp[s|set] =dp[s]+am[i-1];
                }
            }

        }
        if(dp[(1 << N)-1] == 1000000009){
            dp[(1 << N)-1] = -1;
        }

        System.out.println(dp[(1 << N)-1]);

    }

    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is){
            this.br =  new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }
        //next int
        public int ni(){
            return Integer.parseInt(this.nextElement());
        }
        //next long
        public long li(){
            return Long.parseLong(this.nextElement());
        }
        //next int array
        public int[] nia(int n){
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if(!hasElement()){
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null){
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}


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

int main() {
	int a, b, n;

	while (cin >> a) {
		cin >> b >> n;

		int sum = 0;
		for (; n-- > 0;) {
			a = a % b * 10;
			sum += a / b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
N = int(input())
ans = list(map(int, input().split()))

alice=0
bob=0
for _ in range(N):
    alice += max(ans)
    ans.remove(max(ans))
    if len(ans) == 0:
        break
    bob += max(ans)
    ans.remove(max(ans))
    if len(ans) == 0:
        break

print(alice - bob)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
#define inf 2147483647
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(i,x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define ln pc('\n')
#define pk pc(' ')
#define outn(x) out(x);ln;
#define outk(x) out(x);pk
#define out2(x,y) outk(x);outn(y);
#define out3(x,y,z) outk(x);out2(y,z)
#define out4(w,x,y,z) outk(w);out3(x,y,z)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;} 
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 201
ll n,x,ans,f=1;
char s[20];
int main(){
	scanf("%s",s);
	n=strlen(s);
	ans=(n-1)*9;
	Fur(i,1,n-1)if(s[i]!='9'){f=0;break;}
	if(f){outn(ans+s[0]-48);}
	else outn(ans+s[0]-48-1);
}


Measured memory_bytes: 256
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
    Date:12/06/2020
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
// ll mod=1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

const int N=1e5+5;
int cache[105][N];
int a[105][2];
int n,w;
int dp(int idx,int p)
{
    if(p<0)
    return 1e9+7;
    if(p==0)
        return 0;
    if(idx==n)
    return 1e9+7;
    int &ans=cache[idx][p];
    if(ans!=-1)
    return ans;
    ans=min(a[idx][0]+dp(idx+1,p-a[idx][1]),dp(idx+1,p));
    return ans;
}



bool test=0;
void solve()
{
    cin>>n>>w;
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
    memset(cache,-1,sizeof(cache));
    int ans=0;
    for(int i=1;i<N;i++)
    {
        if(w>=dp(0,i))
        ans=i;
    }
    cout<<ans;
}







signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin.exceptions(cin.failbit);
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// 	#endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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


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

using namespace std;

const int M = 3e3;
int n, T, t[M], v[M], memo[M][M][2];

int solve(int m, int i, bool got) {
    if (i == n)
        return 0;

    int &r = memo[m][i][got];

    if (r == -1) {
        if (t[i] + m < T) {
            if (!got)
                r = max(v[i] + solve(m, i + 1, 1), max(solve(m, i + 1, 0), v[i] + solve(t[i] + m, i + 1, 0)));
            else
                r = max(solve(m, i + 1, 1), v[i] + solve(t[i] + m, i + 1, 1));
        } else {
            if (!got)
                r = max(v[i] + solve(m, i + 1, 1), solve(m, i + 1, 0));
            else
                r = solve(m, i + 1, 1);
        }
    }
    return r;
}

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

    memset(memo, -1, sizeof memo);

    cin >> n >> T;
    for (int i = 0; i < n; i++)
        cin >> t[i] >> v[i];

    cout << solve(0, 0, 0) << '\n';

    return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{
	int box[3],i;
	for (i = 0; i < 3; i++) {
		cin >> box[i];
		if (box[i] < 1 || box[i]>10000) {
			cout << "Error! Please input the numbers from 1 to 10000." << endl;
			i--;
		}
	}
	for (i = 0; i < 3; i++) {
		for (int j = 1; j <= 2 - i; j++) {
			if (box[i] > box[i + j]) {
				int temp = box[i];
				box[i] = box[i + j];
				box[i + j] = temp;
			}
		}
	}

	for (i = 0; i < 3; i++) {
		cout << box[i];
		if (i == 2) {
			cout << endl;
		}
		else
			cout << " ";
	}

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s.at(0) == 'a' && s.at(1) == 'b' && s.at(2) == 'c') {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  ll x;
  cin>>x;
  ll now=100;
  for(int i=0;i<4000;i++){
      now+=now/100;
      if(now>=x){
          cout<<i+1<<"\n";
          return 0;
      }
  }
}

Measured memory_bytes: 3652
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;
int n, m;
ll t[200000];
int main(void) {
	ll T;
	cin >> n>> T;
	ll sum = T;
	rep(i, n) {
		cin >> t[i];
	}
	rep(i, n-1) {
		sum += min(T, t[i+1] - t[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



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

	for(int i=0; i<n-2; i++){
		for(int j=i+1; j<n-1; j++){
			for(int k=j+1; k<n; k++){
				if((length[i]+length[j]>length[k]) && (length[j]+length[k]>length[i]) && (length[k]+length[i]>length[j])){
					if((length[i] != length[j]) && (length[j] != length[k]) && (length[k] != length[i])){
						count++;
					}
				}
			}
		}
	}

	printf("%d\n", count);
	
	return 0;
}



Measured memory_bytes: 1728
def solve():
    ret = sum(A)
    dict_A = {}
    for a in A:
        dict_A[a] = dict_A.get(a, 0) + 1
    for i in range(Q):
        tmp = dict_A.get(B[i], 0)
        ret -= tmp * B[i]
        dict_A[B[i]] = 0
        dict_A[C[i]] = dict_A.get(C[i], 0) + tmp
        ret += C[i] * tmp
        print(ret)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    B, C = [], []
    for _ in range(Q):
        b, c = map(int, input().split())
        B.append(b)
        C.append(c)
    solve()

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

int main(){

    int A,B,M; cin >> A >> B >> M;
    int a[A];for(int i = 0; i < A; i++){cin >> a[i];}
    int b[B];for(int i = 0; i < B; i++){cin >> b[i];}
    int x[M],y[M],c[M];for(int i = 0; i < M; i++){cin >> x[i] >> y[i] >> c[i];}

    int min_a = 1000000;for(int i = 0; i < A; i++){min_a = min(min_a,a[i]);}
    int min_b = 1000000;for(int i = 0; i < B; i++){min_b = min(min_b,b[i]);}
 
    int ans = min_a + min_b;

    for(int i = 0; i < M; i++){
        ans = min(ans, a[x[i]-1] + b[y[i]-1] - c[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2176
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
#define MAXN 1000002
char s[MAXN];
int dp[MAXN][2];
int n;
void solve() {
    scanf("%s",s+1);
    n=strlen(s+1);
    s[0]='0';
    dp[n][0]=s[n]-'0';
    dp[n][1]=1+10-(s[n]-'0');
    for(int i=strlen(s+1)-1;i>=1;i--)
    {
        dp[i][0]=min(dp[i+1][0]+s[i]-'0',dp[i+1][1]+s[i]-'0');
        dp[i][1]=min(dp[i+1][0]+1+10-(s[i]-'0'),dp[i+1][1]+11-(s[i]-'0')-2);
    }
    cout<<min(dp[1][0],dp[1][1])<<endl;


}

int32_t main() {
    IOS;
    int test = 1;
     //cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 16896
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


long long lcm(long long n, long long m) {
	long long r,x,tmp;
	x = m * n;
	/* 自然数 a > b を確認・入替 */
	if (n < m) {
		tmp = n;
		n = m;
		m = tmp;
	}

	/* ユークリッドの互除法 */
	r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return x / m;

}



int main() {

	int N;
	pair<int, int> task;
	string ans = "Yes";
	int ctime = 0;


	cin >> N;
	vector<pair<int, int>> tasks(N);
	int time, limit;
	for (auto i = 0; i < N; i++)
	{
		cin >> time >> limit;
		tasks[i] = make_pair(limit, time);
	}
	sort(tasks.begin(), tasks.end());
	
	for (auto i = 0; i < N; i++)
	{
		ctime += tasks[i].second;
		if (ctime > tasks[i].first) {
			ans = "No";
			break;
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def ang(n) Array.new(n){gsmi} end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def arrays(n,num) #要素数、配列数
  ret = Array.new(num){Array.new(n)}
  n.times do |i|
    ins = gsmi
    num.times{|j| ret[j][i] = ins[j] }
  end
  ret
end

$stdin = File.open('input.txt') if File.exist?('input.txt')

n,w_max = gsmi #100, 10**5
w,v = arrays(n,2)
w.unshift 0
v.unshift 0

dp = Array.new(n+1){Array.new(w_max+1){0}}
(1..n).each do |i|
  (0..w_max).each do |j|
    if (j-w[i])>=0
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])
    else
      dp[i][j] = dp[i-1][j]
    end
  end
end

puts dp[-1].max


Measured memory_bytes: 93260
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAX 10000;

int main(){
  int input[3],use[3];
  int k;
  bool isSuccess = false;
  for(int i=0; i < 3; i++){
  	scanf("%d",&input[i]); //r -> g -> b
  }
  scanf("%d",&k);

  for(int n = 0; n < 10000; n++){
  	for(int i = 0; i < 3; i++){
  		use[i] = input[i]; //r -> g -> b
  	}
  	for(int i = 0; i < k; i++){
  		int j = rand() % 3;
  		use[j] = use[j] * 2;
  		if(use[1] > use[0] && use[2] > use[1]){
  			isSuccess = true;
  			break;
  		}
  	}
  }
  if(isSuccess == true){
  	printf("Yes\n");
  }else{
  	printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1660
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,C=mi()
    X = set()
    y = 0
    for x in [A,B,C]:
        if x in X: y = x
        X.add(x)

    for x in [A,B,C]:
        if x != y:
            print(x)
            exit()





if __name__ == "__main__":
    main()

Measured memory_bytes: 61908
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int x,y;
	cin>>x>>y;
	
	int ans = INF;
	{
		int a = y-x;
		int b = -y-x+1;
		if(a>=0)ans = min(a,ans);
		if(b>=0)ans = min(b,ans);
	}
	
	{
		int a = y-(-1)*x+1;
		int b = -y-(-1)*x+2;
		if(a>=0)ans = min(a,ans);
		if(b>=0)ans = min(b,ans);
	}
	cout<<ans<<endl;
}

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

#define lli long long int 
#define pb push_back

struct q 
{
	int at ;
	bool cor ;
};
int main ()
{
	int n , m , a , ans = 0 , ans2 = 0 ;
	cin >> n >> m ;
	string b ;
	struct q que [100001] ;

	for (int i = 0 ; i < 100001 ; i++)
	{
		que[i].at = 0 ;
		que[i].cor = false ;
	}

	for (int i = 0 ; i < m ; i++)
	{
		cin >> a >> b ;

		if (b == "AC" && !(que[a].cor))
		{
			que[a].cor = true ;
			ans += que[a].at ;
			ans2++ ;
		}
		else if (b == "WA")
		{
			que[a].at += 1 ;
		}
	}

	cout << ans2 ;
	cout << " " ;
	cout << ans << endl ;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;

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

  ll ans = LLONG_MAX;
  ll can = solve(h, w);
  ans = min(ans, can);

  can = solve(w, h);
  ans = min(ans, can);

  cout << ans << endl;

  return 0;
}

ll solve(ll h, ll w){
  //res1は縦分割, res2はT字型分割
  ll res1 = LLONG_MAX, res2 = LLONG_MAX;

  ll s1, s2, s3;
  for(int i=1; i<h; i++){
    //縦分割
    ll smax = 0, smin = LLONG_MAX;
    s1 = i*w; smax = max(s1, smax); smin = min(s1, smin);
    s2 = ((h-i)/2)*w; smax = max(s2, smax); smin = min(s2, smin);
    s3 = (h-(h-i)/2-i)*w; smax = max(s3, smax); smin = min(s3, smin);
    res1 = min(res1, smax - smin);
    //T字型分割

    smax = 0; smin = LLONG_MAX;
    s1 = i*w; smax = max(s1, smax); smin = min(s1, smin);
    s2 = (h-i)*(w/2); smax = max(s2, smax); smin = min(s2, smin);
    s3 = (h-i)*(w-w/2); smax = max(s3, smax); smin = min(s3, smin);
    res2 = min(res2, smax - smin);
  }

  return min(res1, res2);
}


Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <stdio.h>
#include <string>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
int MOD = 1e9+7;

int main(){
   int n,k;
   cin >> n >> k;
   vector<int> vec(n);
   vector<int> dp(n);
   for(int i=0;i<n;i++){
       int x;
       cin >> x;
       vec[i]=x;
   }
   dp[0]=0;
   dp[1]=abs(vec[1]-vec[0]);
   for(int i=2;i<n;i++){
       if(i>=k){
           dp[i]=dp[i-1]+abs(vec[i]-vec[i-1]);
           for(int j=2;j<=k;j++){
               dp[i]=min(dp[i],dp[i-j]+abs(vec[i]-vec[i-j]));
           }
       }else{
           dp[i]=dp[i-1]+abs(vec[i]-vec[i-1]);
           for(int j=2;j<=i;j++){
               dp[i]=min(dp[i],dp[i-j]+abs(vec[i]-vec[i-j]));
               
           }
       }
   }
   cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
	
int length(int a[]){
	int res=0,len=0;
	for(int i=0;i<14;i++){
		if(a[i])len++;
		else len=0;
		res=max(res,len);
	}
	return res;
}
int main(){
	int a[14];
	int n;
	while(scanf("%d",&n)!=EOF){
		fill(a,a+14,0);
		a[n-1]++;
		if(n==1)a[13]++;
		for(int i=1;i<5;i++){
			scanf(",%d",&n);
			a[n-1]++;
			if(n==1)a[13]++;
		}
		char *ans="null";
		if(count(a,a+13,4)==1) ans="four card";
		else if(count(a,a+13,3)==1 && count(a,a+13,2)==1)ans="full house";
		else if(length(a)==5) ans="straight";
		else if(count(a,a+13,3)==1) ans="three card";
		else if(count(a,a+13,2)==2) ans="two pair";
		else if(count(a,a+13,2)==1) ans="one pair";
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1004