akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = solve <$> f <*> readLn >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int -> String
solve [a, b, c] k = let (b', k') = f a b 0
                        (_, k'') = f b' c k'
                    in bool "No" "Yes" $ k >= k''
  where
    f x y z = if x < y then (y, z) else f x (2 * y) (z + 1)


Measured memory_bytes: 3916
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

    void solve(){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int N = Integer.parseInt(sc.next());

        int[] a = new int[N];
        for(int i=0; i<N; i++){
            a[i] = Integer.parseInt(sc.next());
        }

        sc.close();

        int[] b = new int[N];
        b[0] = a[1] - a[0];
        for(int i=1; i<N-1; i++){
            b[i] = a[i+1] - a[i];
        }
        b[N-1] = K - a[N-1] + a[0];

        // System.out.println(Arrays.toString(b));

        ArrayList<Integer> list = new ArrayList<>();
        for(int i=0; i< N; i++){
            list.add(b[i]);
        }

        Arrays.sort(b);
        int result=0;
        for(int i=0; i<N-1; i++){
            result += b[i];
        }

        System.out.println(result);

    }
}

Measured memory_bytes: 59980
n = int(input())
sl = [input() for _ in [0]*n]
count = 0
dict = {}
for s_raw in sl:
  s = ''.join(sorted(s_raw))
  if s in dict:
    #count += dict[s]
    dict[s] += 1
  else:
    dict.setdefault(s, 1)
for s in dict:
  count += dict[s]*(dict[s]-1)//2
print(count)

Measured memory_bytes: 24976
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<String> list = new ArrayList<String>();
		for(int i= 0;i < N;i++){
			list.add(scan.next());
		}
		
		for(int i = 1;i < N;i++){
			int size = list.get(i-1).length();
			if(list.get(i).charAt(0) != list.get(i-1).charAt(size-1)){
				System.out.println("No");
				return;
			}
			for(int j = 0;j < i;j++){
				if(list.get(i).equals(list.get(j))){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");


	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	string t;
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+"<<endl;
	else if(a*b==15)cout<<"*"<<endl;
	else cout<<"x"<<endl;
}

	


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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;

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

    ll a,b,i=0;
    cin >> a >> b;
    while(a > 0){
        a -= b;
        i++;
    }
    cout << i << endl;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int b[6], a[4];

signed main() {
	rep(i, 6) {
		cin >> b[i];
		a[b[i]]++;
	}
	sort(a, a + 4);
	if (a[3] == 3||(a[0]==0&&a[1]==a[2]&&a[2]==a[3])) {
		cout << "NO" << endl;
		ggr
	}
	cout << "YES" << endl;
	ggr
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,W;
	cin>>n>>W;
	vl w(n),v(n);
	rep(i,0,n) cin>>w[i]>>v[i];
	vl dp(W+1);
	//dp[i]->max value we can get for max capacity of knapsack is i....
	for(int i=0;i<n;i++){
		vl tmp=dp;
		for(int j=w[i];j<=W;j++){
			tmp[j]=max(tmp[j],dp[j-w[i]]+v[i]);
		}
		dp=tmp;
	}
	cout<<dp[W];
	
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

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

int main() {
    string s;
    cin >> s;
    vector<int> vec(s.size());
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '0'){
            vec.at(i) = 0;
        } else if(s.at(i) == '1'){
            vec.at(i) = 1;
        } else if(s.at(i) == '2'){
            vec.at(i) = 2;
        } else if(s.at(i) == '3'){
            vec.at(i) = 3;
        } else if(s.at(i) == '4'){
            vec.at(i) = 4;
        } else if(s.at(i) == '5'){
            vec.at(i) = 5;
        } else if(s.at(i) == '6'){
            vec.at(i) = 6;
        } else if(s.at(i) == '7'){
            vec.at(i) = 7;
        } else if(s.at(i) == '8'){
            vec.at(i) = 8;
        } else {
            vec.at(i) = 9;
        }
    }
    vector<int> num(s.size()-2);
    for(int i = 0; i < s.size()-2; i++){
        num.at(i) = vec.at(i) * 100 + vec.at(i+1) * 10 + vec.at(i+2);
    }
    int sub = 999;
    for(int i = 0; i < num.size(); i++){
        sub = min(sub, abs(num.at(i) - 753));
    }
    cout << sub << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;

    vl p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(all(p));

    ll ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
map<string,int>vis;
int n;
string s[N];
int main()
{
    scanf("%d",&n);
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];vis[s[i]]++;
        mx=max(mx,vis[s[i]]);
    }
    sort(s+1,s+1+n);
    for(int i=1;i<=n;i++)
        if(vis[s[i]]==mx)
    {
        cout<<s[i]<<endl;
        vis[s[i]]=0;
    }
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    sonic();
    int n, ans = 0;
    cin >> n;
    Vec A(n); rep(i, n)cin >> A[i];
    sort(ALLR(A));
    rep(i, n){
        if (i % 2) ans -= A[i];
        else ans += A[i];
    }
    co(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000
#define NIL -1
#define WHITE 0
#define BLACK 1

int prim(int,int(*)[],int[],int[],int[]);

int main() {
    int i,j,n,ans;
    
    scanf("%d",&n);
    int a[n][n],d[n],pi[n],color[n];
    
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) scanf("%d",&a[i][j]);
    }
    
    ans = prim(n,a,d,pi,color);
    
    printf("%d\n",ans);
    
    return 0;
}


