akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int main(){
	int h,w,K;
	cin >> h >> w >> K;
	char c[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> c[i][j];
		}
	}
	
	/*
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << c[i][j];
		}
		cout << endl;
	}
	*/
	
	vector<vector<int>> hs(1<<h);
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<h;j++){
			if(i&(1<<j)){
				hs[i].push_back(1);
			}else{
				hs[i].push_back(0);
			}
		}
	}
	
	/*
	for(int i=0;i<hs.size();i++){
		for(int j=0;j<hs[i].size();j++){
			cout << hs[i][j];
		}
		cout << endl;
	}
	*/
	
	vector<vector<int>> ws(1<<w);
	for(int i=0;i<(1<<w);i++){
		for(int j=0;j<w;j++){
			if(i&(1<<j)){
				ws[i].push_back(1);
			}else{
				ws[i].push_back(0);
			}
		}
	}
	
	/*
	for(int i=0;i<ws.size();i++){
		for(int j=0;j<ws[i].size();j++){
			cout << ws[i][j];
		}
		cout << endl;
	}
	*/
	
	
	
	/*
	for(int i=0;i<ws.size();i++){
		for(int j=0;j<ws[i].size();j++){
			cout << ws[i][j];
		}
		cout << endl;
	}
	*/
	
	/*
	int ans=0;
	for(int i=0;i<hs.size();i++){
		for(int j=0;j<hs[i].size();j++){
			for(int k=0;k<ws.size();k++){
				for(int l=0;l<ws[k].size();l++){
					int cnt=0;
					
					for(int x=0;x<h;x++){
						if(hs[i][x]==0)continue;
						for(int y=0;y<w;y++){
							if(ws[k][y]==0)continue;
							if(c[x][y]=='#')cnt++;
						}
					}
					
					if(cnt==K)ans++;
				}
			}
		}
	}
	cout << ans << endl;		
	*/
	
	
	
	int ans=0;
	for(int i=0;i<hs.size();i++){
		for(int k=0;k<ws.size();k++){
			int cnt=0;
			for(int x=0;x<h;x++){
				if(hs[i][x]==0)continue;
				for(int y=0;y<w;y++){
					if(ws[k][y]==0)continue;
					if(c[x][y]=='#')cnt++;
				}
			}
			if(cnt==K)ans++;
		}
	}

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


Measured memory_bytes: 3636
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let a: i32 = scan.next();

    writeln!(out, "{}", (a + (a * a) + (a * a * a)));
}

Measured memory_bytes: 2188
//abc128_c.cpp
//Sun May 26 20:47:26 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n >> m;
	int s[m][n];
	for (int i=0;i<m;i++){
		int temp;
		cin >> temp;
		for (int j=0;j<n;j++){
			s[i][j] = 0;
		}
		for (int j=0;j<temp;j++){
			int y;
			cin >> y;
			y--;
			s[i][y]=1;
		}
	}

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

	int ans = 0;
	for (int S=0;S<1<<n;S++){
		int temp[n];
		fill(temp,temp+n,0);
		int flag = 0;
		for (int i=0;i<m;i++){
			int num = 0;
			for (int j=0;j<n;j++){
				if (s[i][j]==1 && S&1<<j){
					num++;
				}
			}
			if (num%2!=p[i]){
				flag = 1;
				break;
			}
		}
		if (flag == 0){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nmx = readInts()
    let (n, m, x) = (nmx[0], nmx[1], nmx[2])
    /// 金額の配列
    var aryCost = [Int]()
    /// 理解度の多次元配列
    var tableUnst = [[Int]]()
    
    for _ in 0..<n {
        let ca = readInts()
        aryCost.append(ca[0])
        tableUnst.append(Array(ca[1...m]))
    }
    //________________________________________ここまで入力
    
    var ans = Int.max
    // bit全探索で解を求める
    for bit in 0..<(1<<n) {
        var res = 0
        var aryUnst = [Int](repeating: 0, count: m)
        
        for i in 0..<n {
            if bit >> i & 1 == 1 {
                res += aryCost[i]
                
                
                for j in 0..<m {
                    aryUnst[j] += tableUnst[i][j]
                }
            }
        }
        if aryUnst.min()! >= x {
            ans = min(res, ans)
        }
    }
    print(ans == Int.max ? -1: ans)
}
main()


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

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

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int K;
  cin >> K;
  int x = 7;
  int ans = 1;
  while(K > x){
    x *= 10;
    x += 7;
    ans++;
  }
  int N = K;
  while(N--){
    if(x % K == 0){
      cout << ans << endl;
      return 0;
    }
    x *= 10;
    x += 7;
    x %= K;
    ans++;
  }
  cout << -1 << endl;
  return 0;
}


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

