akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

// indexを保存して値の昇順にソート
bool comp_p(const pll& l, const pll& r){
	return l.second < r.second;
}

int main(){
	ll N;
	cin >> N;
	vector<pll> P;
	ll i, j;
	for (i = 0; i < N; i++){
		ll p;
		cin >> p;
		P.push_back(pll(i, p));
	}
	sort(P.begin(), P.end(), comp_p);
	ll max_l = 1;
	ll current_l = 1;
	for (i = 0; i < N - 1; i++){
		if (P[i].first < P[i + 1].first){
			current_l++;
		}
		else{
			current_l = 1;
		}
		max_l = max(max_l, current_l);
	}
	cout << N - max_l << endl;

	return 0;
}



Measured memory_bytes: 6384
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main(){
    int q ;
    int mx = 100005 ;
    cin >> q;
    vector<int> isprime (mx, 1) ;
    isprime[0] = 0 ;
    isprime[1] = 0 ;
    for(int i = 2; i < mx ; i++){
        if(isprime[i]){
            for(int j = 2*i ; j < mx ; j += i){
                isprime[j] = 0 ;
            }
        }
    }
    vector<int> like (mx) ;
    rep(i, mx){
        if(i % 2 == 0){
            continue ;
        }
        if(isprime[i] == 1 && isprime[(i + 1)/2] == 1){
            like[i] = 1 ;
        }
    }
    rep(i, mx){
        if(i == 0) continue ;
        else {
            like[i] += like[i - 1] ;
        }
    }
    vector<int> ans ;
    rep(i, q){
        int l, r ;
        cin >> l >> r ;
        if(like[l] != like[l - 1]){
            ans.push_back(like[r] - like[l] + 1) ;
        }
        else {
            ans.push_back(like[r] - like[l]) ;
        }
    }
    rep(i, q){
        cout << ans[i] << endl ;
    }
} 

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

int n, m;

vector <int> g[15], c[15];
void add_edge(int u, int v, int w) {
	g[u].push_back(v);
	c[u].push_back(w);
}

int dp[1 << 15][15];
int prep[1 << 15][15];

void upd(int &x, int y) {
	if (y < x) x = y;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++ i) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		-- u; -- v;
		add_edge(u, v, w);
		add_edge(v, u, w);
	}
	memset(dp, 0x3f, sizeof(dp));
	int full = (1 << n) - 1;
	for (int msk = 1; msk < (1 << n); ++ msk) {
		for (int i = 0; i < n; ++ i) if (!(msk >> i & 1)) {
			for (int e = 0; e < g[i].size(); ++ e) {
				if (msk >> g[i][e] & 1) prep[msk][i] += c[i][e];
			}
		}
	}
	dp[1][0] = 0;
	for (int msk = 1; msk < (1 << n); ++ msk) {
		for (int u = 0; u < n; ++ u) if (msk >> u & 1) {
			for (int e = 0; e < g[u].size(); ++ e) {
				int v = g[u][e];
				if (!(msk >> v & 1))
					upd(dp[msk | 1 << v][v], dp[msk][u] + prep[msk ^ 1 << u][v]);
			}
			for (int s = full ^ msk; s; s = (s - 1) & (full ^ msk)) {
				int cur = 0;
				for (int i = 0; i < n; ++ i) if (s >> i & 1)
					cur += prep[msk ^ 1 << u][i];
				upd(dp[msk | s][u], dp[msk][u] + cur);
			}
		}
	}
	printf("%d\n", dp[full][n - 1]);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> indexed_multiset;


long long l , r;
long long ans = 2019;
int main(){
	cin>>l>>r;
	for(long long i = l ; i <= r ; i++){
		for(long long j = i+1 ; j<= r ; j++){
			ans = min(ans ,(i*j)%2019);
			if(ans == 0){
				cout<<ans;
				return 0;
			}
		}
	}
	cout<<ans;
   	return 0;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,h,w;
    cin>>n>>h>>w;
    int ans=0;
    ans=(n-h+1)*(n-w+1) ;
    cout<<ans;


} 
    
 


