akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    string s;
    cin >> s;

    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        ret();
    }
    if (s.size() != 26) {
        set<char> used;
        rep(i, 27) used.insert('a' + i);
        for (char c : s) used.erase(c);
        char c = *used.begin();
        cout << s + c << endl;
        ret();
    }

    stack<char> st;
    for (char c : s) st.push(c);

    set<char> used;

    [&]() {
        while (!st.empty()) {
            char c = st.top();
            for (char d : used) {
                if (d > c) {
                    st.top() = d;
                    return;
                }
            }
            st.pop();
            used.insert(c);
        }
    }();

    vector<char> ans;
    while (!st.empty()) {
        ans.push_back(st.top());
        st.pop();
    }
    reverse(ans.begin(), ans.end());
    for (char c : ans) cout << c;

}

Measured memory_bytes: 256
/*{{{*/
#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }

template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef int64_t ll;

inline int LG (const unsigned int &_x) { return 32-__builtin_clz(_x); } // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

const int N = 100+10;

int n, a, b;
int dp[N][N];
/*
void go(int p0, int p1, int turn = 0){
    int &p[] = {p0, p1};
    if(dp[p1][p2] != -1) continue;
    int &val = dp[p1][p2];

    if(p1-p2 == 1)
        return val = !turn;
}
//*/

int main(){
    R(n, a, b);

    //MS1(dp);
    //go(a, b);

    W((b-a)&1 ? "Borys" : "Alice");

    return 0;
}


Measured memory_bytes: 256
import math
import numpy as np

A,B,H,M = (int(x) for x in input().split())

minit = M + H * 60
long_r = 360*minit/(60*12)
short_r = 6*M

Ax = A*math.cos(math.radians(long_r))
Ay = A*math.sin(math.radians(long_r))
Bx = B*math.cos(math.radians(short_r))
By = B*math.sin(math.radians(short_r))

d = np.sqrt((Ax-Bx)**2+(Ay-By)**2)
print(d)

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

int main() {
   int a,b,x;
  cin>>a>>b;
  
  x=(a+b)/2;
  if((a+b)%2==0){
  cout<<x<<endl;
  }
  else{
    cout<<x+1<<endl;
  }
  
}
 


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

int ketawa(int a)
{
    int ret = 0;
    while (a) {
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

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

    Int(n);

    set<int> funami;
    Rep(i, 10) funami.insert(i);

    int q = 9;
    Rep(i, 16) {
        int a = i * 10;
        if (i > 10) {
            a -= 10;
        }
        Rep(j, a) {
            funami.insert(j * pow(10, i) + q);
        }
        q *= 10; q += 9;
    }

    int cnt = 0;
    for (auto i : funami) {
        cout << i << endl;
        cnt++;
        if (cnt == n) break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string s,t;
    cin >> N >> s >> t;
    int count = 0;
    for(int i = N; i > 0 ; i -= 1){
        if(s.substr(N-i, i) == t.substr(0,i)){
            count = i;
            break;
        }
    }
    printf("%d\n", 2*N - count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(x) x.begin(),x.end()
const ll MOD=1000000007;
const long double PI=3.14159265358979;

ll x[4]={0,0,1,-1};
ll y[4]={1,-1,0,0};

int main(){
  ll H,W;
  cin>>H>>W;
  ll Map[H][W];
  queue <pair<ll,ll>> q;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char s;
      cin>>s;
      if(s=='.'){
        Map[i][j]=MOD;
      }
      else{
        Map[i][j]=0;
        q.push({i,j});
      }
    }
  }
  while(!q.empty()){
    pair<ll,ll> p=q.front();
    q.pop();
    for(int i=0;i<4;i++){
      if(p.first+x[i]==H||p.first+x[i]==-1||p.second+y[i]==W||p.second+y[i]==-1){
        continue;
      }
      if(Map[p.first+x[i]][p.second+y[i]]>Map[p.first][p.second]+1){
        Map[p.first+x[i]][p.second+y[i]]=Map[p.first][p.second]+1;
        q.push({p.first+x[i],p.second+y[i]});
      }
    }
  }
  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans=max(ans,Map[i][j]);
    }
  }
  cout<<ans;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}

const int mod = 1e9 + 7;

