akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w;
    cin>>h>>w;
    vector<vector<char>> mat(h,vector<char>(w));
     for(int i=0;i<h;i++)
     {
         for(int j=0;j<w;j++)
         {
             cin>>mat[i][j];
         }
     }
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    for(int i=0;i<h;i++)
    {if(mat[i][0]=='#')
             break;
         dp[i][0]=1;
    }
    for(int i=0;i<w;i++)
     {if(mat[0][i]=='#')
             break;
         dp[0][i]=1;
    }
    
     for(int i=1;i<h;i++)
     {
       for(int j=1;j<w;j++)
       {
          if(mat[i][j]=='#')
          {dp[i][j]=0;
              continue;}
          dp[i][j]= (dp[i-1][j]%mod +dp[i][j-1]%mod)%mod;   
       }
     }
    cout<<dp[h-1][w-1];
  return 0;
}

Measured memory_bytes: 12136
#include <iostream>

int main(void) {
    int a, b, c, d;

    std::cin >> a >> b >> c >> d;

    while(true) {
        if ((c -= b) <= 0) {
            std::cout << "Yes" << std::endl;
            break;
        }
        if((a -= d) <= 0) {
            std::cout << "No" << std::endl;
            break;
        }
    }

    return 0;
}


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

int main() {
    string s;
    int counter = 0, result = 0;

    cin >> s;
    for (int i = 0; i < s.size(); i++)
        if (s[i] == 'R')
            counter++;
        else {
            result = max(result, counter);
            counter = 0;
        }
    result = max(result, counter);

    cout << result;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define maxn 100000+10
#define ll long long
/*
    如果是二分图 染色后n1*n2-m
    如果不是二分图 存在环
    环长度为奇数 换上任意两点可以连边
    环长度不可能为偶 为偶数可以看作二分图
*/
int n, m, u, v;
struct Edge {
    int to, next;
} edge[2 * maxn];
int head[maxn];
int vis[maxn];
int bingraph[2];        // 二分图两部分计数
int color[maxn];
int cnt;
void addedge(int u, int v)
{
    edge[++cnt] = {v, head[u]};
    head[u] = cnt;
    edge[++cnt] = {u, head[v]};
    head[v] = cnt;
}

bool flag;
void dfs(int u)
{
    vis[u] = 1;
    bingraph[color[u]]++;
    for (int i = head[u]; i != -1; i = edge[i].next)
    {
        int v = edge[i].to;
        if (!vis[v]) {
            color[v] = 1 - color[u];
            dfs(v);
        }
        if (vis[v] && color[v] == color[u]) {
            flag = true;
            return;
        }
    }
}

int main()
{
    while(scanf("%d%d", &n, &m) == 2)
    {
        memset(bingraph, 0, sizeof(bingraph));
        memset(head, -1, sizeof(head));
        memset(color, 0, sizeof(color));
        memset(vis, 0, sizeof(vis));
        memset(edge, 0, sizeof(edge));
        flag = false;
        cnt = 0;
        for (int i = 0; i < m; i++){
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        dfs(1);
        if (flag) printf("%lld\n", 1ll * n * (n-1) / 2 - m);
        else printf("%lld\n", 1ll * bingraph[0] * bingraph[1] - m);
    }
    return 0;
}


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

from fractions import gcd
from math import ceil,floor

A,B,C,D=map(int, input().split())

Cans = B//C - (A-1)//C
Dans = B//D - (A-1)//D

CD = C * D // gcd(C,D)
CDans = B//CD - (A-1)//CD

ans = (B-A+1) - (Cans + Dans - CDans)

print(ans)

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

#define LOOP(val,times) for(val = 0;val < (times);++val)

int main(){
  int n,m,i,mx;
  string s;
  map <string,int> mp;
  scanf("%d",&n);
  LOOP(i,n){
    cin >> s;
    mp[s] ++;
  }
  scanf("%d",&m);
  LOOP(i,m){
    cin >> s;
    mp[s]--;
  }
  mx = 0;
  for(auto itr = mp.begin();itr != mp.end();++itr){
    mx = max(itr->second,mx);
  }
  if(mx <= 0) printf("0");
  else printf("%d",mx);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
	int T;
	cin >> T;
	for (int i = 0; i < T; i++) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		if (B > A || B > D) {
			cout << "No" << endl;
		}
		else if (B <= C) {
			cout << "Yes" << endl;
		}
		else {
			ll g = gcd(B, D);
			if (B - g + A%g > C) cout << "No" << endl;
			else cout << "Yes" << endl;
		}
	}
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 10000; ++i) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3528
#include<stdio.h>

#define MAXL 20000

typedef struct Pool {
	int position;
	int ar;
} P;
char buf[ MAXL+2 ];
int stack[ MAXL+2 ];
P ars[ 10002 ];
int sdex, adex;

int main( int argc, char *argv[] ) 
{
	int pool, sum = 0;
	int a, b;

	fgets( buf, MAXL, stdin );	
	sdex = adex = 0
	  ;
	for( a=0; '\0'!=buf[a]; a++ ) {
		if( '\\' == buf[a] ) {
			stack[ sdex++ ] = a;
		} else if( 0 < sdex && '/' == buf[a] ) {
			b = stack[ --sdex ];
			pool = a - b;
			sum += pool;
			while( 0 < adex ) {
				if( b < ars[ adex-1 ].position ) {
					pool += ars[ --adex ].ar;
				} else {
					break;
				}
			}
			ars[ adex ].position = b;
			ars[ adex++ ].ar = pool;
		}
	}
	printf( "%d\n", sum );
	printf( "%d", adex );
	
    if( 0 < adex ) printf( " " );
    for( a=0; a<adex; a++ ) {
        printf( "%d", ars[ a ].ar );
        if( a != adex-1 ) printf( " " );
    }
    printf( "\n" );
    
    
    return 0;
}



Measured memory_bytes: 2096
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
c = [0] * w * h
an = [[] for i in range(h)]

j = 0
for i in range(n):
    for _ in range(a[i]):
        c[j] = i+1
        j += 1
        
for i in range(h):
    c[i] = c[i*w:(i+1)*w]
    if i % 2 == 0:
        print(*c[i])
    else:
        print(*c[i][::-1])

Measured memory_bytes: 42480
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int a[2][200];
Int n, res;
int main(){
  cin >> n;
  for(int i = 0;i < n;i++)cin >> a[0][i];
  for(int i = 0;i < n;i++)cin >> a[1][i];

  for(int i = 0;i < n;i++){
    Int tmp = 0;
    for(int j = 0;j <= i;j++)tmp += a[0][j];
    for(int j = i;j < n;j++)tmp += a[1][j];
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
s = list(s)
flag = True
temp = 0
for i in range(len(s)):
    temp += 1
    if temp % 2 == 1 :
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            continue
        else:
            flag = False
    elif temp % 2 == 0:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            continue
        else:
            flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;

//-----------------------------------------
vector<string> split(string str, char del){
    int first = 0;
    int last  = str.find_first_of(del);
 
    vector<string> result;
    while (first < str.size()) {
        string subStr(str, first, last - first);
        result.push_back(subStr);
 
        first = last + 1;
        last  = str.find_first_of(del, first);
 
        if (last == string::npos) {
            last = str.size();
        };
    };
    return result;
}
 

string judge(vector<string> splited_str){

    string ok = "Heisei";
    string ng = "TBD";

    int year  = atoi(splited_str[0].c_str());
    int month = atoi(splited_str[1].c_str());
    int day   = atoi(splited_str[2].c_str());

    if(year==2019 && (month==4) && (day==30)){ return ok; }
    if(year>=2019 && (month>=5) && (month<=12) && (day>=1) && (day<=31)){ return ng; }
    return ok;

}


int main() {
    string S; cin >> S;
    string out;
    vector<string> splited_str;


    splited_str = split(S, '/');
    out = judge(splited_str);
    cout << out << endl;
}

Measured memory_bytes: 256
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

  if(b == 0)
    return a;
  else return gcd(b,a%b);
}


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}

int main(){

  string a,b;
  cin>>a>>b;

   long long cnt=0;

  for(int i=0;i<a.length();i++){

    if(a[i] == b[i])
        continue;
    else cnt++;

  }

  cout<<cnt<<endl;

return 0;
}


Measured memory_bytes: 3916
import java.io.*;
import java.util.*;
 
 
class Main {
    public static void main(String[] args) throws IOException {
 
         
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n =Integer.parseInt(br.readLine());
         
         
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        long sum = 0;
        String[] cut = br.readLine().split(" ");
         
        for (int i=0;i<n;i++) {
            int r =Integer.parseInt(cut[i]);
            if(max<r){
                max=r;
            }
            if(min>r){
                min=r;
            }
            sum+=r;
        }   
        System.out.println(min+" "+max+" "+sum);
     
         
 
    }
}

Measured memory_bytes: 28604
N = int(input())
A = list(map(int, input().split()))
ma = max(A)
mi = min(A)
if ma-mi > 1:
    print("No")
    exit()
if ma-mi == 0 and N-1 == ma:
    print("Yes")
    exit()
d = N-ma
cma = A.count(ma)
if d+1 <= cma <= d*2:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main()
{
    //freopen("test.inp","r",stdin);
    long long int k,x;
    cin >> k >> x;
    if ((500*k) >= x)
    {
        cout << "Yes";
    }
    else
    {
        cout <<"No";
    }
    return 0;
}


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

template <typename T>
void print(const T &v);

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k)
    {
        a -= k;
    }
    else
    {
        k -= a;
        a = 0;
        b -= k;
        if (b < 0)
        {
            cout << 0 << ' ' << 0 << endl;
            return 0;
        }
    }

    cout << a << ' ' << b << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }



    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var X = sc.intarr;
        wr.wri((X[0] - 1) * (X[1] - 1) );
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
h,w = map(int, input().split())
a_list = [list(input()) for _ in range(h)]