Measured memory_bytes: 256
#include <cstdio>
int dp[31]={1,1,2};
int main() {
	for(int i=3;i<=30;i++) {
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(scanf("%d",&n),n) {
		int days=dp[n]/10+((dp[n]%10)?1:0);
		int years=days/365+((days%365)?1:0);
		printf("%d\n",years);
	}
}

Measured memory_bytes: 1028
n = int(input())
ac = wa = tle = re = 0
for _ in range(n):
    tmp = input()
    if tmp == 'AC':
        ac += 1
    elif tmp == 'WA':
        wa += 1
    elif tmp == 'TLE':
        tle += 1
    else:
        re += 1
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')

Measured memory_bytes: 69820
#include <iostream>

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

	int q, r;
	bool flag = false;
	q = n;
	while(q != 0){
		r = q % 10;
		q = q / 10;
		if(r == 7)flag=true;
	}

	if(flag){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int ignore;
    cin >> ignore;
    int fi;
    int se;
    int th;
    vector<int> v;

    while(cin >> fi >> se >> th)
    {
        v.push_back(fi);
        v.push_back(se);
        v.push_back(th);
        sort(v.begin(), v.end(), greater<int>());
        if(v[0] * v[0] == v[1] * v[1] + v[2] * v[2])
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
        v.clear();
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

string str;
ll N;
vll dist;

ll calc_dist(ll pos){
  if(dist[pos]>=0) return dist[pos];
  char c = str[pos];
  if(c=='L'){
    if(str[pos-1]=='L') return dist[pos] = calc_dist(pos-1)+1;
    return dist[pos] = 1;
  }else{
    if(str[pos+1]=='R') return dist[pos] = calc_dist(pos+1)+1;
    return dist[pos] = 1;
  }
}

int main(){
  IN(str);
  N = str.size();
  dist.resize(N, -1);

  vll ans(N, 0);

  //printf("dist\n");
  REP(i,N){
    calc_dist(i);
    //printf("%lld ", dist[i]);
  }
  //printf("\n");

  REP(i,N){
    ll tmp = dist[i];
    ll pos;
    if(str[i]=='L'){
      pos = i-tmp;
      if(tmp%2==1) pos++;
    }else{
      pos = i+tmp;
      if(tmp%2==1) pos--;
    }
    ans[pos]++;
  }

  REP(i,N){
    printf("%lld ", ans[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 5376
x = input()
a = int(x.split()[0])
b = int(x.split()[1])
sum_a = ''
sum_b = ''

for i in range(b):
    str_a = str(a)
    sum_a = sum_a + str_a
sum_a = int(sum_a)

for i in range(a):
    str_b = str(b)
    sum_b = sum_b + str_b
sum_b = int(sum_b)

if sum_a >= sum_b:
    print(sum_a)
else:
    print(sum_b)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();

        int[] a = new int[A];
        int[] b = new int[B];

        int minA = Integer.MAX_VALUE;
        int minB = Integer.MAX_VALUE;

        for(int i=0;i<A;i++){
            a[i] = sc.nextInt();
            minA = Math.min(a[i],minA);
        }

        for(int i=0;i<B;i++){
            b[i] = sc.nextInt();
            minB = Math.min(b[i],minB);
        }

        int ans = minA + minB;

        for(int i=0;i<M;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();

            int price = a[x-1] + b[y-1] -c;
            ans = Math.min(ans,price);

        }

        System.out.println(ans);

    }

}









Measured memory_bytes: 150668
# C

c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

if not(c12 - c11 == c22 - c21 == c32 - c31):
    print("No")
    quit()
if not(c13 - c12 == c23 - c22 == c33 - c32):
    print("No")
    quit()
if not(c21 - c11 == c22 - c12 == c23 - c13):
    print("No")
    quit()
if not(c31 - c21 == c32 - c22 == c33 - c23):
    print("No")
    quit()

print("Yes")

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

int main(int argc, char *argv[])
{
    int ina, inb, inc;
	vector<int> a;

	cin >> ina >> inb >> inc;
	a.push_back(ina);
	a.push_back(inb);
	a.push_back(inc);

	sort(a.begin(), a.end());
	if (a[0] == 5 &&
		a[1] == 5 &&
	    a[2] == 7)
		cout << "YES";
	else
		cout << "NO";

	cout << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int s[1252][1252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int h, w, a, b;
	cin>>h>>w>>a>>b;
	REP(i, b){
		REP(j, a){
			s[i][j]=1;
		}
	}
	FOR(i, b, h){
		FOR(j, a, w){
			s[i][j]=1;
		}
	}
	REP(i, h){
		REP(j, w){
			cout<<s[i][j];
		}
		cout<<'\n';
	}
	return 0;
}


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

int main(){
  vector<int> num(3);
  cin>>num[0]>>num[1]>>num[2];
  sort(num.begin(),num.end());
  long long count=0;
  while(num[0]<num[2] && num[1]<num[2]){
    count++;
    num[0]++; num[1]++;
  }
  while(num[0]<num[2]){
    num[0]+=2;
    count++;
  }
  if(num[0]!=num[2]) count++;
  cout<<count<<endl;
}

Measured memory_bytes: 256
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

K = int(input())
L = list(int(x) for x in input().split())

Ld = sorted(L)

if Ld[int(K / 2) - 1] == Ld[int(K / 2)]:
    print(0)
else:
    print(Ld[int(K / 2)] - Ld[int(K / 2) - 1])

Measured memory_bytes: 15792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ini() {
	var buf = make([]byte, 10000)
	sc.Buffer(buf, 1000000)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	ini()
	N, _ := strconv.Atoi(nextLine())
	S := nextLine()
	b := make([]int, N+1)

	for i, s := range S {
		if s == '#' {
			b[i+1] = b[i] + 1
		} else {
			b[i+1] = b[i]
		}
	}
	ans := N
	for i := 1; i < N+1; i++ {
		ans = min(ans, b[i]+N-i-b[N]+b[i-1])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll l, r;
    ll ans = 2018;

    cin >> l >> r;

    if (r - l > 2019)
    {
        cout << 0 << endl;
        return 0;
    }

    for (ll i = l; i < r; i++)
    {
        for (ll j = i + 1; j <= r; j++)
        {
            ans = min(ans, (i * j % 2019));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(long[] a, long[] b) {
    int n = cast(int) a.length;
    long[] pos, neg;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) pos ~= a[i] - b[i];
        else if (a[i] < b[i]) neg ~= b[i] - a[i];
    }

    if (pos.sum < neg.sum) return -1;

    pos.sort!((x, y) => x > y);
    neg.sort();

    auto pos2 = pos.dup;

    int ans = cast(int) neg.length;
    int p = 0;
    for (int i = 0; i < neg.length; i++) {
        long x = neg[i];
        while (p < pos.length) {
            long t = min(x, pos[p]);
            x -= t;
            pos[p] -= t;
            if (pos[p] == 0) {
                p++;
            }
            if (x == 0) break;
        }
        if (x > 0) return -1;
    }

    for (int i = 0; i < pos2.length; i++) {
        if (pos[i] != pos2[i]) ans++;
    }
    return ans;
}

void main() {
    readint;
    auto a = reads!long;
    auto b = reads!long;
    writeln(calc(a, b));
}


Measured memory_bytes: 11652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

int n, a[maxn];

int cnt[maxn];
pii max1, smax1, max2, smax2;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i += 2)
	{
		cnt[a[i]]++;
	}
	for (int i = 1; i <= N; i++)
	{
		if (pii(cnt[i], i) > max1)
		{
			smax1 = max1;
			max1 = pii(cnt[i], i);
		}
		else if (pii(cnt[i], i) > smax1)
		{
			smax1 = pii(cnt[i], i);
		}
	}
	memset(cnt, 0, sizeof(cnt));
	for (int i = 2; i <= n; i += 2)
	{
		cnt[a[i]]++;
	}
	for (int i = 1; i <= N; i++)
	{
		if (pii(cnt[i], i) > max2)
		{
			smax2 = max2;
			max2 = pii(cnt[i], i);
		}
		else if (pii(cnt[i], i) > smax2)
		{
			smax2 = pii(cnt[i], i);
		}
	}

	if (max1.second != max2.second)
	{
		cout << n - max1.first - max2.first;
	}
	else
	{
		cout << n - max(max1.first + smax2.first, smax1.first + max2.first);
	}
}

Measured memory_bytes: 1792
#include<stdio.h>
 int main(){
 int x;
 scanf("%d",&x);
 int c500 = x/500; // 500 円硬貨の数
 int r500 = x%500; // 端数
 int c5 = r500/5; // 5 円硬貨の数
 printf("%d\n",c500*1000+c5*5);
 }

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 200005
#define lowbit(o) o&(-o)
using namespace std;
int i,j,k,l,s,n,m,R[N],L[N],st[N],ans,mx[N],top;
int a[N],b[N];
char c[N];
inline bool cmp(int x,int y) {
	return R[x]<R[y];
}
int main() {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (i=1;i<=n;i++) a[i]=c[i]-48,L[i]=R[i]=100000000;
	scanf("%s",c+1);
	for (i=1;i<=n;i++) b[i]=c[i]-48;
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (b[j]) L[i]=min(L[i],(i-j+n)%n),R[i]=min(R[i],(j-i+n)%n);
	ans=100000000;
	for (i=1;i<=n;i++) {
		top=0; k=i;
		for (j=1;j<=n;j++) {
			if (a[k]!=b[j]) st[++top]=k;
			k%=n; k++;
		}//printf("%d\n\n",j);
		sort(st+1,st+1+top,cmp);
		mx[top+1]=0;
		for (k=top;k;k--) mx[k]=max(mx[k+1],L[st[k]]);
		
		for (k=0;k<=top;k++) {
			//workL:
			ans=min(ans,(R[st[k]]+max((i-(n+1)+n)%n,mx[k+1]))*2-(i-(n+1)+n)%n+top);
			//workR:
			ans=min(ans,(mx[k+1]+max(((n+1)-i+n)%n,R[st[k]]))*2-((n+1)-i+n)%n+top);
		}
	}
	if (ans>=100000000) ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n;
cin >> n;
string s;
cin >> s;
int ans = 0;
for(int i=2;i<n;i++){
    if(s.at(i-2)=='A'&&s.at(i-1)=='B'&&s.at(i)=='C')ans++;
}
cout << ans << endl;

}







Measured memory_bytes: 256
#include <stdio.h>
long gcd(long,long);
int main(){
  int n;
  long a[100000],L[100001],R[100001],max=1;
  scanf("%d",&n);
  for (int i=0;i<n;i++) scanf("%d",&a[i]);
  L[0]=0;
  R[n]=0;
  for (int i=0;i<n;i++){
    L[i+1]=gcd(L[i],a[i]);
    R[n-i-1]=gcd(R[n-i],a[n-i-1]);
  }
  for (int i=0;i<n+1;i++){
    if (max<gcd(L[i],R[i+1])) max=gcd(L[i],R[i+1]);
  }
  printf("%ld\n",max);
  return 0;
}

long gcd(long x,long y){
  if (x==0) return y;
  else if (y==0) return x;
  else if (x>y) return gcd(y,x%y);
  else return gcd(x,y%x);
}


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

using namespace std;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int n, m, cnt, a[N], b[N];
int tmpx[N], tmpy[N], c1, c2;

struct node {
	int x, y;
	bool operator < (const node &T) const {
		return x == T.x ? y > T.y : x < T.x;
	}
}A[N];

struct Fenwick_Tree {
	int s[N];
	void update(int x, int y) {for(; x <= c2; x += x & -x) (s[x] += y) %= mod;}
	int query(int x) {int res = 0; for(; x; x -= x & -x) (res += s[x]) %= mod; return res;}
}T;

void Init() {
	int x; priority_queue<int, vector<int>, greater<int>> q;
	cin >> n >> m;
	for(int i = 1; i <= n; ++ i) cin >> x, q.push(x);
	for(int i = 1; i <= m; ++ i) cin >> b[i]; n = 0;
	while(!q.empty()) {
		int k = q.top(), pos = lower_bound(b + 1, b + m + 1, k) - b; q.pop();
		if(k <= b[1] || k >= b[m] || b[pos] == k) continue;
		A[++ cnt].x = b[pos] - k; A[cnt].y = k - b[pos - 1];
		tmpx[++ c1] = A[cnt].x, tmpy[++ c2] = A[cnt].y;
	}
	sort(tmpx + 1, tmpx + c1 + 1), sort(tmpy + 1, tmpy + c2 + 1);
	c1 = unique(tmpx + 1, tmpx + c1 + 1) - tmpx - 1;
	c2 = unique(tmpy + 1, tmpy + c2 + 1) - tmpy - 1;
	for(int i = 1; i <= cnt; ++ i) {
		A[i].x = lower_bound(tmpx + 1, tmpx + c1 + 1, A[i].x) - tmpx;
		A[i].y = lower_bound(tmpy + 1, tmpy + c2 + 1, A[i].y) - tmpy;
	}
	sort(A + 1, A + cnt + 1);
}

void Solve() {
	int ans = 1;
	for(int i = 1; i <= cnt; ++ i) {
		if(A[i].y == A[i - 1].y && A[i].x == A[i - 1].x) continue;
		int now = T.query(A[i].y - 1) + 1;
		(ans += now) %= mod;
		T.update(A[i].y, now);
	}
	cout << ans << endl;
}

// $$f[i] = (\sum_{j = 1}^{i - 1} f[j]) + 1$$;

int main() {

	Init();
	Solve();
	return 0;
}



Measured memory_bytes: 2680
X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print("0")
    exit()

n_right = (-X + 2 * Y) / 3
n_up = (2 * X - Y) / 3
if n_right < 0 or n_up < 0:
    print("0")
    exit()


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = 10**6
g1, g2, inverse = [1, 1], [1, 1], [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

n_right, n_up = int(n_right), int(n_up)
print(cmb(n_right + n_up, min((n_right, n_up)), mod))

Measured memory_bytes: 128456
#include<bits/stdc++.h>
 using namespace std;
 int main(){
 char x;
 cin>>x;
 if(int(x)>=65 && int(x)<=90){
    cout<<"A"<<endl;
 }
 else if(int(x)>=97 && int(x)<=122){
    cout<<"a"<<endl;
 }

 return 0;}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int32_t main() {
	aryan_pandeya();
	FIO;

	int n ;
	cin>>n;
	n==0?cout<<1:cout<<0;



	return 0;
}


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

int v[100],w[100],dp[11001];

int main(){
    int N,W,i,j,ans;
    cin>>N>>W;
    for(i=0;i<N;i++)cin>>v[i]>>w[i];
    for(i=0;i<=11000;i++)dp[i]=-1;
    dp[0]=0;
    for(i=0;i<N;i++){
        for(j=0;j<=11000;j++){
            if(dp[11000-j]!=-1&&-j+v[i]<=0){
                if(dp[11000-j+v[i]]==-1){
                    dp[11000-j+v[i]]=dp[11000-j]+w[i];
                }else{
                    dp[11000-j+v[i]]=min(dp[11000-j+v[i]],dp[11000-j]+w[i]);
                }
            }
        }
    }

    for(i=0;i<=11000;i++){
        if(dp[11000-i]!=-1&&dp[11000-i]<=W){
            cout<<11000-i<<endl;
            break;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  cin >> n;
  reps(i, 9) reps(j, 9) {
    if (n == i * j) yes();
  }
  no();
}


Measured memory_bytes: 256
n,q = map(int, input().split())
s = input()

cum_sum = [0]
sum = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        sum += 1
    cum_sum.append(sum)

for i in range(q):
    l, r = map(int, input().split())
    print(cum_sum[r-1] - cum_sum[l-1])


Measured memory_bytes: 6104
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
const LL mod=1e9+7;
int n,m;
std::vector<LL> x,y;
LL sumx,sumy;
int main(){
    std::cin>>n>>m;
    for(int i=0;i<n;i++){
        LL tmp;
        std::cin>>tmp;
        x.emplace_back(tmp);
    }
    for(int i=0;i<m;i++){
        LL tmp;
        std::cin>>tmp;
        y.emplace_back(tmp);
    }
    LL k=0;
    for(int i=1;i<(n + 1)/2;i++){
        k+=(n-1)-2*i+2;
        k%=mod;
        sumx+=k*(x[i]-x[i-1]);
        sumx+=k*(x[n-i]-x[n-i-1]);
        sumx%=mod;
    }
    if(!(n%2)){
        k+=1;
        sumx+=k*(x[n/2]-x[n/2-1]);
        sumx%=mod;
    }
    k=0;
    for(int i=1;i<(m + 1)/2;i++){
        k+=(m-1)-2*i+2;
        k%=mod;
        sumy+=k*(y[i]-y[i-1]);
        sumy+=k*(y[m-i]-y[m-i-1]);
        sumy%=mod;
    }
    if(!(m%2)){
        k+=1;
        sumy+=k*(y[m/2]-y[m/2-1]);
        sumy%=mod;
    }
    std::cout<<(sumx*sumy)%mod<<std::endl;
    return 0;
}

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

serv1 = set()
servN = set()
for _ in range(M):
    a, b = map(int, input().split())
    if a != 1 and b != N:
        continue

    if a == 1:
        serv1.add(b)
    elif b == N:
        servN.add(a)

print("POSSIBLE" if len(serv1.intersection(servN)) > 0 else "IMPOSSIBLE")


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

using namespace std;

int main()
{
    int n,ch;
    cin>>n;
    for (int i=0;i<n;i++)
    {
      cin>>ch;
      if (ch%2==0)
      if (ch%3!=0 && ch%5!=0)
      {
          cout<<"DENIED";
          return 0;
      }
    }
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args) {
        string[] v = Console.ReadLine().Split(' ');

        double x1 = double.Parse(v[0]);
        double y1 = double.Parse(v[1]);
        double x2 = double.Parse(v[2]);
        double y2 = double.Parse(v[3]);

        double p = Math.Sqrt(Math.Pow(Math.Abs(x1 - x2), 2) + Math.Pow(Math.Abs(y1 - y2), 2));
        Console.WriteLine(p);
    }
}


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

bool comp(int h1, int w1, int h2, int w2) {
	const double d1 = h1 * h1 + w1 * w1, d2 = h2 * h2 + w2 * w2;
	if(d1 != d2)
		return d1 > d2;
	else
		return h1 > h2;
}

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

	for(int h, w; cin >> h >> w, h;) {
		int ans_h = 200, ans_w = 200;
		for(int i = 1; i <= 150; ++i) {
			for(int j = i + 1; j <= 150; ++j) {
				if(comp(i, j, h, w)) {
					if(comp(ans_h, ans_w, i, j)) {
						ans_h = i;
						ans_w = j;
					}
					break;
				}
			}
		}

		cout << ans_h << " " << ans_w << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
    string tmp;
    int m, h;
    
    while(1){
        string str;
        cin >> str;
        if(str == "-") break;
        cin >> m;
        for(int i=0;i<m;i++) {
            cin >> h;
            str = str.substr(h) + str.substr(0,h);
        }
        cout << str << endl;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, int>;

struct UnionFind {
    vector<int> d;
    // コンストラクタ　親は-頂点数を保管
    UnionFind(int N) : d(N, -1) {}

    int find(int x) {
        if (d[x] < 0) {
            return x;
        }
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        }
        if (d[x] > d[y]) {
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -d[find(x)];
    }
};

struct Edge{
    int a, b;
    ll cost;
    Edge(int a_, int b_, ll cost_){
        a = a_; b = b_; cost = cost_;
    }
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};

int main() {
    int n;
    cin >> n;
    vector<P> x, y;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        x.push_back(make_pair(a, i));
        y.push_back(make_pair(b, i));
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<Edge> es;
    rep(i, n-1){
        Edge ex(x[i].second, x[i+1].second, x[i+1].first-x[i].first);
        Edge ey(y[i].second, y[i+1].second, y[i+1].first-y[i].first);
        es.push_back(ex);
        es.push_back(ey);
    }
    sort(es.begin(), es.end());

    ll ans = 0;
    UnionFind uf(n);
    for(Edge e : es){
        if(!uf.same(e.a, e.b)){
            ans += e.cost;
            uf.unite(e.a, e.b);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9572
import itertools
N, M = map(int, input().split())

I = [set() for _ in range(N)]
seq = [i for i in range(1,N)]

for _ in range(M):
  a, b = map(int, input().split())
  I[a-1].add(b-1)
  I[b-1].add(a-1)

ans = 0
for p in itertools.permutations(seq):
  flag = True
  for i in range(N-2):
    #print(p,i)
    if p[i+1] not in I[p[i]]:
      flag = False 
      break
  if 0 not in I[p[-1]]:#0を終点とする
    flag = False 
  if flag:
    ans += 1
#print(I)    
print(ans)
    

Measured memory_bytes: 70996
n, l = [int(i) for i in input().split()]

s = n * (l - 1) + n * (n + 1) // 2

if (0 < l):
    print(s - l)
elif (l+n-1 < 0):
    print(s- (l + n - 1))
else:
    print(s)


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = 25 - int.Parse(Console.ReadLine());
            string str = "Christmas";

            for (int i = 0; i < A; i++)
                str += " Eve";

            Console.WriteLine(str);
            Console.ReadKey();
        }
    }
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;

    if (N == 1) {
        cout << 0 << "\n";
        return;
    }

    unordered_map<ll, ll> factors;
    for (ll i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            ++factors[i];
            N /= i;
        }
    }
    if (N > 1) ++factors[N];

    ll ans = 0;
    for (const auto& [p, e] : factors) {
        ll cur = 1;
        ll e_tmp = e;
        while (e_tmp > 0) {
            e_tmp -= cur;
            if (e_tmp >= 0) {
                ++ans;
            }
            ++cur;
        }
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3656
import math
n,d = map(int,input().split())
listx = []
for i in range(n):
    a = [int(x) for x in input().split()]
    listx.append(a)
count = 0
for i in range(n):
    for j in range(i+1,n):
        s = 0
        for k in range(d):
            s = s + (listx[i][k] - listx[j][k])**2
        sr = math.sqrt(s)
        if math.ceil(sr) == sr:
            count += 1
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>

int main() {
  double r;
  std::cin >> r;
  double area = r * r * M_PI;
  double circumference = 2.0 * r * M_PI;
  std::cout << std::fixed << std::setprecision(6) << area << " " << circumference << std::endl;
}

Measured memory_bytes: 3252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 2e3 + 10;
int N; ll X;
ll A[MAXN];
ll B[MAXN][MAXN];
ll ans = 1ll << 60;

int main() {
	register int i, j;
	scanf("%d%lld", &N, &X);
	for(i = 1; i <= N; ++i)
		scanf("%lld", A + i);
	for(i = 1; i <= N; ++i) {
		B[i][0] = A[i];
		for(j = 1; j < N; ++j) {
			int pos = i - j;
			if(pos <= 0) pos = N - abs(pos);
			B[i][j] = min(B[i][j - 1], A[pos]);
		}
	}
	for(j = 0; j < N; ++j) {
		ll res = 0;
		for(i = 1; i <= N; ++i)
			res += B[i][j];
		ans = min(ans, res + X * j);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int main() {
    ld a, b;
    cin >> a >> b;
    cout << a / b << endl;

}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int mi = inf, ma = 0;
    rep(i, N) {
        mi = min(mi, a[i]);
        ma = max(ma, a[i]);
    }
    cout << ma - mi << endl;
    return 0;
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string c){
    cout << char(c[0] + 1) << endl;
}


signed main(){
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, m, x; cin >> n >> m >> x;
  Vll c(n);
  VVll a(n, Vll(m));
  rep(i, n) {
    cin >> c[i] >> a[i];
  }

  ll ans = INFll;
  rep(i, 1<<n) {
    bool ok = true;
    rep(j, m) {
      ll sum = 0;
      rep(k, n) {
        if ((i>>k)&1) sum += a[k][j];
      }
      if (sum < x) ok = false;
    }
    if (ok) {
      ll z = 0;
      rep(k, n) if ((i>>k)&1) z += c[k];
      chmin(ans, z);
    }
  }

  cout << (ans < INFll ? ans : -1) << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(){
int a=1; 
int n=1;
 while(0 < a || 0 < n){scanf("%d%d",&a,&n);
   if(a ==0 && n == 0);
   else if(a > n)printf("%d %d\n",n,a);
   else if(a < n)printf("%d %d\n",a,n);
   else if(a == n)printf("%d %d\n",n,a);}
  return 0;
}
  

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<ll> a(n);
    bool iszero = false;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] == 0)   iszero = true;
        if(a[i] < 0)    ++cnt;
    }
    ll ans = 0;
    if(iszero){
        for(int i = 0; i < n; ++i)  ans += abs(a[i]);
    }
    else{
        for(int i = 0; i < n; ++i)  a[i] = abs(a[i]);
        sort(a.begin(), a.end());
        ans = accumulate(a.begin(), a.end(), 0ll);
        if(cnt % 2 != 0)    ans -= 2 * a[0];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int):
    print((X - Z) // (Y + Z))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    solve(X, Y, Z)


if __name__ == '__main__':
    main()


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

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let mut n = read::<usize>();
    let mut m = n;
    while m % 10 == 0 {
        m /= 10;
    }
    let mut ans = 0;
    if m == 1 {
        ans = 10;
    } else {
        while n > 0 {
            ans += n % 10;
            n /= 10;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
X,N=map(int,input().split())
p=list(map(int,input().split()))


pp=[abs(i-X) for i in p]
ans=0
if 0 not in pp:
    print(X)
else:
    for a in range(1,X+1):
        if pp.count(a)>=2:
            continue
        else:
            ans=a
            break
    
    if X-ans in p:
        print(X+ans)
    else:
        print(X-ans)

Measured memory_bytes: 9140
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

count = 0
for i in range(len(B)):
    n = min(A[i], B[i])
    B[i] -= n
    count += n
    n = min(A[i + 1], B[i])
    A[i + 1] -= n
    count += n

print(count)


Measured memory_bytes: 18624
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i,n){
        ll a;
        cin >> a;
        q.push(a);
    }
    rep(i,m){
        ll b = q.top(); q.pop();
        q.push(b/2);
    }
    ll ans = 0;
    rep(i, n){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

a,b,c,d=MI()
print(max(min(b,d)-max(a,c),0))


Measured memory_bytes: 3316
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    int A, B, C;
    if (scanf("%d%d%d", &A, &B, &C) < 3) return 0;

    printf("%s\n", C <= A + B ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll h[n];
	ll sum=0,cnt=0;
	ll a,b;
	ll s[n];
	if(k>=n)
	{
		cout<<"0"<<endl;
		//system("pause");
		return 0;
	}
	REP(i,n)
	{
		cin>>h[i];
		sum+=h[i];
	}
	sort(h,h+n);
	if(k==0)
	{
		cout<<sum<<endl;
		//system("pause");
		return 0;
	} 
	REP(i,n-k)
	{
		cnt+=h[i];
	}
	cout<<cnt<<endl;
	//system("pause");
	return 0;	
} 

Measured memory_bytes: 1792
W, H, x ,y =  map(int,input().split())
half_area = float(W*H)/2.0
if (W % 2 == 0) and (H % 2 == 0) and (x == int(float(W*0.5)) ) and (y == int(float(H*0.5)) ):
  num = 1
else:
  num = 0
print('{:.6f}'.format(half_area)+" "+ str(num))

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/

int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}

int main() {
  vector<int> arr(3);
  rep(i, 3) cin >> arr[i];
  sort(arr.begin(), arr.end());
  cout << arr[2] * 10 + arr[0] + arr[1] << endl;
}


Measured memory_bytes: 256