ll factorial(ll n){
    if (n == 1) return 1;
    return n * (factorial(n-1) % mod) % mod;
}
int main(){
    int N,M;
    cin >> N >> M;

    int d = abs(N-M);
    ll ans = 0;
    if (d == 0){
        ans = factorial(N) * factorial(M) * 2 % mod;
    } else if (d == 1){
        ans = factorial(N) * factorial(M) % mod ;
    } else {
        ans = 0;
    }

    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 1792
n,d=map(int,input().split())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())


ans=0

for i in range(n):
  if x[i]**2+y[i]**2<=d**2:
    ans+=1
print(ans)


Measured memory_bytes: 77948
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,x,s,e;
    cin>>a>>b>>x;
    if(a%x==0)
		s=a/x;
    else
		s=a/x+1;
    e=b/x;
    cout<<e-s+1<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import fractions
input = sys.stdin.readline
A, B, C, D = map(int, input().split())
root_count = B - A + 1
c = B//C - (A - 1)//C
d = B//D - (A - 1)//D
cd_lcm = C * D // fractions.gcd(C, D)
e = B//cd_lcm - (A - 1)//cd_lcm
print(root_count - c - d + e)

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll n,ans=0;cin>>n;
    string s;cin>>s;
    if(n>=3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
}


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

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2604
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();

        long min = Integer.MAX_VALUE;
        long lim = Math.min(r, l + 4038);
        for (long i = l; i <= lim; ++i) {
            for (long j = i + 1; j <= lim; ++j) {
//                System.out.println(String.format(">> %d, %d -- %d", i, j, (i * j) % 2019));
                long m = (i * j) % 2019L;
                if (min > m) {
                    min = m;
                }
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 25300
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	int K,S;
	int X,Y,Z;
	int XY;
	int count = 0;;

	scanf("%d %d",&K,&S);

	for(int i = 0; i <= K; i++){
		Z = i;
		XY = S - Z;
		for(int j = 0; j <= K; j++){
			Y = j;
			X = XY - Y;
			if(X <= K && X >= 0){
				count++;
				// printf("X=%d,Y=%d,Z=%d\n",X,Y,Z);
			}
			else{
				// printf("X=%d,Y=%d,Z=%d\n",X,Y,Z);
			}
			
		}
	}	
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
using namespace std;
map<string,int> mp;
int main(void)
{
    int n,mx=0;
    string s;
    cin >> n;
    while(n--)
    {
        cin >> s;
        mp[s]++;
        if(mx<mp[s]) mx=mp[s];
    }
    for(auto x:mp)
    {
        if(x.second==mx)
            cout << x.first << '\n';
    }
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>

using namespace std;

const int INF = 999999999;
struct edge{
  int from;
  int to;
  int cost;
};

int main(){
  //Initial process
  int vNum, eNum, r;
  cin >> vNum >> eNum >> r;
  int *d = new int[vNum];
  edge *eArray = new edge[eNum];
  int from, to, cost;
  for (int i=0; i<eNum; i++){
    cin >> from >> to >> cost;
    eArray[i] = {from, to, cost};
  }
  for (int i=0; i<vNum; i++){
    d[i] = INF;
  }
  d[r] = 0;
  //calculation
  bool update;
  int newCost;
  edge e;
  while(true){
    update = false;
    for (int i=0; i<eNum; i++){
      e = eArray[i];
      newCost = d[e.from] + e.cost;
      if (d[e.to] > newCost){
        d[e.to] = newCost;
        update = true;
      }
    }
    if (!update) break;
  }
  //output
  for (int i=0; i<vNum; i++){
    if (d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}

Measured memory_bytes: 7300
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

signed main(){
	int x;
	read(x);
	write(360/__gcd(360,x));
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(b.begin(), b.end(), greater<int>());

    ll mx = 0;
    rep(i, n) mx = max(mx, a[i]);

    ll ans = 0;
    rep(i, n) {
        if(b[i] > mx) {
            ans++;
            h -= b[i];
            if(h <= 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    ans += (h + mx - 1) / mx;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define mod 1000000007
#define md 998244353 
#define N 2e5+10
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;
ll a[200009];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n;
  cin>>n;
  ll i=0;
  while(i<n)
    cin>>a[i++];
  ll ans=0;
  i=1;
  while(i<n)
  {
    if(a[i]<a[i-1])
    {
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
    i++;
  }
  deb(ans)
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     fopen     freopen("in.txt","r",stdin)
#define     fwrite    freopen("o.txt","w",stdout)
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int main()
{
    __
    //fopen;
    //fwrite;
    string s;
    cin>>s;
    if(s.size()==2) cout<<s;
    else
        cout<<s[2]<<s[1]<<s[0];

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 120000;
int L[maxn], R[maxn], m[maxn];
int ins(int i, int j){
    return max(min(R[i], R[j]) - max(L[i], L[j]) + 1, 0);
}
pair<int, int> p[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i += 1) cin >> L[i] >> R[i];
    int l = 0, r = 0;
    for(int i = 1; i <= n; i += 1){
        if(not l or R[i] < R[l]) l = i;
        if(not r or L[i] > L[r]) r = i;
    }
    int ans = 0;
    for(int i = 1; i <= n; i += 1) ans = max(ans, R[i] - L[i] + 1);
    ans += max(R[l] - L[r] + 1, 0);
    for(int i = 1; i <= n; i += 1) p[i] = {ins(i, l), ins(i, r)};
    sort(p + 1, p + n + 1, greater<pair<int, int>>());
    for(int i = n; i >= 1; i -= 1){
        if(i == n) m[i] = p[i].second;
        else m[i] = min(m[i + 1], p[i].second);
    }
    for(int i = 1; i < n; i += 1) ans = max(ans, p[i].first + m[i + 1]);
    cout << ans;
    return 0;
}

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

int main(){
    char a;
    cin >> a;

    if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
    
}

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

int main() {
  int H, W, count;
  string X, Y;
  cin >> H >> W >> X;
  for (int i = 0; i < H; i++){
    cin >> Y;
    X += Y;
  }
  for (int i = 0; i < H * W; i++){
    count = 0;
    if (i >= W && i % W == 0)
      cout << endl;
    if (X.at(i) == '#'){
      cout << "#";
      continue;
    }
    else{
      if (i > W && i % W != 0){
        if (X.at(i - W - 1) == '#'){
          count++;
        }
      }
      if (i >= W){
        if (X.at(i - W) == '#'){
          count++;
        }
      }
      if (i >= W && i % W != W - 1){
        if (X.at(i - W + 1) == '#'){
          count++;
        }
      }
      if (i % W != 0){
        if (X.at(i - 1) == '#'){
          count++;
        }
      }
      if (i % W != W - 1){
        if (X.at(i + 1) == '#'){
          count++;
        }
      }
      if (i < (H - 1) * W && i % W != 0){
        if (X.at(i + W - 1) == '#'){
          count++;
        }
      }
      if (i < (H - 1) * W){
        if (X.at(i + W) == '#'){
          count++;
        }
      }
      if (i < (H - 1) * W && i % W != W - 1){
        if (X.at(i + W + 1) == '#'){
          count++;
        }
      }
      cout << count;
    }
  }
}

Measured memory_bytes: 3552
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println( (int)Math.floor( Math.log10(a+b) ) + 1 );
        }
    }
}

Measured memory_bytes: 20380
/*
	        ######## ##   ## #######          ##########
	           ##    ##   ## ##                 ##    ##
	           ##    ####### ######             ##    ##
	           ##    ##   ## ##                 ##    ##
	           ##    ##   ## ####### ######## ##########
	    */
	    #include<bits/stdc++.h>
	    #include <iomanip>
	    #define int         long long
	    #define ll          long long
	    #define pb          push_back
	    #define pii         pair<int,int>
	    #define vi          vector<int>
	    #define vii         std::vector<vector<int> > v;
	    #define all(a)      (a).begin(),(a).end()
	    #define F           first
	    #define S           second
	    #define sz(x)       (int)x.size()
	    #define hell        1000000007
	    #define rep(i,a,b)    for(int i=a;i<b;i++)
	    #define lbnd        lower_bound
	    #define ubnd        upper_bound
	    #define bs          binary_search
	    #define mp          make_pair
	    #define maxc(v)     max_element(all(v))
	    #define minc(v)     min_element(all(v))
	    #define endl        "\n"
	    using namespace std;
	    #define N  100005
	    //#define M  1000003
	    #define rn return
	    #define B 100000000
	    int modularExponentiation(int x,int n,int M = hell)
		{
	    	if(n==0)
	        	return 1;
	    	else if(n%2 == 0)
	        	return modularExponentiation((x*x)%M,n/2,M);
	    	else
	        	return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

		}
		int abs(int a, int b){
	        if(a>b) return a-b;
	        else return b-a;
	    }
	    void solve();
	    signed main()
	    {
	        ios_base::sync_with_stdio(false);
	        cin.tie(0);
	        cout.tie(0);
	        int TESTS=1;
	        //cin>>TESTS;
	        while(TESTS--)
	        {
	            solve();
	        }
	        return 0;
	    }
	    void solve(){
	    	int n;
	    	cin>>n;
	    	int v[n][3];
	    	rep(i,0,n) cin>>v[i][0]>>v[i][1]>>v[i][2];
	    	int dp[n][3];
	    	dp[0][0] = v[0][0];
	    	dp[0][1] = v[0][1];
	    	dp[0][2] = v[0][2];
	    	rep(i,1,n){
	    		dp[i][0] = v[i][0] + max(dp[i-1][1], dp[i-1][2]);
	    		dp[i][1] = v[i][1] + max(dp[i-1][0], dp[i-1][2]);
	    		dp[i][2] = v[i][2] + max(dp[i-1][1], dp[i-1][0]);
	    	}
	    	int ans = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
	    	cout<<ans<<endl;
	    }

Measured memory_bytes: 4992
import copy
n=int(input())

pro=list(map(int,input().split()))


m=int(input())

drinks=[]
for i in range(m):
    drinks.append(list(map(int,input().split())))

for i in range(m):
    ans=copy.deepcopy(pro)
    ans[drinks[i][0]-1]=drinks[i][1]
    print(sum(ans))


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

int main()
{
	const string str{ "CODEFESTIVAL2016" };
	string s;

	cin >> s;

	int32_t count_mismatch{ 0 };
	for (auto i{ 0 }; i < str.size() && i < s.size(); ++i) {
		if (str[i] != s[i]) {
			++count_mismatch;
		}
	}

	cout << count_mismatch << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,W = map(int,readline().split())
m = map(int,read().split())
WV = zip(m,m)

# 価値 -> 最小重さ
INF = 10**18
dp = np.full(10**5+10,INF,np.int64)

dp[0] = 0
for w,v in WV:
    np.minimum(dp[v:], dp[:-v].copy()+w, out=dp[v:])

answer = np.where(dp<=W)[0][-1]
print(answer)

Measured memory_bytes: 14920
s = list(input())

if ((s.count('S') >= 1 and s.count('N') >= 1) or (s.count('S') == 0 and s.count('N') == 0)) and ((s.count('W') >= 1 and s.count('E') >= 1) or (s.count('W') == 0 and s.count('E') == 0)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int k = sc.nextInt();

    String s = sc.next();

    if (s.length() <= k) {
      System.out.println(s);
    } else {
      String str = s.substring(0, k);
      str += "...";
      System.out.println(str);
    }

  }

}

Measured memory_bytes: 38592
s=input()
a=len(s)
t=input()
b=len(t)
maxcnt=0
for i in range(a-b+1):
	count=0
	for j in range(b):
		s1=s[i+j]
		s2=t[j]
		if(s1==s2):
			count+=1
	if(maxcnt<count):
		maxcnt=count	
print(b-maxcnt)

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, x;
    cin >> n >> x;
    int minM = 1000000;
    for(int i=0; i<n; i++){
        int m;
        cin >> m;
        x-=m;
        minM = min(minM, m);
    }
    cout << n+x/minM << endl;
    return 0;
}

Measured memory_bytes: 256
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;}
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;}
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    auto c=scan!string;
    (c=="ABC"?"ARC":"ABC").writeln;
}


Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    cin >> n;
    int x[3] = {};
    REP(i,n){
        int a;
        scanf("%d", &a);
        if (a % 4 == 0) x[2]++;
        else if (a % 2 == 0) x[1]++;
        else x[0]++;
    }

    if (2*x[2] + x[1] >= n || (2*x[2] >= n-1)) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N;
	int[] a;
	long sum,asum;

	public void solve() {
		N = nextInt();

		a = new int[N];
		sum = 0;
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			sum += a[i];
		}

		asum = 0;
		long ans = Long.MAX_VALUE;
		for(int i = 0;i < N-1;i++){
			asum += a[i];
			ans = Math.min(ans,Math.abs(asum - (sum - asum)));
		}

		out.println(ans);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 41224
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int l[10];
    int a,b;
    while(~scanf("%d,", &l[0])) {
        double sum = 0;
        for(int i=1; i<10; i++) scanf("%d,", &l[i]);
        scanf("%d,%d",&a,&b);
        for(int i=0; i<10; i++) sum += (double)l[i];

        double c=0, d=0;
        int i;
        for(i=0; i<10; i++) {
            c += l[i];
            d += (double)l[i]/a * b;
            if(c + d >= sum) break;
        }

        printf("%d\n", i+1);
    }

    return 0;
}

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

using namespace std;

int a[111111], p[111111], v[111111], t;
vector<int> c[111111];
void f(int n) {
	if (v[n]) return;
	v[n] = 1;
	for (auto i : c[n])
		f(i);
	a[t--] = n;
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		c[a].push_back(b);
	}
	t = n - 1;
	for (int i = 1; i <= n; i++)
		f(i);
	for (int i = 0; i < n; i++)
		for (auto j : c[a[i]])
			p[j] = a[i];
	for (int i = 1; i <= n; i++)
		cout << p[i] << '\n';
	cout << flush;
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;

//------------------------------------------------------------------------------------------

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


    string S;
    cin>>S;

    if(S[S.size()-1]!='s'){
        S=S+'s';
    }else{
        S=S+"es";
    }
    cout<<S<<endl;

    




}


Measured memory_bytes: 3664
def is_prime(n):
    i = 2
    while(i**2 <= n):
        if n % i == 0:
            return False
        i += 1
    return True


def main():
    X = int(input())
    for x in range(X, 2*X):
        if is_prime(x):
            print(x)
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

max_prof = -float('inf')

for s in range(1, 1 << 10):

    sum_prof = 0
    for store_no in range(N):
        state = s

        time_zone = 0
        both_open_cnt = 0
        while state > 0:
            if (state & 1) and F[store_no][time_zone]:
                both_open_cnt += 1

            state >>= 1
            time_zone += 1

        sum_prof += P[store_no][both_open_cnt]

    max_prof = max(max_prof, sum_prof)


print(max_prof)


Measured memory_bytes: 9212
import re,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
A,B = LI()
S = S()
pattern_str = r'\d{{{}}}-\d{{{}}}'.format(A,B)
print('Yes' if re.fullmatch(pattern_str,S) else 'No')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		for(int i = 1; i <= N; i++) {
			System.out.println(function(i));
		}
	}

	public static int function(int n) {
		int count = 0;
		for(int x = 1; x <= n; x++ ) {
			for(int y = 1; y <= n; y++ ) {
				for(int z = 1; z <= n; z++ ) {
					if(x*x + y*y + z*z + x*y + y*z + z*x == n) {
//						System.out.printf("x = %d, y = %d, z = %d ", x, y, z);
						count++;
					}else if(x*x + y*y + z*z + x*y + y*z + z*x > n) {
						break;
					}
				}
				if(x*x + y*y + x*y> n) {
					break;
				}
			}
			if(x*x > n) {
				break;
			}
		}

		return count;
	}
}


