akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
int n,m,s[2001],t[2001],sumarray[2001]={0};

signed main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3620
array_1 = []
for i in range(3):
    line = input().rstrip().split(' ')
    array_1.append(line)

bool_array = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(False)
    bool_array.append(tmp)
num = int(input().rstrip())
for i in range(num):
    input_line = input().rstrip()
    for j in range(3):
        for k in range(3):
            if array_1[j][k] == input_line:
                bool_array[j][k] = True

ans = "No"
for i in range(3):
    if bool_array[i][0] and bool_array[i][1] and bool_array[i][2]:
        ans = 'Yes'

    if bool_array[0][i] and bool_array[1][i] and bool_array[2][i]:
        ans = 'Yes'

if bool_array[0][0] and bool_array[1][1] and bool_array[2][2]:
    ans = 'Yes'

if bool_array[0][2] and bool_array[1][1] and bool_array[2][0]:
    ans = 'Yes'
print(ans)


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

INF = 10**15
d = [INF] * N
d[0] = 0
def bellman_ford():
  global d
  for i in range(N):
    for a, b, c in road:
      d[b] = min(d[b], d[a] + c)

bellman_ford()
for a, b, c in road:
  new_d = d[a] + c
  if new_d < d[b]:
    d[b] = - float('inf')

bellman_ford()
if d[-1] > -float('inf'):
  print(int(-d[-1]))
else:
  print('inf')

Measured memory_bytes: 46440
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>

#define M 1000000000

using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i(0);i<n;i++){
        cin >> a[i];
    }
    
    double ans(0);
    for(int i(0);i<n;i++){
        ans += M/a[i];
    }
    
    cout << setprecision(10) << M/ans << endl;
    
    return 0;
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define double long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n , d ; 
/* END OF VARIABLES */



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

	cin >> n   ; 
	if(n >= 30) 
		cout << "Yes" ; 
	else 
		cout << "No" ;
	

	
	
	return 0 ; 
}



Measured memory_bytes: 3632
S = list(input())

temp1 = S[0]
temp2 = ""
i = 1
c = 1
while i < len(S):
    temp2 += S[i]
    if temp1 != temp2:
        c += 1
        temp1 = temp2
        temp2 = ""
    i += 1

print(c)


