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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);
  
  vector<int> B(N);
  for(int i=0;i<N;i++) cin >> B.at(i);
  
  vector<int> C(N-1);
  for(int i=0;i<N-1;i++) cin >> C.at(i);
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    ans += B.at(A.at(i)-1);
  }
  for(int i=0;i<N-1;i++){
    if(A.at(i)+1 == A.at(i+1)) ans += C.at(A.at(i)-1);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
    vector<int> size, parents;
    UnionFind(int n){
        size.resize(n,0);
        parents.resize(n,0);
        for(int i = 0; i < n; i++){
            makeTree(i);
        }
    }
    void makeTree(int x){
        parents[x] = x;
        size[x] = 1;
    }
    bool isSame(int x, int y){return findRoot(x) == findRoot(y);}
    void unite(int x, int y){
        x = findRoot(x);
        y = findRoot(y);
        if(size[x] > size[y]){
            parents[y] = x;
            size[x] += size[y];
        }else{
            parents[x] = y;
            size[y] += size[x];
        }
    }
    int findRoot(int x){
        if(x != parents[x]){
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x){return size[findRoot(x)];}
};


int main(){
    int n, m; cin >> n >> m;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf(n);
    rep(i,m){
        int x, y; cin >> x >> y;
        --x, --y;
        uf.unite(x,y);
    }
    int ans = 0;
    rep(i,n){
        if(uf.isSame(i,p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
//
//  main.cpp
//  integer cards
//
//  Created by Dong Truong on 5/28/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <queue>

using namespace std;
#define maxn 1000001

struct elem
{
    int sl,gt;
};

int n,m,a[maxn];elem q[maxn];

bool cmp(elem a,elem b)
{
    return a.gt>b.gt;
}
void nhap()
{
    cin>>n>>m;
    for (int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    for (int i=1;i<=m;++i)
        cin>>q[i].sl>>q[i].gt;
    sort(q+1,q+m+1,cmp);
}
void sol()
{
    int x=1,i=1;int64_t kq=0;
    while (i<=n && x<=m)
    {
        if (a[i]>q[x].gt) break;
        while (a[i]<q[x].gt && q[x].sl>0 && i<=n)
        {
            --q[x].sl;
            a[i]=q[x].gt;
            ++i;
        }
        ++x;
    }
    for (int i=1;i<=n;++i) kq+=a[i];
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
   // freopen("a.inp","r",stdin);
    nhap();
    sol();
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

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

	int sc1 = 0;
	int sc2 = 0;

	REP(i, n){
		string s1, s2;
		cin >> s1 >> s2;

		if(s1 == s2){
			sc1 += 1;
			sc2 += 1;
		}
		else if(s1 >= s2){
			sc1 += 3;
		}
		else{
			sc2 += 3;
		}
	}

	cout << sc1 << " " << sc2 << endl;
	
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <math.h>
#include <strings.h>
#include <queue>
#include <algorithm>
using namespace std;

int gcd(int A,int B){
    int a,b,c;
    if(A>B){
        a=A;
        b=B;
    }else{
        a=B;
        b=A;
    }
    while(1){
        a=a%b;
        if(a==0){
            return b;
        }
        b=b%a;
        if(b==0){
            return a;
        }
    }
    return 0;
}

int main()
{
    int i,j,k,K;
    cin >> K;
    int s=0;
    for(i=1;i<=K;i++){
    for(j=1;j<=K;j++){
    for(k=1;k<=K;k++){
        s=s+gcd(gcd(i,j),k);        
    }
    }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 3676
main :: IO ()
main = do
  [_, mm] <- words <$> getLine
  let m = (read :: String -> Double) mm
  as <- map read . words <$> getLine
  let b = sum as / (m * 4)
  let a = fromIntegral $ length $ filter (>= b) as
  putStrLn $
    if a >= m
      then "Yes"
      else "No"


Measured memory_bytes: 892
#include<cstdio>
#include<stack>
#include<algorithm>
using namespace std;

char s[3010],t[3010];
int f[3010][3010];
int g[3010][3010][2];

int main(){
	scanf("%s%s",s+1,t+1);
	
	int ans=0;
	int cur[2];
	for(int i=1;s[i];i++)
		for(int j=1;t[j];j++){
			if(s[i]-t[j]){
				if(f[i-1][j]>f[i][j-1])
					f[i][j]=f[i-1][j],g[i][j][0]=i-1,g[i][j][1]=j;
				else
					f[i][j]=f[i][j-1],g[i][j][0]=i,g[i][j][1]=j-1;
			}else 
				f[i][j]=f[i-1][j-1]+1,g[i][j][0]=i-1,g[i][j][1]=j-1;
			if(f[i][j]>ans) ans=f[i][j],cur[0]=i,cur[1]=j;
		}
	
	stack<char> stk;
	while(cur[0]>0 && cur[1]>0){
		if(g[cur[0]][cur[1]][0]==cur[0]-1 && g[cur[0]][cur[1]][1]==cur[1]-1)
			stk.push(s[cur[0]]);
		int tmp=cur[0];
		cur[0]=g[tmp][cur[1]][0],cur[1]=g[tmp][cur[1]][1];
	}
	while(!stk.empty()){
		putchar(stk.top());
		stk.pop();
	}
	return puts("")&0;
}

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

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

    multiset<string> s;
    rep(i,n){
        string str;
        cin>>str;
        sort(str.begin(),str.end());
        s.insert(str);
    }
    
    long long ans=0;
    while(!s.empty()){
        long long num=s.erase(*s.begin());
        if(num>1) ans+=num*(num-1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 9600
# coding:utf-8

n = int(input().rstrip())

dic = [None for i in range(n + 1)]
def get_ans(amount:int):
    if dic[amount] is not None:
        return dic[amount]

    if amount <= 0:
        return 0

    ans = amount

    for i in reversed(range(6)):
        num = pow(9, i)
        if num > amount:
            continue
        ret = get_ans(amount - num) + 1
        ans = min(ans, ret)

    for i in reversed(range(7)):
        num = pow(6, i)
        if num > amount:
            continue
        ret = get_ans(amount - num) + 1
        ans = min(ans, ret)

    dic[amount] = ans
    return ans

print(get_ans(n))

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n, m, x;
    cin >> n >> m >> x;
    vll c(n);
    vvll a(n, vll(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    ll ans = INF;
    rep(bit, 1<<n) {
        vll tmp(m, 0);
        bool ok = true;
        ll num = 0;
        rep(j, n) {
            if(bit>>j&1) {
                num += c[j];
                rep(k, m) tmp[k] += a[j][k];
            }
        }
        rep(i, m) if(tmp[i] < x) ok = false;
        if(ok) chmin(ans, num);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String N = scanner.nextLine();
		if("1".equals(N)){
			System.out.print("Hello World");
		}else{
			scanner.hasNextLine();
			String A = scanner.nextLine();
			scanner.hasNextLine();
			String B = scanner.nextLine();
			System.out.print(Integer.parseInt(A) + Integer.parseInt(B));
		}
	}

}


Measured memory_bytes: 21204
PROGRAM ATCODER

implicit none
integer(16) :: n,m,i,max=0,l,count=0,h,j,on,check=0
integer(16),allocatable :: k(:),s(:,:),p(:),sw(:)

read*, n,m
allocate(k(m),s(m,10),p(m),sw(n))
s = 0
do i = 1, m, 1
  read*, k(i),s(i,1:k(i))
end do
read*, p(1:m)

do i = 1, n
  max = max + 2**(i-1)
end do

do i = 0, max, 1
  check = 0
  l = i
  sw = 0
  do j = 1, n, 1
    sw(j) = mod(l,2)
    l = l/2
  end do
  do j = 1, m, 1
    on = 0
    do h = 1, k(j), 1
      if ( sw(s(j,h)) == 1 ) then
        on = on + 1
      end if
    end do
    if ( mod(on,2) /= p(j) ) then
      check = 1
      exit
    end if
  end do
  if ( check == 0 ) then
    count = count + 1
  end if
end do

print'(i0)', count

END PROGRAM ATCODER

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e16;
const int MB = 20;
const int MOD = 998244353;
const int maxN = 1e7 + 1;

void solve() {
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int solve() {
	var(int, n, m);
	for (int i = m / n; i > 1; --i) {
		if (m % i == 0 && i * n <= m)
			return i;
	}
	return 1;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

void solve()
{
    lli n;
    cin>>n;

    lli a=0,b=0,c=0,d=0;

    loopl(i,0,n)
    {
        string s;
        cin>>s;

        if(s == "AC") a++;
        if(s == "WA") b++;
        if(s == "TLE") c++;
        if(s == "RE") d++;
    }

    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


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

using namespace std;

const long long INF = 1e18;

pair <int, int> a[105];
long long dp[100005];

int main() {
    int n, w;

    scanf("%d%d", &n, &w);

    for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);

    dp[0] = 0;
    for (int i = 1; i <= 100000; i++) dp[i] = INF;

    for (int i = 0; i < n; i++) {
        for (int j = 100000; j >= a[i].second; j--) dp[j] = min(dp[j], dp[j - a[i].second] + a[i].first);
    }

    int res = 0;

    for (int i = 0; i <= 100000; i++) {
        if (dp[i] <= w) res = i;
    }

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


Measured memory_bytes: 1152
from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
B=list(A.values())
C=list(A.keys())
if len(B)>4:print("No")
elif len(B)==3:
    if B[0]==B[1]==B[2]:
        if C[0]^C[1]==C[2] or C[1]^C[2]==C[0] or C[2]^C[0]==C[1]:print("Yes")
        else:print("No")
    else:print("No")
elif len(B)==2:
    if 0 in C and A[0]*2 in B:print("Yes")
    else:print("No")
else:
    if 0 in C:print("Yes")
    else:print("No")

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

int main() {
    int N, M, K, tmp;
    cin >> N >> M >> K;
    vector<ll> A(N+1), B(M+1);
    ll sumA = 0;
    ll sumB = 0;
    rep(i,N) {
        cin >> tmp;
        sumA += tmp;
        A.at(i+1) = sumA;
    }
    rep(i,M) {
        cin >> tmp;
        sumB += tmp;
        B.at(i+1) = sumB;
    }
    int ans = 0;
    int j = 0;
    rep(i,N+1) {
        if (A.at(N-i) > K) continue;
        int tmp;
        for (; j < M+1; ++j) {
            if ((A.at(N-i) + B.at(j) <= K && j + 1 == M + 1)
            || (A.at(N-i) + B.at(j) <= K && A.at(N-i) + B.at(j+1) > K)) {
                ans = max(ans, N - i + j);
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6392
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for (int  i = 0; i < n; i++)
    {
        cin >> a.at(i);
        b.at(i)=a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    
    for (int  i = 0; i < n; i++)
    {
        if (b.at(i)==a.at(0))
        {
            cout << a.at(1) << endl;
        }
        else
        {
            cout << a.at(0) << endl;
        }
    }
    

}


Measured memory_bytes: 4840
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<iomanip>
#include<unordered_map>
#define deg(x) cerr<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const int inf=1e9+7;
const double eps=1e-6;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return (r+m)%m;}
const double pi=acos(-1);

int n;
ll c;
int main(){
    TB
	cin>>n>>c;
	int cnt=0;
	while(n--){
		ll x,y;cin>>x>>y;
		if(c*c>=x*x+y*y)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3652
function Main(input) {

    const lines = input.split('\n');
    var x = parseInt(lines[0], 10);
    const a = parseInt(lines[1], 10);
    const b = parseInt(lines[2], 10);

    x = x - a;
    x = x - b * Math.floor(x / b);

    console.log(x);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll euclidean_gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = c-a, y = d-b;
  cout << c-y <<" "<< d+x<<" "<< a-y<<" "<< b+x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int takahashi,i;
	takahashi = 0;
	char idea[4];
	scanf ("%s",idea);
	for (i=0; i<4; i++){
		if (idea[i] == '+'){
			takahashi += 1;
		}
		else if (idea[i] == '-'){
			takahashi -= 1;
		}
	}
	printf ("%d\n", takahashi);
	return 0;
}

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

int main() {
    string s;
    int n;
    cin >> s >> n;
    for (int i = 0; i < n; ++i) {
        string func;
        cin >> func;
        if (func == "print") {
            int a, b;
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        } else if (func == "reverse") {
            int a, b;
            cin >> a >> b;
            reverse(s.begin() + a, s.begin() + b + 1);
        } else {
            int a, b;
            string t;
            cin >> a >> b >> t;
            s.replace(a, b - a + 1, t);
        }
    }
}



Measured memory_bytes: 3212
fizzbuzz :: Integer -> Integer
fizzbuzz 0 = 0
fizzbuzz n
    | n `mod` 3 == 0 = fizzbuzz (n-1)
    | n `mod` 5 == 0 = fizzbuzz (n-1)
    | otherwise = n + fizzbuzz (n-1)

main = do
    n <- readLn
    putStrLn $ show (fizzbuzz n)

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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  ll a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  ll cnt = 0;
  for(int i=0;i<N;i++){
    while(a[i] %2 == 0){
      cnt++;
      a[i] = (a[i] >> 1);
    }
  }
  cout << cnt << endl;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            long a = Long.parseLong(strArr[0]);
            String op = strArr[1];
            long b = Long.parseLong(strArr[2]);
            if ("+".equals(op)) {
                System.out.println(a + b);
            } else {
                System.out.println(a - b);
            }
           } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, w;
	cin >> n >> w;
	vector<long long> weights(n);
	vector<long long> values(n);
	for(long long i=0; i<n; ++i) {
		cin >> weights[i] >> values[i];
	}
	vector<vector<long long>> dp(n+1, vector<long long>(w+1));
	for(int i=0; i<=n; ++i) {
		for(int j=0; j<=w; ++j) {
			if(i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if(j - weights[i-1] >= 0) {
				dp[i][j] = dp[i-1][j] >= dp[i-1][j-weights[i-1]] + values[i-1] ? dp[i-1][j] : dp[i-1][j-weights[i-1]] + values[i-1];
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	printf("%lld", dp[n][w]);
	return 0;
}

Measured memory_bytes: 83172
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

Ch += 1
Cw += 1
Dh += 1
Dw += 1


S = ['#'*(W+4)]
S.append('#'*(W+4))
for k in range(H):
  S.append('##' + input() + '##')
S.append('#'*(W+4))
S.append('#'*(W+4))

foo = [[-1 for _ in range(W+4)] for _ in range(H+4)]
for k in range(2, H+2):
  for j in range(2, W+2):
    if S[k][j] == '.':
      foo[k][j] = 10**6

foo[Ch][Cw] = 0

now = []
new = [(Ch, Cw)]
while len(new) > 0:
  item = new.pop()
  now.append(item)
  x = item[0]
  y = item[1]
  if foo[x+1][y] == 10**6:
    foo[x+1][y] = 0
    new.append((x+1, y))
  if foo[x][y+1] == 10**6:
    foo[x][y+1] = 0
    new.append((x, y+1))
  if foo[x-1][y] == 10**6:
    foo[x-1][y] = 0
    new.append((x-1, y))
  if foo[x][y-1] == 10**6:
    foo[x][y-1] = 0
    new.append((x, y-1))


ans = 0
while foo[Dh][Dw] == 10**6:
  if len(now) == 0:
    print(-1)
    exit() 
  ans += 1
  while len(now) > 0:
    item = now.pop()
    x = item[0]
    y = item[1]
    if foo[x+2][y+2] > ans:
      foo[x+2][y+2] = ans
      new.append((x+2, y+2))
    if foo[x+2][y+1] > ans:
      foo[x+2][y+1] = ans
      new.append((x+2, y+1))
    if foo[x+2][y] > ans:
      foo[x+2][y] = ans
      new.append((x+2, y))
    if foo[x+2][y-1] > ans:
      foo[x+2][y-1] = ans
      new.append((x+2, y-1))
    if foo[x+2][y-2] > ans:
      foo[x+2][y-2] = ans
      new.append((x+2, y-2))
    if foo[x+1][y+2] > ans:
      foo[x+1][y+2] = ans
      new.append((x+1, y+2))
    if foo[x+1][y-2] > ans:
      foo[x+1][y-2] = ans
      new.append((x+1, y-2))
    if foo[x][y+2] > ans:
      foo[x][y+2] = ans
      new.append((x, y+2))
    if foo[x][y-2] > ans:
      foo[x][y-2] = ans
      new.append((x, y-2))
    if foo[x-2][y+2] > ans:
      foo[x-2][y+2] = ans
      new.append((x-2, y+2))
    if foo[x-2][y+1] > ans:
      foo[x-2][y+1] = ans
      new.append((x-2, y+1))
    if foo[x-2][y] > ans:
      foo[x-2][y] = ans
      new.append((x-2, y))
    if foo[x-2][y-1] > ans:
      foo[x-2][y-1] = ans
      new.append((x-2, y-1))
    if foo[x-2][y-2] > ans:
      foo[x-2][y-2] = ans
      new.append((x-2, y-2))
    if foo[x-1][y+2] > ans:
      foo[x-1][y+2] = ans
      new.append((x-1, y+2))
    if foo[x-1][y-2] > ans:
      foo[x-1][y-2] = ans
      new.append((x-1, y-2))
    if foo[x-1][y-1] > ans:
      foo[x-1][y-1] = ans
      new.append((x-1, y-1))
    if foo[x-1][y+1] > ans:
      foo[x-1][y+1] = ans
      new.append((x-1, y+1))
    if foo[x+1][y+1] > ans:
      foo[x+1][y+1] = ans
      new.append((x+1, y+1))
    if foo[x+1][y-1] > ans:
      foo[x+1][y-1] = ans
      new.append((x+1, y-1))
      
  while len(new) > 0:
    item = new.pop()
    now.append(item)
    x = item[0]
    y = item[1]
    if foo[x+1][y] == 10**6:
      foo[x+1][y] = 0
      new.append((x+1, y))
    if foo[x][y+1] == 10**6:
      foo[x][y+1] = 0
      new.append((x, y+1))
    if foo[x-1][y] == 10**6:
      foo[x-1][y] = 0
      new.append((x-1, y))
    if foo[x][y-1] == 10**6:
      foo[x][y-1] = 0
      new.append((x, y-1))
print(ans)

Measured memory_bytes: 24120
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i;
  int a[150][150];
  int x,y;
  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      a[x][y]=0;
    }
  }

  for (i = 0; i < n; i++) {
    int l;
    cin >> l;
    int k;
    cin >> k;
    int j;
    for (j = 0; j < k; j++) {
      int m=0;
      cin >> m;
      a[l-1][m-1]=1;
    }

  }

  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      printf("%d",a[x][y]);
      if(y!=n-1){
        printf(" ");
      }
    }printf("\n");
  }

  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int i, sumrika=0, sumsha=0, t, u, cnt=0;
int minrika=110, minsha=110;
int rika[5], sha[3];
int main(){
for(i=1; i<=4; i++){
   cin>>rika[i]; sumrika+=rika[i];
   if(rika[i]<minrika){minrika=rika[i];}
}
for(i=1; i<=2; i++){
    cin>>sha[i]; sumsha+=sha[i];
    if(sha[i]<minsha){minsha=sha[i];}
}
int disp = (sumrika-minrika)+(sumsha-minsha);
cout << disp << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 200020
#define maxm 
using namespace std;

int n, k; char s[maxn];
int main(){ 
	scanf("%d%d", &n, &k);
	scanf("%s", s + 1);
	int seg = 0, first = -1;
	rep(i, 1, n) {
		char now = s[i];
		if (first == -1) first = (now == 'R') ? 1 : 0;
		while (i <= n && s[i] == now) i++; i--;
		seg++;
	}
	printf("%d\n", n - max(1, seg - 2 * k));   
	return 0;
}

Measured memory_bytes: 3908
#include<iostream>
#include<algorithm>
#include<vector>
#include <cstdlib>

using namespace std;
int main(){
  int n, k;
  int min = 2147483645;
  cin >> n >> k;

  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }

  sort(h.begin(), h.end());

  k--;
  for(int i = 0; i < (n - k); i++){
    if(min > abs(h.at(i) - h.at(i + k))){
      min = abs(h.at(i) - h.at(i + k));
    }
  }


  cout << min << endl;


  return 0;
}


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

int main()
{
	int n, t;
	int x[3] = { 0 };
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &t);
		if (t % 4 == 0)
			x[2]++;
		else if (t % 2 == 0)
			x[1]++;
		else
			x[0]++;
	}
	for (int i = 0; i < n - 1; i+=2)
	{
		if (x[0] > 0)
		{
			if (x[2] > 0)
			{
				x[0]--;
				x[2]--;
				continue;
			}
			printf("No\n");
			return 0;
		}
		if (x[1] > 0)
		{
			if (x[1] > 1)
			{
				x[1] -= 2;
				continue;
			}
			else if (x[2] > 0)
			{
				x[2]--;
				x[1]--;
				continue;
			}
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,t;
main()
{
	while(cin>>n>>m>>t,n)
	{
		string s[1001],b[1001];
		s[0]=string(n,'0');
		b[0]=string(m,'0');
		for(int i=0;i++<t;)cin>>s[i]>>b[i];
		bool check[1000]={};
		string ans(m,'?');
		for(int i=0;i<m;i++)
		{
			bool ok[36]={};
			for(int j=0;j<n;j++)ok[j]=1;
			for(int j=0;j++<t;)
			{
				if(b[j-1][i]!=b[j][i])
				{
					for(int k=0;k<n;k++)ok[k]&=s[j][k]=='1';
				}
				else
				{
					for(int k=0;k<n;k++)ok[k]&=s[j][k]=='0';
				}
			}
			int cnt=0,mi;
			for(int j=0;j<n;j++)if(ok[j])cnt++,mi=j;
			if(cnt==1)
			{
				ans[i]=(char)(mi<10?mi+'0':mi-10+'A');
				check[i]=1;
			}
		}
		int cnt=0,mi;
		for(int i=0;i<n;i++)if(ans[i]=='?')cnt++,mi=i;
		if(cnt==1)
		{
			for(int i=0;i<m;i++)if(!check[i])ans[i]=(char)(mi<10?mi+'0':mi-10+'A');
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 4336
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, L;
string S[105];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N>>L;
    REP(i,0,N){
        cin>>S[i];
    }
    sort(S, S+N);
    string ans = "";
    REP(i,0,N){
        ans += S[i];
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

int main() {
    
    //forItachi
	long long int h,w;
	cin>>h>>w;
	if(h==1||w==1){
	    cout<<1<<endl;
	}
	else if((h*w)%2==0){
	    cout<<(h*w)/2<<endl;
	}
	else{
	    cout<<(h*w)/2+1<<endl;
	}
}

Measured memory_bytes: 256
import sys
import heapq
n = int(input())
V = [[int(i) for i in input().split()] for _ in range(n)]
dis = [sys.maxsize for _ in range(n)]
dis[0] = 0
h = []
for i in range(n):
    heapq.heappush(h,(dis[i],i))
while(len(h)>0):
    node = heapq.heappop(h)
    tmp = node[1]
    for i in range(V[tmp][1]):
        ind = V[tmp][2*i+2]
        cos = V[tmp][2*i+3]
        if cos + dis[tmp] < dis[ind]:
            dis[ind] = cos + dis[tmp]
            heapq.heappush(h,(dis[ind],ind))
for i,j in enumerate(dis):
    print(i,j)


Measured memory_bytes: 40548
#include <iostream>
using namespace std;
int main(){
int a,b,c,y;
cin>>a>>b>>c;
if(a>b){
    y=a;
    a=b;
    b=y;
}
if(b>c){
    y=b;
    b=c;
    c=y;
}
if(a>b){
    y=a;
    a=b;
    b=y;
}
cout<<a<<" "<<b<<" "<<c<<endl;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int cnt=0;
  if(a!=b) cnt++;
  if(a!=c) cnt++;
  if(c!=b) cnt++;
  if(cnt==2){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size(); 
  int M = T.size();
  vector<string> cand;
  for (int i = 0; i <= N - M; i++) {
    string str = S;
    bool can = true;
    for (int j = 0; j < M; j++) {
      if (S[i+j] == '?' || T[j] == S[i+j]) {
        str[i+j] = T[j];
      } else {
        can = false;
      }
    }
    if (can) {
      for (int i = 0; i < str.size(); i++) {
        if (str[i] == '?') {
          str[i] = 'a';
        }
      }
      cand.push_back(str);
    }
  }
  if (cand.size() == 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  string ans = cand[0];
  for (int i = 1; i < cand.size(); i++) {
    ans = min(ans,cand[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) p[i] = scan.nextInt();
        Arrays.sort(p);
        int sum = 0;
        for(int i = 0; i < k; i++) sum += p[i];
        System.out.println(sum);
        scan.close();
    }
}

Measured memory_bytes: 30232
n = int(input())
a = [list(map(int, input().split()))]
a.append(list(map(int, input().split())))
dp = [[0] * n, [0] * n]
dp[0][0] = a[0][0]
dp[1][0] = a[0][0] + a[1][0]
for i in range(1, n):
  dp[0][i] = dp[0][i - 1] + a[0][i]
  dp[1][i] = max(dp[1][i - 1], dp[0][i]) + a[1][i]
print(dp[1][-1])

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

using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int inf_int=1e9;
ll inf_ll=1e16;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define siz(a) a.size()
#define EPS 1e-7
#define next asdfafgasgasg
bool debug=0;
typedef long double dbl;
const int MAXN = 2e5;
const int MOD = 1e9 +7;



vector<int> g[MAXN];
pii val[MAXN][11];
void solve()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i=1;i<=m;++i){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }

    int q;
    cin >> q;
    for(int j=1;j<=q;++j){
        int d,v,c;
        cin >> v >> d >> c ;
        val[v][d]={j,c};
    }

    for(int d=10;d>=1;d--){
        for(int v=1;v<=n;v++){
            for(int to:g[v]){
                val[to][d-1]=max(val[to][d-1],val[v][d]);
            }
            val[v][d-1]=max(val[v][d-1],val[v][d]);
        }

    }

    for(int i=1;i<=n;++i){
        if(i>1){
            cout <<"\n";
        }
        cout << val[i][0].se;

    }
    cout <<"\n";

}


#define FILE "palindrome"
int main()
{
        #ifdef zxc
            freopen("input.txt","r",stdin);
 //          freopen("output.txt","w",stdout);
        #else
         //     freopen(FILE".in","r",stdin);
         //     freopen(FILE".out","w",stdout);
        #endif // zxc

     //  freopen(FILE".in","r",stdin);
     //   freopen(FILE".out","w",stdout);

     //   freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);

       if(!debug)
       {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
       }

        int t=1;
        while(t--)
           solve();
        return 0;
}


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

#define ll long long

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

    string str;
    cin >> str;

    int sum = 0;
    for(int i=0;i<str.length();i++){
        int n = str[i] - '0';
        sum += n;
    }
    if(sum % 9 == 0){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

}



Measured memory_bytes: 3720
#include <iostream>

using namespace std;

#define SEGTREE (1 << 18)

int segTree[SEGTREE * 2];

void
add(int i, int x){
    i += SEGTREE;
    segTree[i] += x;
    while(1) {
        i /= 2;
        if(i == 0) break;
        segTree[i] = segTree[i * 2] + segTree[i * 2 + 1];
    }
}

int
sum(int l, int r){
    int ans = 0;
    l += SEGTREE;
    r += SEGTREE;

    while(l < r) {
        if(l % 2 == 1) {
            ans += segTree[l];
            l++;
        }
        l /= 2;
        if(r % 2 == 1) {
            ans += segTree[r-1];
            r--;
        }
        r /= 2;
    }

    return ans;
}

int
main(void)
{
    int n, q, com, x, y;
    cin >> n >> q;

    for(int i = 0; i < q; ++i) {
        cin >> com;
        cin >> x >> y;
        if(com == 0) add(x, y);
        else cout << sum(x, y+1) << endl;
    }
}



Measured memory_bytes: 3872
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSugarWater solver = new CSugarWater();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSugarWater {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int a = in.ints(), b = in.ints(), c = in.ints(), d = in.ints();
            int e = in.ints(), f = in.ints();
            int maxs = 1;
            int maxm = 0;

            for (int x = 0; x <= 30; x++) {
                int rdx = f - 100 * a * x;
                for (int y = 0; y * 100 <= rdx; y++) {
                    int n = a * x + b * y;
                    int cap = n * e;
                    int rdy = rdx - 100 * b * y;
                    for (int z = 0; z * c <= rdy && c * z <= cap; z++) {
                        int rdz = rdy - c * z;
                        for (int w = 0; d * w <= rdz && (c * z + d * w) <= cap; w++) {
                            int m = c * z + d * w;
                            int s = 100 * n + m;
                            if (maxm * s <= m * maxs) {
                                maxm = m;
                                maxs = s;
                            }
                        }
                    }
                }
            }
            out.println(maxs + " " + maxm);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

int main()
{
    int N, count, i, k, num;
    count = 0;
    cin >> N;
    int a[N];
    num = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    // for (int i = 0; i < N; i++)
    // {
    //     cout << a[i];
    // }
    for (int k = 0; k < N; k++)
    {
        if (a[k] != num)
            count++;
        else
            num++;
    }

    if (count == N)
    {
        cout << -1 << endl;
        return (0);
    }
    else
    {
        cout << count << endl;
        return (0);
    }

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define maxn 15
#define inf (int)1e9
int a[maxn][maxn], dst[maxn];
int i,j,k,m,n,x,dau,tmp;
int res = inf;
int main(){
  cin>>n>>m>>x;
  for(i=0;i<n;i++){
    for(j=0;j<=m;j++) cin>>a[i][j];
  }
  /*for(i=0;i<n;i++){
    for(j=1;j<=m;j++) cout<<a[i][j]<<" ";
    cout<<'\n';
  }*/
  for(i=0;i<(1<<n);i++){
        tmp=0;
        dau=0;
        memset(dst,0,sizeof(dst));
    for(j=0;j<n;j++){
        if((i>>j)&1){
            tmp+=a[j][0];
            for(k=0;k<m;k++) dst[k]+=a[j][k+1];
        }
    }
    for(k=0;k<m;k++) if(dst[k]<x) {dau=1;break;}
    if(dau==0) res=min(res,tmp);
  }
  if(res==inf) cout<<-1;
  else cout<<res;
  return 0;
}


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

//int dp[105][4][2];

int main() {
  long long int n, d;
  int cnt = 0;
  
  cin >> n >> d;
  
  long long int x[n];
  long long int y[n];
  
  long long int d_now;
  
  rep(i, n){
    cin >> x[i] >> y[i]; 
    
    if( x[i] > d || y[i] > d){
      //printf("%d!? %f\n", i, (double)d);
      continue;
    }
    
    else if( x[i] < d*(-1) || y[i] < d*(-1)){
      //printf("%d\n", i);
      continue;
    }
    
    d_now = (x[i] * x[i]) + (y[i] * y[i]);
    //printf("%lld\n", x[i] * x[i]);
    
    
    if(d_now <= d*d){
      //printf("[%d] %lld\n", i, d_now);
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
  
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N + 1, 0), V(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &T[i]);
    T[i] *= 2;
    T[i] += T[i - 1];
  }

  for (int i = 1; i <= N; ++i) {
    scanf("%d", &V[i]);
  }

  vector<double> upperV(T[N] + 5, 0);
  double limv = V[1];
  for (int t = 1, vpos = 0; t <= T[N] ; ++t) {
    if (t > T[vpos]) { limv = V[++vpos]; }
    upperV[t] = min(upperV[t - 1] + 0.5, limv);
  }

  upperV[T[N]] = 0;
  limv = V[N];
  for (int t = T[N] - 1, vpos = N; t >= 0; --t) {
    if (t < T[vpos - 1]) { limv = V[--vpos]; }
    upperV[t] = min(upperV[t], min(upperV[t + 1] + 0.5, limv));
  }

  double ans = 0;
  for (int t = 1; t <= T[N]; ++t) {
    ans += (upperV[t - 1] + upperV[t]);
  }
  ans *= 0.25;
  printf("%f\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string a[n];
    int count=0;
    int x=0,y=0;
    int k=0;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        int l=a[i].length();
        for (int j = 0; j < l-1; ++j) {
            if(a[i][j]=='A'&&a[i][j+1]=='B')
            {
                count++;
            }
        }

        if(a[i][l-1]=='A')
            x++;
        if(a[i][0]=='B')
            y++;
        if(a[i][l-1]=='A' && a[i][0]=='B')
        {
            k++;
        }
    }


    if(x==k && y==k && x!=0)
        cout<<k-1+count;
    else {
        int z = min(x, y);

        if (z == n)
            z--;
        cout << z + count;
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

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


int main()
{
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}

Measured memory_bytes: 3636
n = int(input())
w = []
for i in range(n):
   w.append(input())

if (len(set(w)) < len(w)):
   print('No')
   exit()

for i in range(1, n):
   if (w[i][0] != w[i-1][-1]):
      print('No')
      exit()
print('Yes')


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

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=100+5;
int x[N],y[N],h[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d%d%d",x+i,y+i,h+i);
	int aCx=-1,aCy=-1,aH=-1;
	rep(Cx,0,100)
	rep(Cy,0,100)
	{
		int max_h=2e9,must_h=-1;
		rep(i,1,n)
		if(!h[i])chmin(max_h,abs(x[i]-Cx)+abs(y[i]-Cy));
		else 
		{
			int now=h[i]+abs(x[i]-Cx)+abs(y[i]-Cy);
			if(must_h!=-1&&now!=must_h)
			{
				max_h=0;
				break;
			}
			must_h=now;
		}
		if(must_h>max_h)continue;
		if(must_h==-1)
		{
			if(max_h>1)
			{
				puts("More than one!");
				exit(0);
			}
			must_h=1;
		}
		if(aH!=-1)
		{
			puts("More than one!");
			exit(0);
		}
		aCx=Cx;aCy=Cy;aH=must_h;
	}
	if(aH==-1)puts("Not exist!");
	else printf("%d %d %d\n",aCx,aCy,aH);
}

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

int main()
{
	int N;
	int sum = 0;

	scanf("%d", &N);
	int tmp = N;

	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 128
def abc129c():
    n, m = map(int, input().split())
    set_a = set()
    for _ in range(m):
        set_a.add(int(input()))
    dp = [0] * (n+1)
    dp[0] = 1
    for i in range(1, n+1):
        if i in set_a: continue
        dp[i] = dp[i-1]
        if i > 1:
            dp[i] += dp[i-2]
    print(dp[n]%1000000007)
abc129c()

Measured memory_bytes: 503216
s2 = list(input())
t = list(input())

s2.reverse() 
t.reverse() 

ans = 'UNRESTORABLE'

cands = []

for i in range(len(s2) - len(t) + 1):
    for j in range(len(t)):
        if t[j] == s2[i + j] or s2[i + j] == '?':
            if j == len(t) - 1:
                s2[i:i+j + 1] = t
                s2.reverse()
                ans = ''.join(s2)
                ans = ans.replace('?', 'a')
                cands.append(ans)
                break
            else:
                continue
        else:
            break

if cands:
    print(sorted(cands)[0])
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  string line;
  getline(cin, line);
  for (int i = 0; i < line.size(); ++i) {
    char c = line[i];
    if (isupper(c)) {
      c = tolower(c);
    } else if (islower(c)) {
      c = toupper(c);
    }
    line[i] = c;
  }
  cout << line << endl;
}

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

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

int main(){
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        if (A < B) {
            cout << "No" << endl;
            continue;
        }else if (D < B) {
            cout << "No" << endl;
            continue;
        }else if (C > B) {
            cout << "Yes" << endl;
            continue;
        }
        
        ll G = gcd(B, D);
        if (A%G+B-G > C) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
        
    return 0;
}

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

int main() {
  int n, a, b, c; cin >> n >> a >> b >> c;
  vector<int> bamboos(n);
  for (int i = 0; i < n; i++) cin >> bamboos.at(i);
  int answer = 4000;
  
  for (int i = 0; i < pow(2, n * 2); i++) {
    vector<int> av;
    vector<int> bv;
    vector<int> cv;
    
    for (int j = 0; j < n * 2; j = j + 2) {
      if (i & (1 << j) && i & (1 << (j + 1))) av.push_back(bamboos.at(j / 2));
      if (i & (1 << j) && !(i & (1 << (j + 1)))) bv.push_back(bamboos.at(j / 2));
      if (!(i & (1 << j)) && i & (1 << (j + 1))) cv.push_back(bamboos.at(j / 2));
    }
    
    int suma = accumulate(av.begin(), av.end(), 0);
    int sumb = accumulate(bv.begin(), bv.end(), 0);
    int sumc = accumulate(cv.begin(), cv.end(), 0);
    
    if (suma == 0 || sumb == 0 || sumc == 0) continue;
    
    int synthesis = (av.size() + bv.size() + cv.size() - 3) * 10;
    
    answer = min(answer, synthesis + abs(a - suma) + abs(b - sumb) + abs(c - sumc));
    answer = min(answer, synthesis + abs(a - suma) + abs(b - sumc) + abs(c - sumb));
    answer = min(answer, synthesis + abs(a - sumb) + abs(b - suma) + abs(c - sumc));
    answer = min(answer, synthesis + abs(a - sumb) + abs(b - sumc) + abs(c - suma));
    answer = min(answer, synthesis + abs(a - sumc) + abs(b - suma) + abs(c - sumb));
    answer = min(answer, synthesis + abs(a - sumc) + abs(b - sumb) + abs(c - suma));
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256