akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }






int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    double sum = 0.0;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    double ave = sum / n;
    double res = -INF, idx = 0;
    REP(i, n){
        if(abs(ave - res) > abs(ave - a[i])){
            res = a[i];
            idx = i;
        }
    }
    cout << idx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
struct Edge {
	int a, b, c;
};
pair<int, vector<Edge>> solve(int l) {
	if (l == 1) return {1, {}};
	int n;
	vector<Edge> g;
	tie(n, g) = solve(l / 2);
	for (auto &e : g) {
		++e.a;
		++e.b;
		e.c *= 2;
	}
	g.push_back({1, 2, 0});
	g.push_back({1, 2, 1});
	if (l & 1) g.push_back({1, n + 1, l - 1});
	return {n + 1, g};
}
int main() {
	int L;
	scanf("%d", &L);
	int n;
	vector<Edge> g;
	tie(n, g) = solve(L);
	printf("%d %d\n", n, g.size());
	for (auto e : g) printf("%d %d %d\n", e.a, e.b, e.c);
}


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

int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        --A[i];
    }
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    vector<int>C(N-1);
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans +=B[A[i]];
        if(i>0&&A[i]==A[i-1]+1){
            ans += C[A[i-1]];
        }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll x,n,ans;
	cin>>x>>n;
	ll a[n+10];
	map<ll,ll> mp;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(ll i=0;i<500;i++)
	{
		if(mp[x-i]==0)
		{
			ans=x-i;
			break;
		}
		else
		{
			if(mp[x+i]==0)
			{
				ans=x+i;
				break;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> X;
  tools::read(X, M);

  std::sort(X.begin(), X.end());
  std::deque<i64> diffs;
  std::adjacent_difference(X.begin(), X.end(), std::back_inserter(diffs));
  diffs.pop_front();
  std::sort(diffs.begin(), diffs.end());
  diffs.resize(std::max<i64>(static_cast<i64>(diffs.size()) - (N - 1), 0));
  std::cout << std::accumulate(diffs.begin(), diffs.end(), static_cast<i64>(0)) << std::endl;
  return 0;
}

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

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6200
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,res=10000; cin>>n; 
    while (n--){
        int a,c=0;
        cin >> a ; 
        while (a%2==0){
            a/=2;
            c++;
        }
        res = min(res,c);

    }
    cout << res << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main() {
	char s[13];
	scanf("%s", s);
	for (int i = 0; i < 4; i++) {
		printf("%c", s[i]);
	}
	printf(" ");
	for (int i = 4; i < 12; i++) {
		printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N;
string n;

ll solve(int a,int b,string m = ""){
    string s = to_string(a);
    string t = to_string(b);
    ll f = stoll(t+m+s);
    if(f > N) return 0;
    ll res = 1;
    rep(i,10){
        string k = to_string(i);
        res += solve(a,b,m+k);
    }
    return res;
}
 
 
int main(){
    cin >> N;
    n = to_string(N);
    vector<vector<ll>> d(10,vector<ll>(10));
    repr(i,1,10)repr(j,1,10){
        d[i][j] = solve(i,j);
        //cout << i << " " << j << " " << d[i][j] << endl;
        if(i == j && i <= N) d[i][j]++;
        //cout << i << " " << j << " " << d[i][j] << endl;
    }
    ll ans = 0;
    repr(i,1,N+1){
        string h = to_string(i);
        ans += d[h[0]-'0'][h[h.size()-1]-'0'];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#define N_MAX 105
#define INF 32700
using namespace std;
short adj[N_MAX][N_MAX];
struct Node{
    char parent;//父节点
    short weight;//权值
    bool state;//节点状态
}nodes[N_MAX];
char n;
int solve() {
    int res = 0;
    nodes[0].weight = 0;
    nodes[0].parent = -1;
    nodes[0].state = true;
    char nowParent = 0;
    while(true) {
        for(char j = 0; j < n; j++) {
            if(nodes[j].weight > adj[nowParent][j]&&!nodes[j].state) {
                nodes[j].weight = adj[nowParent][j];
            }
        }
        char minId = n;
        for(char i = 0; i < n; i++) {
            if(!nodes[i].state) {
                if(nodes[i].weight < nodes[minId].weight) {
                    minId = i;
                }
            }
        }
        if(minId == n) break;
        else nodes[minId].state = true;
        nodes[minId].parent=nowParent;
        nowParent=minId;
    }
    for(char i = 0; i < n; i++) {
        res += nodes[i].weight;
    }
    return res;
}

int main(){
    scanf("%d", &n);
    for(char i=0;i<n;i++){
        for(char j=0;j<n;j++){
            scanf("%d", &adj[i][j]);
            if(adj[i][j]==-1) adj[i][j]=INF;
        }
        nodes[i].weight=INF;//初始权值
    }
    nodes[n].weight=INF;
    printf("%d\n", solve());
    return 0;
}



Measured memory_bytes: 2720
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]+a
for i in range(n):
  b[i+1]=min(b[i+1],0)
  b[i+1]+=b[i]
c=[0]+a
for i in range(n):
  c[i+1]=max(c[i+1],0)
  c[i+1]+=c[i]
m=sum(max(i,0)for i in a)
ans=[]
for i in range(n-k+1):
  s=b[i+k]-b[i]
  ss=c[i+k]-c[i]
  ans+=[m+s,m-ss]
print(max(ans))

Measured memory_bytes: 24528
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int n=0,x=0;
  cin>>n>>x;
  vector<int> j(n+1);
  
  j.at(0)=0;
  for(int i=1;i<n+1;i++){
   cin>>j.at(i); 
  }
  
  int count=0;
  int target=0;
  for(int i=0;i<j.size();i++){
    target=target+j.at(i);
    
    if(target<=x){
      count++; 
    }
  }
  
  cout<<count<<endl;
}

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

int gcd(int a, int b, int c){
  while(b>0)
    return gcd(b, a%b,c);
  while(c>0)
    return gcd(c,0,a%c);
  return a;
}

int main() {
  int k,sum=0;
  cin>>k;
  for(int i=1; i<k+1; i++){
    for(int n=1; n<k+1; n++){
      for(int m=1; m<k+1; m++){
        sum+=gcd(i,n,m);
      }
    }
  }
    
    
  cout<<sum<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 100000 + 5;
int n;
LL a[maxN], m, v, p;

bool check(int k) {
	eprintf("check %d\n", k);
	if(k <= p) return true;
	LL rm = 0, rv = v - 1;
	for(int i = 1; i <= n; ++i) if(i != k) {
		LL take = 0;
		if(i <= p - 1) take = m;
		else take = a[k] + m - a[i];
		if(take < 0) return false;
		chmin(take, m);
		
		// take away
		if(take <= rm) {
			rm -= take;
		} else {
			if(rv) rm += m, rv--, rm -= take;
			else rm = 0;
		}
		eprintf("after #%d, rm = %lld, rv = %lld\n", i, rm, rv);
	}
	return rm == 0 && rv == 0;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> n >> m >> v >> p;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + n + 1);
	int L = 1, R = n;
	reverse(a + 1, a + n + 1);
	displaya(a, 1, n);
	while(L < R) {
		int M = (L + R + 1) >> 1;
		if(check(M)) L = M;
		else R = M - 1;
	}
	cout << (L) << endl;
	return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)



int main(){
  char c;cin>>c;
  if(c<'a'){
    cout<<'A'<<endl;
  }
  else{
    cout<<'a'<<endl;
  }
  return 0;
}


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
 
/*CODE START HERE*/
int main() {
  string s;
  cin >> s ;
  string a = "abcdefghijklmnopqrstuvwxyz";
  forn(i,26){
    bool ser = false
    forn(j,s.size()){
      if (a.at(i) == s.at(j)){
        ser = true ;
      }
    }
    if ( !ser){
      cout << a.at(i) << endl;
      return 0 ;
    }
  }
  cout << "None" << endl;
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int N, C, s, t, c;
int rec[35][200010] = {{0}};

int main(){
    cin >> N >> C;
    rep(i, N){
        cin >> s >> t >> c;
        s *= 2;
        t *= 2;
        s--;
        c--;
        rec[c][s]++;
        rec[c][t]--;
    }
    rep(i, C){
        REP(j, 1, 200005){
            rec[i][j] += rec[i][j-1];
        }
    }
    int ans = 0;
    rep(j, 200005){
        int tmp = 0;
        rep(i, C){
            if(rec[i][j] > 0){
                tmp++;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24832
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;

char                                      mp[1005][1005];
int                                       cost[1005][1005];
int                                       h, w;
deque <tuple <int, int, int, int, bool> > deq;

int ch, cw;
int dh, dw;

bool end_fg = false;

void bfs(int x, int y, int cst)
{
    if (end_fg) { return; }
    if (x < 0 || y < 0 || h <= x || w <= y) { return; }
    if (mp[x][y] == '#' || cost[x][y] != -1) { return; }
    else { cost[x][y] = cst; }

    if (x == dh && y == dw) { end_fg = true; return; }

    for (int i = -2; i < 3; i++) {
        for (int j = -2; j < 3; j++) {
            if (i == 0 && j == 0) { continue; }
            else if ((i == -1 && j == 0) || (i == 1 && j == 0) || (i == 0 && j == -1) || (i == 0 && j == 1)) {
                tuple <int, int, int, int, bool> tmp = make_tuple(i, j, x, y, false);
                deq.push_front(tmp);
            }
            else {
                tuple <int, int, int, int, bool> tmp = make_tuple(i, j, x, y, true);
                deq.push_back(tmp);
            }
        }
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    cin >> h >> w;


    cin >> ch >> cw;
    ch--;
    cw--;


    cin >> dh >> dw;
    dh--;
    dw--;

    rep(i, 1005) {
        rep(j, 1005) {
            cost[i][j] = -1;
        }
    }

    rep(i, h) {
        char tmp[1005];
        cin >> tmp;

        rep(j, w) {
            mp[i][j] = tmp[j];
        }
    }

    bfs(ch, cw, 0);

    while (deq.size() != 0) {
        tuple <int, int, int, int, bool> next = deq.front();
        deq.pop_front();

        if (get <4>(next)) { bfs(get <0>(next) + get <2>(next), get <1>(next) + get <3>(next), cost[get <2>(next)][get <3>(next)] + 1); }
        else { bfs(get <0>(next) + get <2>(next), get <1>(next) + get <3>(next), cost[get <2>(next)][get <3>(next)]); }
    }

    /*rep(i, h) {
        rep(j, w) {
            cout << cost[i][j];
        }
        cout << endl;
    }*/
    cout << cost[dh][dw] << endl;

    return 0;
}


Measured memory_bytes: 12584
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    int a, b;
    int h, m;
    cin >> a >> b >> h >> m;
    long double theta;

   
    //theta = 2.0*M_PI*((long double)h/12.0 + ((long double)m/60.0)/12.0 - (long double)m/60.0);
    long double arg = abs(30.0*(long double)h + 30.0*(long double) m/60.0 - 6.0*(long double)m);
    theta = min(arg, 360-arg);
    
    long double c = sqrtl((long double)(a*a + b*b) - (long double)(2.0*a*b)*cosl(2*M_PI*theta/360.0));

    printf("%.10Lf\n", c);
    //cout << c << endl;

    return 0;

}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    string S;cin>>S;
    string d=to_string(S.size()-2);
    string a=S[0]+d+S[S.size()-1];
    cout<<a<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int h, n, a[1000], b[1000], dp[20001];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("threesum.in", "r", stdin);
	//freopen("threesum.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	dp[0] = 0;
	for (int H = 1; H <= h + 10000; H++)
	{
		dp[H] = 1e9;
		for (int i = 0; i < n; i++)
			if (H >= a[i])
				dp[H] = min(dp[H], dp[H - a[i]] + b[i]);
	}
	int ans = 1e9;
	for (int H = h; H <= h + 10000; H++)
		ans = min(ans, dp[H]);
	cout << ans;
	return 0;
}

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

int main(void) {
    long n, k, q;
    cin >> n >> k >> q;
    vector<long> a(n);
    for(auto &e: a) cin >> e;

    vector<long> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());

    set<long> bads;
    bads.insert(-1);
    bads.insert(n);

    long r = 1e18;

    for(long mi: b) {
        vector<long> v;

        auto it = bads.begin();
        auto is = it++;
        while(it != bads.end()) {
            vector<long> w;
            // (is, it)
            long cnt = (*it-1 +1) - (*is+1);
            if(cnt-k+1 > 0) {
                copy(a.begin()+(*is+1), a.begin()+(*it-1 +1), back_inserter(w));
                sort(w.begin(), w.end());
                copy_n(w.begin(), cnt-k+1, back_inserter(v));
            }
            is = it++;
        }

        if(v.size() < q) break;
        sort(v.begin(), v.end());
        r = min(r, v[q-1] - v[0]);

        for(long i=0; i<n; i++)
            if(a[i] == mi) bads.insert(i);
    }

    cout << r << endl;

}


Measured memory_bytes: 384
#include <iostream>

typedef long long int ll;

int main() {
  ll k, a, b;
  std::cin >> k >> a >> b;

  if ( k < a - 1 || b - a <= 2) {
    std::cout << k + 1 << std::endl;
    return 0;
  }

  k -= a - 1;
  ll ans = a;
  if (k % 2 == 0) {
    ans += (k / 2) * (b - a);
  } else {
    ans += ((k - 1) / 2) * (b - a) + 1;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
using namespace std;


void solve(long long N, long long M, std::vector<long long> A){
    if(N < M) {
        cout << -1 << endl;
        return;
    }

    long long sum = 0;
    for(int i = 0; i < A.size(); i++) {
        sum += A[i];
    }
    if(N - sum >= 0)  {
        cout << N - sum << endl;
    }else {
        cout << -1 << 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 M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3744
#include<cstdio>
using namespace std;
long long a[110000];
int main(){
	long long n;
	scanf("%lld",&n);
	for(long long i=n;i;i--){
		scanf("%lld",&a[i]);
	}
	long long high,low;
	high=low=2;
	for(long long i=1;i<=n;i++){
		low=low%a[i]==0?low/a[i]:low/a[i]+1;
		high=high/a[i];
		if(high<low){
			printf("-1\n");return 0;
		}
		low=low*a[i];
		high=high*a[i]+(a[i]-1);
	}
	printf("%lld %lld\n",low,high);
}


Measured memory_bytes: 896
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	max := 0
	sum := 0
	for i := 0; i < n; i++ {
		var l int
		fmt.Scan(&l)
		if max < l {
			max = l
		}
		sum += l
	}
	if sum-max > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define maxi 100005
long long  h[maxi];
long long  n,a,b;
long long in=10000000000;
bool C(long long  x)
{
    long long t=x;
    long z;
    for(long long i=0; i<n; i++)
    {
        z=h[i]-x*b;
        if(z<=0) continue;
        long long y;
        y=ceil(z*1.0/(a-b));
        t-=y;
    }
    if(t>=0) return true;
    return false;
}
void solve()
{
    sort(h,h+n);
    long long  lb=0,ub=in;
    while(ub-lb>1)
    {
        long long mid=(lb+ub)/2;
        if(C(mid)) ub=mid;
        else  lb=mid;
    }
    cout<<ub<<endl;
}
int main()
{
    while(cin>>n>>a>>b)
    {
        for(int i=0; i<n; i++)  scanf("%d",&h[i]);
        solve();
    }
    return 0;
}



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

int main(){
  int n,q;
  cin >> n >> q;
  fenwick_tree<long long> fw(n);
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    fw.add(i,a);
  }
  for(int i=0;i<q;i++){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==0){
      fw.add(b,c);
    }
    else{
      cout << fw.sum(b,c) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8216
if __name__ == '__main__':
    N = int(input())
    S = list(input())
    w, e = [0 for i in range(N)], [0 for i in range(N)]
    for i, s in enumerate(S):
        if s == 'W':
            if i > 0:
                w[i] = w[i-1] + 1
                e[i] = e[i-1]
            else:
                w[0] = 1
                e[i] = e[i-1]
        if s == 'E':
            if i > 0:
                w[i] = w[i-1]
                e[i] = e[i-1] + 1
            else:
                w[i] = w[i-1]
                e[0] = 1
    ans = 9999999
    for i in range(N):
        if i > 0:
            ans = min(ans, w[i-1]+(e[-1]-e[i]))
        else:
            ans = min(ans, e[-1]-e[i])
    print(ans)


Measured memory_bytes: 19896
N = int(input())
H = [int(h) for h in input().split()]

cnt = 0
ans = 0

i = 0

while i < N-1:
    if H[i] < H[i+1]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
    i += 1
ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
    long long int a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    long long int sum=0;
    if(k<=a)
    {
        sum+=k;
    }else{
        sum+=a;
        k=k-a-b;
        if(k>0)
        {
            sum-=k;
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1728
# ABC068c
import collections
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
INF = 10**12


class Edge:  # 通常の辺
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


class Dijkstra:  # ダイクストラ法 O(E * logV)
    def __init__(self, n):
        self.n = n
        self.dist = [INF for _ in range(n)]
        self.edges = [list() for _ in range(n)]
        self.q = collections.deque()

    def calcShortest(self, start):
        self.q.append((start, 0))
        while(len(self.q) != 0):
            v, cost = self.q.popleft()
            if cost > 3:
                continue
            if self.dist[v] <= cost:
                continue
            self.dist[v] = cost
            for edge in self.edges[v]:
                self.q.append((edge.to, cost+edge.cost))

    def addEdge(self, st, gl, cost):
        self.edges[st].append(Edge(gl, cost))


v = Dijkstra(n)
for _ in range(m):
    a, b = map(int, input().split())
    v.addEdge(a-1, b-1, 1)
    v.addEdge(b-1, a-1, 1)

v.calcShortest(0)
if v.dist[n-1] <= 2:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')


Measured memory_bytes: 118032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100005

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int n, p[N], m, ans;
bool u[N], u2[N];

int fnd(int q){
    if (q == p[q]) return q;
    p[q] = fnd(p[q]);
    return p[q];
}

int main(){
    cin >> n >> m;
    for (int i=1; i<=n; i++) p[i] = i;
    for (int i=1, x, y, z; i<=m; i++){
        cin >> x >> y >> z;
        p[fnd(x)] = fnd(y);
        u[x] = u[y] = 1;
    }
    for (int i=1; i<=n; i++){
        if (!u[i]) ans++, u[i] = 1;
        else if (!u2[fnd(i)]) ans++, u2[fnd(i)] = 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num;
  bool flag;

  num = 0;
  flag = false;

  int x, y; cin >> x >> y;

  if (x == 2 && y == 2) flag = true;
  if ((x == 4 || x == 6 || x == 9 || x == 11)
      && (y == 4 || y == 6 || y == 9 || y == 11)) flag = true;
  if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
      && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) flag = true;
  
  // cout << num << endl;
  cout << (flag ? YES : NO) << endl;
  
  return 0;
}


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


int main() {
  ll n; cin >> n;
  string s; cin >> s;
  
  map<pair<string, string>, ll> S1, S2;
  ++S1[{"", ""}];
  ++S2[{"", ""}];


  pair<string, string> a;
  ll b;

  rep(i, n) {
    int k = S1.size();
    map<pair<string, string>, ll> T;
    for (auto &z : S1) {
      tie(a, b) = z;
      T[{a.first + s[i], a.second}] += b;
      T[{a.first, a.second + s[i]}] += b;
    }
    swap(S1, T);
  }
  drep2(i, 2*n, n) {
    int k = S2.size();
    map<pair<string, string>, ll> T;
    for (auto &z : S2) {
      tie(a, b) = z;
      T[{a.first, a.second + s[i]}] += b;
      T[{a.first + s[i], a.second}] += b;
    }
    swap(S2, T);
  }

  ll ans = 0;
  for (auto &z : S1) {
    tie(a, b) = z;
    ans += b * S2[a];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 106240
#include <cstdio>
#include <algorithm>
using std::__gcd;
int main(){
	int x,y;
	while( scanf("%d %d",&x,&y) != EOF ){
		int g = __gcd(x,y);
		printf("%d %d\n",g,x/g*y);
	}
	return 0;	
}

Measured memory_bytes: 1024
using AtCoderBeginnerContest133.Questions;
using AtCoderBeginnerContest133.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest133.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var lr = inputStream.ReadIntArray();
            var l = lr[0];
            var r = lr[1];

            var diff = r - l;

            l = l % 2019;
            r = l + Math.Min(diff, 2019);

            var min = int.MaxValue;
            for (int i = l; i < r; i++)
            {
                for (int j = i + 1; j <= r; j++)
                {
                    min = Math.Min(min, (i * j) % 2019);
                }
            }

            yield return min;
        }
    }
}


namespace AtCoderBeginnerContest133
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest133.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest133.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b;
  cin>>a>>b;
  vector<pair<int,int>> c(a);
  fo(i,a)
    cin>>c[i].first>>c[i].second;
  Sort(c);
  int d=0;
  fo(i,a){
    d+=c[i].second;
    if(b<=d){
      cout<<c[i].first<<endl;
      break;
    }
  }
}

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

int main(){
  int dice[6];
  int pos[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
  int a,b,ap,bp,n;
  
  for(int i=0;i<6;i++) cin>>dice[i];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<6;j++){
      if(a==dice[j]) ap=j;
      if(b==dice[j]) bp=j;
    }
    cout<<dice[pos[ap][bp]-1]<<endl;
  }
  return 0;
}

  

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
#include <vector>
#define INF 1000000000000000000LL
#define MP(a,b,c) make_pair((ll)a,make_pair(b,c))
using namespace std;
typedef long long ll;
typedef pair <ll,pair<int,int> > P;
int h,w,n;
ll mp[1010][1010],D[1010][1010];
bool visited[1010][1010];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};

void mk_mp(int x,int y,int t,string str){
  mp[y][x]++;
  while(t--)
    for(int i=0;i<(int)str.size();i++){
      int j=0;//D
      if(str[i]=='U')j=1;
      if(str[i]=='L')j=2;
      if(str[i]=='R')j=3;
      int nx=x+2*dx[j],ny=y+2*dy[j];
      if(nx<1||ny<1||nx>=2*w||ny>=2*h)continue;
      x=nx,y=ny;
      mp[y][x]++;
      mp[y-dy[j]][x-dx[j]]++;
    }  
}

ll dijkstra(int x,int y,int gx,int gy){
  for(int i=0;i<1010;i++)
    for(int j=0;j<=1010;j++) D[i][j]=INF;
  priority_queue <P,vector<P>,greater<P> > Q;
  Q.push(MP(0,x,y));
  D[y][x]=0;
  while(!Q.empty()){
    ll dis=Q.top().first;
    int x=Q.top().second.first;
    int y=Q.top().second.second;
    Q.pop();
    if(x==gx&&y==gy)return dis;
    if(visited[y][x]==1)continue;
    visited[y][x]=1;  
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx<0||ny<0||nx>2*w||ny>2*h||D[ny][nx]<=dis+mp[ny][nx])continue;
      Q.push(MP(dis+mp[ny][nx],nx+dx[i],ny+dy[i]));
      D[ny][nx]=dis+mp[ny][nx];
    }
  }
  return -1;
}

int main() {
  int sx,sy,gx,gy;
  cin>>w>>h>>n;
  cin>>sx>>sy>>gx>>gy;
  for(int i=0;i<n;i++){
    int x,y,t;
    string str;
    cin>>x>>y;
    cin>>t>>str;
    mk_mp(2*x+1,2*y+1,t,str);
  }
  /*
  for(int i=0;i<=2*h;i++){
    for(int j=0;j<=2*w;j++)printf("%3ld",mp[i][j]);
    cout <<endl;
    }*/

  cout << dijkstra(2*sx,2*sy,2*gx,2*gy)<<endl;
  return 0;
}

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

int nGame ;

int AnotherMask[10010][13][13] ;

int dp[10010][13][13] ; // =0 : not confirm , =2 : win , =1 :lose 

int dfs( int mask , int Left , int Right ){
	if( dp[mask][Left][Right] ) return dp[mask][Left][Right] ;
	if( !mask ) return dp[mask][Left][Right] = 2 ;
	int cnt = 0 ;
	if( Left && (mask & (1 << (Left - 1))) ) cnt ++ , dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left - 1 , Right ) ) ;
	if( Right != 12 && (mask & (1 << (Right + 1))) ) cnt ++ , dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left , Right + 1 ) ) ;
	if( !cnt ) dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left , Right ) ) ;
	return dp[mask][Left][Right] ;
}	

int main(){
	
	//freopen( "sevens.inp" , "r" , stdin ) ; freopen( "sevens.out" , "w" , stdout ) ;
	
	cin >> nGame ;
	
	for( int mask = 0 ; mask <= (1 << 13) ; ++ mask ){
		int newmask = (1 << 13) - 1 - mask ;
		for( int Left = 0 ; Left < 13 ; ++ Left ){
			int ansMask = newmask ;
			for( int Right = Left ; Right < 13 ; ++ Right ){
				if( mask & (1 << Right) ) break ;
				ansMask ^= 1 << Right ;
				AnotherMask[mask][Left][Right] = ansMask ;
			}
		}
	}

	for( int mask = 1 ; mask <= (1 << 13) - 1 ; ++ mask ){
		if( mask & (1 << 6) ) continue ;
		if( __builtin_popcount(mask) != 6 ) continue ;
		int zz = dfs(mask , 6 , 6) ;
	}

	while(nGame --){
		int mask = 0 ;
		for( int i = 0 ; i < 6 ; ++ i ){
			int x ; cin >> x ; x -- ; mask |= (1 << x) ;
		}
		if( dp[mask][6][6] == 2 ) cout << "yes" << endl ;
		else cout << "no" << endl ;
	}

	return 0 ;
}


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

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

    int q;
    cin >> q;
    vector<int> res(q);

    rep(_, q){
        string x, y;
        cin >> x >> y;
        if(y.size() > x.size()) swap(x, y);

        int n = y.size();
        int m = x.size();

        vector<vector<int>> dp(n, vector<int>(m, 0));
        if(x[0] == y[0]) dp[0][0] = 1;
        else dp[0][0] = 0;

        rep1(i, m){
            if(y[0] == x[i]) dp[0][i] = 1;
            else dp[0][i] = dp[0][i-1];
        }

        rep1(i, n){
            dp[i][0] = dp[i-1][0];
            if(y[i] == x[0]) dp[i][0] = 1;

            rep1(j, m){
                if(y[i] == x[j]) dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }

        // rep(i, n){
        //     rep(j, m) cout << dp[i][j] << " ";
        //     cout << endl;
        // }

        cout << dp[n-1][m-1] << endl;
        
    }

    return 0;
}


Measured memory_bytes: 6872
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] score = new int[2][10];
		for(int i=0;i<2;i++) {
			for(int j=0;j<10;j++) {
				score[i][j] = sc.nextInt();
			}
		}
		for(int i=0;i<2;i++) {
			Arrays.sort(score[i]);
			int ans = 0;
			for(int j=9;j>=7;j--) {
				ans+=score[i][j];
			}
			if (i==0) {
				System.out.print(ans + " ");
			}else{
				System.out.println(ans);
			}
		}
	}

}