for a in a_list:
    a.insert(0,'#')
    a.append('#')
a_list.insert(0,['#']*(w+2))
a_list.append(['#']*(w+2))

for a in a_list:
    print(''.join(a))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N, M;
    long long ans = 1;
    cin >> N >> M;
    if(abs(N - M) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(N == M){
        ans = 2;
    }
    for(int i = 1; i <= N; i++){
        ans = ans*i % 1000000007;
    }
    for(int i = 1; i <= M; i++){
        ans = ans*i % 1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll l, r;
    cin >> l >> r;
    
    ll ans = 2018;
    if( r - l >= 2019){
        cout << 0 << endl;
        return 0;
    } else {
        for(ll i = l; i < r; i++){
            for(ll j = i + 1; j - 1 < r; j++){
                ans = min(ans, (i * j ) % 2019);
            }
        }
    }
    
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

static const ull mod = 1000000007;

ull modpow(ull p, ull q, ull m=mod){
    ull ans = 1;
    p = p % m;
    for(ull i = 1ULL<<(sizeof(ull)*8-1); i>0; i>>=1){
        if(q&i) ans *= (ans*p)%m;
        else ans *= ans;
        ans %= m;
    }
    return ans;
}

int main(){
    ull m,n;
    cin >> m >> n;
    cout << modpow(m,n) << endl;
}


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

int main(){

    float A, B, C, D;
    cin >> A >> B >> C >> D;

    if (ceil(C/B) <= ceil(A/D)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3720
open System
open System.Collections.Generic

let ReadOne T = stdin.ReadLine()|> T
let ReadSplit T = stdin.ReadLine().Split()|>Array.map T
[<EntryPoint>]
let main argv =
    stdin.ReadLine()
    |>Seq.sumBy(fun c -> if c='o' then 100 else 0)
    |>fun c -> c+700
    |>stdout.WriteLine
    0


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[3];
int main()
{
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n",a[0]*a[1]/2);
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  string str;
  cin >> str;
  cout << str.substr(0, 4) << " " << str.substr(4, 12) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


const int MAX_SIZE = 100;

void heap_sort(int data[], int n){
	priority_queue<int, vi, greater<int> > q;
	for(int i = 0; i < n; i++) q.push(data[i]);
	for(int i = 0; i < n; i++){
		data[i] = q.top();
		q.pop();
	}
}

void insertion_sort(int data[], int n, int h){
	for(int j = 0; j < n; j++){
		if(j != 0) cout<<" ";
		cout<<data[j];
	}
	cout<<endl;
	
	for(int i = h; i < n; i+=h){

		int tmp = data[i];
		int j = i;
		while(j - h >= 0 && data[j - h] > tmp){
			data[j] = data[j - h];
			j-=h;
		}
		data[j] = tmp;


		for(int j = 0; j < n; j++){
			if(j != 0) cout<<" ";
			cout<<data[j];
		}
		cout<<endl;
	}
}

void shell_sort(int data[], int n){
	int h = 0;
	while(h * 3 + 1 < n) h = h * 3 + 1;
	while(h > 1){
		insertion_sort(data, n, h);
		h = ( h - 1) / 3;
	}
	insertion_sort(data, n , 1);
}

void merge(int data[], int l, int r, int d[]){
	if(r - l <= 0) return;

	int m = (l + r) / 2;

	merge(data, l, m, d);
	merge(data, m + 1, r, d);

	for(int i = l; i <= m; i++) d[i] = data[i];
	for(int i = m + 1, j = r; i <= r; i++, j--) d[i] = data[j];

	for(int i = l, j = r, k = l; k <= r; k++){
		if(d[i] <= d[j]){
			data[k] = d[i];
			i++;
		}
		else{
			data[k] = d[j];
			j--;
		}
	}
}

void merge_sort(int data[], int n){
	int d[MAX_SIZE];
	merge(data, 0, n , d);
}

void quick_sort(int data[], int l, int r){
	int i = l, j = r, p = data[(l + r) / 2];
	while(1){
		while(data[i] < p) i++;
		while(data[j] > p) j--;
		if(i >= j) break;
		swap(data[i], data[j]);
		i++;
		j--;
	}
	if(i - l > 1) quick_sort(data, l, i - 1);
	if(r - j > 1) quick_sort(data, j + 1, r);
}


int main(){
	int d[MAX_SIZE];
	int n;
	cin>>n;
	for(int i = 0; i < n; i++) cin>>d[i];
	insertion_sort(d, n, 1);
	
}

Measured memory_bytes: 1164
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				String str = sc.next();
				if(str.contentEquals("-")) break;
				int length = sc.nextInt();

				for(int i=0;i<length;i++) {
					int num = sc.nextInt();
					str = str.substring(num) + str.substring(0,num);
				}
				System.out.println(str);
			}
		}
	}
}


Measured memory_bytes: 26536
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, W = MI()
    items = [[] for _ in range(4)]
    w0, v0 = MI()
    items[0].append(v0)
    for _ in range(N-1):
        w, v = MI()
        items[w - w0].append(v)
    
    cumsum = [[0] + list(accumulate(sorted(items[i],reverse=True))) for i in range(4)]
    ans=0
    for i,c0 in enumerate(cumsum[0]):
        for j,c1 in enumerate(cumsum[1]):
            for k,c2 in enumerate(cumsum[2]):
                s = i * w0 + j * (w0 + 1) + k * (w0 + 2)
                if s <= W:
                    l = min(len(cumsum[3])-1,(W-s)//(w0+3))
                    ans = max(ans, c0 + c1 + c2 +cumsum[3][l])
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 40560
#include "bits/stdc++.h"
#define hhh printf("hhh\n")
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x;}

const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-7;

int a[maxn], b[maxn], c[maxn];
int dp[maxn];

int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    int N=read(), M=read();
    for(int i=0; i<M; ++i) {
        a[i]=read(), b[i]=read();
        for(int j=0; j<b[i]; ++j) c[i]|=1<<(read()-1);
    }
    memset(dp,inf,sizeof(dp)); dp[0]=0;
    for(int i=0; i<M; ++i)
        for(int j=0; j<(1<<N); ++j) dp[j|c[i]]=min(dp[j|c[i]],dp[j]+a[i]);
    printf("%d\n", dp[(1<<N)-1]==inf?-1:dp[(1<<N)-1]);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

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

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    sort(ALL(a));
    cout << accumulate(a.begin(), a.begin() + k, 0);
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3680
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long long> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    long long mod = 1000000007;

    vector<long long> inv(n + 1, 0), inv_sum(n + 1, 0), frac(n + 1, 0);
    inv[1] = 1;
    inv_sum[1] = 1;
    frac[0] = frac[1] = 1;
    for (int i = 2; i <= n; i++) {
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        inv_sum[i] = (inv_sum[i - 1] + inv[i]) % mod;
        frac[i] = frac[i - 1] * i % mod;
    }

    long long res = 0;
    for (int i = 0; i < n - 1; i++) {
        res += (x[i + 1] - x[i]) * inv_sum[i + 1] % mod * frac[n - 1];
        res %= mod;
    }

    cout << res << endl;
}