Measured memory_bytes: 39084
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());
		String ret = "";
		for (int i=3; i<=n; i++){
			int j = i;
			if(i%3==0){
				ret += " " + i;
			}else{
			while(j>0){
				if(j%10==3){
					ret += " " + i;
					break;
				}else{
					j /= 10;
				}
			}}
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 185084
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int n;	scanf("%d",&n);
	int in[n];
	for(int i=0;i<n;i++)	scanf("%d",&in[i]);
	long long int out[n][21];	memset(out,0,sizeof(out));
	out[0][in[0]]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=20;j++){
			if(j-in[i]>=0)	out[i][j-in[i]]+=out[i-1][j];
			if(j+in[i]<=20)	out[i][j+in[i]]+=out[i-1][j];
		}
	}
	printf("%lld\n",out[n-1][0]);//P=a→P-a=0
	return 0;
}

Measured memory_bytes: 1052
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<ll>x(N), y(M);
    for(ll i = 0; i < N; i++)cin >> x[i];
    for(ll i = 0; i < M; i++)cin >> y[i];
    ll flg = 0;
    for(ll z = X + 1; z <= Y; z++){
        ll f = 1;
        for(ll i = 0; i < N; i++)if(x[i] >= z)f = 0;
        for(ll i = 0; i < M; i++)if(y[i] < z)f = 0;
        if(f)flg = 1;
    }
    if(flg)cout << "No War" << endl;
    else cout << "War" << endl;
    
    
    return 0;
}


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


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

    int a,b;
    cin >> a >> b;
    if (a <= 8 && b <= 8 ) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int res = 0;
  for(int i = 0; i < N; i++){
    if(i%2 == 0){
      res += a.at(i);
    }else{
      res -= a.at(i);
    }
  }
  cout << res << endl;
  return 0;
}

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

  int ans = 1, flag = 0;
  for (int i = 1; i < N; i++) {
    if (flag == 0 && A[i-1] < A[i]) {
      flag = 1;
    } else if (flag == 0 && A[i-1] > A[i]) {
      flag = -1;
    } else if (flag == 1 && A[i-1] > A[i] || flag == -1 && A[i-1] < A[i]) {
      flag = 0;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
  int ddx=x2-x1;
  int ddy=y2-y1;
  REP(i,ddx)cout<<'R';
  REP(i,ddy)cout<<'U';
  REP(i,ddx)cout<<'L';
  REP(i,ddy+1)cout<<'D';
  REP(i,ddx+1)cout<<'R';
  REP(i,ddy+1)cout<<'U';
  cout<<'L';
  cout<<'U';
  REP(i,ddx+1)cout<<'L';
  REP(i,ddy+1)cout<<'D';
  cout<<'R';
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y)
{
    if(x==n+1)
    {
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x; i<=n; i++)
    {
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int a = s [0] - '0', b = s [1] - '0', c = s [2] - '0', d = s [3] - '0';
    if (a -b -c - d ==7)
        printf ("%d-%d-%d-%d=7\n ",a,b,c, d );
    else if (a -b - c + d ==7)
        printf ("%d-%d-%d+%d=7\n ",a,b,c, d );
    else if (a - b +c - d ==7)
        printf ("%d-%d+%d-%d=7\n ",a,b,c, d );
    else if (a - b + c + d ==7)
        printf ("%d-%d+%d+%d=7\n",a,b,c, d );
    else if ( a +b -c - d ==7)
        printf ("%d+%d-%d-%d=7\n ",a,b,c, d );
    else if ( a +b - c + d ==7)
        printf ("%d+%d-%d+%d=7\n ",a,b,c, d );
    else if ( a + b +c - d ==7)
        printf ("%d+%d+%d-%d=7\n ",a,b,c, d );
    else if ( a + b + c + d ==7)
        printf ("%d+%d+%d+%d=7\n ",a,b,c, d );
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
long double h[160];
double dp[160][305];

double f(double a, double b, double height) {
    double da = abs(a - height);
    double db = abs(b - height);
    if((a - height) * (b-height) >= 0) {
        return (da + db) / 2.0;
    }
    double xa = da / (da + db);
    double xb = db / (da + db);
    return (xa * da + xb * db) / 2.0;
}

int main() {
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++) {
        cin >> h[i];
    }
    for(int i = 0; i <= 300; i++) {
        dp[0][i] = 1e9;
    }
    dp[0][1] = 0;
    for(int i = 1; i <= n; i++) {
        for(int after = 1; after <= 300; after++) {
            dp[i][after] = 1e9;
        }
        for(int before = 1; before <= 300; before++) {
            for(int after = 1; after <= 300; after++) {
                //cout << before << " " << after << " " << h[i] << " " << f(before, after, h[i]) << endl;
                dp[i][after] = min(dp[i][after], dp[i-1][before] + f(before, after, h[i]));
            }
        }
    }
    double ans = 1e9;
    for(int i = 1; i <= 300; i++) {
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
N, M = gets.split.map(&:to_i)
ks_list = M.times.map { gets.split.map(&:to_i) }
s_list = ks_list.map.with_index { |(k, *ary), i| [i, ary] }
p_list = gets.split.map(&:to_i)

count = 0
(0...(2 ** N)).each do |n|
  bits = (0..(N - 1)).map do |i|
    n[i] == 1
  end
  ret = s_list.all? do |i, slist|
    c = slist.count do |s|
      bits[s - 1]
    end
    c % 2 == p_list[i]
  end
  count += 1 if ret
end
puts count


Measured memory_bytes: 1916
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>

using namespace std;


int main(){

	int n,m,sum,in,out,max;
	bool FLG = true;

	scanf("%d",&n);
	scanf("%d",&m);
	sum = m;
	max = m;

	for(int i = 0; i < n; i++){
		scanf("%d %d",&in,&out);
		sum += (in - out);
		if(sum < 0){
			printf("0\n");
			FLG = false;
			break;
		}

		max = (max >= sum)?max:sum;
	}

	if(FLG)printf("%d\n",max);

	return 0;
}

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

using namespace std;
string s1, s2;
int i, j, n, m;
int f[3001][3001] = {0};
int main()
{
    //freopen("test.inp","r", stdin);
    string res = "";
    cin >> s1 >> s2;
    s1 = " "+s1;
    s2 = " "+s2;
    n = s1.length()-1;
    m = s2.length()-1;
    for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++)
        if (s1[i] == s2[j]) f[i][j] = f[i-1][j-1]+1; else f[i][j] = max(f[i-1][j], f[i][j-1]);
    i = n; j = m;
    while (i > 0 && j > 0)
    {
        if (s1[i] == s2[j])
        {
            res = s2[j]+res;
            i--; j--;
        }
        else if (f[i-1][j] > f[i][j-1]) i--; else j--;
    }
    cout << res;
    return 0;
}


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

using namespace std;

int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

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

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

int main()
{
    string x , y;
    cin>> x >> y;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    reverse(y.begin(),y.end());
    if(lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())){
        puts("Yes");
    }
    else
        puts("No");
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);	
	int n;
	cin >> n;
	vector<int> ans(3);
	while (n > 0) {
		ans.push_back(n % 10);
		n /= 10;
	}	
	bool ok = false;
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i] == 7) {
			ok = true;
			break;
		}
	}
	if (ok) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