Measured memory_bytes: 17172
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
   	string s;
   	cin >> s;
   	if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) cout << "Yes";
   	else cout << "No";
}

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

int main(){
  string S;
  cin >> S;
  
  if(S=="SUN"){
    cout << 7 << endl;
  }
  else if(S=="MON"){
    cout << 6 << endl;
  }
  else if(S=="TUE"){
    cout << 5 << endl;
  }
  else if(S=="WED"){
    cout << 4 << endl;
  }
  else if(S=="THU"){
    cout << 3 << endl;
  }
  else if(S=="FRI"){
    cout << 2 << endl;
  }
  else if(S=="SAT"){
    cout << 1 << endl;
  }
}


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

int main()
{
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	
	int i, minn=INT_MAX, id;
	
	a *= 1000;
	b *= 1000;
	for (i=1; i<=n; i++){
		int x;
		cin >> x;
		x *= 6;
		
		if (abs (b-(a-x)) < minn){
			minn = abs (b-(a-x));
			id = i;
		}
	}
	
	cout << id << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> cost(3);
    for(int i = 0; i < 3; i++) cin >> cost[i];
    sort(cost.begin(),cost.end());
    cout << cost[1] - cost[0] + cost[2] - cost[1] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
R = lambda:map(int,raw_input().split())
n = int(raw_input())

for i in xrange(n):
    run = []
    cnt = 0
    score = 0
    while cnt < 3:
        s = raw_input()
        if s == 'OUT': cnt += 1
        elif s == 'HIT':
            if len(run) is 3: score += 1
            else: run.append(1)
        else:
            score += (len(run)+1)
            run = []
    print score

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int main() {
  string s;
  while (getline(cin, s) && s != "#") {
    vector<string> v;
    for (size_t i = 0; i < s.size(); i += v.back().size()) {
      if (s[i] == 'n') v.push_back(s.substr(i, 5));
      else v.push_back(s.substr(i, 4));
    }
    reverse(v.begin(), v.end());
    int a = 0, b = 1;
    if (v[0] == "north") a = 0;
    else a = 90;
    for (size_t i = 1; i < v.size(); ++ i) {
      a *= 2; b *= 2;
      if (v[i] == "north") a -= 90;
      else a += 90;
    }
    int g = __gcd(a, b);
    a /= g, b /= g;
    if (b > 1) cout << a << "/" << b << endl;
    else cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll sum[N][10];//sum[i][j]i + 1文字目までのjの個数
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < 10; j++){
            sum[i][j] = 0;
        }
    }
    for(ll i = 0; i < N; i++){
        //一つ前をトレスした上で追加
        if(i != 0){
            for(int j = 0; j < 10; j++){
                sum[i][j] = sum[i - 1][j];
            }
        }
        sum[i][S[i] - '0']++;
        for(int j = 0; j < 10; j++){
            //cout << sum[i][j] << " ";
        }
        //cout << endl;
    }
    bool isEnable[10][10][10];
    for(int xi = 0; xi < 10; xi++){
        for(int yi = 0; yi < 10; yi++){
            for(int zi = 0; zi < 10; zi++){
                isEnable[xi][yi][zi] = false;
            }
        }
    }

    for(ll i = 1; i < N - 1; i++){
        ll sumB [10];
        ll sumA [10];
        int current = S[i] - '0';
        for(int tmpi = 0; tmpi < 10; tmpi++){
            sumB[tmpi] = sum[i - 1][tmpi];
            sumA[tmpi] = sum[N - 1][tmpi] - sum[i][tmpi];
        }
        for(int bi = 0; bi < 10; bi++){
            for(int ai = 0; ai < 10; ai++){
                if(sumA[ai] > 0 && sumB[bi] > 0){
                    isEnable[bi][current][ai] = true;
                }
            }
        }
    }
    ll result = 0;
    for(int xi = 0; xi < 10; xi++){
        for(int yi = 0; yi < 10; yi++){
            for(int zi = 0; zi < 10; zi++){
                if(isEnable[xi][yi][zi]){
                    //cout << xi << yi << zi << endl;
                    result++;
                }
            }
        }
    }
    cout << result << endl;

}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class Mod{
  public:
    ll mod;
    // mod must be a prime number
    Mod(ll m){
        mod = m;
    }
    //a^p
    ll modpow(ll a, ll p){
        if(p == 0) return 1;
        if(p%2 == 0){
            ll half = modpow(a, p/2);
            return half * half % mod;
        }
        else return a * modpow(a,p-1) % mod;
    }

    //nCr
    ll comb(ll n, ll r){
        if(r > n-r) return comb(n,n-r);
        ll mul = 1;
        ll div = 1;
        for (int i = 0;i < r;i++){
            mul *= n-i;
            mul %= mod;
            div *= i+1;
            div %= mod;
        }
        return mul * modpow(div,mod-2) % mod;
    }
};

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

    Mod md(1e9+7);

    ll n,a,b; cin >> n >> a >> b;

    ll ans = md.modpow(2,n);

    ans += md.mod;
    ans -= md.comb(n,a);
    ans += md.mod;
    ans -= md.comb(n,b);

    ans %= md.mod;

    cout << ans-1 << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int price = 700, cnt = 0;
    string S;
    cin >> S;
    for(int i = 0; i < 3; i++)
    {
        if(S[i] == 'o')
            cnt++;
    }
    price += cnt * 100;
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256