akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
 
#define tate 3
#define yoko 3
#define Total (tate*yoko)
#define TryCnt 45

extern inline void down_0(void);    // 0 を下に移動
extern inline void up_0(void);      // 0 を上に移動
extern inline void right_0(void);   // 0 を右に移動
extern inline void left_0(void);    // 0 を左に移動

extern int  serch(int x, int y, int MaxCnt, int pre);

int num = 0;        // 0 の位置を示す
int val[Total] ={}; // 数値配列


int main( void )
{
    int i = 0;
    int x,y = 0;
    
    // 文字列の取り込み
    for(i=0; i<Total; i++)
    {
        scanf("%d",&val[i]);
        
        if(val[i] == 0)
        {
            num = i;
        }
    }
    
    // 右下に行くために 0 を何回動かせばいいか。
    x = tate - (num/yoko) -1;
    y = yoko - (num%yoko) -1;
    
    for(i=0; i<TryCnt; i++)
    {
        if( serch(x,y,i,4) == 1 )
        {
            printf("%d\n",i);
            break;
        }
    }     
    
    return 0;
}

int serch(int x, int y, int MaxCnt, int pre)
{
    int result;
    int i=0;
    
    // 最大数でゴールと一致しているか確認
    if(MaxCnt==0)
    {
        for(i=0; i<Total-1; i++)
        {
            if(val[i] != (i+1))
            {
                // ゴールと不一致
                return 0;
            }
        }
        // ゴールと一致！！
        return 1;
    }
    
    
    // 0 の移動
    for(i=0; i<4; i++)
    {
        result = 0;
        
        switch(i)
        {
            case 0:
                if( (x > 0) && (pre != 3) )
                {
                    down_0();
                    
                    result = serch(x-1, y, MaxCnt-1, 0);
                    
                    up_0();
                }
                break;
                
            case 1:
                if( (y > 0) && (pre != 2) )
                {
                    right_0();
                    
                    result = serch(x, y-1, MaxCnt-1, 1);
                    
                    left_0();
                }
                break;
                
            case 2:
                if( (y < yoko -1 ) && (pre != 1) )
                {
                    left_0();
                    
                    result = serch(x, y+1, MaxCnt-1, 2);
                    
                    right_0();
                }
                break;
                
            case 3:
                if( (x < tate -1 ) && (pre != 0) )
                {
                    up_0();
                    
                    result = serch(x+1, y, MaxCnt-1, 3);
                    
                    down_0();
                }
                break;
                
            default:
                // 何もしない。
                break;
        }
        
        if(result)
        {
            return 1;
        }
    }
    
    return 0;
}


inline void down_0()
{
    val[num] = val[num + yoko];
    num = num + yoko;
}
 
inline void up_0()
{
    val[num] = val[num - yoko];
    num = num - yoko;
}
 
inline void right_0()
{
    val[num] = val[num +1];
    num = num + 1;
}
 
inline void left_0()
{
    val[num] = val[num -1];
    num = num - 1;
}


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

