akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll> a(n);
map<ll,ll> num_dict;
rep(i,n){
    cin>>a[i];
    num_dict[a[i]]++;
}

//先にすべての組み合わせを計算しておく
ll all_cnt=0;
for(auto v:num_dict){
    ll num = v.second;
    all_cnt+=(num*(num-1))/2;
}

vector<ll>ans;
rep(k,n){
    ll num = num_dict[a[k]];
    ll cnt=all_cnt;
    //今抜いたボールに関係のあるところだけ引いて足す
    if(num>=2){
        //同じ整数が2個以上あるボール以外は無視して良い
        cnt=cnt-(num*(num-1)/2)+((num-1)*(num-2)/2);
    }
    ans.pb(cnt);
}

rep(i,n)cout<<ans[i]<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 12784
#include<stdio.h>
#include<string.h>
#define MAX 100005

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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[MAX+1];
int head=1,tail,n;

void enqueue(P x){
  Q[tail]=x;
  if(tail!=MAX){
    tail++;
  } else {
    tail=1;
  }
}

P dequeue(){
  P x;
  x=Q[head];
  if(head!=MAX){
    head++;
  } else {
    head=1;
  } 
  return x;
}


int main(){
  int i,j,s,e=0;
  P u;
  scanf("%d%d",&n,&j);
  for(i=1;i<= n;i++) scanf("%s %d",Q[i].name,&Q[i].t); 
  
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    s=min(j,u.t);
    u.t-=s;
    e+=s;
    if(u.t<=0){
      printf("%s %d\n",u.name,e);
    }
    else if(u.t>0){
      enqueue(u);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	ll n, d;
	cin >> n >> d;
	double dis = 0;
	int cnt = 0;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		dis = sqrt(x*x + y * y);
		if (dis <= d) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long 
#define ld long double
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;

int trie[2000000][30];
bool isEnd[2000000];

int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));

	int n;
	cin >> n;
	
	string s;
	vector<int> path[n];
	memset(trie, -1, sizeof(trie));
	memset(isEnd, false, sizeof(isEnd));
	int cur = 1;
	string arr[n];

	for(int i = 0;i < n; i++) {
		cin >> s;
		reverse(s.begin(), s.end());
		arr[i] = s;
		int now = 0;
		path[i].push_back(0);
		for(char ch : s) {
			if(trie[now][ch - 'a'] == -1)	trie[now][ch - 'a'] = cur++;
			path[i].push_back(trie[now][ch - 'a']);
			now = path[i].back();
		}
		isEnd[now] = true;
	}
	int ans = 0;

	for(int i = 0; i < n; i++) {
		set<int> st;
		st.insert(arr[i].back() - 'a');
		for(int j = arr[i].length() - 1; j >= 0; j--) {
			for(auto x : st) {
				if(trie[path[i][j]][x] != -1 and isEnd[trie[path[i][j]][x]])	 ans++;
			}
			if(j)
				st.insert(arr[i][j - 1] - 'a');
		}
	}
	cout << ans - n;
}



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

using namespace std;

int main(){
    long long int A,B,M,ans = 1000000000,x,y,z,amin=1000000000,bmin=1000000000;
    cin >> A >> B >> M;
    vector<long long int> a(A),b(B);


    for(int i=0;i<A;i++){
        cin >> a[i];
        amin = min(amin,a[i]);
    }

    for(int i=0;i<B;i++){
        cin >> b[i];
        bmin = min(bmin,b[i]);
    }

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

    cout << min(ans,amin+bmin) << endl;
    
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)

func main() {

	n := ScanInt()
	a := ScanInt64Slice(n)

	approved := true

	for i := range a {
		if a[i]%2 == 0 {
			if a[i]%3 != 0 && a[i]%5 != 0 {
				approved = false
				break
			}
		}
	}

	if approved {
		P("APPROVED")
	} else {
		P("DENIED")
	}
	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a=0,b,c=0,d=0,e,n;
  string s[101];
  c2(a,b);
  rep(i,0,a) c(s[i]);
  sort(s,s+a);
  string t={};
  rep(i,0,a) t+=s[i];
  co(t);
  return 0;
}


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

char s[8][8];

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

void reverse(int x,int y,char c) {
    for(int d=0;d<8;++d) {
        int nx=x+dx[d],ny=y+dy[d];
        int tmp=0;
        while(s[nx][ny]==(c=='o'?'x':'o')) {
            nx+=dx[d],ny+=dy[d];
            if(nx<0||ny<0||nx>7||ny>7) {
                nx-=dx[d],ny-=dy[d];
                break;
            }
        }
        if(s[nx][ny]==c) {
            while(nx!=x||ny!=y) {
                nx-=dx[d],ny-=dy[d];
                s[nx][ny]=c;
            }
        }
    }
}