int prim(int n,int a[n][n],int d[n],int pi[n],int color[n]) {
    int i,j,u,ans=0;
    int mincost;
    
    for(u=0; u<n; u++) {
        d[u] = MAX;
        pi[u] = NIL;
        color[u] = WHITE;
    }
    
    d[0] = 0;
    pi[0] = NIL;
    
    while(1) {
        mincost = MAX;
        
        for(i=0; i<n; i++) {
            if(color[i]!=BLACK && d[i]<mincost) {
                mincost = d[i];
                u = i;
            }
        }
        
        if(mincost==MAX) break;
        
        color[u] = BLACK;
        
        for(j=0; j<n; j++) {
            if(color[j]!=BLACK && a[u][j]<d[j] && a[u][j]!=NIL) {
                pi[j] = u;
                d[j] = a[u][j];
            }
        }
    }
    
    for(i=0; i<n; i++) ans += d[i];
    
    return ans;
}

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

int main(){
    ll n;
    cin>>n;
    ll a[n+1];
    for(ll i=1;i<n+1;i++)cin>>a[i];
    ll dp[n+5];
    memset(dp,1e9+7,sizeof(dp));
    dp[0]=0;dp[1]=0;
//    cout<<dp[1]<<endl;
    for(ll i=1;i<n+1;i++){
        if(i>2)dp[i]=min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
        dp[i]=min(dp[i],dp[i-1]+abs(a[i-1]-a[i]));
    }
    //for(ll i=0;i<n+1;i++)
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

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

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, P);
    vector<int> a(N);
    read(a);

    i64 cnt[2]{};
    for (int e : a) cnt[e & 1] += 1;

    if (cnt[0] == N) {
        print(P == 0 ? 1LL << N : 0);
    } else {
        print(1LL << (N - 1));
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int gcc(int a, int b)
{
	if(a%b==0)
      return b;
    return gcc(b, a%b);
}
int main(void)
{
	int i, j, k, num, m;
	long sum=0;
	scanf("%d", &num);
	for(i=1;i<=num;i++)
		for(j=1;j<=num;j++)
			for (k = 1; k <= num; k++){
				sum += gcc(i, gcc(j,k));
    }
	printf("%ld", sum);
	return 0;
}

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

const int N = 200 + 5;

int n, m, d[N][N], f[N][N];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%d", &d[i][j]);
    for (int i = 0; i <= 100; ++i)
        for (int j = 0; j <= 100; ++j)
            for (int x = 1; x <= n; ++x)
                for (int y = 1; y <= m; ++y)
                    f[i][j] = max(f[i][j], d[x][y] - i * x - j * y);
    for (int x = 1; x <= n; ++x)
        for (int y = 1; y <= m; ++y) {
            int tmp = INT_MAX;
            for (int i = 0; i <= 100; ++i)
                for (int j = 0; j <= 100; ++j)
                    tmp = min(tmp, i * x + j * y + f[i][j]);
            if (tmp != d[x][y]) { puts("Impossible"); return 0; }
        }
    printf("Possible\n%d %d\n", 202, 10401);
    for (int i = 0; i < 100; ++i) printf("%d %d X\n%d %d Y\n", i + 1, i + 2, 103 + i, 102 + i);
    for (int i = 0; i <= 100; ++i)
        for (int j = 0; j <= 100; ++j) printf("%d %d %d\n", 1 + i, 102 + j, f[i][j]);
    puts("1 102");
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

struct UnionFind {
private:
    vector<int> par,ran;
    vector<int> edge,size;
    int n;
public:
    UnionFind(int x){
      n=x;
      par.resize(n,0);
      ran.resize(n,0);
      edge.resize(n,0);
      size.resize(n,1);
      rep(i,n){
        par[i]=i;
      }
    }
    int find(int x) {
        if (par[x]==x)return x;
        else return par[x]=find(par[x]);
    }
    void unite(int x, int y) {
        x=find(x),y=find(y);
        if (x==y){
            edge[x]++;
            return;
        }
        if (ran[x]<ran[y]) {
            par[x]=y;
            size[y]+=size[x];
            edge[y]+=edge[x]+1;
        }
        else {
            par[y]=x;
            size[x]+=size[y];
            edge[x]+=edge[y]+1;
            if (ran[x]==ran[y])ran[x]++;
        }
    }
    bool same(int x,int y) {
        return find(x)==find(y);
    }
    int getSize(int x){
        return size[find(x)];
    }
    int getEdge(int x){
        return edge[find(x)];
    }
};

int n,q;

void solve(){
  cin >> n >> q;
  UnionFind uf(n);
  rep(i,q){
    int t,u,v;cin >> t >> u >> v;
    if(t==0) uf.unite(u,v);
    else cout << uf.same(u,v) << endl;
  }
}

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

Measured memory_bytes: 6200
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define lli long long int
#define MAX 100000000
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N, M;
    cin >> N >> M;
    vector<pair<lli, lli>> vec;
    pair<lli, lli> tmp;
    for (lli i = 0; i < N; i++)
    {
        cin >> tmp.first >> tmp.second;
        vec.push_back(tmp);
    }
    sort(vec.begin(), vec.end());
    lli n = 0;
    lli answer = 0;
    /*
    for (auto &&i : vec)
    {
        cout << i.first << "," << i.second << endl;
    }
    */

    for (int i = 0; i < vec.size(); i++)
    {
        if (M - n <= vec[i].second)
        {
            answer += vec[i].first * (M - n);
            break;
        }
        else
        {
            n += vec[i].second;
            answer += vec[i].first * vec[i].second;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2420
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			BigInteger a = new BigInteger(scanner.next()), b = new BigInteger(scanner.next());
			System.out.println((a.equals(b) ? "EQUAL" : (a.compareTo(b) < 0) ? "LESS" : "GREATER"));
		}
	}
}