int main(){
	string op;
	ll a,b;
	cin >> a >> op >> b;
	if(op=="+"){
		cout << a+b << endl;
	}else{
		cout << a-b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys


def solv(s):
    for i in range(10):
        i = str(i)
        s2 = s.replace('X', i)
        left, right = s2.split('=')
        l1, l2 = left.split('+')
        if any([x[0] == '0' and len(x) > 1 for x in [l1, l2, right]]):
            continue
        if int(l1) + int(l2) == int(right):
            return i
    else:
        return 'NA'


for line in sys.stdin:
    print solv(line.rstrip('\n'))

Measured memory_bytes: 4272
a=input()
b=input()
c=input()

#l=a+b+c

#n=a[0]
#a=a.lstrip(n)
n='a'
while True: 
    if n=='a':
        if len(a)==0:
            print('A')
            exit()
            
        n=a[0]
        #a=a.lstrip(n)
        a=a[1:]
        
    elif n=='b':
        if len(b)==0:
            print('B')
            exit()
            
        n=b[0]
        #b=b.lstrip(n)
        b=b[1:]
        
    else:
        if len(c)==0:
            print('C')
            exit()
            
        n=c[0]
        #c=c.lstrip(n)
        c=c[1:]



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());

  if (S < T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

const int maxn = 1e5 + 10;

int n, m, a, b, c, d, l, r, s;
int bio[maxn];
vector <int> v[maxn];
deque <int> q;

int main(){
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	l = 1;
	r = 1;
	bio[1] = 1;
	q.push_back(1);
	
	while(!c || !d){
		int f;
		
		if(!c){
			f = 0;
		
			for(int i = 0; i < v[l].size(); i++){
				int sus = v[l][i];
				
				if(!bio[sus]){
					bio[sus] = 1;
					l = sus;
					q.push_front(sus);
					f = 1;
					break;
				}
			}
			
			if(!f) c = 1;
		}
		
		if(!d){
			f = 0;
		
			for(int i = 0; i < v[r].size(); i++){
				int sus = v[r][i];
				
				if(!bio[sus]){
					bio[sus] = 1;
					r = sus;
					q.push_back(sus);
					f = 1;
					break;
				}
			}
			
			if(!f) d = 1;
		}
	}
	
	cout << q.size() << "\n";
	
	while(!q.empty()){
		cout << q.front() << ' ';
		q.pop_front();
	}
	
	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  int t = 0;
  int x = 0;
  int y = 0;
  R(i,n){
    int t2,x2,y2;
    cin >> t2 >> x2 >> y2;
    int td = t2 - t;
    int od = abs(x - x2) + abs(y - y2);
    if(td < od || (td + od) % 2){
      cout << "No\n";
      return 0;
    }
    t = t2;
    x = x2;
    y = y2;
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
import collections as col
 
s = list(input())
t = list(input())
 
c1 = col.Counter(s)
c2 = col.Counter(t)
 
cv1 = sorted(c1.values())
cv2 = sorted(c2.values())
 
if cv1 == cv2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 70220
import std.stdio;
import std.algorithm;

void main()
{
  int N, K;
  readf("%d %d", &N, &K);

  int ans = int.max;
  foreach (i; 0 .. (N+1))
    ans = min(ans, 2^^i - i*K + N*K);

  writeln(ans);
}


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

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

#define ll long long
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

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

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;


ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}



ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}



ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

//const long sz=1e6+10;
int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        ll a,b,c;
        cin>>a>>b>>c;

        cout<<max(0ll,(c-(a-b)));
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
using ll = long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    int n;
    cin >> n;
    int ab=0;
    int a=0;
    int b_a=0;
    int b=0;
    bool h=false;
    for(int i=0;i<n;i++){
        string s;cin >> s;
        if(s[0]=='B'){
            b++;
        }
        if(s[s.size()-1]=='A'){
            a++;
        }
        if(s[0]=='B'&&s[s.size()-1]=='A'){
            a--;b--;b_a++;
        }
        for(int j=0;j<s.size();j++){
            if(s[j]=='A'){
                if(s[j+1]=='B'){
                    ab++;
                }
            }
        }
    }
    if(b_a==0){
        cout<<ab+min(a,b)<<endl;
    }else{
        if(a+b>0){
            cout<<ab+b_a+min(a,b)<<endl;
        }else{
            cout<<ab+b_a-1<<endl;
        }
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> fact;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			fact.push_back(i);
			fact.push_back(n / i);
		}
	}
	ll m   = fact.size();
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		ll di = n / fact[i] - 1;
		if (fact[i] < di) ans += di;
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    int join, cost;
    int pay;
    int get_pay = 0;
    
    while(1){
        cin>>join>>cost;
        
        if(join == 0 && cost == 0)break;
        
        else{
            int ave_cos = cost/join;
            
            for(int i=0;i<join;i++){
                cin>>pay;
                if(pay>=ave_cos) get_pay += ave_cos;
                else if(pay < ave_cos) get_pay += pay;
            }
            
            cout<<get_pay<<endl;
        }
        
        get_pay = 0;
    }
    
    return 0;
}


