akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int m;
	cin >> m;
	int b[m];
	for(int i = 0; i < m; i++)cin >> b[i];
	for(int i = 0; i < m; i++){
		if(!binary_search(a, a + n, b[i])){
			cout << 0 << '\n';
			return 0;
		}
	}
	cout << 1 << '\n';
    return 0;
}



Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)

bool isInclude(pair<lli,lli> left, pair<lli,lli> right,pair<lli,lli> target){
	if(left.first <= target.first && target.first <= right.first){
		if(left.second <= target.second && target.second <= right.second){
			if(DEBUG)cout<<"include!"<<endl;
			return true;
		}
	}
	return false;
}

int main(){

	lli n,k;
	cin>>n>>k;
	vector<pair<lli,lli>> v(n);
	REP(i,n)cin>>v[i].first>>v[i].second;

	/*2点選んで、そこでできた長方形の中に点が何個含まれているかを数える。*/
	/*条件を満たしている場合のみカウントする*/

	lli ans = 8000000000000000000;
	REP(ix,n)REP(jx,n)REP(iy,n)REP(jy,n){
		pair<lli,lli> left;
		pair<lli,lli> right;
		left.first  = min(v[ix].first,v[jx].first);
		left.second = min(v[iy].second,v[jy].second);
		right.first = max(v[ix].first,v[jx].first);
		right.second= max(v[iy].second,v[jy].second);

		if(DEBUG)cout<<"leftF = "<<left.first<<"leftS="<<left.second;
		if(DEBUG)cout<<"rightF= "<<right.first<<"right.S="<<right.second;
		lli space = abs(right.first-left.first)*abs(left.second-right.second);

		/*条件判定*/
		lli cnt=0;
		REP(target,n){
			if(DEBUG)cout<<"target="<<target<<endl;
			if(isInclude(left,right,v[target]))cnt++;
		}
		if(cnt>=k)ans = min(ans,space);
	}
	cout<<ans<<endl;

	return 0;
}

 

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

void solve()
{
    long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn=0,mx,a[10];

    cin >> n;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                kk=__gcd(i,j);
                z=__gcd(kk,k);
                mn+=z;
            }
        }
    }

    cout << mn << endl;

}