Measured memory_bytes: 35868
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() 
{
    string s,t;
    cin >> s >> t;//改行を気にしない
    int numS[s.length()];
    int numT[t.length()];
    int n = fmin(s.length(), t.length());
    bool answer = false;
    bool answerChecked = false;
    
    for(int i = 0; i < s.length(); i++)
    {
      numS[i] = s[i] - 'a';
    }
    for(int i = 0; i < t.length(); i++)
    {
      numT[i] = t[i] - 'a';
    }
    sort(numS, numS+s.length());
    sort(numT, numT+t.length());

    //cout << n << endl;
    for(int i = 0; i < n; i++)
    {
    //cout << numS[i] << " "<< numT[n-1-i]<< endl;
      if(numS[i] < numT[t.length()-1-i])
      {
        answer = true;
        answerChecked = true;
        break;
      }else if(numS[i] > numT[t.length()-1-i])
      {
        answerChecked = true;
        break;
      }
    }

    if(!answerChecked && n < t.length()) answer = true;

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


Measured memory_bytes: 256
/*AGC*/
#include<stdio.h>

int exchangesCount(int a,int b, int c){
    int as,bs,cs,i=0;
    while(a%2==0 && b%2==0 && c%2==0){
        as=(b+c)/2;
        bs=(c+a)/2;
        cs=(a+b)/2;
        a=as;
        b=bs;
        c=cs;
        i++;
        if(a==b && b==c)return -1;
    }
    return i;
}

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    printf("%d\n",exchangesCount(a,b,c));
    return 0;
}