Measured memory_bytes: 2996
n,q=map(int,input().split())
s=input()
l=[0]*q
r=[0]*q
c=[0]*n
ans=0
for i in range(q):
    l[i],r[i]=map(int,input().split())
if s[0]=='A' and s[1]=='C':
    c[0]=1
for i in range(1,n-1):
    if s[i]=='A' and s[i+1]=='C':
        c[i]=c[i-1]+1
    else:
        c[i]=c[i-1]
for i in range(q):
    print(c[r[i]-2]-c[l[i]-2])

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

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()å
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

 
signed main(){
 
    int n,a,b,c,d,e;
     cin >>n>>a>>b>>c>>d>>e;

    int ans = min({a,b,c,d,e});
    if(n%ans==0){
        ans = n/ans;
    }
    else{
        ans = n/ans+1;
    }
    cout <<ans+4<<endl;
    return 0;

}


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

int main (void) {
    int N, A, B;
    cin >> N >> A >> B;
    vector<char> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    
    int pass_num = 0, pass_num_f = 0;
    for (auto s : S) {
        bool ans;
        if (s == 'c') {
            ans = false;
        } else if (s == 'a' && pass_num < A + B) {
            ans = true;
            pass_num ++;
        } else if (s == 'b' && pass_num < A + B && pass_num_f < B) {
            ans = true;
            pass_num++;
            pass_num_f++;
        } else {
            ans = false;
        }
        
        cout << (ans ? "Yes": "No") << endl;
    }
    
}

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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
using ll  = long long;
using vi  = vector<ll>;
constexpr ll inf = 1ll<<62;