int main()
{
     long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn,mx;

     //cin >> t;

     //while(t--)
     solve();

}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
	int K,A,B,i;
	char str1[1000],str2[1000];
 
	fgets(str1, sizeof(str1), stdin);
	fgets(str2, sizeof(str2), stdin);
	
	if(strncmp(str1,str2,(strlen(str1)-1)) == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int A[200010];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	ARY_SORT(A, N);

	for (int i = 0; i < N - 1; i++)
	{
		if (A[i] == A[i + 1])
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    char c;
    cin >> c;
    
    if(c == 'A')
    {
        cout << 'T';
    }
    else if(c == 'T')
    {
        cout << 'A';
    }
    else if(c == 'C')
    {
        cout << 'G';
    }
    else
    {
        cout << 'C';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

using namespace std;

int main()
{
    int N;cin >> N;
    int Y;cin >> Y;
    vector<int> sen,man,gosen;
    for(int a = 0;a < (Y/10000)+1;a++){
        int ins = Y-(a*10000);
        for(int b = 0;b < (ins/5000)+1;b++){
            int s = ins;
            s = s-(b*5000);
            s /= 1000;
            if(a+b+s == N){
                sen.push_back(s);
                man.push_back(a);
                gosen.push_back(b);
            }
            //cout<<a<<" "<<b<<" "<<s<<endl;
        }
    }
    if(sen.empty()){
        cout<<-1<<" "<<-1<<" "<<-1<<endl;
    }else{
        cout<<man.front()<<" "<<gosen.front()<<" "<<sen.front()<<endl;
    }
    return 0;
}


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

const ll INF = -1e18;
int n;

vector<ll> a(202020);
vector<vector<ll>> dp(3, vector<ll>(202020, INF));

int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];
  	
    rep(i, 3) dp[i][i] = a[i];
    for(int i = 0; i < n - 2; i++)
    {
        
        dp[0][i + 2] = max(dp[0][i + 2], dp[0][i] + a[i + 2]);
        dp[1][i + 3] = max(dp[1][i + 3], dp[0][i] + a[i + 3]);
        dp[2][i + 4] = max(dp[2][i + 4], dp[0][i] + a[i + 4]);
        
        dp[1][i + 2] = max(dp[1][i + 2], dp[1][i] + a[i + 2]);
        dp[2][i + 3] = max(dp[2][i + 3], dp[1][i] + a[i + 3]);
        

        dp[2][i + 2] = max(dp[2][i + 2], dp[2][i] + a[i + 2]);
    }

    
    ll res = INF;
    if(n % 2 == 1)
    {
        res = max(res, dp[0][n - 3]);
        res = max(res, dp[1][n - 2]);
        res = max(res, dp[2][n - 1]);
    }
    else
    {
        res = max(res, dp[0][n - 2]);
        res = max(res, dp[1][n - 1]);
    }
    
    cout << res << endl;

    
    return 0;
}


Measured memory_bytes: 10936
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = 1_000_000_007;

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

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		List<Pair<Integer,Integer>> list = new ArrayList<Pair<Integer,Integer>>();
		
		for(int i = 0; i < n; i++) {
			list.add(new Pair<Integer,Integer>(sc.nextInt(),sc.nextInt()));
		}
		
		list.sort((a,b) -> a.getValue() - b.getValue());
		
		long sum = 0;
		int end = 0;
		
		for(int i = 0; i < n; i++) {
			if(end != list.get(i).getValue()) {
				end = list.get(i).getValue();
				sum+=list.get(i).getKey();
			}else{
				sum+=list.get(i).getKey();
			}
			if(end < sum) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
		
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long min(long... a) {
		long min = Long.MAX_VALUE;
		for(int i = 0; i < a.length; i++) {
			if(a[i] < min) min = a[i];
		}
		return min;
	}

	public static long max(long... a) {
		long max = Long.MIN_VALUE;
		for(int i = 0; i < a.length; i++) {
			if(a[i] > max) max = a[i];
		}
		return max;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL as(N), bs(N);
  cin >> as >> bs;

  VL ds(N);
  REP(i,N) ds[i] = as[i] - bs[i];
  SORT(ds);

  if(ds[0] >= 0){
    cout << 0 << endl;
    return 0;
  }
  if(accumulate(ALL(ds), 0ll) < 0){
    cout << -1 << endl;
    return 0;
  }

  LL acc = 0;
  int ans = 0;
  for(int b=0,e=N-1;b<=e;){
    if(ds[b] >= 0) break;
    if(ds[b] + acc >= 0){
      acc += ds[b];
      ++ans;
      ++b;
    }
    else{
      acc += ds[e];
      ++ans;
      --e;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 3000
#define INF 1001001001
struct edge{
    int from, to, cost;
};

int main() {
    int n,m,p;
    cin >> n >> m >> p;
    int d[MAX_N];
    int d2[MAX_N];
    vector<edge> edges;
    vector<edge> edges2;

    rep(i,m){
        edge e;
        cin >> e.from >> e.to >> e.cost;
        e.cost *= -1;
        e.cost += p;
        edges.push_back(e);
        edge e2;
        e2.to = e.from;
        e2.from = e.to;
        e2.cost = 1;
        edges2.push_back(e2);
    }

    fill(d,d+MAX_N,INF);
    d[1] = 0;

    srep(i,1,n+1){
        rep(j,edges.size()){
            edge e = edges[j];
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    
    int tmp[n];
    rep(i,n+1){
        tmp[i] = d[i];
    }

    srep(i,1,n+1){
        rep(j,edges.size()){
            edge e = edges[j];
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    rep(i,n+1){
        if(d[i] < tmp[i] && d[i] < INF/2){
            tmp[i] = -INF;
        }
    }

    int ans = tmp[n];

    if(ans == -INF){
        cout << "-1" << endl;
        return 0;
    }

    fill(d2,d2+MAX_N,INF);
    d2[n] = 0;
    srep(i,1,n+1){
        rep(j,edges2.size()){
            edge e = edges2[j];
            if(d2[e.to] > d2[e.from] + e.cost){
                d2[e.to] = d2[e.from] + e.cost;
            }
        }
    }

    

    srep(i,1,n+1){
        if(tmp[i]==-INF && d2[i]<INF/2 && d[i]<INF/2){
            cout << "-1" << endl;
            return 0;
        }
    }

    if(ans>0){
        ans = 0;
    }else{
        ans = -ans;
    }
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 512
r, c = map(int, input().split())

table = []
for i in range(r):
    array = list(map(int, input().split()))
    table.append(array)

ans = 0
for i in range(r):
    for j in range(c):
        print('{} ' .format(table[i][j]), end='')
        ans += table[i][j]
    print(ans)
    ans = 0

total = 0
for i in range(c):
    for j in range(r):
        ans += table[j][i]
    print('{} ' .format(ans), end='')
    total += ans
    ans = 0
print(total)



Measured memory_bytes: 6252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;}

int main()
{   
    int n; cin >> n;
    vector<double> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    double dp[3000][3000] = {0.0}; //[投げたコイン][表の数]
    dp[0][0] = 1.0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1- p[i]);
        }
    }
    double res = 0.0;
    for(int i=(n+1)/2;i<=n;i++) res += dp[n][i];
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 70528
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#define T long long

int n,m,q;
std::vector<int > a,b,c,d;
int list[10];
T calc(){
	T result = 0;
	for(int i=0;i<q;i++){
		if((list[b[i]]-list[a[i]])==c[i]){
			result += d[i];
		}
	}

	return result;
}

T search(int itr,int prev){
	if(itr == n){
		return calc();
	}
	T max = 0;
	for(int i=prev;i<m;i++){
		list[itr]=i;
		T score = search(itr+1,i);
		if(score >max){
			max = score;
		}
	}
	return max;
}

int main(){
	std::cin >> n>>m>>q;
	T m=100;
	for(int i=0;i<q;i++){
		int ai,bi,ci,di;
		std::cin >> ai>>bi>>ci>>di;
		a.push_back(ai-1);
		b.push_back(bi-1);
		c.push_back(ci);
		d.push_back(di);
	}
	std::cout << search(0,0)<<std::endl;
}


Measured memory_bytes: 3628
// 2013/05/12 Tazoe

#include <iostream>
#include <vector>
using namespace std;

bool isSequence(vector<int>& v)
{
	int d = v[1]-v[0];

	for(int i=1; i<v.size()-1; i++){
		if(v[i+1]-v[i]!=d)
			return false;
	}

	return true;
}

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

		if(n==0)
			break;

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

		for(int i=0; i<n+1; i++){
			vector<int> tmp = h;
			tmp.erase(tmp.begin()+i);

			if(isSequence(tmp)){
				cout << h[i] << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

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

int main(void)
{
    int q1, b, c1, c2, q2;
    int aChick, bChick, newChick;
    int flag;
    
    while (1){
        scanf("%d", &q1);
        
        if (q1 == 0){
            break;
        }
        
        scanf("%d%d%d%d", &b, &c1, &c2, &q2);
        
        aChick = min(q2, b / c1);
        b -= aChick * c1;
        
        bChick = b / c2;
        b -= bChick * c2;
        
        flag = 0;
        while (aChick != 0){
            if (aChick + bChick >= q1){
                printf("%d %d\n", aChick, bChick);
                flag = 1;
                break;
            }
            aChick--;
            b += c1;
            bChick += b / c2;
            newChick = b / c2;
            b -= newChick * c2;
        }
        
        if (!flag){
            printf("NA\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = int(math.MaxInt32)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func uniqIntSlice(a []int) []int {
	m := make(map[int]struct{})
	for _, v := range a {
		m[v] = struct{}{}
	}
	u := []int{}
	for k := range m {
		u = append(u, k)
	}
	return u
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

//a:old b:new a>b -> a=b (update) more small
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax64(a *int64, b int64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func main() {
	const W = 110000
	n := nextInt()
	w := int64(nextInt())
	wi := make([]int64, n)
	v := make([]int64, n)
	for i := 0; i < n; i++ {
		wi[i] = int64(nextInt())
		v[i] = int64(nextInt())
	}
	dp := make([][]int64, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int64, W)
	}
	for i := 0; i < n; i++ {
		for sum := int64(0); sum <= w; sum++ {
			if sum-wi[i] >= 0 {
				chmax64(&dp[i+1][sum], dp[i][sum-wi[i]]+v[i])
			}
			chmax64(&dp[i+1][sum], dp[i][sum])
		}
	}
	fmt.Println(dp[n][w])
}


Measured memory_bytes: 89984
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7

factorial=[1 for i in range(n+2)]
for i in range(1,n+2):
    if i==1:factorial[i]=1
    else:factorial[i] = factorial[i-1]*i % mod

def comb(n,k):
    return factorial[n]*pow(factorial[n-k]*factorial[k], -1, mod)

mc = Counter(a).most_common()[0][0]

indices=[]
for i in range(n+1):
  if a[i]==mc:indices.append(i)
    
m = [indices[0]+1,n+1-indices[1]]
m = sorted(m)
    
for i in range(1,n+2):
  if i == 1:
    print(n)
    continue
  if i == n+1:
    print(1)
    continue
  if i <= m[0]+m[1]-1:
    print((comb(n+1,i) - comb(m[0]+m[1]-2,i-1)) % mod)
  else:
    print(comb(n+1,i) % mod)

Measured memory_bytes: 30716
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL h, n;
  cin >> h >> n;
  VLL A(n);
  INPUT(A);
  REP(i, n) h -= A[i];
  if (h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
#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<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ld x,s=100;cin>>x;
    int cnt=0;
    while(s<x){
        s*=1.01;
        ll m=s;
        s=(ld)m;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
	 int n,m;
	 cin>>n>>m;
	 int min,max;
	 min=m-n+1;
	 max=m+n-1;	
	 for(int i=min;i<=max;i++){
		 cout<<i<<" ";
	 }
	 cout<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc101_a(){
    //入力
    string s;
    cin >> s;
    int ans = 0;
    
    //処理
    REP(i,4){
        if(s[i]=='+') ans++;
        else ans--;
    }
    
    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;
int a,n,b[11];
bool vis[11],ans=false;
int main(){
	for(int i=1;i<=9;i++)
	{
		cin>>b[i];
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		for(int j=1;j<=9;j++)
		{
			if(a==b[j])vis[j]=true;
		} 
	}
	if((vis[1]==true&&vis[4]==true&&vis[7]==true)||(vis[2]==true&&vis[5]==true&&vis[8]==true)
	||(vis[3]==true&&vis[6]==true&&vis[9]==true))ans=true;
	if((vis[1]==true&&vis[2]==true&&vis[3]==true)||(vis[4]==true&&vis[5]==true&&vis[6]==true)
	||(vis[7]==true&&vis[8]==true&&vis[9]==true))ans=true;
	if((vis[1]==true&&vis[5]==true&&vis[9]==true)||(vis[3]==true&&vis[5]==true&&vis[7]==true))
	ans=true;
	if(ans==true)cout<<"Yes";
	else cout<<"No"; 
    return 0;
}

Measured memory_bytes: 256
k, a, b = list(map(int,input().split()))

if b - 1 <= a:
    print(k + 1)
    exit()
if k <= 2:
    print(k+1)
    exit()

diff = b - a
k -= a + 1
n = k // 2
rest = k % 2
if n == 0:
    print(b + rest)
    exit()
print(b + n * diff + rest)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
ll geti(){
    ll ret=0;char ch=getchar(),k=1;
    while((ch<'0' || ch>'9') && ch!='-')ch=getchar();
    if(ch=='-')k=0,ch=getchar();
    while(ch>='0' && ch<='9')ret=ret*10+ch-'0',ch=getchar();
    return k?ret:-ret;
}
const int maxn = 200000 + 52;
ll n,k,N;
struct pre{
    ll s,pos;
}t[maxn];
ll a[maxn],mx[maxn],s[maxn],ts[maxn];
bool cmp(const pre &x,const pre &y){
    return x.s<y.s;
}
int lowbit(int x){
    return x&(-x);
}
void inc(int x){
    for(int i=x;i<=N;i+=lowbit(i)) mx[i]+=1;
}
int query(int x){
    int ret=0;
    for(int i=x;i;i-=lowbit(i)) ret+=mx[i];
    return ret;
}
int main(){
    n=geti(); k=geti();
    for(int i=1;i<=n;i+=1) a[i]=geti();
    for(int i=1;i<=n;i+=1) a[i]-=k;
    for(int i=1;i<=n;i+=1) t[i].s=t[i-1].s+a[i],t[i].pos=i,ts[i]=t[i].s;
    sort(t+1,t+1+n,cmp);
    int ss=2;
    for(int i=1;i<=n;i+=1){
        if(i!=1 && t[i].s!=t[i-1].s){
            ++ss;
        }
        s[t[i].pos]=ss;
    }
    N=ss+10;
    ll ans=0;
    for(int i=1;i<=n;i+=1){
        ans+=query(s[i]);
        inc(s[i]);
        if(ts[i]>=0) ++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9600
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

// #define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int num;
  string s; cin >> s;
  string t; cin >> t;
  num = 0;
  for (int i = 0; i < 3; ++i) if (s[i] == t[i]) ++num;
  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cassert>
// using namespace std;
// #define int long long
#define REP(i,s,n) for (int i = (s); i < (n); ++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; i--)
#define INF (int)(1e9+7)
#define space " "
#define ENDL "\n"
#define MAXL 100

int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};

inline void init() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
}
// アドレスを渡すのを間違えないように!!
inline void nextInt(int *a) { scanf("%d", a); }
inline void nextInt(int *a, int *b) { scanf("%d %d", a, b); }
inline void nextInt(int *a, int *b, int *c) { scanf("%d %d %d", a, b, c); }
inline void nextDouble(double *a) { scanf("%lf", a); }
inline void nextDouble(double *a, double *b) { scanf("%lf %lf", a, b); }
inline void nextDouble(double *a, double *b, double *c) { scanf("%lf %lf %lf", a, b, c); }
inline void nextLine(char *c) { scanf("%s", c); getchar();/*改行の読み捨て*/ }
inline std::string nextLine() {
    std::string s = ""; char str[MAXL+1];
    scanf("%s", str); getchar(); /*改行の読み捨て*/
    return s += str;
}
inline void print(double *a, int n = 0) {
    std::cout << std::fixed << std::setprecision(n) << *a << ENDL;
}
inline void print(int a) {
    printf("%d\n", a);
}

int n, x = 0, maxx = 0;
std::string s;

int main() {

    init();
    std::cin >> n;
    std::cin >> s;

    rep(i,n) {
        if (s[i] == 'I') {
            x++;
            if (x > maxx) maxx = x;
        } else {
            x--;
            if (x > maxx) maxx = x;
        }
    }

    std::cout << maxx << ENDL;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;

int main() {
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    #ビット全探索を行う
    import itertools
    li = list(itertools.product([0, 1], repeat=n)) # ０が不親切もの、１が親切もの

    #dd[i][x] = y:人iが人xをy（０なら不親切,１なら親切)だと思っていることを収納
    NIL = -1
    dd = [[NIL]*n for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = map(int, input().split())
            x = x-1
            dd[i][x] = y


    from copy import deepcopy
    max_sum = 0 #親切者の数の最大値
    for i in li: # i には親切者のタプルが入っている
        ppp = 0
        for ggg in i:
            ppp += ggg
        if ppp <= max_sum:
            continue
        sum_ = 0
        flag = True
        for k in range(len(i)): #全員の証言が矛盾しないかを考える
            if i[k] == 0: # 不親切ものの場合
                continue
            else: #以下k人目の証言を考える
                sum_ += 1
                for l in range(n):
                    if dd[k][l] != NIL and dd[k][l] != i[l]: #証言と一致していない場合
                        flag = False
                        break
        if flag:
            max_sum = max(max_sum, sum_)

    print(max_sum)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 50412
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<map>
//#define ll long long
using namespace std;
const int maxn=100010;
int v[maxn];
int plate[maxn];

int main( )
{
    int a,b,c,x,y;
    long long sum;
    cin>>a>>b>>c>>x>>y;//一盒南方规则棋盘价格为A，一盒北方规则棋盘价格为B
                      //X盒适用南方规则的棋盘和Y盒北方规则的棋盘
    int k=min(x,y);
    if(2*c<a+b)
        sum=c*k*2;
    else
        sum=(a+b)*k;
   
    if(x>k)
    {
        if(2*c<a)
            sum+=2*c*(x-k);
        else
            sum+=a*(x-k);
    }
    if(y>k)
    {
        if(2*c<b)
            sum+=2*c*(y-k);
        else
            sum+=b*(y-k);
    }
    cout<<sum;
	 return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
string a,b="CODEFESTIVAL2016";
int c=16;
int main()
{
    cin>>a;
    for(int i=0;i<16;i++)
    	c-=(a[i]==b[i])?1:0;
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, Q;
    cin >> n >> Q;

    vector<ll> t(Q), v(Q);
    rep(i, Q) {
        cin >> t[i] >> v[i];
        v[i]--;
    }

    ll W = n-1, H = n-1;
    vector<ll> a(n), b(n);

    ll black = (n - 2) * (n - 2);
    rep(i, Q) {
        if (t[i] == 1) {
            // 横
            for (ll x = v[i]; x < W; x++) {
                // これより→はひっくりかえせる数は変動しないので確定される
                a[x] = H;
            }
            if (v[i] < W) W = v[i];
            black -= a[v[i]] - 1;
        }
        else {
            // 縦
            for (ll x = v[i]; x < H; x++) {
                b[x] = W;
            }
            if (v[i] < H) H = v[i];
            black -= b[v[i]] - 1;
        }
    }
    
    put(black)
}
signed main(){ Main();return 0;}

Measured memory_bytes: 9572
I,*U=N,*D=9**9,
P,*L='x+y,',
M,*R='x-y,',
for t in[*open(0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S in(D,U,'x,y,'),(L,R,'y,x,'),(U,R,P+M),(L,D,P+M),(L,U,M+P),(D,R,M+P):
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in P)'%S):
  if r:S,p=x,y
  elif x==S:N=min(N,y-p)
print(N%I*5or'SAFE')

Measured memory_bytes: 72464
#include <bits/stdc++.h>
using namespace std;
long long a[200002];
long long b[200002];
long long s[200002];
int check(long long mid,long long q,int n)
{
	for(int i=0;i<n;i++)
	{
		if(s[i]>mid)
		{
			long long u=mid/b[i];
			u=a[i]-u;
			q-=u;
			if(q<0) return 0;
		}
	}
	return 1;
}
int main()
{
	int n;
	long long k;
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++) scanf("%lld",&b[i]);
	sort(a,a+n);
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++)
	{
		s[i]=a[i]*b[i];
	}
	long long r=1000000000000,l=0;
	while(r>l)
	{
		long long mid=l+(r-l)/2;
		if(check(mid,k,n))
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	//	cout<<r<<' '<<l<<endl;
	}
	printf("%lld",r);
	return 0;
} 

Measured memory_bytes: 4992
// Last Change: 07/20/2019 23:03:49.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const ll INF = numeric_limits<ll>::max();

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (auto &&e : A) {
    cin >> e;
  }

  vector<vector<ll>> dp(2, vector<ll>());
  dp[0].push_back(-1);
  dp[1].push_back(INF);
  for (ll i = 0; i < N; ++i) {
    ll tar = A[i], pos;
    // lower_bound
    ll left, right, center, tmp;
    left = dp.size() - 2;
    right = 0;
    while (left > right) {
      center = left - (left - right) / 2;
      tmp = dp[center][0];
      if (tmp < tar) {
        left = center - 1;
      } else {
        right = center;
      }
    }
    pos = right + 1;

    if (dp[pos][0] == INF) {
      dp.push_back(vector<ll>());
      dp[pos + 1].push_back(INF);
    }
    dp[pos].push_back(tar);
    dp[pos][0] = tar;
  }
  /*
    for (auto &&e : dp) {
      for (auto &&f : e) {
        if (f == INF) {
          cout << "INF ";
        } else {
          cout << f << ' ';
        }
      }
      cout << endl;
    }
  */
  cout << dp.size() - 2 << endl;
}


Measured memory_bytes: 7604
import java.util.*;

class Main{
public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int k = sc.nextInt();
  
  int sum = Math.min(a,k) + 0*(Math.min(k-Math.min(a,k),b)) + (-1)*(k-Math.min(a,k)-Math.min(k-Math.min(a,k),b));
  System.out.println(sum);
  
  sc.close();
}//void
}//class

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

int main(){
  string S,T="";
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      T.push_back('0');
    }
    else if(S.at(i)=='1'){
      T.push_back('1');
    }
    else if(T.size()!=0){
      T.pop_back();
    }
  }
  cout << T << endl;
} 

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


void solve(long long N, long long K, std::vector<long long> A){
  map<long long, long long> counts;
  vector<long long> values;

  for(long long i = 0; i < N; i++){
    counts[A[i]]++;
  }
  for(auto a: counts){
    values.push_back(a.second);
  }

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

  if(values.size() <= K) {
    cout << 0 << endl;
  }
  else {
    long long acc = 0;
    for(long long i = 0; i < (values.size() - K); i++) {
      acc += values[i];
    }

    cout << acc << endl;
  }

  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;



int main(){
    int n,x,t;
    cin>>n>>x>>t;

    cout<<(int)(ceil((double)n/x))*t;
}

Measured memory_bytes: 3632
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A =[[int(j) for j in input().split()] for i in range(N)]

ans=0
for i in A:
    sum=C
    for x in range(M):
        sum+=i[x]*B[x]
    if sum>0:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define min(a,b) (a<b?a:b)
int main(){
	int i,n,m,x,a[1001],sum1=0,sum2=0;
  	scanf("%d%d%d",&n,&m,&x);
  	for(i=0;i<m;i++){
		scanf("%d", &a[i]);
      	if(a[i]<x){
		sum1++;
        }else{
		sum2++;
        }
    }

  	printf("%d",min(sum1,sum2));
}
  	

Measured memory_bytes: 128
n = int(input())
s = input()

cnt = 0
for i in range(n-2, -1, -1):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        s = s[0:i+1] + s[i+1+cnt:]
        cnt = 0

print(len(s[cnt:]))

Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
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;}
const int MOD = 1e9+7;

signed main(){
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {

    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    if(a[0] == a[1] && a[1] == a[2]) cout << 1 << endl;
    else if(a[0] == a[1] || a[1] == a[2] || a[2] == a[0]) cout << 2 << endl;
    else cout << 3 << endl;

    return 0;

}

Measured memory_bytes: 256
n = int(input())
ids = [input() for _ in range(n)]
m = int(input())
cnt = 0
for _ in range(m):
  t = input()
  if t in ids:
    cnt += 1
    move = ["Closed by", "Opened by"]
    print(move[cnt % 2], t)
  else:
    print("Unknown", t)


Measured memory_bytes: 5608
def main():
	N = int(input())
	p = 1000000007
	ten = [10]
	nine = [9]
	eight = [8]
	for i in range(23):
		ten.append((ten[-1] ** 2) % p)
		nine.append((nine[-1] ** 2) % p)
		eight.append((eight[-1] ** 2) % p)

	t = 1
	n = 1
	e = 1

	b_N = format(N, 'b')
	for i in range(len(b_N)):
		if b_N[- 1 - i] == "1":
			t = (t * ten[i]) % p
			n = (n * nine[i]) % p
			e = (e * eight[i]) % p
	print((t - 2 * n + e) % p)

main()

Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


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

	int n;
	cin >> n;
	rep(i, 10) {
		rep(j, 10) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	int w, h;

	while( 1 ) {
		cin >> h >> w;
		if( h == 0 && w == 0 ) break;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				cout << "#" ;
			}
			cout << endl;
		}
		cout << endl;
	}
 
	//while (1){}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    if(n==0) break;
    char t[n];
    char kt;
    int tt[2][n];
    int k;
    int h;
    for(int i=0;i<2;i++){
      for(int j=0;j<n;j++){
	tt[i][j] = 0;
      }
    }
    for(int i=0;i<n;i++){
      cin >> t[i];
      for(int j=0;j<n-1;j++){
	cin >> h;
	if(h==0) tt[0][i] += 1;
	if(h==1) tt[1][i] += 1;
      }
    }
    for(int i=n-1;i>0;i--){
      for(int j=0;j<i;j++){
	if(tt[0][j]<tt[0][j+1]){
	  k = tt[0][j];
	  tt[0][j] = tt[0][j+1];
	  tt[0][j+1] = k;
	  k = tt[1][j];
	  tt[1][j] = tt[1][j+1];
	  tt[1][j+1] = k;
	  kt = t[j];
	  t[j] = t[j+1];
	  t[j+1] = kt;
	}
	else if(tt[0][j]==tt[0][j+1]&&tt[1][j]>tt[1][j+1]){
    	  k = tt[0][j];
	  tt[0][j] = tt[0][j+1];
	  tt[0][j+1] = k;
	  k = tt[1][j];
	  tt[1][j] = tt[1][j+1];
	  tt[1][j+1] = k;
	  kt = t[j];
	  t[j] = t[j+1];
	  t[j+1] = kt;
	}
      }
    }
    for(int i=0;i<n;i++) cout << t[i] << endl;
  }
  return 0;
}

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


int main()
    {
        int n;
        cin>>n;
        if(n%2==1)
        cout<<'0';
        else{
            int arr[n];
            for(int i=0;i<n;i++)cin>>arr[i];
            sort( arr , arr+n);
        
            cout<<arr[(n/2)]-arr[(n/2)-1];
        
        
        }
	return 0;
}


Measured memory_bytes: 768
<?php
$n=trim(fgets(STDIN));
$a=explode(' ',trim(fgets(STDIN)));

$mi=$mx=$sm=$a[0];

for($i=1;$i<$n;$i++){
  $ai=$a[$i];
  if($ai<$mi){$mi=$ai;}
  elseif($mx<$ai){$mx=$ai;}
  $sm+=$ai;
}

echo $mi,' ',$mx,' ',$sm;
?>

Measured memory_bytes: 16740
#include <stdio.h>

int main(void){
   char S[200001];
   int i,buf,sum=0;
  
   scanf("%s",S);
   i = 0;
	while(S[i] != '\0'){
		sum+=(S[i]-48);
		i++;
	}
   
   if(sum%9==0)
  printf("Yes\n");
   else
  printf("No\n");
   return 0;
}


Measured memory_bytes: 1784
N, M = map(int, input().split())
matrix = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    matrix[a-1].append(b-1)
    matrix[b-1].append(a-1)

for i in matrix[0]:
    if N-1 in matrix[i]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 38296
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, k, res = 0;
    cin >> n >> k;

    if (n >= 10) res = k;
    else res = k + 100 * (10 - n);

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int H, W;
    cin >> H >> W;
    string s;
    vector<int> c(26, 0);
    for (int i = 0; i < H; i++) {
        cin >> s;
        for (int j = 0; j < W; j++) {
            c[s[j] - 'a']++;
        }
    }

    int odd, two;
    odd = 0; two = 0;
    for (int i = 0; i < 26; i++) {
        if(c[i] % 2 == 1){
            odd++;
        }
        if(c[i] % 4 == 2 || c[i] % 4 == 3){
            two++;
        }
    }

    bool ans = false;
    if(H%2 == 0 && W%2 == 0){
        if(odd == 0 && two == 0){
            ans = true;
        }
    }
    else if(H%2 == 1 && W%2 == 1){
        if(odd <= 1 && two <= (H+W-2)/2){
            ans = true;
        }
    }
    else if(H%2 == 1){
        if(odd == 0 && two <= W/2){
            ans = true;
        }
    }
    else{
        if(odd == 0 && two <= H/2){
            ans = true;
        }
    }

    if(ans){
        Yes();
    }
    else{
        No();
    }

}

Measured memory_bytes: 3608