Measured memory_bytes: 128
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  val INF = 1 << 30
  val value = Array.fill(n)(INF)
  case class Edge(node:Int, cost:Int)
  val graph = Array.fill(n)(mu.ListBuffer.empty[Edge])

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => {
      val l = e(0) - 1
      val r = e(1) - 1
      val d = e(2)
      graph(l) += new Edge(r, d)
      graph(r) += new Edge(l,-d)
    })

  def dfs(node:Int):Unit = {
    type Node = Int
    value(node) = 0
    val stk = mu.Stack.empty[Node]
    stk push node
    while(stk.nonEmpty) {
      val v = stk.pop
      if(graph(v).nonEmpty)
        graph(v).foreach( edge => {
          if(value(edge.node) == INF) {
            value(edge.node) = value(v) + edge.cost
            stk push edge.node
          }
        })
    }
  }

  (0 until n) foreach ( i => if(value(i) == INF) dfs(i) )

  val valid =
    (0 until n).par.forall( i => {
      graph(i).forall( edge => {
        value(i) + edge.cost == value(edge.node)
      })
    })

  val ans = if(valid) "Yes" else "No"
  println(ans)
}

Measured memory_bytes: 106100
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var abc = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        if (abc[0] % 2 == 1 || abc[1] % 2 == 1 || abc[2] % 2 == 1) { WriteLine(0);return; }
        if (abc[0] == abc[1] && abc[0] == abc[2]) { WriteLine(-1);return; }
        var result = 0L;
        while (abc[0] % 2 == 0 && abc[1] % 2 == 0 && abc[2] % 2 == 0)
        {
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
            abc[0] = b / 2 + c / 2;
            abc[1] = a / 2 + c / 2;
            abc[2] = a / 2 + b / 2;
            result++;
        }
        WriteLine(result);
    }
}


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


int main(){
int n ;
cin >> n;
vector<int>h(n);
rep(i,n) cin >> h[i];

int count1 = 0,count2 = 0; 
int ans1 =0,ans2 =0;
rep(i,n-1){
  if(h[i+1]<=h[i]) {count1++;
  ans1 = max(ans1,count1);}
  else count1 = 0;
}
cout << ans1 << endl;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll n,h,w;
    cin >> n >> h >> w;
    int cc=0;

    FOR(i,0,n){
    	ll a,b;
    	cin >> a >> b;

    	if(h<=a && w<=b)
    		cc++;
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();

    int a = 60 * h2 + m2;
    int b = 60 * h1 + m1;

    if (a-b < k) {
      System.out.println(0);
    } else {
      System.out.println(a-b-k);
    }
  }

}