Measured memory_bytes: 4840
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.equals("SUN")){
      System.out.println(7);
    }else if(s.equals("MON")){
      System.out.println(6);
    }else if(s.equals("TUE")){
      System.out.println(5);
    }else if(s.equals("WED")){
      System.out.println(4);
    }else if(s.equals("THU")){
      System.out.println(3);
    }else if(s.equals("FRI")){
      System.out.println(2);
    }else if(s.equals("SAT")){
      System.out.println(1);
    }
  }
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(n) for(int s = 0; s < 1 << n; ++s)
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define parity(a,b) (((a) & 1)^((b) & 1)^1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<class T,class U> auto LB(T v, U in){ return lower_bound(begin(v), end(v), in); }

template<class T,class U> auto UB(T v, U in){ return upper_bound(begin(v), end(v), in); }

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N,H,a[100001],b[100001];

void solve(){
	
	sort(a,a+N);
	sort(b,b+N);
	
	int p = lower_bound(b,b+N,a[N-1]) - begin(b);
	int c = 0;
	
	repD(i,N-1,p){
		++c;
		H -= b[i];
		if(H <= 0){
			cout<<c<<endl;
			return;
		}
	}
	
	c += (H % a[N-1] > 0);
	cout<< c + H/a[N-1] <<endl;
	
	return;
}

void input(){
	
	cin>>N>>H;
	rep(i,N) cin>>a[i]>>b[i];
	
	return;
}

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





Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

const ll WEIGHT=-1;
struct stick{
	ll r,b,p,q;
	stick(ll r,ll b,ll p,ll q):r(r),b(b){
		ll g=gcd(p,q);
		this->p=p/g;
		this->q=q/g;
	}
	ll getroot(ll index,vector<stick> &sticks){
		REP(i,sticks.size()){
			if(sticks[i].r==index||sticks[i].b==index){
				return sticks[i].getroot(i,sticks);
			}
		}
		return index;
	}
	ll go(vector<stick> &sticks){
		ll rw=0,bw=0;
		if(r!=WEIGHT){
			rw=sticks[r].go(sticks);
		}else{
			rw=1;
		}
		if(b!=WEIGHT){
			bw=sticks[b].go(sticks);
		}else{
			bw=1;
		}

		ll l = lcm(p * rw, q * bw);
		rw=l/p;
		bw=l/q;
		assert(rw);
		assert(bw);

		return rw+bw;
	}
};


int main(){
	ll n;
	while(cin>>n,n){
		vector<stick> sticks;
		REP(i,n){
			ll p,q,r,b;
			cin>>p>>q>>r>>b;
			r--;b--;
			sticks.push_back(stick(r,b,p,q));
		}
		ll root=sticks[0].getroot(0,sticks);
		cout<<sticks[root].go(sticks)<<endl;
	}
}

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

int	main(void)
{
	int		K, slen, i;
	char	S[101];

	scanf("%d", &K);
	scanf("%s", S);
	slen = strlen(S);
	if (K < slen)
	{
		for (i = 0; i < K; i++)
			putchar(S[i]);
		puts("...");
	}
	else
		printf("%s\n", S);
	return (0);
}

Measured memory_bytes: 1596
#include<iostream>
using namespace std;
int swp(int &a, int &b)
{
    int temp;
    temp=a;
    a=b;
    b=temp;
}
int main()
{
    int a,b,c;

    cin>>a>>b>>c;

    if(a>b)
        swp(a,b);
    if(b>c)
        swp(b,c);
    if(a>b)
        swp(a,b);

    cout<<a <<" "<< b<<" "<<c<<endl;

    return 0;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MAX=100000;

typedef long long ll;

int cnt[MAX],n;

bool check(int id){
  while(id<=n-1){
    if(cnt[id] != 2) return false;
    id = id+2;
  }
  return true;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    int x; cin >> x;
    cnt[x]++;
  }
  bool pos;
  if(n % 2==0){
    pos=check(1);
  }else{
    if(cnt[0] != 1) pos=false;
    else pos=check(2);
  }
  if(pos){
    ll ans=1;
    for(int i=0;i<n/2;i++){
      ans = (ans*2) % 1000000007;
    }
    cout << ans << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mts(N);
  int ans = 0;
  
  for(int k=0; k<N; k++){
    cin >> mts.at(k);
  }
  
  for(int i=0; i<N; i++){
    
    int a = 0;
    
    for(int j=0; j<i; j++){
      
      if(mts.at(i) < mts.at(j)){
        
        a++;
        
      }
      
    }
      
    if(a == 0){
      
      ans++;
      
    }
      
    }
      
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>
#include <numeric>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
  int n;
  cin >> n;
  vector<double> v(n);

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

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

  double nowval = v[0];
  for(int i=1; i<n; ++i){
    nowval = (nowval + v[i])/ 2.0;
   }

	cout.precision(8);
  cout << nowval << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main(){
int n,ans,temp;
  scanf("%d%d",&n,&ans);
  n--;
  while(n--){
  scanf("%d",&temp);
    ans=gcd(ans,temp);
  } 
  printf("%d\n",ans);
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

vector<int> a(3);

void solve() {
	for(int i = 0; i < 3; i++) cin >> a[i];
	sort(a.begin(), a.end());
	if (a[0] == a[1] && a[1] != a[2]) {
		cout << "Yes";
	} else if (a[0] != a[1] && a[1] == a[2]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,c;
    scanf("%d%d",&A,&B);
    if(A<=5)
    {
        printf("%d",0);
    }
    else if(A>=6&&A<=12)
    {
        printf("%d",B/2);
    }
    else
    {
        printf("%d",B);
    }
    return 0;
}


Measured memory_bytes: 128
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    do i=1,n
        a=0
        b=x(i)
        do j=1,100
            if(mod(b,2)/=0)then
                x(i)=a
            else
                a=a+1
                b=b/2
            end if
        end do
    end do
    write(*,*)minval(x)

    stop
end program sample
  



Measured memory_bytes: 2824
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair< int , int >PII;
// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<PII,null_type,less<PII>,rb_tree_tag,tree_order_statistics_node_update>
ordered_set;

typedef long long LL;
const int MAXN = 1e5+7;

int a[MAXN];
int cum[MAXN];
int n;

LL solve(int x) {
    LL ans = 0;
    ordered_set os;
    os.insert(PII(0, 0));
    for (int i = 1; i <= n; i++) {
        cum[i] = cum[i-1];
        if (a[i] <= x) cum[i]++;
        else cum[i]--;
        ans += os.order_of_key(PII(cum[i], 0));
        os.insert(PII(cum[i], i));
    }

//    cout << x << " -> " << ans << endl;
    return ans;
}


int main() {
    cin >> n;

    vector< int >v(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        v[i-1] = a[i];
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    LL k = n*1LL*(n+1);
    k /= 2;
    k = k/2+1;

//    cout << "need " << k << "-th" << endl;

    int lo = 0, hi = v.size()-1;
    while (lo <= hi) {
        int mid = (lo+hi)/2;
        if (k <= solve(v[mid])) hi = mid-1;
        else lo = mid+1;
    }

    cout << v[lo] << endl;


    return 0;
}


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

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

using ll=long long;
const int Nmax=100010;
int N; 
ll dp[Nmax];
int h[Nmax];
const ll INF=1LL<<60;


int main(){
  cin >> N;
  for (int i=0;i<N;i++)
    cin >> h[i];
  for (int i=0;i<Nmax;i++)
    dp[i]=INF;
  dp[0]=0;
  for (int i=0;i<N;i++){
    chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  }
  cout << dp[N-1] << endl;
  
}

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

int main() {

    while(1){

        int h;

        cin >> h;

        if(h == 0) break;

        int puzzle[h][5];

        for(int i=h-1; i>=0; i--){
            for(int j=0; j<5; j++){
                cin >> puzzle[i][j];
            }
        }

        int score = 0;

        while(1){

            bool deleted = false;

            for(int i=0; i<h; i++){

                for(int j=0; j<3; j++){
                    int matchnum = 1;
                    int index = -1;
                    for(int k=j; k<4; k++){
                        if(puzzle[i][k] == puzzle[i][k+1] && puzzle[i][k] != 0){
                            matchnum++;
                        }
                        else{
                            index = k;
                            break;
                        }
                    }
                    if(matchnum >= 3){

                        deleted = true;
                        if(index==-1){
                            index = 4;
                        }

                        score += matchnum * puzzle[i][index];

                        for(int k=0; k<matchnum; k++){
                            puzzle[i][index-k] = 0;
                        }

                        break;

                    }
                }

            }


            for(int g=0; g<h-1;g++) { //複数行同時に消えた時のため
                for (int j = 0; j < h - 1; j++) {
                    for (int k = 0; k < 5; k++) {
                        if (puzzle[j][k] == 0 && puzzle[j + 1][k]) {
                            swap(puzzle[j][k], puzzle[j + 1][k]);
                        }
                    }
                }
            }


            if(!deleted) break;

        }

        cout << score << endl;

    }

    return 0;
}


Measured memory_bytes: 3068
import Text.Printf

solve :: [Double] -> [Double]
solve [a, b, c] = [area, perimeter, height]
    where
        theta     = pi * c / 180
        height    = b * sin theta
        width     = b * cos theta - a
        area      = a * height / 2
        perimeter = a + b + (sqrt $ height * height + width * width)

main :: IO ()
main = getLine >>= putStr . unlines . map (printf "%.8f") . solve . map read . words

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

class DisjointSet {
public:
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for(int i=0; i<size; i++) makeSet(i);
    }

    void makeSet(int x) {
        p.at(x) = x;
        rank.at(x) = 0;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if(rank.at(x)>rank.at(y)) {
            p.at(y)=x;
        }
        else {
            p.at(x)=y;
            if (rank.at(x)==rank.at(y)) {
                rank.at(y)++;
            }
        }
    }

    int findSet(int x) {
        if (x!=p.at(x)) {
            p.at(x) = findSet(p.at(x));
        }
        return p.at(x);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;

    DisjointSet ds = DisjointSet(N);

    int x, y, z;
    for(int i=0;i<M;i++) {
        cin >> x >> y >> z;
        x--; y--;

        ds.unite(x, y);
    }

    vector<int> parent(N);
    for(int i=0;i<N;i++) {
        parent.at(i) = ds.findSet(i);
    }

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

    int cnt=1;
    for(int i=0;i<N-1;i++) {
        if(parent.at(i)!=parent.at(i+1)) cnt++;
    }

    cout << cnt << endl;
    
    return (0);
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();
		System.out.println((int)Math.min(B, D) - (int)Math.max(A, C) >= 0 ? (int)Math.min(B, D) - (int)Math.max(A, C) : 0);
		scan.close();

	}

}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;



typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
/**********showtime************/


int main(){
            string str;
            cin>>str;
            sort(str.begin(), str.end());
            int flag = 1;
            if(str[0] == str[1] && str[2] == str[3] && str[0] != str[2]) puts("Yes");
            else puts("No");

            return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,k;
    scanf("%d",&k);
    scanf("%d %d",&A,&B);
    for(int i=A;i<=B;i++)
    {
        if(i%k==0)
        {
            printf("OK\n");
            return 0;
        }

    }
            printf("NG\n");



}


Measured memory_bytes: 1636
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          #define pb push_back
          #define ll long long
          #define ld long double

          int main()
          {
               tani_nachi_ke  

            
            long long n,d,a;
            cin >> n >> d >> a;
            map<long long,long long> mp;
            map<long long,long long> f;
            for(int i = 0; i < n; i++)
            {
                long long x,y;
                cin >> x >> y;
                mp[x] = max(mp[x],y);
                f[x];
            }
            
            long long t = 1;
            for(auto &it:f)
                f[it.ff] = (t++);

            long long pref[n+100] = {0};
            long long ans = 0;

            for(auto &it:mp)
            {
                // cout << it.ff << " it " << it.ss << endl;

                long long x=it.ff,y=it.ss;
                pref[f[x]] += pref[f[x]-1];
                // cout << f[x] << " " << pref[f[x]] << endl;
                if(pref[f[x]] >= y)
                    continue;
                else
                {
                    long long m = (y - pref[f[x]] + a - 1)/a;
                    pref[f[x]] += m*a;
                    ans += m;
                    auto itt = f.upper_bound(x + 2*d);
                    // cout << m << endl;
                    if(itt == f.end())
                        continue;
                    pref[(*itt).ss] -= m*a;

                    // cout << m << " m " << (*itt).ss << endl;
                }
            }
            cout << ans << endl;



         
               return 0;
          }

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

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	if (b + W < a) cout << a - (b + W);
	else if (a + W < b) cout << b - (a + W);
	else cout << 0;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、連結でない時、つまり動かさなければいけない時を考えてみよう

1. 二つ目の長方形が左側にある
 →b+W < aである よってa-(b+W)だけ動かせば連結になる
2. 二つ目の長方形が右側にある
 →a+W < bである よってb-(a+W)だけ動かせば連結になる

この条件に引っかからなければ連結なので0を出力すれば良いね
……連結って言葉にすごく違和感を感じるけど、入出力例が一致するのこれしかないから、仕方ないね
*/

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

#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f // 100'000'000'000'000
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N= 1e5+10, mod=1e9+7;

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

    double r;
    cin>>r;
    cout<<fixed<<setprecision(10)<<(2*acos(-1)*r);
    
    return 0;
}



Measured memory_bytes: 3796
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
 
using namespace std;
int main(){
    string str;
    int p, a, b;
    string command, alt;
     
    string abb ; 
    cin >> str >> p;
    for(int i = 0; i < p; i++){
        cin >> command;
        if(command == "replace"){
            cin >> a >> b >> alt;
            str.replace(a, b-a+1, alt);
            }
         
        if(command == "reverse"){
            cin >> a >> b;
            string rev;
            abb = str.substr(0, a);
            alt = str.substr(b + 1, str.size() - 1);
             
            for(int i = b; i >= a; i--){
                rev += str[i];
            }
            str = abb + rev + alt;
        }
        if(command == "print"){
            cin >> a >> b;
            for(int i = a; i <= b; i++){
                cout << str[i];
            }
            cout << endl;
        } 
    }
    return 0;
    }
 
     
 
           


Measured memory_bytes: 3208
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		try(Scanner sc=new Scanner(System.in)){
			String line=sc.nextLine();
			String answer="";
			int length=line.length();
			for(int i=0;i<length;i++) {
				char ch=line.charAt(i);
				if(Character.isLowerCase(ch)) {
					answer+=Character.toUpperCase(ch);
				}else if(Character.isUpperCase(ch)) {
					answer+=Character.toLowerCase(ch);
				}else {
					answer+=ch;
				}
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 31416
n = int(input())
v = [list(map(int,input().split())) for i in range(n)]

dp = [[0,0,0] for i in range(n+1)]
dp[0] = v[0]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i+1][k])
print(max(dp[n-1]))

Measured memory_bytes: 76380
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  if ( tail + 1 == LEN ) {
    tail = 0;
  } else {
    tail++;
  }
}

P dequeue() {
  P x = Q[head];
  if ( head + 1 == LEN ) {
    head = 0;
  } else {
    head++;
  }
  return x;
}

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

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++ ){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }

  return 0;
}


Measured memory_bytes: 12832
#include<iostream>
using namespace std;
int main()
{
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {

  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int M = N/2;
  
  int check = 0;
  
  if (N % 2 == 1) check = 1;
  
  else {
    for (int i = 0; i < N/2; i++) {
      if (S[i] != S[M + i]) {
        check = 1;
        break;
      }
    }
  }
  
  if (check == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long long S,x[5],y[5],F=1e9;
int main(){
	scanf("%lld",&S);
	x[1]=y[1]=0; x[2]=1; y[2]=F; x[3]=S/F+(S%F!=0); y[3]=x[3]*F-S;
	for(int i=1;i<=3;++i) printf("%lld %lld%c",x[i],y[i],i==3?'\n':' ');
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <tuple>
#include <vector>
#include <numeric>

#define ll uint64_t
using namespace std;
ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

ll lcm(ll a, ll b){
  if(a < b) return lcm(b,a);
  if(a%b == 0) return a;
  ll g = gcd(a, b);
  return a / g * b;
}

int main() {
  int n; cin >> n;
  ll arr[n] ; 
  for(int i=0; i < n; i++) cin >> arr[i];
  ll ans = arr[0];
  for(int i=0; i<n; i++){
     ans = lcm(ans, arr[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			d = scanner.nextInt();
			n = scanner.nextInt();
			if ((d | n) == 0)
				break;
			aer = new AER[n];
			for (int i = 0; i < n; i++) {
				aer[i] = new AER(scanner.nextInt(), scanner.nextInt(),
						scanner.nextInt());
			}
			dp = new int[d + 1][101];
			for (int[] dpp : dp)
				Arrays.fill(dpp, INF);
			PriorityQueue<AER> pq = new PriorityQueue<AER>();
			pq.offer(new AER(d, 0, 0));
			ans = INF;
			while (!pq.isEmpty()) {
				AER now = pq.poll();
				if (now.a == 0) {
					ans = Math.min(ans, now.r);
					break;
				}
				for (AER a : aer) {
					if (now.e < a.r)
						continue;
					int nhp = Math.max(0, now.a - a.a);
					int nexp = Math.min(100, now.e + a.e);
					if (now.a == nhp && now.e == nexp)
						continue;
					if (dp[nhp][nexp] <= now.r + 1)
						continue;
					dp[nhp][nexp] = now.r + 1;
					pq.offer(new AER(nhp, nexp, now.r + 1));

				}
			}
			System.out.println(ans == INF ? "NA" : ans);
		}
	}

	int d, n;
	int[][] dp;
	int INF = 1 << 30;
	AER[] aer;
	int ans;

	class AER implements Comparable<AER> {
		int a, e, r;

		public AER(int a, int e, int r) {
			super();
			this.a = a;
			this.e = e;
			this.r = r;
		}

		@Override
		public String toString() {
			return "AER [a=" + a + ", e=" + e + ", r=" + r + "]";
		}

		@Override
		public int compareTo(AER o) {
			if (this.r == o.r)
				return this.a - o.a;
			return this.r - o.r;
		}
	}
}

Measured memory_bytes: 49696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

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

int main() {
    // input, ready
    ll H,N;
    vector<int> AList;
    cin >> H >> N; 
    AList.resize(N);
    ll totalAtack=0;
    for (int i=0; i<N; i++) cin >> AList.at(i);
    for (int i=0; i<N; i++) totalAtack += AList[i];

    // output
    if (H<=totalAtack) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 768
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X-500*i-100*j-50*k==0:
        ans+=1
print(ans)

Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true){
                
                string[] input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]);
                if (x == 0 && y == 0)
                {
                    break;
                }
                if(x > y)
                {
                    int a = y;
                    y = x;
                    x = a;
                }
                Console.WriteLine(x + " " + y);
            
            }
        }
    }
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<lint> A(N), B(N);
    for_(i,0,N) {
        cin >> A[i] >> B[i];
        if ((N & 1) == 0) {
            A[i] *= 2;
            B[i] *= 2;
        }
    }

    sort(ALL(A));
    sort(ALL(B));

    lint a = (N & 1 ? A[N/2] : (A[N/2-1] + A[N/2]) / 2);
    lint b = (N & 1 ? B[N/2] : (B[N/2-1] + B[N/2]) / 2);
    if (a > b) swap(a, b);
    cout << b - a + 1 << endl;
}

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

ll N,h[100],th[100];
bool flag = true;

bool check(){
    rep(i,N) if(h[i] != th[i])return false;
    return true;
}

int main(void){
    cin >>N;
    rep(i,N)cin >> h[i];
    
    ll i,ans=0;
    while(!check()){
        i = 0;
        while(i<N){
            flag = false;
            while(h[i]>th[i]){
                flag = true;
                th[i]++;
                i++;
            }
            if(flag)ans++;
            else i++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N; cin>>N;
	vi V(N);
	rp(i,N)	{
		cin>>V[i];
	}
	int ans = 0;
	rp(i,N){
		int c; cin>>c;
		ans += max(0, V[i]-c);
	}
ote(ans);
}

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

int main() {
	
    string ans="Yes";
    string s;
	cin>>s;

    if(s.size()%2==1){
        ans="No";
        cout << ans << "\n";
        return 0;
    }

    for(int i=0;i<s.size();i=i+2){
        if(!(s.at(i)=='h'&&s.at(i+1)=='i'))ans="No";
    }

	cout << ans << "\n";
	return 0;
}


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

signed main(){

    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        a[i] = b[n - i - 1] = 20000 * i + 1;
    } 

    for(int i = 0; i < n; i++){
        a[p[i] - 1] += i;
        b[p[i] - 1] += i;
    }

    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    
    for(int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int i=-118;i<=119;i++){
        for(int j=-119;j<=118;j++){
            long long int x = pow(i,5);
            long long int y = pow(j,5);
            if(x-y==n){
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4104
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a:usize = sc.read();
    let b:usize = sc.read();
    println!("{}", 6-a-b);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
#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,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
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);}
}

const int N=2e5+5;
int ma,a[N],b[N],L[N],R[N],n;

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),R[a[i]]=i;
	for(int i=1;i<=n;i++) read(b[i]),L[b[i]]=!L[b[i]]?i:L[b[i]];
	L[n+1]=n+1;
	for(int i=n;i;i--) L[i]=!L[i]?L[i+1]:L[i];
	for(int i=1;i<=n;i++) R[i]=!R[i]?R[i-1]:R[i];
	for(int i=1;i<=n;i++) ma=max(ma,R[i]-L[i]+1);
	rotate(b+1,b+n-ma+1,b+1+n);
	for(int i=1;i<=n;i++) if(a[i]==b[i]) return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;i++) write(b[i]),putchar(' ');
}