int main(){
#define int ll
  int n; cin >> n;
  vi a(n+1);
  vi f(n+1,-1),g(n+1,-1);
  rep(i,n){
    cin >> a[i+1];
    a[i+1] += a[i];
  }
  int j = 1;
  FOR(i,2,n-1){
    while(j < i-1 and a[i]/2 > a[j+1]) j++;
    if(abs(a[i]-a[j]*2) > abs(a[i]-a[j+1]*2)) j++;
    f[i] = j;
  }
  j = n-1;
  ROF(i,n-1,2){
    while(j > i+1 and (a[n]-a[i])/2 > (a[n]-a[j-1])) j--;
    if(abs(a[n]+a[i]-a[j]*2) > abs(a[n]+a[i]-a[j-1]*2)) j--;
    g[i] = j;
  }

  int ans = inf;
  rep(i,n+1)
    if(f[i] != -1){
      int maxv = max({ a[f[i]], a[i]-a[f[i]], a[g[i]]-a[i], a[n]-a[g[i]] });
      int minv = min({ a[f[i]], a[i]-a[f[i]], a[g[i]]-a[i], a[n]-a[g[i]] });
      ans = min(ans, abs(maxv-minv));
    }
  cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
s = (input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ls = ["+","-"]
ans = a+b+c+d
if ans == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a+b+c-d
if ans == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a+b-c+d
if ans == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a-b+c+d
if ans == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a-b-c+d
if ans == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a+b-c-d
if ans == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a-b+c-d
if ans == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a-b-c-d
if ans == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    sys.exit()

Measured memory_bytes: 3188
//													\[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 1000000
#define xx first
#define yy second

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

const ll INF = 1e11L;
int main()
{

	int n, W;
	cin >> n >> W;

	vector<pll> a(n);

	ll SUM = 0;
	fr(i,0,n)
	{
		ll x, y;
		cin >> x >> y;
		SUM += y;
		a[i] = mp(x, y);
	}

	vl dp(1e5+1, INF);
	dp[0] = 0;
	fr(i,0,n)
	{
		for(int j = SUM - a[i].yy; j >= 0; j--)
		{
			dp[j+a[i].yy] = min(dp[j+a[i].yy], dp[j] + a[i].xx);
		}
	}

	// fr(i,0,1e5+1)
	// 	cout << dp[i] << " ";
	// cout << "\n";

	ll answer = 0;
	fr(i,0,1e5+1)
	{
		if(dp[i] <= W)
			answer = max(answer, (ll)i);
	}

	cout << answer;

}



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

using namespace std;

class Router;

class Router
{
    public:

    enum TYPE{
        ADD,
        MUL,
    };

    Router(int level, TYPE type){
        level--;

        if(level>0){
            route[0] = new Router(level, ADD);
            route[1] = new Router(level, MUL);

            last = false;
        }
        else{
            route[0] = NULL;
            route[1] = NULL;

            last = true;
        }

        if(type==ADD){
            calc = add;
        }
        else if(type==MUL){
            calc = mul;
        }
    }

    void run(int A, int K, vector<int>& res)
    {
        int ans = calc(A, K);

        if(last){
            res.push_back(ans);
        }
        else{
            route[0]->run(ans, K, res);
            route[1]->run(ans, K, res);
        }
    }

    private:

    bool last;

    Router* route[2];

    int (*calc)(int, int);

    static int add(int A, int K){
        return A + K;
    }

    static int mul(int A, int K){
        return A * 2;
    }
};

class Top
{
    public:
    Top(int level)
    {
        route[0] = new Router(level, Router::ADD);
        route[1] = new Router(level, Router::MUL);
    }

    void search(int A, int K, vector<int> &res)
    {
        route[0]->run(A, K, res);
        route[1]->run(A, K, res);
    }

    private:
    Router* route[2];
};


int main()
{
    int N, K;

    cin >> N >> K;

    Top top(N);

    vector<int> results;

    top.search(1, K, results);

    int min = results[0];
    for(vector<int>::iterator it=results.begin(); 
        it!=results.end();
         ++it)
    {
        if(min > *it){
            min = *it;
        }
    }

    cout << min << endl;

    return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vl red(a),green(b),extra(c);
	for(ll i=0;i<a;i++)
		cin >> red[i];

	for(ll i=0;i<b;i++)
		cin >> green[i];

	for(ll i=0;i<c;i++)
		cin >> extra[i];

	sort(red.rbegin(),red.rend());
	sort(green.rbegin(),green.rend());

	priority_queue<ll,vl,greater<ll> > pq;

	for(ll i=0;i<x;i++)
		pq.push(red[i]);

	for(ll i=0;i<y;i++)
		pq.push(green[i]);

	for(ll i=0;i<c;i++){
		if(pq.top() < extra[i]){
			pq.pop();
			pq.push(extra[i]);
		}
	}

	ll ans=0;
	while(pq.size()){
		ans+=pq.top();
		pq.pop();
	}

	cout << ans;
	return;
}

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

	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;

int main()
{
    int d, g;
    cin >> d >> g;
    int *p = new int[d];
    int *c = new int[d];

    for (size_t i = 0; i < d; i++)
    {
        cin >> p[i] >> c[i];
    }

    int max_score = 0, min_num = 10000, max_bits = 0;
    for (int bits = 0; bits < 1 << d; bits++)
    {
        int score = 0, num = 0;
        for (int i = 0; i < d; i++)
        {
            if ((bits >> i) & 1)
            {
                score += p[i] * 100 * (i + 1) + c[i];
                num += p[i];
            }
        }

        int index = d - 1;
        while (index >= 0 && (bits >> index) & 1) index--;

        for (int i = 0; score < g && i < p[index]; i++)
        {
            score += (index + 1) * 100;
            num++;
        }
        
        if (score >= g && num < min_num) min_num = num;
    }
 
    cout << min_num << endl;
    return 0;    
}

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

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
}

inline void sub(int &x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
}

inline int mul(int x, int y) {
  return (int) ((long long) x * y % md);
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  string s;
  cin >> n >> m >> s;
  if (s[0] == 'B') {
    for (auto &c : s) {
      c ^= 'R' ^ 'B';
    }
  }
  int first = m;
  for (int i = 0; i < m; ++i) {
    if (s[i] == 'B') {
      first = i;
      break;
    }
  }
  if (first == m) {
    vector<int> dp(4);
    dp[0] = dp[3] = 1;
    for (int i = 1; i < n; ++i) {
      vector<int> new_dp(4);
      for (int a = 0; a < 2; ++a) {
        for (int b = 0; b < 2; ++b) {
          for (int c = 0; c < 2; ++c) {
            if (!b || !c) {
              add(new_dp[a * 2 + b], dp[a * 2 + c]);
            }
          }
        }
      }
      swap(dp, new_dp);
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
      add(ans, dp[i]);
    }
    cout << ans << "\n";
    return 0;
  }
  int last = m - 1;
  while (s[last] == 'R') {
    --last;
  }
  int limit = n, cur = 0;
  for (int i = last; i >= -1; --i) {
    if (i == -1 || s[i] == 'B') {
      if (cur) {
        if (cur & 1) {
          limit = min(limit, cur + 1);
        } else if (i == -1) {
          limit = min(limit, cur + 2);
        }
        cur = 0;
      }
    } else {
      ++cur;
    }
  }
  vector<int> dp(n + 1);
  dp[0] = dp[2] = 1;
  for (int i = 4; i <= n; ++i) {
    dp[i] = mul(dp[i - 2], 2);
    if (i >= limit + 2) {
      sub(dp[i], dp[i - (limit + 2)]);
    }
  }
  int ans = 0;
  for (int i = 2; i <= limit; i += 2) {
    add(ans, mul(dp[n - i], i));
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1360
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int t,n,m,a,b;
int vis[10010];
int main(){
	int i,j;
	scanf("%d%d%d",&n,&a,&b);
	memset(vis,0,sizeof(vis));
	long long ans=0;
	for(i=1;i<=n;i++){
		int temp=i;
		t=0;
		while(temp){
			t+=temp%10;
			temp/=10;
		}
		if(t>=a&&t<=b)
			ans+=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
char a[20000],b[20000];
int ans;
int main(){
    cin>>a;
    cin>>b;
    for(int i=0;i<3;i++)
        if(a[i]==b[i]) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define maxn 200005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, sum[maxn * 44], rt, a[maxn], cnt, L = -200000, R = (1e9) + 200000, ls[maxn * 44], rs[maxn * 44];
il void insert(int &k, int l, int r, int ll) {
	if(!k) k = ++ cnt; ++ sum[k];
	if(l == r) return;
	int mid = (l + r) >> 1;
	if(ll <= mid) insert(ls[k], l, mid, ll);
	else insert(rs[k], mid + 1, r, ll);
}
il int query(int k, int l, int r, int ll) {
	if(l == r) return sum[k];
	int mid = (l + r) >> 1;
	if(ll <= mid) return query(ls[k], l, mid, ll);
	else return query(rs[k], mid + 1, r, ll);
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) {
		m += query(1, L, R, i - a[i]);
		insert(rt, L, R, i + a[i]);
	}
	cout << m;
	return 0;
}


Measured memory_bytes: 45980
#include<stdio.h>

int main(void){

	int n;
	int a[3000];
	int i;
	int f_crnt;
	int m_max;

	m_max = 2;

	f_crnt = 0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		f_crnt += a[i];
	}
	f_crnt -= n;

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

}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
    static long n = long.Parse(Console.ReadLine());
    static long count = 0L;
    static void Main(string[] args) {
        dfs(0, false, false, false);
        Console.WriteLine(count);
    }
    static void dfs(long x, bool t, bool f, bool s) {
        if(x>n) return;
        if(t&&f&&s) count ++;
        dfs(x*10+3, true, f, s);
        dfs(x*10+5, t, true, s);
        dfs(x*10+7, t, f, true);
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
#define MAX 100
int main()
{
    int N,K;
    int x[MAX];
    cin>>N>>K;
    int sum=0;
    for(int i=0;i<N;i++)
    {
        cin>>x[i];
        if (x[i]<=K-x[i])
            sum+=x[i];
        else
            sum+=(K-x[i]);
    }
    sum*=2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc020/tasks/agc020_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, z1 = 0, z2 = 0;
    cin >> n;
    string s;
    cin >> s;
    REP(i, n) {
        if (s[i] == '(') {
            z1++;
        } else {
            if (z1 > 0) {
                z1--;
            }
        }
    }
    REPR(i, n) {
        if (s[i] == ')') {
            z2++;
        } else {
            if (z2 > 0) {
                z2--;
            }
        }
    }
    REP(i, z2) cout << '(';
    cout << s;
    REP(i, z1) cout << ')';
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int count = 0;
    for(int i = a; i <= b; i++){
        if(i / 10000 == i % 10){
            if( (i % 10000) / 1000 == ((i - i % 10) / 10) % 10){
                count++;
            }
        }
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		
		for(int b = -127; b < 127; b++) {
			for(int a = b + 1; a < 127; a++) {
				
				if(Math.pow(a, 5) - Math.pow(b, 5) == X) {
					System.out.println(a + " " + b);
					return;
				}
			}
		}
    }
}


Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  long double r;
  cin >> r;
  printf("%.10Lf\n", r * 2.0 * 3.14159265359);
}

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

long long mod = 1000000007;

long long modpow(long long a, long long b, long long m) {
	long long r = 1;
	for (int i = 0; i < b; i++) { r *= a; r %= m; }
	return r;
}

long long modpow2(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2LL == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long solve(long long A) {
	if (A <= 4) return 0LL;

	if (A % 2LL == 1LL) {
		long long N = (A - 5LL) / 2LL;
		long long r1 = N + 2;
		long long r2 = N + 3;
		long long r3 = N + 4;
		long long r4 = N + 5;
		long long r5 = 0;
		r5 += modpow(N, 11LL, mod) * 128LL; r5 %= mod;
		r5 += modpow(N, 10LL, mod) * 8288LL; r5 %= mod;
		r5 += modpow(N, 9LL, mod) * 236640LL; r5 %= mod;
		r5 += modpow(N, 8LL, mod) * 3913980LL; r5 %= mod;
		r5 += modpow(N, 7LL, mod) * 41410404LL; r5 %= mod;
		r5 += modpow(N, 6LL, mod) * 291875409LL; r5 %= mod;
		r5 += modpow(N, 5LL, mod) * (1383099625LL % mod); r5 %= mod;
		r5 += modpow(N, 4LL, mod) * (4339493095LL % mod); r5 %= mod;
		r5 += modpow(N, 3LL, mod) * (8647376943LL % mod); r5 %= mod;
		r5 += modpow(N, 2LL, mod) * (10121451228LL % mod); r5 %= mod;
		r5 += modpow(N, 1LL, mod) * (6046779060LL % mod); r5 %= mod;
		r5 += modpow(A, 0LL, mod) * (1362160800LL % mod); r5 %= mod;
		long long r6 = modpow2(163459296000LL % mod, mod - 2, mod);

		long long ans = r1 * r2 % mod * r3 % mod * r4 % mod * r5 % mod * r6 % mod;
		return ans;
	}
	else {
		long long N = (A - 6LL) / 2LL;
		long long r1 = N + 2;
		long long r2 = N + 3;
		long long r3 = N + 4;
		long long r4 = N + 5;
		long long r5 = 0;
		r5 += modpow(N, 11LL, mod) * 128LL; r5 %= mod;
		r5 += modpow(N, 10LL, mod) * 9248LL; r5 %= mod;
		r5 += modpow(N, 9LL, mod) * 297120LL; r5 %= mod;
		r5 += modpow(N, 8LL, mod) * 5587140LL; r5 %= mod;
		r5 += modpow(N, 7LL, mod) * 68078724LL; r5 %= mod;
		r5 += modpow(N, 6LL, mod) * 561796179LL; r5 %= mod;
		r5 += modpow(N, 5LL, mod) * (3184474795LL % mod); r5 %= mod;
		r5 += modpow(N, 4LL, mod) * (12299108485LL % mod); r5 %= mod;
		r5 += modpow(N, 3LL, mod) * (31370183973LL % mod); r5 %= mod;
		r5 += modpow(N, 2LL, mod) * (49565868948LL % mod); r5 %= mod;
		r5 += modpow(N, 1LL, mod) * (42793104060LL % mod); r5 %= mod;
		r5 += modpow(A, 0LL, mod) * (14983768800LL % mod); r5 %= mod;
		long long r6 = modpow2(163459296000LL % mod, mod - 2, mod);

		long long ans = r1 * r2 % mod * r3 % mod * r4 % mod * r5 % mod * r6 % mod;
		return ans;
	}
}

int main() {
	int T; cin >> T;
	for (int i = 1; i <= T; i++) {
		long long N; cin >> N;
		cout << solve(N) << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
using namespace std;
int ans;
int n;
int p[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",p+i);
	}
	for(int i=1;i<=n;)
	{
		int pr=i;
		while(i<=n && i==p[i])i++;
		ans+=(i-pr+1)/2;
		i++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	var max int
	for _, e := range []int{a, b, c} {
		if e > max {
			max = e
		}
	}

	x := max
	if max%2 != (a+b+c)%2 {
		x = max + 1
	}

	ans := (3*x - (a + b + c)) / 2

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m,r;
    cin>>n>>m>>r;
    int town[r];
    for(int i=0;i<r;i++){
        cin>>town[i];
        town[i]--;
    }
    int a,b,c;
    int d[n][n] = {};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if (i!=j) d[i][j] = 1e9;
    }
    for(int i=0;i<m;i++) {
        cin>>a>>b>>c;
        d[a-1][b-1]=c;
        d[b-1][a-1]=c;
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }

    int ans = 1e9;
    sort(town,town+r);
    while(next_permutation(town,town+r)){
        int tmp = 0;
        for(int i=0;i<r-1;i++){
            tmp += d[town[i]][town[i+1]];
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  vector<int> line(5);
  for(int i = 0; i < 5; i++) {
    cin >> line.at(i);
    if (line.at(i) == 0) {
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(double x = 0,double y = 0) : x(x), y(y) {}

  Point operator + (const Point &p)const{
    return Point(x + p.x , y + p.y);
  }

  Point operator - (const Point &p)const{
    return Point(x - p.x , y - p.y);
  }

  Point operator * (const double &k)const{
    return Point(x * k , y * k);
  }

  Point operator / (const double &k)const{
    return Point(x / k , y / k);
  }

  bool operator < (const Point &p)const{
    if(x != p.x) return x < p.x;
    else return y < p.y;
  }

  double dot(const Point &p)const{
    return x*p.x + y*p.y;
  }

  double cross(const Point &p)const{
    return x*p.y - p.x*y;
  }

  double dist(const Point &p)const{
    return sqrt(pow(x-p.x,2) + pow(y-p.y,2));
  }

  double norm(){
    return x*x + y*y;
  }

  double Abs(){
    return sqrt(norm());
  }
};

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(a.cross(b) > EPS){
    return COUNTER_CLOCKWISE;
  }else if(a.cross(b) < -EPS){
    return CLOCKWISE;
  }else if(a.dot(b) < -EPS){
    return ONLINE_BACK;
  }else if(a.norm() < b.norm()){
    return ONLINE_FRONT;
  }else{
    return ON_SEGMENT;
  }
}

struct Line{
  Vector s,t;
 
  Line(){}
  Line(Vector s, Vector t) : s(s), t(t) {}

  bool isOrthogonal(Line &l){
    Vector a = t - s;
    Vector b = l.t - l.s;
    if(equal(a.dot(b),0.0)){
      return true;
    }else{
      return false;
    }
  }

  bool isParallel(Line &l){
    Vector a = t - s;
    Vector b = l.t - l.s;
    if(equal(a.cross(b),0.0)){ 
      return true; 
    }else{
      return false;
    }
  }

  Point Projection(Point &p){
    Vector u = t - s;
    double v = u.dot(p - s) / u.norm();
    return s + u * v;
  }

  Point CrossPoint(Line &l){
    Vector v = l.t - l.s;
    double a = abs(v.cross(s-l.s));
    double b = abs(v.cross(t-l.s));
    double c = a / (a + b);
    return s + (t - s) * c;
  }

  Point Reflection(Point &p){
    return p + (Projection(p) - p) * 2.0;
  }

  bool isIntersect(Point p0,Point p1,Point p2,Point p3){
    return (ccw(p0,p1,p2)*ccw(p0,p1,p3) <= 0 &&
            ccw(p2,p3,p0)*ccw(p2,p3,p1) <= 0);
  }
  
  bool isIntersect(Line &l){
    return isIntersect(s,t,l.s,l.t);
  }
};

int main(){
  int Q;
  cin >> Q;
  while(Q--){
    Line s1,s2;
    cin >> s1.s.x >> s1.s.y >> s1.t.x >> s1.t.y;
    cin >> s2.s.x >> s2.s.y >> s2.t.x >> s2.t.y;
    cout << s1.isIntersect(s2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

#include<string.h>


int main(void){


    int sum;


    int i;


    char str[1100];


    for(i=0; i<1100; i++){


       str[i] = 0;


    }


    while(1){


        scanf(" %s", str);


        if(strcmp(str, "0") == 0){


            break;


        }


        sum = 0;


        for(i=0; str[i]!='\0';i++){


            sum+= str[i] - '0';


       }


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


    }


    return 0;


}

Measured memory_bytes: 536
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

int t, n;

LL a, b, c;

int main(int argc, char const *argv[]) {
    // code
    cin >> a >> b;
    for (int i=1; i<=1000000; ++i) {
        int ansa = i * 8 / 100, ansb = i * 10 / 100;
        if (ansa == a && ansb == b) {
            printf("%d\n", i);
            return 0;
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
  
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      int i=0;
      for (String var : br.readLine().split(" "))
        seq[i++] = Integer.parseInt(var);

      int q = partition(seq, 0, n-1);
      dispIntArrayPartition(seq, q);
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }

  public int partition(int[] seq, int p, int r) {

    int x = seq[r];
    int i = p-1;
    int t;

    for(int j=p; j<r; j++) {
      if(seq[j] <= x) {
        t = seq[++i]; seq[i] = seq[j]; seq[j] = t;
      }
    }
    t = seq[i+1]; seq[i+1] = seq[r]; seq[r] = t;

    return i+1;
  }

public void dispIntArrayPartition(int[] target, int q) {
  StringBuilder s = new StringBuilder();
  int l=target.length-1;

  for (int i=0; i<q; i++) { s.append(target[i]).append(" "); }
  s.append("[").append(target[q]).append("] ");
  for (int i=q+1; i<l; i++) { s.append(target[i]).append(" "); }
  s.append(target[l]);

  System.out.println(s);
  }
}


Measured memory_bytes: 40920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 1<<29;


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(ALL(h));
  int ans = h[k - 1] - h[0];
  for (int i = 1; i < n - k + 1; i++){
    int x = h[i + k - 1] - h[i];
    ans = min(x, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int X,Y; cin >> X >> Y;
    ll ans = 0;
    int score[3] = {300000,200000,100000};
    if(X <= 3) ans += score[X-1];
    if(Y <= 3) ans += score[Y-1];
    if(X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
}


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

int main()
{
  vector<int> a(5);
  int buf = 100;
  int tmp;
  for (int i = 0; i < 5; i++)
  {
    cin >> a[i];
    if (a[i] % 10 > 0 && buf > a[i] % 10)
    {
      buf = a[i] % 10;
      tmp = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++)
  {
    if (i == tmp)
    {
      ans += a[i];
    }
    else if (a[i] % 10 == 0)
    {
      ans += (a[i] / 10) * 10;
    }
    else
    {
      ans += ((a[i] / 10) + 1) * 10;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
int main(){
  char N[200001];
  scanf("%s",N);
  int S=0;
  int k=0;
  int L=strlen(N);
  while(k<L){
    S=S+N[k]-'0';
    k++;
  }
  if(S%9==0) printf("Yes\n");
  else printf("No\n"); 
  return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
ll exp(ll a,ll b)
{
  if(b==0)
    return 1;
  if(b%2==0)
    return exp(a*a%mod,b/2);
  return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
   string s;
   cin>>s;
   int n=s.size();
   ll ans=1;
   for(int i=n-1; i>=0; i--){
    if(s[i]=='1'){
        ans=(exp(3,n-i-1)+2*ans)%mod;
      }
    }
   cout<<ans;
   return 0;
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N, M, C, tmp, ans;
int B[25], A[25][25];

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

	cin >> N >> M >> C;

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

	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}

	for(int i = 0; i < N; i++){
		int sum = 0;
		for(int j = 0; j < M; j++){
			sum += A[i][j]*B[j];
		}

		if(sum + C > 0)
			ans ++;
	}

	cout << ans << "\n";

	return 0;		
}

Measured memory_bytes: 256
d,g = map(int,input().split())
P = [0]*d
C = [0]*d
for i in range(d):
    P[i],C[i] = map(int,input().split())

ans = float('inf')
bit_n = d
for i in range(2**d):
    tmp = 0
    solved = 0
    for j in range(d):
        if ((i>>j)&1):
            tmp+=C[j]
            tmp+=(j+1)*100*P[j]
            solved+=P[j]
    if tmp>=g:
        ans = min(ans,solved)
    else:
        for j in range(d-1,-1,-1):
            if tmp>=g:
                ans = min(ans,solved)
                break
            if not ((i>>j)&1):
                for k in range(P[j]):                 
                    if tmp>=g:
                        ans = min(ans,solved)
                        break
                    solved+=1
                    tmp+=(j+1)*100
print(ans)

Measured memory_bytes: 3188
import heapq
n,m=map(int,input().split())
l=map(float,input().split())
l=[-1*i for i in l]
heapq.heapify(l)
for i in range(m):
    tmp=heapq.heappop(l)/2
    heapq.heappush(l,tmp)
print(sum([int(-1*i) for i in l]))

Measured memory_bytes: 13380
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define MOD 1000000007;

int main(){
  ll n;cin>>n;
  ll ans=n/2;
  if(n%2==1){ans++;}
  cout<<fixed<<setprecision(10)<<(float)ans/n<<endl;
}



Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
cost = 0
mincost = 100000*5000*10

for i in range(0,max(x,y)+1):
    cost = a*max(x-i,0)+b*max(y-i,0)+c*(2*i)
    mincost = min(cost,mincost)
    
print(mincost)

Measured memory_bytes: 9164
program main
implicit None
	character::s*3,t,k*2
	
	read *,s
	
	if(s(3:3) /= " ")then
		t = s(3:3)
		s(3:3) = s(1:1)
		s(1:1) = t
		print 101,s
		else
		k = s(1:2)
		print 101,k
	endif
	
101 format(a)
end program main

Measured memory_bytes: 768
#include <stdio.h>

int main()
{
	int i,j,n,ans;
	while(scanf("%d",&n)!=EOF){
	ans=0;
	int p[n];
	for(i=0;i<n;i++)p[i]=0;
	p[0]=1;
	for(i=2;i<=n/2;i++)for(j=2;i*j<=n;j++)if(p[i*j-1]==0)p[i*j-1]=1;
	for(i=0;i<n;i++)if(p[i]==0)ans++;
	printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4500
#include<stdio.h>
#include<stack>
#include<vector>
#include<string.h>

using namespace std;

int main()
{
	char c[20000];
	int D[10000];
	stack<int> S1;
	stack<pair<int, int> > S2;
	int len,sum=0,n,i;

	scanf("%s",c);
	len = strlen(c);
	for (int i = 0; i < len; i++)
	{
		if(c[i]=='\\')
		{
			S1.push(i);
		}
		else if (c[i] == '/')
		{
			if (!S1.empty())
			{
				int j = S1.top();
				int a = i - j;
				S1.pop();
				sum += a;
				while (!S2.empty() && S2.top().first > j)
				{
					a += S2.top().second;
					S2.pop();
				}
				S2.push(make_pair(j,a));
			}
		}
	}
	n = S2.size();
	i = n;
	while (S2.size() > 0)
	{
		D[--i] = S2.top().second;
		S2.pop();
	}
	printf("%d\n",sum);
	printf("%d", n);
	for (i = 0; i < n; i++)
	{
		printf(" %d", D[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2784