Measured memory_bytes: 35760
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (a, b), (k, l) in d.items():
    now = 1
    now = (now + mod_pow(2, k, mod) - 1) % mod
    now = (now + mod_pow(2, l, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
zeros = zeros % mod
ans = (ans + zeros) % mod
print(ans)

Measured memory_bytes: 60384
#include<stdio.h>
#include<string.h>

#define MAX 1000

int main(){
  int i,j,k,l,m,n,c[MAX+1][MAX+1];
  char X[MAX],Y[MAX];

  scanf("%d",&l);

  for(i=0;i<strlen(X);i++)
    c[i][0] = 0;
  for(j=0;j<strlen(Y);j++)
    c[0][j] = 0;

  for(k=0;k<l;k++){
    scanf("%s",X);
    scanf("%s",Y);
    m = strlen(X);
    n = strlen(Y);
    for(i=0;i<m;i++)
      c[i][0] = 0;
    for(j=0;j<n;j++)
      c[0][j] = 0;

    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
	if(X[i-1] == Y[j-1])c[i][j] = c[i-1][j-1] + 1;
	else if(c[i-1][j] >= c[i][j-1])c[i][j] = c[i-1][j];
	else c[i][j] = c[i][j-1];
      }
    }
    printf("%d\n",c[m][n]);
  }

  return 0;
}



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define ff first
#define ss second 
#define pb push_back
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Craig ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 9999999999999
#define vll vector<ll>
  
int main()
{ 

    ll n,y,i,j;
    cin>>n;
    string s="ACL";
    while(n--)
        cout<<s;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    cout << (r/d-(l-1)/d) << endl;
    return 0;
}


Measured memory_bytes: 3676
H,W = map(int,input().split())

# 1-indexedになるように調整
coin = [None]
for h in range(H):
  coin.append([None]+[int(x) for x in input().split()])

# 各行で右に流して、右端列で下に流せば高々1つを除き完成

moves = []

# row moves
for i in range(1,H+1):
  for j in range(1,W):
    if coin[i][j]%2 == 1:
      coin[i][j] -= 1 # 不要
      coin[i][j+1] += 1
      moves.append((i,j,i,j+1))

# col moves
for i in range(1,H):
  if coin[i][W]%2 == 1:
    coin[i][W] -= 1
    coin[i+1][W] += 1
    moves.append((i,W,i+1,W))

# 出力
N = len(moves)
print(N)
for a,b,c,d in moves:
  print(a,b,c,d)

Measured memory_bytes: 22352
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;

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

string solve(std::vector<int>& stones,int k){
	int n=stones.size();
	bool dp[k+1]={0};
	for(int i=1;i<=k;i++){
		for(int move : stones){
			if(move<=i){
				if(dp[i-move]==0)
					dp[i]=1;
			}
		}
	}
	return dp[k] ? "First" : "Second"; 
}


int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n,k;
    cin>>n>>k;
    vector<int> stones(n);
    for(int i=0;i<n;i++)
    	cin>>stones[i];
    bool flag=1;
    cout<<solve(stones,k);


    return 0;
}

Measured memory_bytes: 3760
#import <stdio.h>
int main(){
    int a[101] = {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,3,8,8,11,11,11,11,14,14,32,32,35,35,35,35,42,42,42,42,49,49,49,49,49,49,75,75,86,86,86,86,86,86,123,123,131,131,131,131,148,148,153,153,170,170,170,170,170,170,227,227,227,227,227,227,250,250,323,323,324,324,324,324,354,354,354,354,384,384,384,384,384,391,491,491,529,529,529,529,529,529,543};
    int n;
    scanf("%d",&n);
    printf("%d",a[n]);
}


Measured memory_bytes: 7624
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N, K;
	cin >> N >> K;
	cout << (K == 1 ? 0 : N - K) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,a,b,c,i,x;
	scanf("%d%d%d",&n,&a,&b);
	x=(a>b?a:b);
	if(n==3){
		scanf("%d",&c);
		x=(x>c?x:c);
		for(i=1;i<=x;i++){
			if(a%i==0&&b%i==0&&c%i==0)
				printf("%d\n",i);
		}
	}
	else{
		for(i=1;i<=x;i++){
			if(a%i==0&&b%i==0)
				printf("%d\n",i);
		}
	}
	return 0;
}



Measured memory_bytes: 2604
#include <iostream>
#include <limits>

int n, k;
long long arr[100010];
long long plus[100010];

long long Psum(int x, int y) {
    if(y < 0)
        return 0;
    if(y >= n)
        y = n - 1;
    if(x > y)
        return 0;

    if(x == 0) {
        return plus[y];
    }else {
        return plus[y] - plus[x - 1];
    }
}