Measured memory_bytes: 3576
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(n)]
sirusi=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
D=deque([0])
visited=[False]*n
visited[0]=True
while D:
    v=D.popleft()
    for i in graph[v]:
        if visited[i]:continue
        visited[i]=True
        sirusi[i]=v
        D.append(i)
print("Yes")
for i in range(1,n):
    print(sirusi[i]+1)

Measured memory_bytes: 34860
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int a,b;
    cin>>a>>b;
    if(a != 1 and b != 1) cout<<1<<"\n";
    else if(a != 2 and b != 2) cout<<2<<"\n";
    else cout<<3<<"\n";

    return 0;
}

Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

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

	int n;
	scanf("%d", &n);
	vector < int > v(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &v[i]);
	int ptr1 = 0, ans = 0;
	while(ptr1 < n)
	{
		ans++;
		if (ptr1 == n - 1)
			break;
		int ptr2 = ptr1, ptr3 = ptr1;
		while(ptr2 < n - 1 && v[ptr2 + 1] >= v[ptr2])
			ptr2++;
		while(ptr3 < n - 1 && v[ptr3 + 1] <= v[ptr3])
			ptr3++;
		ptr1 = max(ptr2, ptr3) + 1;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
map<char,int> logic;
string s;
int ind;
int atom()
{
  int tmp=logic[s[ind]];
  ++ind;
  return tmp;
}
int formula()
{
  if(s[ind]=='-'){
    ++ind;
    return 2-formula();
  }else if(s[ind]=='('){
    ++ind;
    int tmpl=formula();
    int tmp;
    if(s[ind]=='+') tmp=0;
    if(s[ind]=='*') tmp=1;
    ++ind;
    int tmpr=formula();
    ++ind;
    return tmp ? min(tmpl,tmpr) : max(tmpl,tmpr);
  }else return atom();
}

int main(void)
{
  int n;
  REP(i,3)logic['0'+i]=i;
  while(getline(cin,s)){
    if(s==".") break;
    int ans=0;
    REP(p,3) REP(q,3) REP(r,3){
      logic['P']=p;
      logic['Q']=q;
      logic['R']=r;
      ind=0;
      if(formula()==2) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}

int main(){
  char ans;
  cin>>ans;
  if(isupper(ans)){
    cout<<'A'<<endl;
  }else{
    cout<<'a'<<endl;
  }
  
}


Measured memory_bytes: 3632
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int main(void) {
  lld s,w;
  scanf("%lld%lld", &s, &w);
  puts(s > w ? "safe" : "unsafe");
}

Measured memory_bytes: 1660