Measured memory_bytes: 3328
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1e18
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int n;
ll dp[3000][3000];
vl a;

ll rec(int l, int r, int turn)
{
	if(dp[l][r] != INF)
		return dp[l][r];

	// printf("%d %d %d\n", l, r, turn);

	if(l == r)
	{
		if(turn)
			dp[l][r] = a[l];
		else
			dp[l][r] = -a[l];
		return dp[l][r];
	}

	ll x = rec(l+1, r, turn^1);
	ll y = rec(l, r-1, turn^1);

	if(turn)
	{
		dp[l][r] = max(x + a[l], y + a[r]);
		return dp[l][r];
	}
	else
	{
		dp[l][r] = min(x - a[l], y - a[r]);
		return dp[l][r];
	}
}

int main()
{
	cin >> n;
	a.resize(n,0);

	invec(a,n);

	fr(i,0,n)
		fr(j,0,n)
			dp[i][j] = INF;

	rec(0,n-1,1);

	// fr(i,0,n)
	// {
	// 	fr(j,0,i)
	// 		cout << "\t\t";
	// 	fr(j,i,n)
	// 		cout << dp[i][j] << "\t\t";
	// 	cout << "\n";
	// }

	cout << dp[0][n-1];
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if (A==B && B!=C){
        printf("Yes\n");
    }else if (A==C && B!=C){
        printf("Yes\n");
    }else if (B==C && A!=C){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

#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 PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,k;
    cin>>n>>k;

    int l[n];

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

    sort(l,l+n);

    int ans=0;
    for(int i=0;i<k;i++){
        ans+=l[n-1-i];
    }

    cout<<ans<<endl;

    return 0;
}




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

using namespace std;

int main()
{
    int t,x,k,c=0,ans=0;
    cin>>t>>k;
    map<int,int> m;
    while(t--){
        cin>>x;
        m[x]++;
    }
    map<int,int>::iterator it=m.begin();
    vector <int> v;
    for(;it!=m.end();it++){
        v.push_back(it->second);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        if(v.size()-i <=k )break;
        ans+=v[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 

    int n,m;
    cin>>n>>m;

    int l,r,l_max=-1,r_min=10000000;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        l_max=max(l_max,l);
        r_min=min(r,r_min);
    }

    cout<<max(0,r_min-l_max+1)<<endl;

    return 0; 
} 

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k;
	cin>>k;
	int ans=0;
	for(int a=1;a<=k;++a){
		for(int b=1;b<=k;++b){
			for(int c=1;c<=k;++c){
				ans+=gcd(a,gcd(b,c));
			}
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
using ll = long long;
int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  
  ll x = c - a - b;
  ll y = 4 * a * b;
  if (x <= 0 || x * x <= y) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

struct thing {
	int x0, y0, x1, y1;
	thing(int _x0 = -1, int _y0 = -1, int _x1 = -1, int _y1 = -1): x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
};

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int h, w; cin >> h >> w;
	int a[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> a[i][j];
	vector<thing> ans;
	// sweep everything right
	for (int j = 0; j < w-1; j++)
		for (int i = 0; i < h; i++)
			if (a[i][j]&1) {
				ans.push_back(thing(i+1,j+1,i+1,j+2)); a[i][j+1]++;
			}
	// sweep the right edge down
	for (int i = 0; i < h-1; i++)
		if (a[i][w-1]&1) {
			ans.push_back(thing(i+1,w,i+2,w)); a[i+1][w-1]++;
		}

	cout << ans.size() << endl;
	for (thing m : ans)
		cout << m.x0 << ' ' << m.y0 << ' ' << m.x1 << ' ' << m.y1 << endl;

	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const ll INF = 1e18 + 7;
const int N = 2002;

pi a[N];
ll dp[N][N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i].F, a[i].S = i;
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = -INF;
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= i; j++) {
			if(j > 0) {
				int pos = j;
				dp[i][j] = max(dp[i][j], (ll) a[i].F * abs(a[i].S - pos) + dp[i-1][j-1]);
			}
			int pos = n - i + j + 1;
			dp[i][j] = max(dp[i][j], (ll) a[i].F * abs(a[i].S - pos) + dp[i-1][j]);
		}
	}
	ll mx = 0;
	for(int i = 0; i <= n; i++) mx = max(mx, dp[n][i]);
	cout << mx << endl;

}





Measured memory_bytes: 34960
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, a;
	int count[105] = { 0 };
	cin >> n;
	REPS(i, n) {
		cin >> a;
		count[a] = 1;
	}
	int ans = 0;
	REPS(i, 100) {
		ans += count[i];
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 256
function Main(input) {
  const tmp = input.trim().split('\n').map(v => parseInt(v, 10))

  const a = tmp[0];
  const b = tmp[1];
  const h = tmp[2];

  const result = ((a + b) * h) / 2;

  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int N;
vector<int> t, x, y;
void solve();

int main() {
  cin >> N;
  t.resize(N + 1);
  x.resize(N + 1);
  y.resize(N + 1);
  rep(i, N) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  solve();
}

void solve() {
  bool enable = true;
  rep(i, N) {
    // 時間変化量
    int dt = t[i + 1] - t[i];
    // マンハッタン距離変化量
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dist > dt) {
      enable = false;
    }
    // dtとdistの偶奇が一致するという性質を利用する
    if (dist % 2 != dt % 2) {
      enable = false;
    }
  }
  cout << (enable ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool graph[101][101];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
char c[10][10];
bool visited[10][10];
char math[1010][1010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>p(n);
	ll ans = 0;
	vector<ll>res;
	bool flag = false;
	rep(i, n) {
		cin >> p[i];
		p[i]--;
		if (p[i] == i&&flag==false) {
			res.push_back(1);
			flag = true;
		}
		else if (p[i] == i && flag == true) {
			ll k = res.size();
			res[k - 1]++;
		}
		else {
			flag = false;
		}
	}
	rep(i, res.size()) {
		ans += (res[i] + 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    if (a==b && b==c) {
        if (a % 2 == 0) cout << -1 << endl;
        else cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    while(a%2==0 && b%2==0 && c%2==0) {
        ll ta = a, tb = b, tc = c;
        a = (tb+tc)/2;
        b = (ta+tc)/2;
        c = (ta+tb)/2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

int main()
{
	char s[3];
	cin >> s;
	if (s[0] >= 'a') printf("a");
	else printf("A");
	printf("\n");
	return 0;
}


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

int main() {
  
  long int n, a, b;
  cin >> n >> a >> b;
  
  long int x = n / (a + b);
  long int c = n % (a + b);
  long int d = min(a, c);
  long int ans = a * x + d; 
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
for i in range(3, n + 1):
    x = i
    if x % 3 == 0 or x % 10 == 3:
        print(" " + str(i), end="")
    else:
        while True:
            x = x // 10
            if x == 0:
                break
            if x % 10 == 3:
                print(" " + str(i), end="")
                break
print()



Measured memory_bytes: 5876
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using P = pair<ll, ll>;

ll m[20][20];

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

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

int main(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll p = 0;

    ll left = 0;
    ll right = k - 1;
    double max = 0;
    double x = 0;
        for(ll i = left; i <= right; ++i)
        {
            x += (double) (1 + a[i]) / (double) 2;
        }

    while(right < n)
    {
        if(left > 0)
        {
            x -= (double) (1 + a[left - 1]) / (double) 2;
            x += (double) (1 + a[right]) / (double) 2;
        }
        if(max < x)
        {
            max = x;
        }

        left++;
        right++;
    }

    cout << fixed;
    cout << setprecision(12) << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {

int n,i,ai,min,max;

long sum;

sum = 0; 

min=1000000;

max=-1000000; 

scanf("%d",&n);

for(i=1;i<=n;i++){ 

scanf("%d",&ai);

sum+=ai;

if(min>ai){

min=ai;

}

if(max<ai){

max=ai;

}

}

printf("%d %d %lld\n",min,max,sum);

return 0;

}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

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

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

const int MAX = 1e5 + 2;

int cnt[MAX];

int32_t main()
{
    FASTIO;

    ll sum = 0;

    int n;
    cin >> n;
    for(int i = 0, x; i < n; i++){
        cin >> x;
        cnt[x]++;
        sum = sum+x;
    }
    int q;
    cin >> q;
    while(q--){
        ll b, c;
        cin >> b >> c;
        sum = sum + cnt[b]*(c-b);
        cout << sum << "\n";
        cnt[c] += cnt[b];
        cnt[b] = 0;
    }

    return 0;
}

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

int main() {
  string S; cin >> S;
  int digit = S.size();
  long long ans = 0;
  if (S == "1") {
    cout << 1 << endl;
    return 0;
  }
  for (int i = (1 << (digit - 2)); i < ((1 << (digit - 1)) + (1 << (digit - 2))) - 0; i++) {
    bitset<10> tmp = i;
    bool current_state = false;
    int starting_point = 0;
    for (int j = 0; j < digit; j++) {
      if (tmp.test(j) == current_state) continue;
      ans += stoll(S.substr(digit - 1 - j, j - starting_point + 1));
      current_state ^= 1;
      starting_point = j + 1;
    }
  }

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

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

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


Measured memory_bytes: 3092
def buttons(A: int, B: int)->int:
    s = 0
    for _ in range(2):
        if A > B:
            s += A
            A -= 1
        else:
            s += B
            B -= 1
    return s


if __name__ == "__main__":
    A, B = map(int, input().split())
    ans = buttons(A, B)
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, D;

int main()
{
    cin >> N >> D;
    int l = 2 * D + 1;
    cout << (N + l - 1) / l << endl;
}

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

int main() {
    int A, B, C; cin >> A >> B >> C;
    if(A > B) swap(A, B);
    if(B > C) swap(B, C);
    if(A > B) swap(A, B);
    cout << A << ' ' << B << ' ' << C << endl;
}


Measured memory_bytes: 3116
#pragma region template
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(ll S, ll W) {
  string Yes = "safe\n", No = "unsafe\n";
  Yes(S > W);
}

int main() {
  ll S;
  ignore_ret(scanf("%lld",&S));
  ll W;
  ignore_ret(scanf("%lld",&W));
  solve(S, W);
  return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;
typedef pair<int,int> P;

signed main() {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        cout << N / 2 - 1 << endl;
    }
    else {
        cout << (N - 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
struct edge{
	int to,cost;
};
class DIJ{
	public:
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
//		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n,m,s;
	cin>>n>>m>>s;
	DIJ dij(n);
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		dij.add_edge(a,b,c);
	}
	dij.dij(s);
	rep(i,n)if(dij.d[i]!=inf)cout<<dij.d[i]<<endl;
		else cout<<"INF"<<endl;
}

Measured memory_bytes: 13956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const int MAXN = 2*1e5+10;

int32_t main() {
	string s, t;
	cin >> s >> t;
	
	ll ans = 0;
	
	set<int> fila[27];
	
	for(int i = 0; i < s.size(); i++)
		fila[s[i]-'a'].insert(i);
	
	int posi = -1;
	for(auto i : t) {
		if(fila[i-'a'].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
		auto it = fila[i-'a'].upper_bound(posi);
		
		if(it == fila[i-'a'].end()) {
			ans += (s.size() - posi) + *fila[i-'a'].begin();
			posi = *fila[i-'a'].begin();
		}
		else {
			ans += *it - posi;
			posi = *it;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    vi T;
    int k;
    rep(i, 0, 5){
        int a;
        cin >> a;
        T.pb(a);
    }
    cin >> k;
    rep(i, 0, 5){
        rep(j, 0, 5){
            if(abs(T[i] - T[j]) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}




Measured memory_bytes: 3616