long long Asum(int x, int y) {
    if(y < 0)
        return 0;
    if(y >= n)
        y = n - 1;
    if(x > y)
        return 0;

    if(x == 0) {
        return arr[y];
    }else {
        return arr[y] - arr[x - 1];
    }
}

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

    for(int i = 0; i < n; ++i) {
        std::cin >> arr[i];

        if(arr[i] > 0) {
            plus[i] = arr[i];
        }
    }
    for(int i = 1; i < n; ++i) {
        plus[i] += plus[i - 1];
        arr[i] += arr[i - 1];
    }

    long long ans = std::numeric_limits<long long>::min();
    for(int i = 0; i < n - k + 1; ++i) {
        ans = std::max(ans, Psum(0, i - 1) + Asum(i, i + k - 1) + Psum(i + k, n - 1));
        ans = std::max(ans, Psum(0, i - 1) + Psum(i + k, n - 1));
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<vector<long> > fishrange;
    vector<long> xi;
    vector<long> yi;
    vector<long> di;
    unsigned long long n,k,p,checker;
    unsigned long long volume = 0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        vector<long> v;
        for(int j=0;j<6;j++)
        {
            int h;
            cin>>h;
            v.push_back(h);
        }
        fishrange.push_back(v);
        p = fishrange[i][0];
        xi.push_back(p);
        p = fishrange[i][3];
        xi.push_back(p);
        p = fishrange[i][1];
        yi.push_back(p);
        p = fishrange[i][4];
        yi.push_back(p);
        p = fishrange[i][2];
        di.push_back(p); 
        p = fishrange[i][5];
        di.push_back(p);
        
    }
    sort(xi.begin(),xi.end());
    xi.erase(unique(xi.begin(),xi.end()),xi.end());
    sort(yi.begin(),yi.end());
    yi.erase(unique(yi.begin(),yi.end()),yi.end());
    sort(di.begin(),di.end());
    di.erase(unique(di.begin(),di.end()),di.end());
    
    for(int i=0;i<n*2-1;i++)
    {
        for(int j=0;j<n*2-1;j++)
        {
            for(int l=0;l<n*2-1;l++)
            {
                checker = 0;
                for(int c=0;c<n;c++)
                {
                    if(xi[i]>=fishrange[c][0]&&xi[i+1]<=fishrange[c][3]&&yi[j]>=fishrange[c][1]&&yi[j+1]<=fishrange[c][4]&&di[l]>=fishrange[c][2]&&di[l+1]<=fishrange[c][5])
                    checker++;
                }
                if(checker>=k)
                 volume += (xi[i+1]-xi[i])*(yi[j+1]-yi[j])*(di[l+1]-di[l]);
            }
        }
    }
    
  
    cout<<volume<<endl;
    return 0;
}