Measured memory_bytes: 6736
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
ans = 0
# for bin_a in map(bin, a):
d = 1
num_of_one_per_keta = []
while d < (1 << 61):
    cnt = np.count_nonzero(a & d)
    num_of_one_per_keta.append(cnt)
    d <<= 1
ans = 0
for i, num_of_one in enumerate(num_of_one_per_keta):
    ans += (n-num_of_one)*num_of_one*pow(2, i, mod) % mod
print(ans % mod)


Measured memory_bytes: 48852
s = input()
N = len(s) + 1
a = [0] * N

for i in range(len(s)):
    if s[i] == '<':
        a[i + 1] = a[i] + 1

for i in range(len(s) - 1, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)

print(sum(a))

Measured memory_bytes: 23336
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct st{
int bit;
int count;
};
int main() {
int n,m;
	cin>>n>>m;
	int bit=0;
	REP(i,n){
	int shift;
	cin >> shift;
	bit |= shift << (n - i-1);
	}
	vector<int> ans(m);
	REP(i,m){
		cin>>ans[i];
	}
	int bit_ans=0;
	int bit_ans2;
	REP(i,m){
		REP(j, ans[i]){
			bit_ans <<=1;
			if (i % 2 == 0){
			bit_ans|=1;
			}
			
	}
	}
	bit_ans2=bit_ans^((1<<n)-1);
	int count=0;
	set<int> dp;
	dp.insert(bit);
	queue<st> P;
	P.push({bit,0});
	while (!P.empty()){
		st p = P.front(); P.pop();
		if (p.bit == bit_ans || p.bit == bit_ans2){
		count=p.count;
		break;
		}
		REP(i,n-1){
			if ((p.bit >> i & 1 ) != (p.bit >> (i + 1) & 1)){
				int bitc = p.bit^3<<i;
				if (dp.find(bitc) == dp.end()){
					dp.insert(bitc);
					P.push({ bitc, p.count + 1 });
				}
			}
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3448
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    mod = 10**9 + 7

    # max_nCrまで調べられる
    max_n = 4*10**5
    fac, inv = [1]*(max_n+1), [0]*(max_n+1)
    for i in range(2, max_n+1):
        fac[i] = fac[i-1] * i % mod
    inv[-1] = pow(fac[-1], mod-2, mod)
    for i in range(max_n, 0, -1):
        inv[i-1] = inv[i] * i % mod
    
    # nCrを求める
    def ncr(n, r):
        return fac[n]*inv[r]*inv[n-r]%mod

    n,m,k = map(int, input().split())

    base = ncr(n*m-2, k-2)

    res = 0
    # x方向
    for i in range(1, m):
        res += n**2 * i * (m-i)
        res %= mod

    for i in range(1, n):
        res += m**2 * i * (n-i)
        res %= mod

    print(res*base%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35060
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			string input = Console.ReadLine();
			int num = int.Parse(input);
			if (num < 357)
			{
				Console.WriteLine(0);
				return;
			}
			List<string> data = new List<string>() { "357", "375", "537", "573", "735", "753" };

			for(int i = 3; i < input.Length; i++)
			{
				List<string> temp = new List<string>();
				temp.AddRange(data);
				foreach (var v in data)
				{
					temp.AddRange(push(v));
				}
				data.Clear();
				data.AddRange(temp);
				data = data.Distinct().ToList();
			}
			var result = data.Where(x => int.Parse(x) <= num);

			Console.WriteLine(result.Count());
		}
		static string[] push(string input)
		{
			List<string> data = new List<string>();
			for (int i = 0; i < input.Length + 1; i++)
			{
				data.Add(input.Insert(i, "3"));
			}
			for (int i = 0; i < input.Length + 1; i++)
			{
				data.Add(input.Insert(i, "5"));
			}
			for (int i = 0; i < input.Length + 1; i++)
			{
				data.Add(input.Insert(i, "7"));
			}
			return data.Distinct().ToArray();
		}
	}
}


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

void f(int &d,int p,int a){
  if(p<0)return;
  if(d<0||d>p+a)d=p+a;
}

int N,M,T,S,a,b,c,key;

signed main(){
  cin>>N>>M;T=1<<N;
  vector<int> dp(T,-1);dp[0]=0;
  while(M--){
    key=0,S=T;cin>>a>>b;
    while(b--){
      int c;cin>>c;c--;
      key|=1<<c;
    }
    while(S--)f(dp[S|key],dp[S],a);
  }
  cout<<dp[T-1]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    int flag=0;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
      
        if(a==b)
        {
            cnt++;
        }
        else 
        cnt=0;
        if(cnt>=3){flag=1;break;}
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x < 0 || x + r > W)
        	System.out.println("No");
        else if(y < 0 || y + r > H)
        	System.out.println("No");
        else if(x >= 0 && x + r <= W)
        	System.out.println("Yes");
        else if(y >= 0 && y + r <= H)
        	System.out.println("Yes");
	}
}