bool mami() {
    int x,y,maxi=0;
    for(int i=0;i<8;++i) {
        for(int j=0;j<8;++j) {
            if(s[i][j]!='.') continue;
            int cnt=0;
            for(int d=0;d<8;++d) {
                int nx=i+dx[d],ny=j+dy[d];
                int tmp=0;
                while(s[nx][ny]=='x') {
                    nx+=dx[d],ny+=dy[d];
                    if(nx<0||ny<0||nx>7||ny>7) {
                        nx-=dx[d],ny-=dy[d];
                        break;
                    }
                    ++tmp;
                }
                if(s[nx][ny]=='o') cnt+=tmp;
            }
            if(maxi<cnt) maxi=cnt,x=i,y=j;
        }
    }
    if(maxi) {
        s[x][y]='o';
        reverse(x,y,'o');
        return true;
    }
    return false;
}

bool majo() {
    int x,y,maxi=0;
    for(int i=7;i>=0;--i) {
        for(int j=7;j>=0;--j) {
            if(s[i][j]!='.') continue;
            int cnt=0;
            for(int d=0;d<8;++d) {
                int nx=i+dx[d],ny=j+dy[d];
                int tmp=0;
                while(s[nx][ny]=='o') {
                    nx+=dx[d],ny+=dy[d];
                    if(nx<0||ny<0||nx>7||ny>7) {
                        nx-=dx[d],ny-=dy[d];
                        break;
                    }
                    ++tmp;
                }
                if(s[nx][ny]=='x') cnt+=tmp;
            }
            if(maxi<cnt) maxi=cnt,x=i,y=j;
        }
    }
    if(maxi) {
        s[x][y]='x';
        reverse(x,y,'x');
        return true;
    }
    return false;
}

