akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int a[128];
int main2() {
  int N = nextInt();
  REP(i, N) a[i] = nextInt();

  int ans = 0;

  int prev = -1;
  int cont = 0;
  for (int i = 0; i < N; i++) {
    if (prev == a[i]) {
      cont++;
    } else {
      ans += cont / 2;
      cont = 1;
    }
    prev = a[i];
  }
  ans += cont / 2;
  cont = 0;

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 768
#include"iostream"
using namespace std;
int main(void) {
	int a;
	int b[1000];

	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}

	for (int i = 0; i < a; i++) {
		if (b[i] % 2 == 0) {
			if (b[i] % 3 == 0 || b[i] % 5 == 0) {
			}
			else {
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";

}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class AAirConditioner {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int x;
        cin>>x;
        x>=30?cout<<"Yes":cout<<"No";
	}
};


int main() {
	AAirConditioner solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 100002;
ll n,a[N];

int main(){
	cin>>n;
	ll be,af,ans=1;
	ll k=0;
	cin>>be;
	FOR(i,1,n){
		cin>>af;
		if(af>be){
			if(k==0){
				k=2;
			}else if(k!=2){
				ans++;
				k=0;
			}
		}else if(af<be){
			if(k==0){
				k=1;
			}else if(k!=1){
				ans++;
				k=0;
			}
		}
		be=af;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int card[4][14];
 
int main(void){
    int n,i,j;
    char a;
 
    scanf("%d",&n);
 
 
    for(i = 0;i < n;i++){
       scanf(" %c %d",&a,&j);
       if(a == 'S')
           card[0][j] = 1;
       else if(a == 'H')
           card[1][j] = 1;
       else if(a == 'C')
           card[2][j] = 1;
       else
           card[3][j] = 1;
    }
    for(i = 0;i < 4;i++){
        if(i == 0)
            a = 'S';
        else if(i == 1)
            a = 'H';
        else if(i == 2)
            a = 'C';
        else
            a = 'D';
 
        for(j = 1;j <= 13;j++)
            if(card[i][j] == 0)
                printf("%c %d\n",a,j);
    }
 
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    int S, W;
    cin>>S>>W;
    if(W>=S)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
    
    return 0;
}


Measured memory_bytes: 3596
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
ll mod = 1000000007;
const int empty = 0;
const int A = 1;
const int C = 2;
const int G = 3;
const int T = 4;
int encode(int b, int c, int d)
{
    return b * 25 + c * 5 + d;
}
int encode(int a, int b, int c, int d)
{
    return a * 125 + b * 25 + c * 5 + d;
}
int decode(int order, int code)
{
    return code / (int)pow(5, order) % 5;
}
int removeTop(int code)
{
    return code % 125;
}
bool okay(int code)
{
    return removeTop(code) != encode(A, G, C) &&
           removeTop(code) != encode(G, A, C) &&
           removeTop(code) != encode(A, C, G) &&
           code != encode(A, G, G, C) &&
           code != encode(A, C, G, C) &&
           code != encode(A, T, G, C) &&
           code != encode(A, G, C, C) &&
           code != encode(A, G, T, C) ;
}
map<int, ll> solve(ll length)
{
    if (length == 0)
    {
        map<int, ll> ret;
        ret.insert(make_pair(0, 1));
        return ret;
    }
    else
    {
        auto prev = solve(length - 1);
        map<int, ll> ret;
        for (auto item : prev)
        {
            int code = removeTop(item.first);
            ll value = item.second;
            for (int i = 1; i <= 4; i++)
            {
                auto nextcode = code * 5 + i;
                if (okay(nextcode))
                {
                    auto find = ret.find(nextcode);
                    if (find == ret.end())
                    {
                        ret.insert(make_pair(nextcode, value));
                    }
                    else
                    {
                        ret.at(nextcode) = (ret.at(nextcode) + value) % mod;
                    }
                }
            }
        }
        return ret;
    }
    throw 42;
}
int main()
{
    ll N;
    cin >> N;
    auto ans = solve(N);
    ll sum = 0;
    for (auto item : ans)
    {
        sum = (sum + item.second) % mod;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
	let a = read();
	let b = read();
	let c = read();
	let ab = a + b;
	if ab >= c {
		println!("Yes");
	} else {
		println!("No");
	}
}


fn read() -> usize {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e17
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n,m; cin>>n>>m;
    ll sum = 0; ll temp;
    forin(0,m)
    {
        cin>>temp;
        sum +=temp;
    }
    if(n<sum)   cout<<-1<<endl;
    else
    {
        cout<<n-sum<<endl;
    }
    
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int oddCnt = N / 2 + N % 2;

        double ret = oddCnt / (double)N;
        System.out.print(ret);
    }
}
//[B@25618e91
//[B@326de728
//

Measured memory_bytes: 35832
s = list(input())
l = len(s)
if l % 2 == 0:
    for i in range(l//2):
        a = s[l//2]
        if s[l//2 - 1 - i] != a or s[l//2 + i] != a:
            print(l//2 + i)
            exit()
else:
    for i in range(1, (l-1)//2 + 1):
        a = s[(l-1)//2]
        if s[(l-1)//2 - i] != a or s[(l-1)//2 + i] != a:
            print((l-1)//2 + i)
            exit()
print(l)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 100
using namespace std;
typedef long long ll;
int n;
ll data[MAX_N + 1];

ll calcSum() {
    ll sum = 0, wait = 0;
    for(int r = 0; r < n; r++) {
        sum += wait;
        wait += data[r];
    }
    return(sum);
}

void solve() {
    sort(data, data+n);
    printf("%lld\n", calcSum());
}

int main(void) {
    while(cin >> n, n) {
        memset(data, INF, sizeof(data));
        for(int r = 0; r < n; r++) {
            cin >> data[r];
        }
        solve();
    }
    return(0);
}

Measured memory_bytes: 1252
nu = gets.to_i
array = Array.new(nu).map{Array.new(3, 0)}
py = Array.new(101).map{Array.new(101, 0)}
for i in 0..nu - 1
  array[i] = gets.chomp.split(" ").map(&:to_i)
end

for i in 0..nu - 1
  for j in 0..100
    for k in 0..100
      if array[i][2] > 0
        if py[k][j] == 0
          py[k][j] = (k - array[i][1]).abs + (j - array[i][0]).abs + array[i][2]
        elsif py[k][j] != (k - array[i][1]).abs + (j - array[i][0]).abs + array[i][2]
          py[k][j] = -1
        end
      elsif array[i][2] == 0
        if (py[k][j] - (k - array[i][1]).abs - (j - array[i][0]).abs) > 0
          py[k][j] = -1
        end
      end
    end
  end
end
for i in 0..nu - 1
  for j in 0..100
    for k in 0..100
      if array[i][2] > 0
        if py[k][j] == 0
          py[k][j] = (k - array[i][1]).abs + (j - array[i][0]).abs + array[i][2]
        elsif py[k][j] != (k - array[i][1]).abs + (j - array[i][0]).abs + array[i][2]
          py[k][j] = -1
        end
      elsif array[i][2] == 0
        if (py[k][j] - (k - array[i][1]).abs - (j - array[i][0]).abs) > 0
          py[k][j] = -1
        end
      end
    end
  end
end

for j in 0..100
  for k in 0..100
    if py[k][j] > 0
      puts "#{j} #{k} #{py[k][j]}"
      exit
    end
  end
end


Measured memory_bytes: 1916
N, M = map(int, input().split())

a = [0] * N
A = []

for i in range(N):
    a[i] = [int(k) for k in input().split()]

ans = 0
for x in (1, -1):
    for y in (1, -1):
        for z in (1, -1):
            total = [x * a[k][0] + y * a[k][1] + z * a[k][2] for k in range(N)]
            total.sort(reverse=True)
            ans = max(ans, sum(total[:M]))

print(ans)

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

#define ff       first
#define ss       second
#define vpop     pop_back
#define pb       push_back
#define mp       make_pair
#define ll       long long int
#define umap	 unordered_map
#define pii	 pair<int, int>
#define clz(x)   __builtin_clz(x)       
#define ctz(x)   __builtin_ctz(x)      
#define all(v)   v.begin(), v.end() 
#define sbts(x)  __builtin_popcount(x) 
#define ull      unsigned long long int
#define ms(a,v)  memset(a, v, sizeof(a))
#define ps(x, y) fixed << setprecision(y) << x
const int MOD  = 1e9 + 7;
const ll  INF  = 1e12;
const int   N  = 1e5 + 1;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
//  *-------------------------------*
    int n; cin >> n;
    int dp[3][n + 1]; ms(dp, 0);
    for (int i = 1; i <= n; i++) {
        int a[3]; cin >> a[0] >> a[1] >> a[2];
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[j][i] = max(dp[j][i], dp[k][i - 1] + a[j]);
            }
        }
    }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n]));
    return 0;
}



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

using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
ll a[1000][1000];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    rep(i,1000)rep(j,1000)a[i][j] = -1;
    ll N;
    cin >> N;
    bool ok = false;
    ll cnt;
    for (ll x = 1; x * (x - 1) / 2 <= 2*N; x++) {
        if (x * (x - 1) / 2 == N) {
            ok = true;
            cnt = x;
            break;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << cnt << endl;
    int c = 1;
    rep1(i, cnt + 1)
        rep1(j, cnt + 1) {
            if (i >= j)continue;
            a[i][j] = c;
            c++;
        }
    rep1(i, cnt + 1)
        rep1(j, cnt + 1) {
            chmax(a[i][j], a[j][i]);
        }
    rep1(i, cnt + 1) {
        cout << cnt - 1 << " ";
        rep1(j, cnt + 1) {
            if (i == j)continue;
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int func(int x){
	bool ans=false;
	int a=x,cnt=2;
	if(a==1)ans=true;
	while(a!=1){
		if(a%cnt==0){
			ans=true;
			a=a/cnt;
			if(cnt==a)return ans;
		}else{
			ans=false;
			cnt++;
			a=x;
			if(cnt*cnt>x)return ans;
		}
	}
	return ans;
}

int main(){
	int x;
	cin >> x;
	for(int i=x;i>0;i--){
		if(func(i)==1){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <limits.h>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
  char s[100001];cin>>s;
  bool b[26];
  for(int i=0;i<26;i++){
    b[i] = false;  
  }
  for(int i=0;s[i]!='\0';i++){
    b[s[i]-'a'] = true;
  }
  for(int i=0;i<26;i++){
    if(!b[i]){
      cout<<(char)(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
}

Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

a#b = abs$a-b

main = B.interact$B.pack.show.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:h1:h2:hr)=s 0 (h2#h1) (take n (h1:h2:hr))
s _ c [_,_] = c
s c1 c2 (h1:h2:h3:hr)=s c2 (min (c1+h3#h1) (c2+h3#h2)) (h2:h3:hr)


Measured memory_bytes: 1916
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        sc.close();
        int ans = WeatherMatch(S, T);

        System.out.println(ans);
    }
    public static int WeatherMatch(String S, String T) {
        if (S.length() == 0) {
            return 0;
        }
        if (S.charAt(0) == T.charAt(0)) {
            return 1 + WeatherMatch(S.substring(1), T.substring(1));
        }
        return WeatherMatch(S.substring(1), T.substring(1));
    }
}


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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define show(x) cout<<(x)<<endl
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/
const int maxn = 1e5 + 1;
int main() {
	FAST;
	int n;
	cin>>n;
	V<int> a(maxn),b(maxn),c(maxn);
	REP(i,1,n+1) cin>>a[i]>>b[i]>>c[i];
	int dp[maxn][3];
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	REP(i,2,n+1) {
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	show(max(dp[n][0],max(dp[n][1],dp[n][2])));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,K,m=0,M,w;bool x=true;cin>>N>>K;vector<long long int>a(N);
  for(long long int i=0;i<N;i++)cin>>a.at(i);
  for(long long int i=0;i<(1<<15);i++){
    bitset<16>p(i);
    if(p.test(N-1))break;
    w=a.at(0),M=0;
    if(p.count()>=K-1){
      for(long long int j=1;j<N;j++){
        if(p.test(j-1)){
          w=max(w+1,a.at(j));
          M+=w-a.at(j);
        }
        else if(w<a.at(j))w=a.at(j);
      }
      if(x)m=M;
      m=min(m,M);
      x=false;
    }
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000001
#define VMAX 10000
void CountingSort(void);

int A[MAX],B[MAX],n;
int main()
{
  int i;
  scanf("%d",&n);
  for(i=1;i<n+1;i++)
    {
      scanf("%d",&A[i]);
    }
  CountingSort();
  for(i=1;i<n;i++)
    {
      printf("%d ",B[i]);
    }
  printf("%d\n",B[n]);
  return 0;
}

void CountingSort(void)
{
  int i,j,C[VMAX+1];
  for(i=0;i<=VMAX;i++)
    {
      C[i]=0;
    }
  for(j=1;j<n+1;j++)
    {
      C[A[j]]=C[A[j]]+1;
    }
   
  for(i=1;i<=VMAX;i++)
    {
      C[i]=C[i]+C[i-1];
     
    }
 
  
  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]=C[A[j]]-1;
    }
}



Measured memory_bytes: 17368
S = input()

A = S[:2]
B = S[2:] 

if int(A) >= 1 and int(A) <= 12 and int(B) >= 1 and int(B) <= 12:
  print('AMBIGUOUS')
elif int(A) >= 1 and int(A) <= 12:
  print('MMYY')
elif int(B) >= 1 and int(B) <= 12:
  print('YYMM')
else:
  print('NA')


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

bool check(char *chars);

int main(void)
{
  // Prompt for input
  char inptr[99];
  scanf("%s", inptr);
  // Calculate length
  int length = 0;
  for (int i = 0; inptr[i] != '\0'; i++)
  {
    length++;
  }
  // Check if S is a palindrome
  bool s = check(inptr);
  if (s == false)
  {
    printf("No\n");
    return 0;
  }
  // Check if 1->(N-1)/2 is a palindrome
  char *inptr1 = malloc(sizeof(char) * ((length - 1) / 2 + 1));
  for (int i = 0; i < (length - 1) / 2; i++)
  {
    inptr1[i] = inptr[i];
  }
  bool s1 = check(inptr1);
  if (s1 == false)
  {
    printf("No\n");
    return 0;
  }
  // Check if (N+3)/2->N is a palindrome
  char *inptr2 = malloc(sizeof(char) * ((length - 3) / 2 + 1));
  for (int i = 0; i < (length - 1) / 2; i++)
  {
    inptr2[i] = inptr[(length + 3) / 2 - 1 + i];
  }
  bool s2 = check(inptr2);
  if (s2 == false)
  {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  free(inptr1);
  free(inptr2);
  return 0;
}

bool check(char *chars)
{
  int length = 0;
  for (int i = 0; chars[i] != '\0'; i++)
  {
    length++;
  }
  for (int i = 0; i < length / 2 + 1; i++)
  {
    if (chars[i] - chars[length - i - 1] != 0)
    {
      return false;
    }
  }
  return true;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    W_li = LI()

    D_S_min = INF
    for i in range(N+1):
        S1 = sum(W_li[:i])
        S2 = sum(W_li[i:])
        D_S_min = min(D_S_min, abs(S1-S2))

    print(D_S_min)

main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
long long dp[5005][5005][2];
int a[5005],id[5005];
int main(){
	int n;
	long long A,B;
	cin>>n>>A>>B;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		id[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j)dp[i][j][0]=min(min(dp[i-1][j][0],dp[i-1][j][1]),dp[i][j-1][0]);
			else dp[i][j][0]=dp[i-1][j][0];
		}
		for(int j=0;j<=n;j++){
			if(j>=id[i])dp[i][j][0]+=A; else dp[i][j][0]+=B;
			dp[i][j][1]=dp[i][j][0];
		}
		long long mi=1e18;
		for(int j=0;j<id[i];j++){
			mi=min(mi,min(dp[i-1][j][0],dp[i-1][j][1]));
		}
		dp[i][id[i]][1]=mi;
	//	cout<<dp[i][id[i]][1]<<" ";
	}
	long long mi=1e18;
	for(int i=0;i<=n;i++){
		mi=min(min(dp[n][i][0],dp[n][i][1]),mi);
	}
	cout<<mi;
}

Measured memory_bytes: 391296
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007

int *array;

int min(int a, int b) {
    return a<b?a:b;
}

int max(int a, int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

int abs(int n) {
    if(n < 0)
        return n*(-1);
    return n;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

int binSearch(int a[], int x, int l, int r) {
    if(r >= l) {
        int mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

int isRound(int n) {
    int count=0, count_0=0;
    while(n) {
        int x = n%10;
        
        // printf("%d\n", n%10);
        if(x == 0)
            count_0++;
        else
            count++;
        n /= 10;
    }
    if(count == 1)
        return 1;
    return 0;
}

int findRound(int n) {
    int count=0;
    int temp = n;
    while(temp) {
        count++;        
        temp /= 10;
    }
    int power=1;
    for(int i=0;i<count-1;i++)
        power *= 10;
    int res = n - (n%power);
    return res;
}

void testCase() {
    int i, a, b, c, k;
    // char s[14], t[15];
    int res;
    if(scanf("%d%d%d%d", &a, &b, &c, &k)) {
        if(k <= a) {
            res = k;
        }
        else if(k <= a+b) {
            res = a;
        }
        else {
            res = (a) - (k-(a+b));
        }
        printf("%d", res);
    }
    
}

int main() {
    int t=1;
    // scanf("%d", &t);
    while(t--) {
        testCase();
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1732
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("Yes\n")
#define no printf("No\n")

int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    int a[100001],b[100001],c,d,e,f,m,n,p,x,y,z,t,i,j,k;
       cin>>c>>d>>e;
       m=d*e;
       if(c<=m)
        yes;
       else
        no;
    }



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll n;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll a[n],b[n],c[n];
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans = 0;
  rep(i,n) ans += (lower_bound(a,a+n,b[i])-a) * (n-(upper_bound(c,c+n,b[i])-c));
  cout<<ans<<endl;

}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;
random_device rd;
mt19937 mt(rd());

int d;
vi c;
vvi s;

vi res;
vvi last;

vi ans, test;
ll mx = 0;

ll score(vi t, int st = 0, int pre = -1, int now = -1) {

	rep_lr(i, st, d) {
		ll plus = 0;
		rep(j, 26) {
			plus += s[i][t[i]];
			if (j == t[i])last[i + 1][t[i]] = i + 1;
			else last[i + 1][j] = last[i][j];
			plus -= c[j] * ((ll)i + 1 - last[i + 1][j]);
			res[i + 1] = res[i] + plus;
		}
	}
return res[d - 1];

}

void init() {

	c.resize(26);
	s.resize(d, vi(26));
	last.assign(d + 1, vi(26, 0));
	res.resize(d + 1, 0);
	ans.resize(d);
	test.resize(d);

}

int main() {

	cin >> d;

	double time = (double)clock() / CLOCKS_PER_SEC;
	
	init();
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	vi first(d);
	rep(i, d)first[i] = mt() % 26;

	rep(i, d)ans[i] = test[i] = first[i];
	mx = score(first);

	int loop = 0, rec = 0;
	while (((double)clock() / CLOCKS_PER_SEC) - time < 1.8) {

		int change = mt() % d;
		int pre = test[change];
		test[change] = mt() % 26;
		int now = test[change];
		ll re = score(test, change, pre, now);
		if (mx < re) {
			mx = re;
			rep(i, d)ans[i] = test[i];
			rec++;
		}

		loop++;
	}

	cerr << "err" << loop << endl;
	cerr << "err" << rec << endl;
	cerr << "err" << mx << endl;
	for (auto x : ans)cout << x + 1 << endl;

}

Measured memory_bytes: 3780
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int l[n];
  int sum = 0;
  for(int i = 0; i < n; ++i){
    scanf("%d",&l[i]);
    sum += l[i];
  }
  int flag = 0;
  for(int i = 0; i < n; ++i){
    if(sum <= 2*l[i]) flag = 1;
  }
  if(flag == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main() {
	int x, y, s;
	int a, b;
	int p, q, res;

	while (true) {
		scanf("%d%d%d", &x, &y, &s);
		if (x == 0 && y == 0 && s == 0) {
			break;
		}

		res = 0;
		for (a = 1;a < s;a++) {
			p = (100 + x)*a / 100;
			q = s - p;
			if (q > 0) {
				if ((int)100 * q / (100 + x) != (int)100 * (q + 1) / (100 + x)) {
					if ((int)100 * (q + 1) / (100 + x) == (double)100 * (q + 1) / (100 + x)) {
						b = 100 * q / (100 + x);
					}
					else {
						b = 100 * (q + 1) / (100 + x);
					}
					if ((int)a*(100 + y) / 100 + (int)b*(100 + y) / 100 > res) {
						res = (int)a*(100 + y) / 100 + (int)b*(100 + y) / 100;
					}
				}
			}
		}

		printf("%d\n", res);
	}

	return 0;
}

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

int main()
{
    ll A, B; cin >> A >> B;
    ll ans = 0;
    for (ll i = A; i <= B; ++i) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans << endl;


}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a*b%2==0)ou("Even");
  else ou("Odd");
}

Measured memory_bytes: 256
fn main() {
    let xa = read_vec::<usize>();
    let x = xa[0];
    let a = xa[1];

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,d; cin>>h>>w>>d;
    vector<pi> c(h*w);
    rep(i,h)rep(j,w){
        int a; cin>>a; a--;
        c[a] = mp(i,j);
    }
    vector<vi> sum(d);
    rep(i,d) sum[i].pb(0);
    FOR(i,d,h*w-1){
        int cost = abs(c[i-d].fi-c[i].fi)+abs(c[i-d].se-c[i].se);
        sum[i%d].pb(sum[i%d].back()+cost);
    }
    int q; cin>>q;
    while(q--){
        int l,r; cin>>l>>r; l--; r--;
        int p = l%d;
        int left = (l-p)/d;
        int right = (r-p)/d;
        cout<<sum[p][right]-sum[p][left]<<endl;
    }
    return 0;
}


Measured memory_bytes: 6144
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))

using namespace std;

/*
N
h1 ... hN

N 2,10^5
hi 10^4
 */

int N;
int h[100000];
vector<int> dp(100000, 0);

int main(){
  cin >> N;
  cin >> h[0] >> h[1];

  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);

  FOR_IN(i,2,N){
    cin >> h[i];
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] + abs(h[i-2]-h[i]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
MOD=1000000007
hats=[0,0,0]
ans=1
for i in range(n):
    ai=a[i]
    ans=((ans%MOD)*hats.count(ai))%MOD
    if(ans==0):
        break
    hats[hats.index(ai)]+=1
#    print(ai,ans,hats)
print(ans%MOD)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=100000000000;

void display(long j,vector<long> x){
    cout<<"data "<<j<<" display_start"<<endl;
    for(int i=0;i<x.size();i++){
        cout<<x.at(i)<<" ";
    }
    cout<<endl<<"display_end"<<endl<<endl;
}


//main
int main() {
    
    //入力
    long A,B,C;
    cin>>A>>B>>C;
    
    
    //計算
    
    
    //出力
    cout<<min(C,B/A)<<endl;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<c-d+b<<" "<<d+c-a<<" "<<a-d+b<<" "<<b+c-a<<endl;
}









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

import sys

def main():
    s = input()

    if s[-1]=="s":
        print(s+"es")
    else:
        print(s+"s")

#    b,c = [int(i) for i in input().split()]
#    t_l = [[int(i) for i in input().split()] for _ in range(n)]

if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         10000009
#define NUM2        1000000000


int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n,i,j,k,g;
        cin >> n ;
        int aa[n],left[n],right[n];
        for(i=0;i<n;i++)sc(aa[i]);
        g=aa[0];
        for(i=0;i<n;i++)
        {
            g=__gcd(g,aa[i]);
            left[i]=g;
        }
        g=aa[n-1];
        for(i=n-1;i>=0;i--)
        {
            g=__gcd(g,aa[i]);
            right[i]=g;
        }
        g=max(right[1],left[n-2]);
        for(i=1;i<n-1;i++)g=max(g,__gcd(left[i-1],right[i+1]));
        cout << g ;
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 4860
use std::io::*;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    let nums: Vec<i32> = buf.split_whitespace().map(|n| n.parse().unwrap()).collect::<Vec<i32>>();
    
    let x = nums[0];
    let y = nums[1];

    let mut yes = false;

    for i in 0..x+1 {
        let kame = i;
        let tsuru = x-i;
        if 4 * kame + tsuru * 2 == y {
            yes = true;
            break;
        }
    }

    let out = stdout();
    let mut out = out.lock();
    if yes {
        writeln!(out, "{}\n", "Yes").unwrap();
    } else {

        writeln!(out, "{}\n", "No").unwrap();
    }
}


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

int main() {
        ll n, ans=0;
        cin >> n;
        if(n%2!=0) ans=0;
        else {
          ll d = 10;
          while(d<=n) {
            ans+=n/d;
            d*=5;
          }
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def insert(node:Node, keyNode:Node):Unit =
    if(node.key > keyNode.key) {
      if(node.left == null) node.left = keyNode
      else insert(node.left, keyNode)
    } else {
      if(node.right == null) node.right = keyNode
      else insert(node.right, keyNode)
    }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 306872
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char *args[])
{
	char string_w[11];
	char string_t[1001];
	int match_count = 0;

	scanf("%s", string_w);

	while(1) {
		scanf("%s", string_t);

		if( strcmp(string_t,"END_OF_TEXT") == 0 ) break;

		if( strcasecmp(string_t, string_w) == 0 ) {
			match_count++;
		}
	}

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


	return 0;

}

Measured memory_bytes: 556
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
int main() {
  fio;
  ll a,p;
  cin>>a>>p;
  a=a*3;
  cout<<(a+p)/2<<endl;
  return 0;
}


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

int main() {
 int a,b;
 cin>>a;
 cin>>b;
 if(a>b)cout<<"a > b\n";
 else if(a<b)cout<<"a < b\n";
 else if(a==b)cout<<"a == b\n";





}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d,e,r,i,j,kl;
    cin>>a;
    d=1;e=1;j=1;
       c=1e9+7;
       for(i=1;i<=a;i++)
       {
           d*=10;d%=c;
           e*=9;e%=c;
           j*=8;j%=c;
        //cout<<d<<endl;
       }
      // cout<<d<<" "<<j<<" "<<e<<" "<<e<<endl;
      b=d+j;b-=(2*e);
        if(b<0)
        cout<<(b%c)+c<<endl;
        else
        cout<<(b%c)<<endl;
    }



Measured memory_bytes: 3616
N = int(input())
P = [int(i) for i in input().split()]

flag = 0
cnt = 0
for i, p in enumerate(P):
    if p == i + 1 and flag == 0:
        cnt += 1
        flag = 1
    elif p != i + 1 or flag == 1:
        flag = 0
        
print(cnt)

Measured memory_bytes: 13880
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


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

int main() {
    string s;
    int n, ans = 0;
    cin >> n >> s;
    for(int i = 0; i < 1000; ++i) {
        string temp = to_string(i);
        while(temp.size()<3) temp = '0' + temp;
        int j = 0;
        rep(i,s.size()){
            if(s[i]==temp[j]) j++;
            if(j>=3) break;
        }
        if(j==3) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    register int x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define mp make_pair

#define int long long
const int maxn = 2e5;
int n, L, Sum;
int maxx, pos;

int a[maxn];
signed main() {
	n = read(), L = read();
	for (int i = 1; i <= n; i++) {
		a[i] = read();
		if (a[i] + a[i - 1] > maxx) maxx = a[i] + a[i - 1], pos = i;
	}
	if (maxx < L) {
		puts("Impossible"); return 0;
	}
	puts("Possible");
	for (int i = 1; i <= pos - 2; i++) printf("%d\n", i);
	for (int i = n - 1; i >= pos; i--) printf("%d\n", i);
	printf("%d\n", pos - 1);
	return 0;
}


Measured memory_bytes: 4508
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

struct UF{
    vl par;
    UF(ll N):par(N){
        rep(i,N)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    void unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
};

int main() {
string S;
  cin >>S;
  ll n=S.size();
  ll x=(n-1)/2;
  bool ans=true;
  rep(i,x) {
    if(S.at(i)!=S.at(n-1-i)) {
ans=false;
      break;
    }
  }
  
string str1=S.substr(0,x);
string str2=S.substr((n+3)/2-1,x);
  
  
   ll n1=str1.size();
  ll x1=0;
  if(n1%2!=0) {
   x1=(n1-1)/2;
  }
  else {
    x1=n1/2;
  }
  
  //bool ans=true;
  rep(i,x1) {
    if(str1.at(i)!=str1.at(n1-1-i)) {
ans=false;
      break;
    }
  }
  
  
   ll n2=str2.size();
  ll x2=0;
 if(n2%2!=0) {
   x2=(n2-1)/2;
  }
  else {
    x2=n2/2;
  }
  
  
  //bool ans=true;
  rep(i,x2) {
    if(str2.at(i)!=str2.at(n2-1-i)) {
ans=false;
      break;
    }
  }
  
  
  
  
  if(ans) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}



  
  
  

  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      
      int x1,x2,x3,x4,x5;
      
      cin >> x1 >> x2 >> x3 >> x4 >> x5;
      if(x1==0) cout << 1 ;
      else if(x2==0) cout << 2;
      else if(x3==0) cout << 3;
      else if(x4==0) cout << 4;
      else if(x5==0) cout << 5;
      
}


Measured memory_bytes: 3568
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>  
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<utility>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<vector>
#include<ctime>
#define INF 1000000000000000000ll
#define ll long long
#define max(x,y) (x>y?x:y)
#define min(x,y) (x>y?y:x) 
#define db double
#define EPS 1e-6
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const int MAXN=1000010;
int n;
int ans;
char a[MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	scanf("%s",a+1);
	n=strlen(a+1);
	int p=0;a[n+1]=0;
	for(int i=1;i<=n;++i)
	{
		int c=a[i]-'0';
		if(p)
		{
			if(c<=3||(c==4&&a[i+1]<='4'))ans+=p+c,p=0;
			else ans+=10-c-1;
		}
		else
		{
			if((a[i]=='5'&&a[i+1]>='5')||c>=6)ans+=10-c,p=1;
			else ans+=c;
		}
	}
	ans+=p;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	string ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	ll fl[n+1][26];
	memset(fl,0,sizeof(fl));
	for(i=1;i<=n;i++){
		for(j=0;j<ar[i].length();j++){
			fl[i][ar[i][j]-'a']++;
		}
	}

	for(i=0;i<26;i++){
		ll mn=1e10;
		for(j=1;j<=n;j++){
			mn=min(mn,fl[j][i]);
		}
		char c=('a'+i);
		for(j=0;j<mn;j++){
			cout<<c;
		}
	}
	return 0;
}

Measured memory_bytes: 256