Measured memory_bytes: 26348
#↓s      g↓
#0001000100
#0123456789
# x  x x   

n,m=map(int,input().split())
s=input()
s=s[::-1]

ans=[]
i=0
while i < n:
    best=min(i+m,n)
    flag=0
    while best>i:

        if s[best]=="0":
            ans.append(str(best-i))
            i=best
            flag=1
        else:
            best-=1


    if flag==0:
        print(-1)
        exit()

print(" ".join(ans[::-1]))



    

Measured memory_bytes: 47856
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print(x3, y3, x4, y4)


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

int main() {
  char moji;
  cin >> moji;
  if(moji=='a'||moji=='i'||moji=='u'||moji=='e'||moji=='o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

int main(){
    char a,b;
    cin >> a >> b;
    string s1 = "",s2 = "";
    for(int i = 1;i <= (a-'0');i++){
    	s2 = s2 + b;
	}
	for(int i = 1;i <= (b-'0');i++){
    	s1 = s1 + a;
	}
	if(s1 < s2) cout << s1 << endl;
	else cout << s2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  FORe(i, 1, n){
    int t = i;
    int sum = 0;
    while(t != 0){
      sum += t % 10;
      t /= 10;
    }
    if(a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
flag = all(c == "A" for c in s) or all(c == "B" for c in s)
ans = "No" if flag else "Yes"
print(ans)


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

int main(){
    int N;  cin >> N;
    vector<pair<int, int>> W(N);
    for(int i=0; i<N; i++){
        cin >> W[i].first >> W[i].second;
    }
    sort(W.begin(), W.end(), [](const pair<int, int>& a, const pair<int, int>& b){
        return a.second < b.second;
    });

    int now = 0;
    for(auto w : W){
        if(now + w.first > w.second){
            cout << "No" << endl;
            return 0;
        }else{
            now += w.first;
        }
    }
    cout << "Yes" << endl;
}   

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))

cs = [0]*9
for a in A:
    if a >= 3200:
        cs[-1] += 1
    else:
        cs[a//400] += 1
mn = len([1 for c in cs[:-1] if c>0])
if mn==0:
    print(1,N)
else:
    print(mn,mn+cs[-1])

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

//C

int main() {
	// your code goes here
	long long n,m,a[100005],f[100005],ans=1,mod=1000000007;
	int i;
	cin >> n >> m;
	f[0]=1; f[1]=1;
	for(i=2;i<=n;i++){
		f[i]=(f[i-1]+f[i-2])%mod;
	}
	if(m==0){
		cout << f[n] << endl;
		return 0;
	}
	a[0]=-1;
	for(i=1;i<=m;i++){
		cin >> a[i];
		if(a[i]-a[i-1]==1) ans=0;
		else ans=(ans*f[a[i]-a[i-1]-2])%mod;
	}
	ans=(ans*f[n-a[m]-1])%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI()

    r = []
    for i in range(k,n):
        if a[i] > a[i-k]:
            r.append('Yes')
        else:
            r.append('No')

    return JA(r, "\n")

print(main())





Measured memory_bytes: 33612