int main(){
    int n[4];
    cin >> n[0] >> n[1] >> n[2]>> n[3];
    bool flag = true;
    for(int i=0; i<4; i++){
        if(n[i]==1) break;
        if(i==3) flag = false;
    }
    for(int i=0; i<4; i++){
        if(n[i]==9) break;
        if(i==3) flag = false;
    }
    for(int i=0; i<4; i++){
        if(n[i]==7) break;
        if(i==3) flag = false;
    }
    for(int i=0; i<4; i++){
        if(n[i]==4) break;
        if(i==3) flag = false;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

using namespace std;

int main(void){
  int n, m;
  int l, r;
  int max_sum , min_sum;
  int i, j, c;
  
  cin >> n >> m;
  cin >> min_sum >> max_sum;
  for(i = 1; i < m; i++){
  	cin >> l >> r;
    if(min_sum < l){
      min_sum = l;
    }
    if(max_sum > r){
      max_sum = r;
    }
  }
  if(max_sum - min_sum >= 0){
    cout << max_sum - min_sum + 1<< endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n,ca=0,cb=0;
	string s;
	cin>>n>>s;
	rep(i,s.size()) if(s[i]=='R') ca++;else cb++;
	if(ca>cb) puts("Yes");
	else puts("No");
	rt0;
}

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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll n,sum = 0,i,bc = 0;
    string st;
    cin>>st;
    n = st.size();
    vector<ll> op(n);
    For(i,0,n){
        if(st[i] == 'B') bc++;
        else op[i] = bc;
    }
    For(i,0,n) sum += op[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 2196
def calc(a)
  stack = []
  symbol = '+-*/'
  a.each do |e|
    stack << 
    if symbol.include?(e)
      a, b = stack.pop(2)
      eval("#{a}#{e}#{b}")
    else
      e.to_i
    end
  end
  stack[0]
end

p calc(gets.split)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N, X, T;
	cin >> N >> X >> T;
	ce(T*((N+X-1)/X ))
    return 0;
}



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

void solve()
{
}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int f = 1;
    while (a > 0 && c > 0)
    {
        if (f)
        {
            c = c - b;
            f = 0;
        }
        else
        {
            f = 1;
            a = a - d;
        }

        //cout<<"a health is "<<a<<" c health is "<<c<<"\n";
    }
    if (a > 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	double r;
	cin >> r;
	cout << std::setprecision(10) << 2 * r * 3.1415926535 << "\n";

	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
string a;
signed main(){
	cin>>a;
	if(a[2]==a[3]&&a[4]==a[5])
	{
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

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

struct Node T[MAX];

void preParse(int);

void inParse(int);

void postParse(int);

int main(){
    int i,v,l,r,n,root;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        T[i].p = NIL;
    }
    for(i = 0;i < n;i++){
        scanf("%d%d%d",&v,&l,&r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL)T[l].p = v;
        if(r != NIL)T[r].p = v;
    }
    
    for(i = 0;i < n;i++){
        if(T[i].p == NIL)root = i;
    }
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
    return 0;
}
void preParse(int u){
    if(u == NIL)return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
void inParse(int u){
    if(u == NIL)return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
void postParse(int u){
    if(u == NIL)return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}


Measured memory_bytes: 2140
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        int result = 0;
        for (int i = s.length() - 1; 0 < i && result == 0; i--) {
            if (i % 2 == 0) {
                String head = s.substring(0, i / 2);
                String foot = s.substring(i / 2, i);
                if (head.equals(foot)) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scn=new Scanner(System.in);
        int n = scn.nextInt();
        int d=scn.nextInt();
        int[][] dot=new int[n][d];
        int answer=0;

        for(int i=0;i<n;i++){
            for(int j=0;j<d;j++){
                dot[i][j]=scn.nextInt();
            }
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double check=0;
                for(int k=0;k<d;k++){
                    check+=(dot[i][k]-dot[j][k])*(dot[i][k]-dot[j][k]);
                }
                check=Math.sqrt(check);
                if(check==(int)check){
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23636
var
	N,A,i:Longint;
	f:Boolean;
begin
	f:=True;
	read(N);
	for i:=1 to N do begin
		read(A);
		if A mod 2=0 then begin
			if(A mod 3<>0)and(A mod 5<>0)then f:=False;
		end;
	end;
	if f then writeln('APPROVED')else writeln('DENIED');
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{	
	string s;
	cin >> s;
	int curr=0, highest=0;
	for (int i=0; i<3; i++) {
		if (s[i]=='S') curr=0;
		else curr++, highest=max(highest, curr);
	}
	cout << highest;
	return 0;
}

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

using namespace std;
#define int long long

signed main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  vector<int> c1(41,0);
  for (auto a:A) for(int i=0;i<41;i++) if(a&(1LL<<i)) c1[i]++;

  int maxf = 0;

  for(int i=40; i>=0; i--) {
    if( (K & (1LL << i)) == 0 ) continue;

    int f = 0;
    for(int j=40; j>i; j--) {
      int p = 1LL<<j;
      int c1j = c1[j];
      int c0j = N - c1j;
      f += K&p ? p * c0j : p * c1j;
    }

    f += (1LL<<i) * c1[i];

    for(int j=i-1; j>=0; j--) {
      int p = 1LL<<j;
      int c1j = c1[j];
      int c0j = N - c1j;
      f += p * max(c1j, c0j);
    }
    maxf = max(maxf, f);
  }

  int fk = 0;
  for(int i=40; i>=0; i--) {
    int p = 1LL<<i;
    int c1i = c1[i];
    int c0i = N - c1i;
    fk += K&p ? p * c0i : p * c1i;
  }
  maxf = max(maxf, fk);

  cout << maxf << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    vll A(N);
    cin >> A;
    ll score=abs(A[0]);
    for(int i=1; i<N; i++){
        score += abs(A[i]-A[i-1]);
    }
    score += abs(A[N-1]);

    cout << (score - abs(A[0]) - abs(A[1]-A[0]) + abs(A[1])) << endl;

    for(int i=1; i<N-1; i++){
        cout << (score - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1])) << endl;
    }

    cout << (score - abs(A[N-1]-A[N-2]) - abs(A[N-1]) + abs(A[N-2])) << endl;

}

Measured memory_bytes: 4040
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<i64>();
    }
    let mut ans = seq[0];
    for i in 0..n {
        ans = gcd(ans, seq[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  int count = 0 ;
  int n = s.size() ;
  
  rep(i, n){
    if(s.at(i) == 'o'){
      count++ ;
    }
  }
  cout << 700+count*100 <<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=-1;
  for(int i=1;i<=5;i++)
  { 
    n=sc.nextInt();
    if(n==0)
    { System.out.println(i);
     break;
    }
  }
}}

Measured memory_bytes: 35624
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

signed  main(){
    int r;
    cin >> r;
    Pr(3*r*r);
    return 0;
}



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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main() {
  Real r; cin >> r;
  cout.precision(18);
  cout << (r*r*PI) << ' ' << (r*2*PI) << endl;
  return 0;
}

Measured memory_bytes: 1284
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var intArray []int

	fmt.Scanf("%d", &n)
	intArray = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &intArray[i])
	}
	sort.Ints(intArray)

	mostLong := intArray[n-1]
	v := 0
	for i := 0; i < n-1; i++ {
		v += intArray[i]
	}

	if v > mostLong {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import collections

n = int(input())
a = [int(num) for num in input().split()]

list_num = collections.Counter(a)

count_max = 0
for x in range(min(a), max(a)+1):
    count = list_num[x-1] + list_num[x] + list_num[x+1]
    count_max = max(count_max, count)

print(count_max)

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll a, p;
  cin >> a >> p;
  COUT((3 * a + p) / 2);

}

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

/*

3 2
*/


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

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

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int i;
    int cnt=0; 
    for(i=a;i<=b;i++){
        if(c % i == 0){
            cnt++;
        } 
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

#define ll long long

int main(){
   
   ll N,K,cnt=0;
   cin>>N>>K;
   for(ll i=0;i<N;i++){
       ll a;
       cin>>a;
   }
   
   for(ll i=0;i<N-1;){
       i+=K-1;
       cnt++;
   }
   
   cout<<cnt<<endl;
   
   return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
dog, cat = map(int, input().split())
pd = 1
pc = 1
ans = 0
if abs(dog - cat) > 1:
    ans = 0
elif abs(dog - cat) == 1:
    for i in range(1, min(dog, cat)+1):
        pd = pd * i % MOD
    pc = pd * max(dog, cat) % MOD
    ans = pd * pc % MOD
else:
    for i in range(1, dog+1):
        pd = pd * i % MOD
    ans = pd * pd % MOD
    ans = ans * 2 % MOD
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()

int solve(string &s, int &i){
    vector<int> v;
    if(isdigit(s[i])){
        int num = 0;
        while(isdigit(s[i])){
            num = num*10 + s[i]-'0';
            i++;
        }
        return num;
    }
    while(s[i] == '['){
        i++;
        v.push_back(solve(s,i));
        assert(s[i] == ']');
        i++; // ]
    }

    int n = v.size();
    sort(all(v));
    int num = 0;
    rep(k,(n+1)/2){
        num += (v[k]+1)/2;
    }
    return num*2-1;
}

int main(void){
    int T;
    cin>>T;
    rep(_,T){
        string s;
        cin>>s;
        int index = 0;
        cout<<(solve(s,index)+1)/2<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define int ll
#define pb push_back
#define bp pop_back
#define X first
#define Y second
#define sz(a) (int)(a.size())

const int MAXN = 1e5 + 10; // ios_base :: sync_with_stdio(false);

signed main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	set<int> adj[MAXN], add[MAXN];
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].insert(b);
		adj[b].insert(a);
		add[a].insert(b);
		add[b].insert(a);
	}
	deque <int> dq;
	int a = 0;
	int b = *adj[0].begin();
	for(int i : adj[a])
		adj[i].erase(a);
	for(int i : adj[b])
		adj[i].erase(b);
	adj[a].erase(b);
	adj[b].erase(a);
	dq.pb(a);
	dq.pb(b);
	while(true) {
		if(sz(adj[dq.back()])) {
			int s = *adj[dq.back()].begin();
//			cout << s << " is in " << dq.back() << endl;
			for(int i : add[s]) {
				adj[i].erase(s);
//				cout << s << " is not in " << i << endl;
			}
			adj[s].erase(dq.back());
			adj[dq.back()].clear();
			dq.push_back(s);
		} else if(sz(adj[dq.front()])) {
			int s = *adj[dq.front()].begin();
//			cout << s << " is in " << dq.front() << endl;
			for(int i : add[s]) {
				adj[i].erase(s);
//				cout << s << " is not in " << i << endl;
			}
			adj[s].erase(dq.front());
			adj[dq.front()].clear();
			dq.push_front(s);	
		} else
			break;
//		for(int i = 0; i < sz(dq); i++)
//			cout << dq[i] << ' ';
//		cout << endl;
	}
	cout << sz(dq) << endl;
	for(int i = 0; i < sz(dq); i++)
		cout << dq[i] + 1 << ' ';
}


Measured memory_bytes: 29824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 2019;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

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

  ll arr[200100];
  ll count[3000];

  // int keta = 0;
  // for (int i = s.size() - 1; i >= 0; i--)
  // {
  //   struct mint m(10);
  //   struct mint tmp(s[i] - '0');
  //   int val = (tmp * m.pow(keta)).x;
  //   arr[i] = (arr[i + 1] + val) % 2019;
  //   count[arr[i]]++;
  //   keta++;
  // }

  ll keta = 1;
  reverse(s.begin(), s.end());
  rep(i, s.size())
  {
    ll val = (keta * (s[i] - '0')) % 2019;
    if (i == 0)
      arr[i] = val % 2019;
    else
      arr[i] = (arr[i - 1] + val) % 2019;
    count[arr[i]]++;
    keta *= 10;
    keta %= 2019;
  }

  ll ans = 0;
  count[0]++;
  rep(i, 2019)
  {
    // {
    //   if (count[i] == 0)
    //     continue;
    //   if (count[i] == 1)
    //   {
    //     ans++;
    //     continue;
    //   }
    //   ans += ((count[i] + 1) * count[i]) / 2;
    //   continue;
    // }

    ans += (count[i] * (count[i] - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5296
#include <atcoder/fenwicktree>
#include <cstdio>

using namespace std;
using namespace atcoder;

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

    fenwick_tree<long long> fw(n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        fw.add(i, a);
    }

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int p, x;
            scanf("%d %d", &p, &x);
            fw.add(p, x);
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", fw.sum(l, r));
        }
    }
}

Measured memory_bytes: 8216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[201][201];
int main() {
	int n;
	cin >> n;
	vector<string> c;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s != "-") c.push_back(s);
	}
	n = c.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if (c[i] == "U") {
				(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
				(dp[i + 1][j] += (dp[i][j] * j) % MOD) %= MOD;
			}
			else {
				(dp[i + 1][j - 1] += (dp[i][j] * j*j) % MOD) %= MOD;
				(dp[i + 1][j] += (dp[i][j] * j) % MOD) %= MOD;
			}
		}
	}
	cout << dp[n][0] << endl;
}


Measured memory_bytes: 3436
#include <iostream>

using namespace std;
long long N,W,w[101],v[101],i,j;
int main()
{
    // freopen("knapsack.inp","r",stdin);
    cin >> N >> W;
    for (i=1;i<=N;i++)
    {
        cin >> w[i] >> v[i];
    }
    long long F[N+1][W+1];
    F[0][0]=0;
    for (i=1;i<=N;i++)
    {
        F[i][0]=0;
    }
    for (i=1;i<=W;i++)
    {
        F[0][i]=0;
    }
    for (i=1;i<=N;i++)
    {
        for (j=1;j<=W;j++)
        {
            if (j<w[i])
            {
                F[i][j]=F[i-1][j];
            }
            else
            {
                F[i][j]=max(F[i-1][j],F[i-1][j-w[i]]+v[i]);
            }
        }
    }
    cout << F[N][W];
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    pair<int,int> itv[M];
    for(int i=0;i<M;i++){
        cin>>itv[i].second>>itv[i].first;
    }
    sort(itv,itv+M);
    int ans=0,t=0;
    for(int i=0;i<M;i++){
        if(t<=itv[i].second){
            ans++;
            t=itv[i].first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " " <<
#define X first
#define Y second
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

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

const int MAX = 1<<18;

vector <int> V[MAX];
int in[MAX], deg[MAX];
int n;
int p[MAX];
int ima[MAX];

int mex(int ind) {
  for (auto it : V[ind])
    if (p[it] != -1)      
      ima[p[it]] = 1;
  
  int ret=-1;
  REP(i, MAX) {
    if (!ima[i]) {
      ret = i;
      break;
    }
  }

  for (auto it : V[ind])
    if (p[it] != -1)
      ima[p[it]] = 0;
  
  return ret;  
}

void yup() {
  printf("POSSIBLE\n");
  exit(0);
}

void check() {
  REP(i, n)
    if (mex(i) != p[i])
      return;  
  yup();
}

int main()
{
  memset(p, -1, sizeof p);
  
  scanf("%d", &n);
  REP(i, n) {
    int x;
    scanf("%d", &x); x--;
    in[i] = x;
    V[x].push_back(i);
    deg[x]++;
  }

  queue <int> Q;
  REP(i, n)
    if (!deg[i])
      Q.push(i);

  for (; !Q.empty(); ) {
    int tmp = Q.front();
    Q.pop();
    
    p[tmp] = mex(tmp);
    deg[in[tmp]]--;
    if (!deg[in[tmp]])
      Q.push(in[tmp]);
  }

  int prvi=-1;
  REP(i, n)
    if (deg[i])
      prvi = i;

  assert(prvi != -1);

  int kamo = -1;
  for (auto it : V[prvi])
    if (deg[it])
      kamo = it;

  assert(kamo != -1);

  int poc = mex(prvi);
  p[prvi] = poc;
  for (int st=0, tmp=prvi; !st || tmp != prvi; st=1, tmp=in[tmp])
    p[tmp] = mex(tmp);
  
  check();

  p[kamo] = poc;
  for (int st=0, tmp=prvi; !st || tmp != prvi; st=1, tmp=in[tmp])
    p[tmp] = mex(tmp);

  check();

  printf("IMPOSSIBLE\n");  

  return 0;
}


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

const int maxn = 100005;

int n, ans = 0;
int a[maxn];
unordered_map < int, pair < int, int > > cnt;

signed main () {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (i & 1)
            ++cnt[a[i]].first;
        else
            ++cnt[a[i]].second;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        if (i & 1) {
            if (cnt[a[i]].first)
                --cnt[a[i]].first;
            else
                ++ans;
        }
        else {
            if (cnt[a[i]].second)
                --cnt[a[i]].second;
            else
                ++ans;
        }
    }
    printf("%d\n", ans / 2);
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define S second
#define F first
#define ll long long
using namespace std;
main(){
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    for (ll b = k +1; b <= n; b++){
        ll L = (n - b +1)-(n - b +1)%b + b;
        ans += min(-k+b,L  -(n - b + 1) )*((n - b + 1)/b)+(max((ll)0,n - k - L + 1))*((n - b + 1)/b + 1)+b-max((ll)1,k);
    }
    cout << ans << endl;
}


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

int main() {
	int K, S;
	cin >> K >> S;
	int count = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			int k = S - i - j;
			if(k >= 0 && k <= K) count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
import math
import itertools


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n=int(input())
d = make_divisors(n)
len = len(d)
if len % 2 == 0:
    print((d[int(len/2)]-1)+(d[int(len/2-1)]-1))
else:
    print((d[int((len-1)/2)]-1)+(d[int((len-1)/2)]-1))


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


ll N, A, B;
ll H[101010];

ll ng = 0, ok = 1000000000LL;

bool check(ll p){
    ll al = B * p;
    ll tmp = A - B;
    for(ll i = 0; i < N; i++){
        ll h = H[i] - al;
        if(h > 0){
            ll hoge = (h + (tmp - 1)) / tmp;
            p -= hoge;
        }
        if(p < 0)return false;
    }
    return true;
}

int main(){
    
    cin >> N >> A >> B;
    for(ll i = 0; i < N; i++)cin >> H[i];
    while(ng + 1 < ok){
        ll p = (ng + ok) / 2;
        bool flg = check(p);
        if(flg)ok = p;
        else ng = p;
    }
    cout << ok << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#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--------------------*/

const int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

vector<vector<vi>> dist;
vector<vector<vi>> todir;
vs fld;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int h, w, n;
	string s;
	while (cin >> h >> w >> n, n)
	{
		dist.clear(), todir.clear();
		dist.resize(h, vector<vi>(w, vi(4, INF)));
		todir.resize(n + 1, vector<vi>(4, vi(4, INF)));
		fld.clear();
		fld.resize(h);
		cin >> s;
		REP(i, 4) todir[n][i][i] = n;
		for (int i = n - 1; i >= 0; i--)REP(j, 4)REP(k, 4)
		{
			if (j == k)
			{
				todir[i][j][k] = i;
				continue;
			}
			int nx;
			if (s[i] == 'L') nx = (j + 1) % 4;
			else nx = (j + 3) % 4;
			todir[i][j][k] = todir[i + 1][nx][k];
		}
		REP(i, h) cin >> fld[i];
		pii go;
		queue<tuple<int, int, int>> que;
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == 'S')
			{
				que.emplace(i, j, 0);
				dist[i][j][0] = 0;
				fld[i][j] = '.';
			}
			if (fld[i][j] == 'G')
			{
				go = pii(i, j);
				fld[i][j] = '.';
			}
		}
		bool f = false;
		while (!que.empty())
		{
			int x, y, dir;
			tie(x, y, dir) = que.front();
			que.pop();
			int p = dist[x][y][dir];
			if (pii(x, y) == go)
			{
				f = true;
				break;
			}
			int nx = x + dx[dir], ny = y + dy[dir];
			if (valid(nx, ny, h, w) && fld[nx][ny] != '#' && dist[nx][ny][dir] > p)
			{
				dist[nx][ny][dir] = p;
				que.push(make_tuple(nx, ny, dir));
			}
			REP(i, 4)
			{
				int tmp = todir[p][dir][i];
				if (tmp < INF && dist[x][y][i] > p)
				{
					dist[x][y][i] = tmp;
					que.push(make_tuple(x, y, i));
				}
			}
		}
		if (f) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 59732
N = int(input())
CC = [0] * (N-1)
SS = [0] * (N-1)
FF = [0] * (N-1)

for i in range(N-1):
    C, S, F = map(int,input().split())
    CC[i] = C
    FF[i] = F
    SS[i] = S

for i in range(N-1):
    T = 0
    Max = 0
    for k in range(i,N-1):
        Max = max(T, SS[k])
        U = Max % FF[k]
        if U == 0:
            T = Max + CC[k]
        else:
            T = Max - U + FF[k] + CC[k]
        #print(i,k,T)
    print(T)
print(0)

Measured memory_bytes: 41964
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,scnt[64];
string s[64];
signed main(){
    bool b=true;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    for(int i=0;i<('z'-'a')+1;i++){
        int ocnt=1145141919;
        for(int j=0;j<n;j++){
            int cnt=0;
            for(;scnt[j]<s[j].size();scnt[j]++){
                if(s[j][scnt[j]]!=char(i+'a'))goto ioi;
                cnt++;
            }
            ioi:;
            ocnt=min(ocnt,cnt);
        }
        if(ocnt!=0)b=false;
        cout<<string(ocnt,char(i+'a'));
    }
    if(b)cout<<" ";
    cout<<endl;
    system("PAUSE");
}

Measured memory_bytes: 504
import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N, K, C = map(int, input().split())
S = list(input())[: -1]
e = [-1] * N
os = []
for i in range(N):
  if S[i] == "o": os.append(i)
for i in range(N):
  if S[i] == "o":
    j = br(os, i + C)
    if j == len(os): continue
    e[i] = os[j]
#print(e)
dp = [0] * N
for i in range(N - 1, -1, -1):
  if e[i] != -1:
    dp[i] = dp[e[i]] + 1
  else: dp[i] += S[i] == "o"
if max(dp) > K:
  print()
  exit(0)
l = []
r = []
ls = 0
rs = 0
for i in range(N):
  if S[i] == "o":
    ls = i
    break
l.append(ls)

for i in range(N - 1, -1, -1):
  if dp[i] == K:
    rs = i
    break
r.append(rs)
#print(l, r)
for i in range(ls, N):
  if S[i] == "x": continue
  if l[-1] + C < i: l.append(i)
for i in range(rs, N):
  if S[i] == "x": continue
  if r[-1] + C < i: r.append(i)
  elif dp[r[-1]] == dp[i]: r[-1] = i
res = set(l) & set(r)
for r in sorted(res):
  print(r + 1)

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

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> color(n);
    for (int i = 0; i < n; i++) {
        color[i] = i;
    }
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            int col_y = color[y];
            for (int i = 0; i < n; i++) {
                if (color[i] == col_y) color[i] = color[x];
            }
        } else {
            cout << (color[x] == color[y]) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,j,k,l,m,n,a,b,c,d,cnt=0;
    cin>>a>>b>>c>>k;
    if(a>=k)
        cout<<k<<endl;
    else
    {
        ll sum=0;
        sum+=a;
        k-=a;
        if(b>=k)
            cout<<sum<<endl;
        else
        {
            k-=b;

            sum-=min(c,k);
            cout<<sum<<endl;

        }



    }
}


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

	int V[105][10005];

int dp(int n,int C,int v[],int w[]){
	memset(V,0,sizeof(V));
	for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= C; j++)
        {
            if(j < w[i])
                V[i][j] = V[i-1][j];
            else
                V[i][j] = max(V[i-1][j], V[i-1][j-w[i]]+v[i]);
        }
    }
    
	
	
	return V[n][C];
}



int main(){
	int v[110];
    int w[110];
    int n,C;

	cin>>n>>C;
	
	for(int i=1;i<=n;i++){
		cin>>v[i]>>w[i];
	}
	int s=dp(n,C,v,w);
	cout<<s<<endl;
} 


Measured memory_bytes: 7196
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define vll vector<ll>
#define nloop(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define fill(i,n) memset(i,n,sizeof i)
#define all(a) a.begin(),a.end()
#define pb(x) push_back(x)
#define sz() size()
#define T(n) while(n--)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define endl '\n'
#define nfs  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll bin_expo(ll a, ll b, ll m){ll res = 1LL;while (b > 0){if(b % 2 == 1){res = (res * a) % m;}a = (a * a) % m; b = b/ 2;}return res;}

const  int MAXn= 3e5+5;
const  long long INF= 1e18;

int main(){
    int t=1;
    //cin>>t;
    T(t){
    int n; cin>>n;
    ll dp[3][n];
    for(int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        ll a,b,c; cin>>a>>b>>c;
        if(i==0){
            dp[0][i]=a;
            dp[1][i]=b;
            dp[2][i]=c;
        }
        else{
            dp[0][i]= a+ max(dp[1][i-1],dp[2][i-1]);
            dp[1][i]= b+ max(dp[0][i-1],dp[2][i-1]);
            dp[2][i]= c+ max(dp[0][i-1],dp[1][i-1]);
        }
    }
    ll ans= max(dp[0][n-1],dp[1][n-1]);
    ans= max(ans,dp[2][n-1]);
    cout<<ans<<endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    int N=2*n;
    int l[N];
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    sort(l,l+N);
    long long ans=0;
    for(int i=0;i<N;i+=2){
        ans+=l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

A, B = [int(x) for x in input().strip().split()]

flg = 0
for i in range(1,1250):
        x = math.floor(i * 0.08)
        y = math.floor(i * 0.1)
        if x == A and y == B:
                print(i)
                flg = 1
                break
if flg == 0:
        print(-1)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  int n, m, sum = 0, res = 0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  rep(i, n) if ((double)a[i] >= (double)sum / (4 * m)) res++;
  cout << ((res >= m) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	long long scannum;
	long long num = 0;
	long long i;
	scanf("%lld", &scannum);
	for (i = 0; num <= scannum; i++) {
		num += i + 1;
		if (num >= scannum) {
			break;
		}
	}
	
	printf("%lld", i + 1);

	return 0;
}

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<long long> a(x);
  for (int i = 0; i < x; i++) {
    cin >> a[i];
  }
  debug(a);
  vector<long long> b(x * y);
  int cur = 0;
  for (int i = 0; i < y; i++) {
    long long val;
    cin >> val;
    for (int j = 0; j < x; j++) {
      b[cur++] = a[j] + val;
    }
  }
  sort(b.rbegin(), b.rend());
  debug(b);
  vector<long long> c(z * (min((int)b.size(), k)));
  cur = 0;
  for (int i = 0; i < z; i++) {
    long long val;
    cin >> val;
    for (int j = 0; j < min((int)b.size(), k); j++) {
      c[cur++] = b[j] + val;
    }
  }
  sort(c.rbegin(), c.rend());
  debug(c);
  for (int i = 0; i < k; i++) {
    cout << c[i] << '\n';
  }
  return 0;
}




Measured memory_bytes: 34676
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
using namespace std;

void solve()
{
    ll x,k,d;
    cin >> x >> k >> d;
    x=abs(x);
    ll p=x/d;
    if(k<p)
        cout << abs(x-k*d) << endl;
    else
    {
        k-=p;
        if(k%2==0)
            cout << abs(x-p*d) << endl;
        else
        {
            p++;
            cout << abs(x-p*d) << endl;
        }
    }
}

int main()
{
    int t=1;
    //cin >> t;
    while(t--)
    solve();

    return 0;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int a; cin>>a;
    cout << a + a*a + a*a*a;
    
    return 0;
}
    

// Химаншу


Measured memory_bytes: 3648