int main() {
    for(int i=0;i<8;++i) for(int j=0;j<8;++j) cin >> s[i][j];
    bool flag=true;
    while(flag) {
        flag=false;
        flag|=mami();
        flag|=majo();
    }
    for(int i=0;i<8;++i) {
        for(int j=0;j<8;++j) cout << s[i][j];
        cout << endl;
    }

    return 0;
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll t , n, a[MAXX], b[MAXX], c[MAXX];

signed main()
{
	FAST;
	cin >> n;
	ll ay = n/100, il = n%100;
	if(ay >= 1 && ay <= 12){
		if(il >= 1 && il <= 12){
			cout << "AMBIGUOUS";
		}
		else{
			cout << "MMYY";
		}
		return 0;
	}
	else{
		if(il >= 1 && il <= 12){
			cout << "YYMM";
		}
		else cout << "NA";
	}
	
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=4
es=[[] for i in range(n)]
for i in range(n-1):
   a,b=map(int,input().split())
   es[a-1].append(b-1)
   es[b-1].append(a-1)
use=sorted([len(es[i]) for i in range(4)])

print("YES" if use==[1,1,2,2] else "NO")

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
typedef pair<int,int> PA;
typedef pair<int,PA> P;
 
int cho,che;
char table[8][8];
vector<P> v;
 
const int dx[8] = {0,0,1,1,1,-1,-1,-1};
const int dy[8] = {1,-1,0,-1,1,-1,0,1};
const char ch[3] = {'x','o'};
 
void check(int x,int y,int turn,vector<P> &v){
    char c = ch[turn],d = ch[1-turn];
    int count = 0;
 
    for(int i = 0 ; i < 8 ; i++){
	int cnt = 0;
	int nx = x + dx[i];
	int ny = y + dy[i];
 
	while(true){
	    if(0 > nx || 0 > ny || nx >= 8 || ny >= 8){
		break;
	    }
	    if(table[nx][ny] != d){
		if(table[nx][ny] == c){
		    count += cnt;
		}
		break;
	    }
	    cnt++;
	    nx += dx[i];
	    ny += dy[i];
	}
    }   
 
    if(count == 0) return;
    
    if(turn){
	v.push_back(P(-count,PA(x,y)));
    }else{
	v.push_back(P(-count,PA(-x,-y)));
    }
}
 
void change(P a,int turn){
    char c = ch[turn],d = ch[1-turn];
 
    a.first = -a.first;
 
    if(!turn){
	a.second.first = -a.second.first;
	a.second.second = -a.second.second;
    }
    table[a.second.first][a.second.second] = c;
 
    for(int i = 0 ; i < 8 ; i++){
	int nx = a.second.first + dx[i];
	int ny = a.second.second + dy[i];
	vector<PA> v;
 
	while(true){
	    if(0 > nx || 0 > ny || nx >= 8 || ny >= 8){
		break;
	    }
	    if(table[nx][ny] != d){
		break;
	    }
	    v.push_back(PA(nx,ny));
	    nx += dx[i];
	    ny += dy[i];
	}
 
	if(!(0 > nx || 0 > ny || nx >= 8 || ny >= 8) && table[nx][ny] == c){
	    while(true){     
		if(nx == a.second.first && ny == a.second.second){
		    break;
		}
		table[nx][ny] = c;  
		nx -= dx[i];
		ny -= dy[i];
	    }
	}
    } 
 
    if(turn){
	cho += a.first+1;
	che -= a.first;
    }else{
	cho -= a.first;
	che += a.first+1;
    }
}
 
int main(){
    for(int i = 0 ; i < 8 ; i++){
	for(int j = 0 ; j < 8 ; j++){
	    cin >> table[i][j];
 
	    if(table[i][j] == 'o'){
		cho++;
	    }else if(table[i][j] == 'x'){
		che++;
	    }
	}
    }
 
    //true mami ------ false witch
    bool turn = true;
    int pass = 0;
 
    while(true){
	vector<P> v;
  
	if(pass == 2 || !cho || !che || cho+che == 64){
	    break;
	}
  
	for(int i = 0 ; i < 8 ; i++){
	    for(int j = 0 ; j < 8 ; j++){
		if(table[i][j] == '.'){
		    int n = turn ? 1 : 0;
		    check(i,j,n,v);
		}
	    }
	}  
 
	int size = (int)v.size();
 
	if(size == 0){
	    pass++;
	}else{
	    pass = 0;
	    int n = turn ? 1 : 0;
	    sort(v.begin(),v.end());
	    change(v[0],n);
	}
 
	turn = !turn;
    }
 
    for(int i = 0 ; i < 8 ; i++){
	for(int j = 0 ; j < 8 ; j++){
	    cout << table[i][j];
	}
	cout << endl;
    }
    return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    string s;
    cin >> s;
    int n = s.size(), ans = n, len = 1;
    string save;
    int i=0;
    while(i+len<n) {
        //cout << i << " " << len << " " << save << " " << s.substr(i, len) << endl;
        if (save != s.substr(i, len)) {
            save = s.substr(i, len);
            i += len;
            len = 1;
        } else {
            len++;
            ans--;
        }
    }
    if (save != s.substr(i, len)) {
            save = s.substr(i, len);
            i += len;
            len = 1;
        } else {
            len++;
            ans--;
        }
    cout << ans << endl;
    return 0;
}



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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, a, b, c, d;
    cin>>n>>a>>b>>c>>d;
    a = a-1;
    b = b-1;
    c = c-1;
    d = d-1;
    char k;
    int michi[n];
    int i, j;
    for(i=0; i<n; i++){
        cin>>k;
        if(k == '#'){
            michi[i] = 1;
        }
        else{
            michi[i] = 0;
        }
    }
    int renzoku = 0;
    if(c<d){
        for(i=a+1; i<d; i++){
            if(michi[i] == 1){
                renzoku++;
            }
            else{
                renzoku = 0;
            }
            if(renzoku == 2){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }

    else{
        for(i=a+1; i<c; i++){
            if(michi[i] == 1){
                renzoku++;
            }
            else{
                renzoku = 0;
            }
            if(renzoku == 2){
                cout<<"No"<<endl;
                return 0;
            }
        }
        renzoku = 0;
        for(i=b-1; i<=d+1; i++){
            if(michi[i] == 0){
                renzoku++;
            }
            else{
                renzoku = 0;
            }
            if(renzoku == 3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int_;
inline int readint() {
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0' or c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c and c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
void writeint(int_ x){
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) writeint(x/10);
	putchar((x%10)^48);
}
# define MB template < typename T >
MB void getMax(T &a,const T &b){ if(a < b) a = b; }
MB void getMin(T &a,const T &b){ if(b < a) a = b; }
# define FOR(i,n) for(int i=0; i<(n); ++i)

int main(){
	int_ x = 100, ans = 0, goal;
	scanf("%lld",&goal);
	while(x < goal)
		x += x/100, ans ++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3824
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 10000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n;
	cin >> n;
	int a[100003], ans[100003], sum = 0, cnt = 0;
	rep(i, n) {
		int x;
		cin >> x;
		x *= 2;
		a[i] = x;
		sum += x;
	}
	ans[0] = 0;
	for (int i = 1; i < n; i += 2) {
		ans[i + 1] = ans[i - 1] + (a[i] - a[i - 1]);
		cnt += ans[i + 1];
	}
	ans[1] = ans[n - 1] + (a[0] - a[n - 1]);
	cnt += ans[1];
	for (int i = 2; i < n; i += 2) {
		ans[i + 1] = ans[i - 1] + (a[i] - a[i - 1]);
		cnt += ans[i + 1];
	}
	cnt = (sum / 2 - cnt) / n;
	rep(i, n) {
		cout << ans[i] + cnt << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        string str;
        cin >> str;
        int flags=0;
        int ans=0;
        rep(i,str.size()){
                if(str[i]=='S') {
                        flags++;
                }
                if(flags==0&&str[i]=='T') {
                        ans++;
                }
                if(flags>0&&str[i]=='T') {
                        flags--;
                }
        }

        cout << ans*2 <<  endl;

        return 0;
}


Measured memory_bytes: 640
def f(scores):
    res = sum(scores)
    if res % 10 == 0:
        candidates = list(score for score in scores if score % 10 != 0)
        if candidates:
            res -= min(candidates)
        else:
            res = 0
    return res
 
N = int(input())
scores = []
for _ in range(N):
    scores.append(int(input()))
print(f(scores))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,m;
ll s[2001],t[2001];
ll dp[2001][2001];

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

  cin>>n>>m;
  rep(i,n)cin>>s[i];
  rep(j,m)cin>>t[j];

  dp[0][0]=1;
  rep(i,n+1)rep(j,m+1){
    if(i==0&&j==0)continue;
    if(i>0&&j>0&&s[i-1]==t[j-1])(dp[i][j]+=dp[i-1][j-1])%=mod;
    if(i>0)(dp[i][j]+=dp[i-1][j])%=mod;
    if(j>0)(dp[i][j]+=dp[i][j-1])%=mod;
    if(i>0&&j>0)(dp[i][j]+=mod-dp[i-1][j-1])%=mod;
  }
  cout<<dp[n][m]<<endl;

  return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n , h ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>h>>n ;
	int sum = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		sum += x ;
	}
	if(sum >= h)
		return cout<<"Yes\n" , 0 ;
	return cout<<"No\n" , 0 ;
}		

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, min_n = INF; cin >> N;
    vector<int> s(N);
    long long total = 0;
    rep (i, 0, N) {
        cin >> s[i];
        total += s[i];
        if (s[i] % 10 != 0)
            min_n = min(min_n, s[i]);
    }

    if (total % 10 != 0) {
        cout << total << endl;
        return 0;
    }

    if (min_n != INF) {
        total -= min_n;
        cout << total << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <ctime>
#include <cassert>


using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << n / 2;
	}
	else {
		cout << n / 2 - 1;
	}
	return 0;
}

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

int main(void)
{
	int N;
	vector<int> V, C;
	int sum = 0;
	cin >> N;
	V.resize(N);
	C.resize(N);
	for (int i = 0; i < N; i++)cin >> V[i];
	for (int i = 0; i < N; i++)cin >> C[i];
	for (int i = 0; i < N; i++) {
		int tmp = V[i] - C[i];
		if (tmp > 0)sum += tmp;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);

int main() {
  FASTIO
  long long int n; cin >> n;
  long long int res = 0;
  for(long long int i=1; i<=n; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      res += i;
    }
  }
  cout << res << endl;
}

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

int lcs(void);

char s1[1001],s2[1001];
int a[1001][1001];
int m,n;

int main(){
  int i,q;
  
  scanf("%d",&q);
  
  for(i = 0;i < q;i++){
    scanf("%s %s",s1,s2);
    printf("%d\n",lcs());
  }
  
  return 0;
}

int lcs(void){
  int i,j;

  m = strlen(s1);
  n = strlen(s2);
  
  for(i =0;i <= m;i++)a[i][0] = 0;
  for(j = 0;j <= n;j++)a[0][j] = 0;

  for(i = 1;i <= m; i++){
    for(j = 1;j <= n; j++){
      
      if(s1[i-1] == s2[j-1]){
	a[i][j] = a[i - 1][j - 1] + 1;
      }
      else if( a[i - 1][j] >= a[i][j - 1]){
	a[i][j] = a[i - 1][j];
      }
      else a[i][j] = a[i][j - 1];
    }
  }
  
  return a[m][n];
  
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
int cnt[26];
char cs[110];

int sokuhou(int t){
    int mx = max_element(cnt, cnt + 26) - cnt;
    
    bool flag = true;
    for(int i=0;i<26;++i){
        if(i == mx){continue;}
        if(cnt[i] + (N - t) < cnt[mx]){
            
        }else{
            flag = false;
        }
    }

    if(flag){
        return mx;
    }
    return -1;
}

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

    while(true){
        std::cin >> N;
        if(!N){break;}

        memset(cnt, 0, sizeof(cnt));

        int res = -1;
        char winner = 'A';
        
        for(int i=1;i<=N;++i){
            char c;
            std::cin >> c;

            ++cnt[c - 'A'];

            int s = sokuhou(i);
            if(s != -1 && res == -1){
                res = i;
                winner = 'A' + s;
            }
        }

        if(res == -1){
            std::cout << "TIE" << std::endl;
        }else{
            std::cout << winner << " " << res << std::endl;
        }
    }
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<char,int>mp;
    string s;
    int i;
    cin>>s;
    int n=s.size();

    for(i=0;i<n;i++)
        mp[s[i]]++;

  for(char j='a';j<='z';j++)
  {
      if(mp[j]%2)
      {
          cout<<"No\n";
          return 0;
      }
  }
  cout<<"Yes\n";
  return 0;
}


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

#define INF 15
#define A 0
#define B 1
#define C 2

char cond[INF];
char n;
int  m;
int sum;

void move(int pos, char dist) {
    char now = cond[pos];

    if (now == dist) {
        return;
    } else if (abs(now-dist) == 2) {
        move(pos, B);
        move(pos, dist);
    } else {
        int i;
        char no_present = (dist+now == 1)?C:
                          (dist+now == 2)?B:
                                          A;
        for (i=1;pos+i < n;i++){
            if (cond[pos+i] == dist || cond[pos+i] == now) {
                move(pos+i, no_present);
            }
        }

        cond[pos] = dist;
        sum += 1;
    }

    return;
}

int main() {
    while (1) {
        int i;
        char dist;
        sum = 0;

    
        scanf("%d %d", &n, &m);
        if (n == 0 && m ==0) {
            break;
        }

        for (i=0;i < 3;i++) {
            int j,k;

            scanf("%d", &k);
            for (j=0;j < k;j++) {
                int tmp;
    
                scanf("%d", &tmp);
                cond[tmp-1] = i;
            }
        }
    
        dist = (cond[0] != B)?cond[0]:A;
    
        for (i=0;i < n;i++) {
            move(i, dist);
        }
    
        if (sum <= m) {
            printf("%d\n", sum);
        } else {
            printf("-1\n");
        }
    }
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n;
cin>>n;
int m=2*n;
int a[m],i;
for(i=0;i<m;i++)
cin>>a[i];
sort(a,a+m);
int s=0;
for(i=0;i<m;i+=2)
s+=a[i];
cout<<s;
     return 0;
}

Measured memory_bytes: 256
n = int(input())
nums = []
for _ in range(n):
    nums.append(tuple(map(int,input().split())))
# print(nums)
dp = [[10**9]*n for _ in range(n)]
for i in range(n):
    dp[i][i] = 0
# for i in range(n):
#     print(*dp[i])
for l in range(2,n+1):
    for i in range(n-l+1):
        for k in range(l-1):
            # print(l,i,k,dp[i][i+k],dp[i+k+1][i+l-1])
            dp[i][i+l-1] = min(dp[i][i+l-1],dp[i][i+k] + dp[i+k+1][i+l-1] + nums[i][0]*nums[i+k][1]*nums[i+l-1][1])
print(dp[0][n-1])
# for i in range(n):
#     print(*dp[i])



Measured memory_bytes: 5656
#include <stdio.h>
#include <queue>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
vector<pii> v;
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		v.push_back(make_pair(a,-1));
		v.push_back(make_pair(b,1));
	}
	int cnt=0,sum=0,pre=0;
	sort(v.begin(),v.end());
	for(auto it : v){
		int x=it.first, d=-it.second;
		if(cnt==M){
			sum+=x-pre+1;
		}
		cnt+=d;
		if(cnt==M){
			pre=x;
		}
	}
	printf("%d",sum);
	
}

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

#define rep(i,n) for(int i=0;i<(int)(n);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 lf 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;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	priority_queue<double, vector<double>, greater<double>> que;
	rep(i, n){
		double temp; cin >> temp;
		que.push(temp);
	}

	while(que.size()>=2){
		double x = que.top(); que.pop();
		double y = que.top(); que.pop();
		que.push((x+y)/2);
	}

	cout << que.top() << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,n,l,r,s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        s+=(r-l+1);
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll N, Z, W;

ll a[10010];

int main()
{
	cin >> N >> Z >> W;
	for (ll i = N - 1; i >= 0; i--)
	{
		cin >> a[i];
	}

	if (N == 1)
	{
		cout << abs(a[0] - W) << endl;
		return 0;
	}

	cout << max(abs(a[0] - W), abs(a[0] - a[1])) << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int A, B, C;

	
	
	cin >> A >> B >> C;

	if ((A + B + C) >= 22){
		cout << "bust" << endl;
	}
	else{
		cout << "win" << endl;
	}

	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;

  vector<int> w(n + 1, 0), e(n + 1, 0);
  rep(i, 0, n) {
    if (s[i] == 'W')
      w[i + 1] = w[i] + 1;
    else
      w[i + 1] = w[i];
  }

  repr(i, 0, n) {
    if (s[i] == 'E')
      e[i] = e[i + 1] + 1;
    else
      e[i] = e[i + 1];
  }

  int ans = 1e9;
  rep(i, 1, n + 1) {
    // test
    chmin(ans, w[i - 1] + e[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6096
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for ( int i = 1; i <= N; i ++ ){
        if ( i < 10 || i > 99 && i < 1000 || i > 9999 && i < 100000 ) ans ++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int k;
  int a,b;
  int i=0;
  scanf("%d",&k);
  scanf("%d %d",&a, &b);
  while(1){
    i+=k;
    if(i>=a && i<=b ){
      printf("OK\n");
      return 0;
    }else if(i>b){
      printf("NG");
      return 0;
    }
  }
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  int Q;
  cin >> Q;
  int m[Q];
  bool ans[Q]={};
  rep(i,Q) cin >> m[i];
  int sum=0;
  for(int j=0;j<Flag(N);j++){
    sum=0;
    rep(k,N) if(j & Flag(k)) sum+=A[k];
    rep(h,Q) if(sum==m[h]){
      ans[h]=1;
    }
  }
  rep(i,Q){
  if(ans[i]==0) cout << "no" << endl;
  else cout << "yes" << endl;
  }
}


Measured memory_bytes: 3108
#include <stdio.h>
int main(void)
{
    int a;
    int b;
    scanf("%d", &a);
    scanf("%d", &b);
    int num1;
    num1=b-a;
    int i;
    int sum=0;
    for(i=1; i<=num1; i++)
    { sum += i; }
    int sum2;
    sum2=sum-b;
     printf("%d",sum2);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  int n; cin>>n;
  int ans=0;
  for(int i=0;i<n;++i){
    string t; cin>>t;
    t+=t;
    int cnt=0,k=0;
    for(int j=0;j<t.size();++j){
      if(t[j]==s[k]){
	++cnt; ++k;
      }else if(t[j]==s[0]){
	cnt=k=1;
      }else cnt=k=0;
      if(cnt==s.size()){
	++ans;
	break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
double pi=2*acos(0.0);
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int n,m;
    scanf("%d %d",&n,&m);
    if(n>m*2){
        printf("%d\n",n-m*2);
    }
    else{
        printf("0\n");
    }
    return 0;
}



Measured memory_bytes: 256
n=int(input())
a=[0]+input().split()+[0]
sum=0
for i in range(n+1):
    sum+=abs(int(a[i])-int(a[i+1]))
for j in range(n):
    print(sum-(abs(int(a[j])-int(a[j+1]))+abs(int(a[j+1])-int(a[j+2]))-abs(int(a[j])-int(a[j+2]))))

Measured memory_bytes: 11104
#include<stdio.h>
int main() {
	int H,W,i,a;
	while(1) {
	scanf("%d %d",&H,&W);
	if(H==0 && W==0) break;
	if(H>=1 && H<=300 && W>=1 && W<=300) {
		for(i=1;i<=H;i++) {
			for(a=1;a<=W;a++) {
					if((a+i)%2==0) {
						printf("#");
					} else {
						printf(".");
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

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

typedef long long ll;

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

    ll n,m;
    cin >> n >> m;
    if(m-2*n<0){
        if(m==1) cout << 0 << endl;
        else cout << m/2 << endl;
    }else cout << n+(m-2*n)/4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


int main(void){
    ll x;
    cin >> x;

    ll ans = 0;
    rep(i, 2, x + 1){
        ll n = i;
        while(n * i <= x){
            ans = max(ans, n * i);
            n = n * i;
        }
    }

    if(ans == 0){
        ans = 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int binary_search(int s[], int n, int key) {
	int low = 0, high = n;
	while (low < high) {
		int mid = (low + high) / 2;
		if (key == s[mid]) return mid;
		else if (key < s[mid]) high = mid;
		else if (key > s[mid]) low = mid + 1;
	} 
	return -1;
} 
int main() {
	int n;
	scanf("%d", &n);
	int s[n];
	for (int i = 0; i < n; i++) scanf("%d", &s[i]);
	
	int q, temp, cnt = 0;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &temp);
		if (binary_search(s, n, temp) != -1) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const long long INF=(LL)(1e9)*(LL)(1e9);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    LL k;
    cin>>n>>k;
    vector<LL> a(n),b(n);
    REP(i,n)
    {
        cin>>a[i]>>b[i];
    }

    bool bit[30];
    REP(i,30)
    {
        if(((1<<i)&k)>0)
            bit[i]=1;
        else
            bit[i]=0;
    }
    LL ans=0,sum=0;

    REP(j,n)
    {
        bool flag=1;
        REP(t,30)
        {
            if(!bit[t] && ((1<<t)&a[j])>0)
                flag=0;
        }
        if(!flag)
            continue;
        sum+=b[j];
    }
    ans=sum;
    REP(i,30)
    {
        if(((1<<i)&k)==0)
        {
            bit[i]=1;
            continue;
        }
        bit[i]=0;

        sum=0;
        REP(j,n)
        {
            bool flag=1;
            REP(t,30)
            {
                if(!bit[t] && ((1<<t)&a[j])>0)
                    flag=0;
            }
            if(!flag)
                continue;
            sum+=b[j];
        }
        //cout<<sum<<endl;
        ans=max(ans,sum);

        bit[i]=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import sys
import string
input = sys.stdin.readline

N = int(input())
S = input().strip()
ans = 0
for i in range(1000):
    now = str(i)
    if i < 10:
        now = '00' + str(i)
    elif i < 100:
        now = '0' + str(i)
    try:
        left = S.index(now[0])
        next_S = S[left + 1:]
        middle = next_S.index(now[1])
        next_next_S = next_S[middle+1:]
        right = next_next_S.index(now[2])
        ans += 1
    except:
        continue
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll H;
  ll res=1;
  cin >> H;

  while(H>1){
    H = H>>1;
    res=res*2+1;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
k = int(input())

todo = [1,2,3,4,5,6,7,8,9]

lunlun = [1,2,3,4,5,6,7,8,9]

while len(todo) != 0:
    now = todo.pop()
    if now > 3234566668:
        # if now > 3234566668:
        continue
    if str(now)[-1] == '0':
        lunlun.append(int(str(now) + '0'))
        lunlun.append(int(str(now) + '1'))
        todo.append(int(str(now) + '0'))
        todo.append(int(str(now) + '1'))
    elif str(now)[-1] == '9':
        lunlun.append(int(str(now) + '8'))
        lunlun.append(int(str(now) + '9'))
        todo.append(int(str(now) + '8'))
        todo.append(int(str(now) + '9'))
    else:
        temp = int(str(now)[-1])
        lunlun.append(int(str(now) + str(temp - 1)))
        lunlun.append(int(str(now) + str(temp)))
        lunlun.append(int(str(now) + str(temp + 1)))
        todo.append(int(str(now) + str(temp - 1)))
        todo.append(int(str(now) + str(temp)))
        todo.append(int(str(now) + str(temp + 1)))

lunlun.sort()
print(lunlun[k - 1])



Measured memory_bytes: 16388
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair
#define maxn 200005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int inf = 0x3f3f3f3f;
int n;
ll a[maxn],fir[maxn],lst[maxn];
P pos[maxn];//id,val.
int ta;
int dif(ll x,ll y){
	ll cnt = 0;
	while(x <= y){
		x <<= 2;
		cnt++;
	}
	return cnt - 1;
}
ll mul4(int x){
	ll ret = pos[ta].first - x + 1;
	pos[ta].second--;
	if(pos[ta].second == 0) ta--;
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	lst[n] = 0;
	pos[++ta] = mp(n,inf);
	for(int i=n - 1;i>=1;i--){
		lst[i] = lst[i + 1];
		if(a[i] <= a[i + 1]){
			int val = dif(a[i],a[i + 1]);
			if(val) pos[++ta] = mp(i,val);
		}else{
			ll tmp = a[i + 1];
			while(tmp < a[i]){
				lst[i] += mul4(i + 1) * 2;
				tmp <<= 2;
			}
		}
	}
	for(int i=1;i<=n;i++) a[i] *= 2;
	reverse(a + 1,a + n + 1);
	
//	for(int i=1;i<=n;i++){
//		cout << a[i] << " ";
//	}
//	system("pause");
	
	ta = 0;
	fir[n] = 0;
	pos[++ta] = mp(n,inf);
	for(int i=n - 1;i>=1;i--){
		fir[i] = fir[i + 1];
		if(a[i] <= a[i + 1]){
			int val = dif(a[i],a[i + 1]);
			if(val) pos[++ta] = mp(i,val);
		}else{
			ll tmp = a[i + 1];
			while(tmp < a[i]){
				fir[i] += mul4(i + 1) * 2;
				tmp <<= 2;
			}
		}
	}
	reverse(fir + 1,fir + n + 1);
	for(int i=1;i<=n;i++) fir[i] += i;
	ll ans = 0x3f3f3f3f3f3f3f3fll;
	for(int i=1;i<=n + 1;i++){
		ans = min(ans,fir[i - 1] + lst[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int main(){
    ll n,m;cin>>n>>m;
    if(n!=1) n-=2;
    if(m!=1) m-=2;
    cout<<n*m<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string N, S;
    cin >> N >> S;
    int i = N.size();
    S.erase(i);
    if (N == S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

const int INF = 1001001001;

int main() {
  string S;
  cin>>S;
  if(S=="AAA"||S=="BBB"){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
// Date: 2020-08-28

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int p[N], n, m;
LL dis[N];

int Find(int x) {
    if(x != p[x]) {
        int rt = Find(p[x]);
        dis[x] += dis[p[x]];
        p[x] = rt;
    }
    return p[x];
}

int main() {
    scanf("%d%d", &n, &m);
    rep(i, 1, n) p[i] = i;
    int flag = 1;
    while(m--) {
        int x, y, d;
        scanf("%d%d%d", &x, &y, &d);
        int fx = Find(x), fy = Find(y);
        if(fx != fy) {
            p[fx] = fy;
            dis[fx] = d + dis[y] - dis[x];
        } else {
            if(dis[x]-dis[y] != d) {
                flag = 0;
            }
        }
    }
    if(flag) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 4948
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    print("ABC" if N < 1200 else "ARC")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> a(N, vector<int>(N));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> a[i][j];
    }
  }
  vector<int> dp(1 << N, 0);
  dp[0] = 1;
  for (int i = 0; i < (1 << N); i++){
    for (int j = 0; j < N; j++){
      if ((i >> j) & 1){
        if (a[__builtin_popcount(i) - 1][j] == 1){
          dp[i] = (dp[i] + dp[i - (1 << j)]) % MOD;
        }
      }
    }
  }
  cout << dp[(1 << N) - 1];
}

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

int main(){
  int N;
  cin >>N;
  vector<pair<int,int>>vec(N);
  for (int i=0;i<N;i++){
    cin>>vec[i].second>>vec[i].first;
  }
  sort(vec.begin(),vec.end());
  int now=0;
  for (int i=0;i<N;i++){
    now=now+vec[i].second;
    if(now>vec[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    rrep (i, N, 999) {
        if (i % 111 == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
 
#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007

const int MAXN = 1e3 + 50;
const int MAXH = 1e4 + 50;

ll a[MAXN], b[MAXN], dp[MAXH];
int main() {
	ll h, n; scanf("%lld%lld", &h, &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld%lld", &a[i], &b[i]);

	for(int i = 0; i < MAXH; i++)
		dp[i] = IINF;

	dp[0] = 0;
	for(ll x = 0; x < h; x++) {
		for(int i = 1; i <= n; i++) {
			ll y = min(h, x + a[i]);
			dp[y] = min(dp[y], dp[x] + b[i]);
		}
	}
	printf("%lld", dp[h]);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

int main(){
	int n;
	double ans,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		ans+=1/a;
	}
	ans=1/ans;
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}

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

main() {
    int N; cin >> N;
    int T,A; cin >> T >> A;
    int H[N]; rep(i,N) cin >> H[i];
    int ans; double pos=1000000;
    rep(i,N){
        if(pos>abs(A-((double)T-H[i]*0.006))){
            pos=abs(A-((double)T-H[i]*0.006));
            ans=i+1;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, K, a;
  cin >> N >> K;
  a = 1;
  
  for (int i = 0; i < N; i++) {
    if (a * 2 < a + K) {
      a = a * 2;
    }
    else {
      a = a + K;
    }
  }
  
  cout << a;
}

Measured memory_bytes: 256
using System;
 
public class Example{
        public static void Main(){
                string a = Console.ReadLine();
                char[] c = Console.ReadLine().ToCharArray();
                Array.Reverse(c);
                if(a == new string(c))
                       System.Console.WriteLine("YES");
                 else
                       System.Console.WriteLine("NO");
        }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0;  i < n - 2; i ++)
    	if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans ++;
    cout << ans;
    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define PI 3.1415926535

int main(){
    int n, m;
    cin >> n >> m;
    int res = 0;
    while(m--) {
        int t;
        cin >> t;
        res += t;
    }
    if (res <= n) cout << n - res;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 3192
h, n = gets.chomp.split(" ").map(&:to_i)
INF = 1 << 40
ans = Array.new(h+1, INF)
ans[0] = 0

n.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    (h+1).times do |i|
        m = i+a > h ? h : i+a
        ans[m] = ans[i] + b if ans[m] > ans[i] + b
    end
end

puts ans[h]

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

using namespace std;

int main()
{ 
	int K;
	cin >> K;
	long ans = 0;

	for (int a = 1; a <= K; a++)
	{
		for (int b = a; b <= K; b++)
		{
			for (int c = b; c <= K; c++)
			{
				for (int x = a; x >= 1; x--)
				{
					if (a % x == 0 && b % x == 0 && c % x == 0)
					{
						if (a == b && a == c)
						{
							ans += x;
						}
						else if (a == b || a == c || b == c)
						{
							ans += x * 3;
						}
						else
						{
							ans += x * 6;
						}
						break;
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >count(100000,0);
  for(int i=0,a;i<n;i++){cin>>a;count[a]++;}
  //for each number I want the nearest neighbours
  int maxi=0;
  int curr=0;
  for(int i=0;i<100000;i++){
  	curr = 0;
    curr+=count[i];
    if(i-1>=0)curr+=count[i-1];
    if(i+1 < 100000)curr+=count[i+1];
    maxi = max(maxi,curr);
  }
  cout<<maxi;
}

Measured memory_bytes: 3764