Measured memory_bytes: 3140
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int gcd(int a, int b){
        if(b==0){
            return a;
        }
        return gcd(b,a%b);
    }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        int t = ob.nextInt();
        long sum=0;
        for (int i = 1; i <=t ; i++) {
            for (int j = 1; j <=t ; j++) {
                for (int k = 1; k <=t ; k++) {
                    sum+=gcd(i,gcd(j,k));
                }
            }

        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 32776
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
template <typename T, typename U>
using P = pair<T,U>;
template <typename T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
  int K,A,B;
  cin >> K >> A >> B;

  if (B - A <= 2 || A >= K)
  {
    cout << (ll)1+K << endl;
  }
  
  else
  {
    ll ans = A;
    K -= (A-1);
    ans += (ll)(B-A)*(K/2) + K%2;
    cout << ans << endl;    
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, N) {
		ll a;
		cin >> a;
		A.at(a - 1)++;
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	rep(i, K) {
		N -= A.at(i);
	}
	cout << N << endl;
}

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

int main() {
    long long int x, y;
    cin >> x >> y;
    int cnt = 1;
    long long int n = y/x + 1;
    for(int i = 0; i < n; i++){
        if(x * 2 > y){
            break;
        }else{
            x *= 2;
            cnt++;
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;


void solve(){
  int n, m; cin >> n >> m;
  int ans = ((1900 * m) + (100 * (n - m))) * pow(2, m);
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    n=int(input())
    A=[list(map(int,list(input()))) for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==0): A[i][j]=INF
    B=[a[:] for a in A] # deep copy
    E=[[] for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==1): E[i].append(j)

    # bipartile check
    from collections import deque
    d=[-1]*n # -1: unvisited
    def bfs(v)->bool:
        # initialize
        if(d[v]!=-1): return True
        d[v]=0
        Q=deque([v])
        while(Q):
            v=Q.popleft()
            for nv in E[v]:
                if(d[nv]==-1):
                    d[nv]=d[v]^1
                    Q.append(nv)
                else:
                    if(d[nv]^d[v]==0):
                        return False
        return True

    for v in range(n):
        if(not bfs(v)):
            print(-1)
            return

    # Warshall-Floyd
    for k,i,j in product(range(n),repeat=3):
        B[i][j]=min(B[i][j],B[i][k]+B[k][j])

    # output
    diam=0
    for i,j in product(range(n),repeat=2):
        if(B[i][j]==INF): continue # connectedなので必要ない
        diam=max(diam,B[i][j])
    print(diam+1)
resolve()

Measured memory_bytes: 58460
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

uintmax_t combination(unsigned int n, unsigned int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

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

	ll  d, n, r ,l ,k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	cin >> n;
	vll v(n);
	rep(i,n)cin >> v[i];
	rep(i, n) {
		if (v[i] > i + 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	vll qu, rec;
	vll chk(n,0);
	vb x(n);
	while (rec.size() != n) {
		repr(i, n) {
			if (v[i] <= i + 1 && v[i] <= chk[i] + 1 && !x[i]) {
				rec.pb(v[i]);
				REP(j,i,n)chk[j]++;
				//cout << chk[8] << " " << v[i]<< endl;
				x[i] = true;
				break;
			}
		}
	}
	rep(i, rec.size()) cout << rec[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int main(void){
    // Your code here!
   int N,M,C;
   cin >> N >> M >> C;
   vector<int> B(M);
   for(int i = 0; i < M; i++) cin >> B.at(i);
   int count = 0;
   for(int i = 0; i < N; i++){
       int sum = C;
       vector<int> A(M);
       for(int j = 0; j < M; j++){
           cin >> A.at(j);
       }
       
       for(int j = 0; j < M; j++){
           sum += A.at(j) * B.at(j);
       }
       if(sum > 0) count++;
   }
   cout << count << endl;
   
   
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j;

	while(1)
	{
	    scanf("%d %d", &H, &W);
	
		if (H + W == 0)break;

		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				if ((i + j) % 2 == 0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2116
#include<stdio.h>

int a[200],b;
int a_num,b_num,j=0;

int solve(int, int);
int main()
{

  int b_num,i,j = 0;


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

  scanf("%d",&b_num);
  for(i = 0;i < b_num; i++){
    scanf("%d",&b);
    j = 0;
    if(solve(j,b) == 1){
      printf("yes\n");
    }
    if(solve(j,b) == 0){
      printf("no\n");   
    }
  }
  
  return 0;
}


int solve(int i,int m)
{
  int res;
  if(m == 0)return 1;
  if(i >= a_num)return 0;
  res = solve(i+1,m) || solve(i+1,m-a[i]);
}
      

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    vector<int>a(3);
    int cnt1=0,cnt2=0;
    rep(i,3){
        cin>>a[i];
        if(a[i]==5){
            cnt1++;
        }
        else if(a[i]==7){
            cnt2++;
        }
    }
    if(cnt1==2&&cnt2==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>>
#include<string.h>
int main()
{
    char S[21],T[21],U[21];
    scanf("%s %s",S,T);
    int s,t;
    scanf("%d %d %s",&s,&t,U);
    if(strcmp(U,S)==0)
        printf("%d %d",s-1,t);
    else
        printf("%d %d",s,t-1);
    return 0;
}


Measured memory_bytes: 128