akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int max3(int a,int b, int c){
  int max = a;
  if(max < b){
    max = b;
  }
  if(max < c){
    max = c;
  }
  return max;
}

//grobal var
//------------------------------------------
LL dp[100002];

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N;
  while(cin >> N){
    VI d;
    int ans = 0;
    REP(i,N){
      int tmp;
      cin >> tmp;
      d.PB(tmp);
    }
    SORT(d);
    ans = d[N/2] - d[N/2-1];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#define N 100000
#define Q 50000
int S[N],T[Q],n,l,r,m;
int main(){
  int i,q,Sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    if(Binary(T[i]))
      Sum++; 
  }    
  printf("%d\n",Sum);
  return 0;
}
int Binary(int key){
 int l=0;
 int r=n;

  while(l<r){
    m=(l+r)/2;
    if(key==S[m])
      return 1;
    else if(key<S[m])r=m;
    else if(key>S[m])l=m+1;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

int main(){
    int a;
    char s[15]={};
    scanf("%d%s",&a,s);
    if(a>=3200)printf("%s\n",s);
    else printf("red\n");
    return 0;
}

Measured memory_bytes: 256
A = input()
B = input()
if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
else:
    for k in range(len(A)):
        if int(A[k]) > int(B[k]):
            print("GREATER")
            exit(0)
        elif int(A[k]) < int(B[k]):
            print("LESS")
            exit(0)
    print("EQUAL")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int n;
int main()
{
	cin >> n;
	int x=0,y=0,l=0;
	for(int i=0,t,a,b; i<n; i++)
	{
		cin >> t >> a >> b;
		int k=abs(x-a)+abs(y-b);
		if(t-l < k || (k-t+l)%2)
		{
			cout << "No";
			return 0;
		}
		x=a,y=b,l=t;
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 3616
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
int main()
{

  string s;
  cin >> s;
  ll num = 0;

  for (ll i = 0; i < s.length(); i++)
  {
    if (s[i] == '+')
    {
      num++;
    }
    else
    {
      num--;
    }
  }

  cout << num << endl;

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M;
    ll count = 0, pen = 0;
    vector<pair<bool, ll>> a;
    cin >> N >> M;
    a.resize(N);
    for(ll i = 0;i < M;i++) {
        ll p;
        string S;
        cin >> p >> S;
        if(S == "AC") {
            a[p - 1].first = true;
        } else if(!a[p - 1].first) {
            a[p - 1].second++;
        }
    }
    for(auto &i: a) {
        if(i.first) {
            count++;
            pen += i.second;
        }
    }
    cout << count << ' ' << pen << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
int main() {
  int n;
  int b, f, r, v;
  int i, j, k;
 
  int tenants[4][3][10] = {{{}}};
 
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenants[b-1][f-1][r-1] += v;
  }
 
  for(i = 0; i < 4; ++i) {
    for(j = 0; j < 3; ++j) {
      for(k = 0; k < 10; ++k) {
    printf(" %d", tenants[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3) printf("####################\n");
  }
 
  return 0;
}


Measured memory_bytes: 2132
#include <cstdio>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int vs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
    vs[i]--;
  }

  int res = 0;
  int cur = 0;
  REP(i, 200000+10) {
    if(cur == 1) {
      break;
    } else {
      ++res;
      cur = vs[cur];
    }
  }

  printf("%d\n", res < 150000 ? res : -1);
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int m = 1000000007;
    int A[N/2] = {}; 
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A[a/2]++;
    }
    long long res;
    bool flag = false;
    if(N==1){
        res = 1;
    } else if(N%2){
        if(A[0] == 1){
            for(int i=1;i<N/2;i++){
                if(A[i] != 2) flag = true;
            }
        }else{
            flag = true;
        }
        if(flag){
            res = 0;
        }else{
            res = 1;
            for(int i=0;i<N/2;i++){
                res *= 2;
                res %= m;
            }
        }
    }else{
        for(int i=0;i<N/2;i++){
            if(A[i] != 2) flag = true;
        }
        if(flag){
            res = 0;
        }else{
            res = 1;
            for(int i=0;i<N/2;i++){
                res *= 2;
                res %= m;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int row[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << row[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(){
	int n, a;
	vector<int> A;
	cin >> n;
	
	for(int i=0 ; i<n ; i++){
		A.clear();
		for(int j=0 ; j<10 ; j++){
			cin >> a;
			A.push_back(a);
		}
		stack<int> B, C;
		bool flag = true;
		B.push(0);
		C.push(0);
		for(int j=0 ; j<10 ; j++){
			a = A[j];
			if( B.top() == 0 ){
				B.push( a );
			}else{
				if( B.top() > a ){
					if( C.top() > a ){
						cout << "NO" << endl;
						flag = false;
						break;
					}else{
						C.push(a);
					}
				}else{
					if( C.top() > a ){
						B.push(a);
					}else{
						( a-B.top() < a-C.top() )? B.push(a) : C.push(a) ;
					}
				}
			}
		}
		if( flag ){
			cout << "YES" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

vector<int> vec[200010];

bool isExist(int x,int y){
	int ind = lower_bound(all(vec[y]),x) - vec[y].begin();
	return vec[y][ind] == x;
}

signed main(){
	int h,w,n;
	cin >> h >> w >> n;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y; x--;y--;
		vec[y].push_back(x);
	}
	for(int i = 0;i < w;i++){
		vec[i].push_back(h);
		sort(all(vec[i]));
	}
	int mi = INF,pos = 0;
	for(int i = 0;i < w;i++){
		int ind = lower_bound(all(vec[i]),pos) - vec[i].begin();
		chmin(mi,vec[i][ind]);
		if(i == w - 1) break;
		if(isExist(pos + 1,i)){
			cout << mi << endl;
			return 0;
		}
		pos++;
		while(isExist(pos,i + 1)){
			if(isExist(pos + 1,i)){
				cout << mi << endl;
				return 0;
			}
			pos++;
		}
	}
	cout << mi << endl;
}

Measured memory_bytes: 12288
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func abs(v int) int {
	if v > 0 {
		return v
	}
	return -v
}

func main() {
	N := readInt()
	A := readIntArray()
	l := 0
	var m []int
	for i := 0; i < N; i++ {
		l += A[i]
		m = append(m, l)
	}
	dist := l
	for i := 0; i < N; i++ {
		d := abs(m[i]*2 - l)
		if d < dist {
			dist = d
		}
	}
	fmt.Println(dist)
}


Measured memory_bytes: 15360
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    long long n;
    cin >> n;
    if (n == 1) cout << 1 << endl;
    for (long long i = 1; i < n; i++) {
        if ((i + 1) * (i + 1) > n) {
            cout << i * i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)
total = as.inject(:+)
ans = 10 ** 10
x = 0
for i in 0..(N - 2) do
  x += as[i]
  y = total - x
  diff = (x - y).abs
  ans = diff if diff < ans
end

puts ans

Measured memory_bytes: 15516
#include<bits/stdc++.h>
using namespace std;
 
int h,n;
int a[1005],b[1005];
int dp[1005][20005];
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    cin>>h>>n;
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        for(int j=0;j<=h+10000;j++){//由于可能伤害不是正好杀死，一定要预留一点伤害的量
            dp[i+1][j]=dp[i][j];
            if(j+a[i]<=h+10000)dp[i][j+a[i]]=min(dp[i][j+a[i]],dp[i][j]+b[i]);
        }
    }
    int ans=0x3f3f3f3f;
    for(int i=h;i<=h+10000;i++){
        ans=min(ans,dp[n - 1][i]);
    }
    cout<<ans<<endl;
 
    return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll a , b ;

int main() {
    cin >> a >> b ;
    if( b % 2 ) b-- ;
    if( b / 2 >= a ){
        cout << abs( a - b / 2 ) / 2 + a << "\n" ;
    } else cout << b / 2 ;


    return 0 ;
}



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

using namespace std;

int main()
{
   int n, i, z=0;
   char a[200000];
   scanf("%s",a);
   n=strlen(a);
   for(i=1;i<n;i++)
   {
       if(a[0]=='1')
       {
           if(((i+1)%2==0&&a[i]=='0')||((i+1)%2==1&&a[i]=='1'))
            ;
           else
            z++;
       }
       if(a[0]=='0')
       {
           if(((i+1)%2==0&&a[i]=='1')||((i+1)%2==1&&a[i]=='0'))
            ;
           else
            z++;
       }
   }
   printf("%d\n",z);
   return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int h,w,num=0;
vector<string> s(100);
queue<pair<int,int>> q;
int vis[100][100]={};


void bfs(int ih,int iw){
    if(ih>=1){
        if(s[ih-1][iw]=='.'&&vis[ih-1][iw]==-1){
            vis[ih-1][iw]=vis[ih][iw]+1;
            q.push(MP(ih-1,iw));
        }
    }
    if(ih<h-1){
        if(s[ih+1][iw]=='.'&&vis[ih+1][iw]==-1){
            vis[ih+1][iw]=vis[ih][iw]+1;
            q.push(MP(ih+1,iw));
        }

    }
    if(iw>=1){
        if(s[ih][iw-1]=='.'&&vis[ih][iw-1]==-1){
            vis[ih][iw-1]=vis[ih][iw]+1;
            q.push(MP(ih,iw-1));
        }

    }
    if(iw<w-1){
        if(s[ih][iw+1]=='.'&&vis[ih][iw+1]==-1){
            vis[ih][iw+1]=vis[ih][iw]+1;
            q.push(MP(ih,iw+1));
        }

    }


    return;
}


int main(void) {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            vis[i][j]=-1;
        }
    }

    cin>>h>>w;

    for (int ih = 0; ih < h; ih++) {
        cin>>s[ih];
        for (int iw = 0; iw < w; iw++) {
            if(s[ih][iw]=='.')num++;
        }
    }

    vis[0][0]=1;
    q.push(MP(0,0));
    while(!q.empty()){
        bfs(q.front().first,q.front().second);
        q.pop();
    }

    if(vis[h-1][w-1]==-1){
        cout<<-1<<"\n";
    }else{
        cout<<num-vis[h-1][w-1]<<"\n";
    }

    

    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n, ans = 0;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 1) ans++;
	}
	if (ans % 2 == 1) cout << "NO" << endl;
	else cout << "YES" << endl;
}

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

typedef long long lglg;

int N, M, costs[1012];
vector<int> unlocks[1012];
int dp[1<<12];

void prnt(int x) {
	for (int i=11; i>=0; --i) {
		if (x&(1<<i)) cout << 1;
		else cout << 0;
	}
	cout << endl;
}

int solve(int x) {
	if (dp[x] != -1) return dp[x];
	int best = -1;
	for (int k=0; k<M; ++k) {
		int cost = costs[k];
		int newx = x;
		for (int u : unlocks[k]) {
			newx &= ~(1<<u);
		}
		if (x == newx) continue;
		cost += solve(newx);
		if (best == -1 || cost < best) best = cost;
	}
	dp[x] = best;
	return best;
}

int main() {
    ios::sync_with_stdio(0);//, cin.tie(0), cout.tie(0);

	cin >> N >> M;
	int boxes = 0;
	for (int i=0; i<M; ++i) {
		int a, b; cin >> a >> b;
		costs[i] = a;
		for (int j=0; j<b; ++j) {
			int c; cin >> c;
			unlocks[i].push_back(c-1);
			boxes |= 1 << (c-1);
		}
	}
	if (boxes != (1<<N)-1) cout << -1;
	else {
		for (int i=0; i<(1<<12); ++i) dp[i] = -1;
		dp[0] = 0;
		cout << solve((1<<N)-1);
	}
}

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

int main() {
int n;
int i;
cin >> n;
int a[100];
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
	 if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0){
		 puts("DENIED");
		 return 0;
	 }
}
puts("APPROVED");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int f = 0, s = 0;
	for (int i = 0; i < 3; i ++)
	{
		cin >> n;
		f += n == 5;
		s += n == 7;
	}
	if (f == 2 && s == 1) puts("YES");
	else puts("NO");
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int 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() {
    int n;
    cin >> n;
    vector<vector<bool>> sell(n, vector<bool>(10));
    rep(i, n) rep(j, 10) {
            int k;
            cin >> k;
            sell[i][j] = k == 1;
        }

    vector<vector<ll>> benefit(n, vector<ll>(11));
    rep(i, n) rep(j, 11) cin >> benefit[i][j];
    ll ans = -INF;
    for (ll i = 1; i < (1 << 10); i++) {
        ll now = 0;
        for (ll k = 0; k < n; k++) {
            ll m = 0;
            for (ll l = 0; l < 10; l++) {
                if ((i >> l) & 1) if (sell[k][l]) m++;
            }
            now += benefit[k][m];
        }
        cmax(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main()
{
	int a, b;
	cin >> a >> b;
	//cout << a << "," << b << endl;
    
	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}


}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		if(a == b) System.out.println(c);
		else if(b == c) System.out.println(a);
		else System.out.println(b);
	}

}


Measured memory_bytes: 22996
A, B, C, X = (int(input()) for _ in range(4))
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            result = 500 * i + 100 * j + 50 * k
            if result == X:
                count += 1
print(count)
        


Measured memory_bytes: 2940
#include <iostream>
#include <cctype>
#include <cstdio>
using namespace std;

int main(void){
	char s;
	while(1){
		scanf("%c", &s);
		if(s=='\n'){
			break;
		}
		if(islower(s)){
			printf("%c", toupper(s));
		}else if(isupper(s)){
			printf("%c", tolower(s));
		}else{
			cout <<s;
		}
	}
	cout <<endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> V(M);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    V.at(i) = {s, c};
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (i == j) continue;
      if (V.at(i).first == V.at(j).first) {
        if (V.at(i).second != V.at(j).second) return cout << -1 << "\n", 0;
      }
    }
  }
  int mi = (N == 1) ? 0 : (N == 2) ? 10 : 100;
  int mx = (N == 1) ? 9 : (N == 2) ? 99 : 999;
  for (int i = mi; i <= mx; i++) {
    for (int j = 0; j < M; j++) {
      auto[a, b] = V.at(j);
      string tmp = to_string(i);
      if (tmp.at(a) - '0' != b) goto NG;
    }
    return cout << i << "\n", 0;
    NG:;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3652
def calcScore():
    for d in range(1, D + 1):
        id = t[d]  # この日に開催するコンテスト
        sinceLast[d][id] = 0
        score[d][id] = s[d][id]


        for i in range(1, 26 + 1):
            if i == id:  continue
            sinceLast[d][i] = sinceLast[d - 1][i] + 1
            score[d][i] = -c[i] * sinceLast[d][i]

    ans = 0
    for d in range(1, D + 1):
        ans += sum(score[d])

    return ans

def calcScoreDiff(score, d, before, after):
    ans = 0
    for dd in range(d, D + 1):
        if dd > d and t[dd] == before:  break
        sinceLast[dd][before] = sinceLast[dd - 1][before] + 1
        ans -= score[dd][before]
        score[dd][before] = -c[before] * sinceLast[dd][before]
        ans += score[dd][before]

    ans -= score[d][after]
    sinceLast[d][after] = 0
    score[d][after] = s[d][after]
    ans += score[d][after]

    for dd in range(d + 1, D + 1):
        if t[dd] == after:  break
        sinceLast[dd][after] = sinceLast[dd - 1][after] + 1
        ans -= score[dd][after]
        score[dd][after] = -c[after] * sinceLast[dd][after]
        ans += score[dd][after]

    return ans

D = int(input())
c = [0] + [int(x) for x in input().split()]
s = [[0 for _ in range(26 + 1)]] + \
    [[0] + [int(x) for x in input().split()] for _ in range(D)]
t = [0] + [int(input()) for _ in range(D)]

score = [[0] * (26 + 1) for _ in range(D + 1)]
sinceLast = [[0] * (26 + 1) for _ in range(D + 1)]
tot = calcScore()

M = int(input())
for i in range(M):
    d, after = [int(x) for x in input().split()]
    before = t[d]
    t[d] = after
    diff = calcScoreDiff(score, d, before, after)
    tot += diff
    print(tot)

Measured memory_bytes: 71796
#include  <bits/stdc++.h>
#include  <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);

int main(){
  string S;
  int n,a=0;
  cin>>S;
  n=S.size();
  REP(i,n){
    if(S[i]=='o')a++;
  }
  if(15-n+a>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
b = lines.shift().split(' ')
a = []
for (i=N; i>0; i--) {
    found = false
    for (j=i; j>0; j--) {
        if (b[j-1] == j) {
            a.push(b.splice(j-1, 1))
            found = true
            break;
        }
    }
    if (!found) {
        a = [-1]
        break;
    }
}
console.log(a.reverse().join("\n"))

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

int cost[101][101],t[101][101];
bool tf,cf;

int wf(int p,int q,int r,int m){
	if(r){
		if(tf){
			for(int k=1 ; k <= m ; ++k){
				for(int i=1 ; i <= m ; ++i){
					for(int j=1 ; j <= m ; ++j){
						if(t[i][j] > t[i][k] + t[k][j]) t[i][j] = t[i][k] + t[k][j];
					}
				}
			}
			tf = false;
			return t[p][q];
		}else return t[p][q];
	}else if(cf){
		for(int k=1 ; k <= m ; ++k){
			for(int i=1 ; i <= m ; ++i){
				for(int j=1 ; j <= m ; ++j){
						if(cost[i][j] > cost[i][k] + cost[k][j]) cost[i][j] = cost[i][k] + cost[k][j];
				}
			}
		}
		cf = false;
		return cost[p][q];
	}
	else return cost[p][q];
}

int main(){
	int a,b,c,d,n,m,k,p,q,r;
	
	while(cin >> n >> m && n && m){
		for(int i=1 ; i <= m ; ++i){
			for(int j=1 ; j <= m ; ++j){
				cost[i][j] = 10000;
				t[i][j] = 10000;
			}
		}
		cf = true;
		tf = true;
		for(int i=0 ; i < n ; ++i){
			cin >> a >> b >> c >> d;
			cost[a][b] = c;
			cost[b][a] = c;
			t[a][b] = d;
			t[b][a] = d;
		}
		cin >> k;
		for(int i=0 ; i < k ; ++i){
			cin >> p >> q >> r;
			cout << wf(p,q,r,m) << endl;
		}
	}
	return 0;
} 

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


int main(){

    int n;
    cin>>n;
    vector<int> arr(n+1);

    for(int i = 1; i <= n; i++) cin>>arr[i];

    vector<ll> pf(n+1);
    vector<ll> dp(n+1,LLONG_MIN);
    for(int i = 1; i <= n; i++) if(i&1) pf[i]+=arr[i]+pf[i-2 < 0 ? 0 : i-2]; // pref of odd sum

    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        if(i&1) dp[i] = max(dp[i-1],arr[i]+dp[i-2]); // for odd 
        else dp[i] = max(pf[i-1],dp[i-2]+arr[i]); //for even
    }
    cout<<dp[n];
}


Measured memory_bytes: 7200
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll power(ll a, ll b, ll m){
    if(b==0) return 1;
    if((b%2)==0) return (power((a*a)%m, b/2, m))%m;
    return (a*(power(a, b-1, m)%m))%m;
}

int main(){
    cpp();
    ll k;
    cin>>k;
    if(k==7){
        cout<<1<<endl;
        return 0;
    }
    ll sum = 0;
    ll ans = -1;
    for(ll i=0; i<=(1e6); i++){
        sum+=(power(10, i, k))*7;
        sum%=k;
        if(sum==0){
            ans = i+1;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
	//セルの中身
	class CELL{
	public:
		enum STATE{
			SPACE,	//'.'
			WALL,	//'#'
		};
		CELL(int i, int j, STATE s) : x(i), y(j), state(s), dist(-1){}

		int up(){
			return y - 1;
		}
		int down(){
			return y + 1;
		}
		int left(){
			return x - 1;
		}
		int right(){
			return x + 1;
		}
		int getDist(){
			return dist;
		}
		int getX(){
			return x;
		}
		int getY(){
			return y;
		}

		void setDist(int d){
			dist = d;
		}
		STATE getState(){
			return state;
		}
	private:

		STATE state;
		int x, y;
		int dist;
	};

	int H, W;	//グリッド数,縦H,横Wマス
	cin >> H >> W;
	vector<vector<CELL>> s;	//マスの中身
	int black = 0;	//最初から黒いマス

	//入力部,文字列からCELL型に変換して格納
	for (int j = 0; j < H; j++){
		vector<CELL> tv;
		for (int i = 0; i < W; i++){
			CELL* c = 0;
			char ch;
			cin >> ch;
			switch (ch)
			{
			case '.':
				c = new CELL(i, j, CELL::SPACE);
				break;
			case '#':
				c = new CELL(i, j, CELL::WALL);
				black++;
				break;
			default:
				cout << "不正な数値" << endl;
				return 1;
				break;
			}
			tv.push_back(*c);
			delete c;
		}
		s.push_back(tv);
	}
	/*
	for (int j = 0; j < H; j++){
		for (int i = 0; i < W; i++){
			cout << s[j][i].getState();
		}
		cout << endl;
	}
	*/
	//幅優先探索を用いた最小経路探索をしたい

	queue<CELL> q;
	s[0][0].setDist(0);
	q.push(s[0][0]);
	while (!q.empty()){
		CELL c = q.front();
		CELL* next = 0;
		q.pop();
		//上下左右の点を調べて距離を計算
		if (c.up() >= 0){
			next = &s[c.up()][c.getX()];
			if (next->getState() == CELL::SPACE){
				if (next->getDist() < 0){
					next->setDist(c.getDist() + 1);
					q.push(*next);
				}
				else{
					if (next->getDist() > c.getDist() + 1){
						next->setDist(c.getDist() + 1);
					}
				}
			}
		}
		if (c.left() >= 0){
			next = &s[c.getY()][c.left()];
			if (next->getState() == CELL::SPACE){
				if (next->getDist() < 0){
					next->setDist(c.getDist() + 1);
					q.push(*next);
				}
				else{
					if (next->getDist() > c.getDist() + 1){
						next->setDist(c.getDist() + 1);
					}
				}
			}
		}
		if (c.down() < H){
			next = &s[c.down()][c.getX()];
			if (next->getState() == CELL::SPACE){
				if (next->getDist() < 0){
					next->setDist(c.getDist() + 1);
					q.push(*next);
				}
				else{
					if (next->getDist() > c.getDist() + 1){
						next->setDist(c.getDist() + 1);
					}
				}
			}
		}
		if (c.right() < W){
			next = &s[c.getY()][c.right()];
			if (next->getState() == CELL::SPACE){
				if (next->getDist() < 0){
					next->setDist(c.getDist() + 1);
					q.push(*next);
				}
				else{
					if (next->getDist() > c.getDist() + 1){
						next->setDist(c.getDist() + 1);
					}
				}
			}
		}

	}

	//ゴールまでたどり着けたらDistに-1以外の数値が入っているはず
	if (s[H-1][W-1].getDist() > 0){
		//最短距離+1マスを通ることさえできれば他のマスは全て塗りつぶしても構わないので
		//塗りつぶして得点計算,最大得点は全マス数-最初から黒います-最短で通るマスとなる
		int score = W*H - black - (s[H-1][W-1].getDist() + 1);
		cout << score << endl;
	}
	//そうでない時はたどり着けないので-1
	else{
		cout << -1 << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  string S;
  cin >> S;
  int w;
  cin >> w;
  string ans;
  REP(i, (int)S.size()){
    if(i % w == 0){
      ans += S[i];
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
//C 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
int qwq[maxn],raw[maxn];
int main(){
	int n,k,cnt = 1;
	cin >> n >> k;
	for(int i = 1;i <= k;i++){
		cin >> raw[i];
		if(i > 1)qwq[cnt++] = raw[i] - raw[i-1];
	}
	qwq[cnt] = raw[1] + n - raw[k];
	sort(qwq+1,qwq+cnt+1);
	ll ans = 0;
	for(int i = 1;i < k;i++)ans += qwq[i];
	cout << ans; 
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    const int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int k;

    scanf("%d", &k);
    printf("%d\n", a[k - 1]);

    return 0;
}


Measured memory_bytes: 128
// code written by kshitij_coder
#include<bits/stdc++.h>
using namespace std;
 
#define ll int64_t
#define pii pair<ll,ll>
#define psi pair<string,ll> 
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pb push_back
#define lim 100000
#define f(k) k.first
#define s(k) k.second
#define bcnt __builtin_popcount
#define endl "\n"
#define PI 3.1415926535

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const{ 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

ll power(ll a,ll b){ ll ans = 1; ll k = a;while(b > 0){ if(b & 1){ ans *= k; ans %= MOD; } k = (k*k)%MOD; b = b >> 1;} return ans;}

// ll ncr(ll n,ll r,ll*arr){
//     if(r==0) return 1;
//     ll res = 1;
//     return (arr[n]*(power(arr[n-r],MOD-2))%MOD*(power(arr[r],MOD-2))%MOD)%MOD;
// }

ll gcd(ll a,ll b){ if(a == 0) return b; if(b == 0) return a; return gcd(b,a%b); }
ll add_mod(ll a,ll b,ll m){return ((a%m) + (b%m))%m;}
ll sub_mod(ll a,ll b,ll m){return ((a%m) - (b%m) + m)%m;}
ll mul_mod(ll a,ll b,ll m){return ((a%m)*(b%m))%m;}
void print(double val,int k){ cout<<fixed<<setprecision(k)<<val<<endl;}
ll toint(string s) {stringstream ss; ss << s; ll x; ss >> x; return x;}

void solve(){
    int n;
    cin >> n;
    
    int *arr = new int[n+1];
    for(int i = 1;i <= n;i++) cin >> arr[i];
    
    int *score = new int[n+1];
    score[1] = 0;
    score[2] = abs(arr[2] - arr[1]);
    
    for(int i = 3;i<=n;i++){
        score[i] = min((score[i-1] + abs(arr[i] - arr[i-1])), (score[i-2] + abs(arr[i] - arr[i-2])));
    }
    
    cout<<score[n]<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
    return 0;
}

Measured memory_bytes: 4404
N = int(input())
a = list(map(int, input().split()))
a.sort()

def gcd(a, b):
    if b != 0:
        return gcd(b, a%b)
    else:
        return a
ans = 10**10
for i in range(N-1):
    ans = min(ans, gcd(a[i], a[i+1]))
print(ans)


Measured memory_bytes: 20132
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.Array.Unboxed    as A
import qualified Data.ByteString.Char8 as BC
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, k] <- readInts
  as <- readInts
  print $ solve n k as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> Int -> [Int] -> Int
solve n k as = sum $ take (l - k) cs where
  cs = sort hist
  hist = A.elems $ (A.accumArray (+) 0 (1, n) [(i, 1) | i <- as] :: A.UArray Int Int)
  l = length cs


Measured memory_bytes: 20220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> Bom(H, vector<char>(W));
	vector<vector<int>> C(H, vector<int>(W));
	vector<int> X(8);//右,右上,上,左上,左,左下,下,右下
	X = {1, 1, 0, -1, -1, -1, 0, 1};
	vector<int> Y(8);
	Y = {0, 1, 1, 1, 0, -1, -1, -1};
	char A = '.';
	char B = '#';
	rep(i, H){
		rep(j, W){
			cin >> Bom[i][j];
			if(Bom[i][j] == A)C[i][j] == 0;
			else C[i][j] == -1;
		}
	}
	
	rep(i, H){
		rep(j, W){
			if(Bom[i][j] == A){
				for(int k = 0; k < 8; k++){
					int s = i + X[k];
					int t = j + Y[k];
					if(s < 0 || s >= H || t < 0 || t >= W)continue;
					else{
						if(Bom[s][t] == B)C[i][j]++;
					}
				}
			}
		}
	}
	rep(i, H){
		rep(j, W){
			if(Bom[i][j] == B)cout << B;
			else cout << C[i][j];
			if(j == W - 1)cout << endl;
		}
	}
}

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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b,c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
given a 2d grid, find total path from (0, 0) to (h-1, w-1)

...#
.#..
....

3

..
..

dp
dp[i][j] = dp[i-1][j] + dp[i][j-1] if they are not walls
*/
using ll = long long; 
int add(int a, int b) {
    int MOD = 1e9 + 7;
    return (a + b) % MOD;
}
int main() {
    int H;
    int W;
    scanf("%d%d", &H, &W);
    vector<vector<int>> dp(H, vector<int>(W));
    char sl[H][W];
    //vector<vector<char>> sl(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        scanf("%s", sl[i]);
    }
    /*
    vector<vector<bool>> is_wall(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        scanf("\n");
        for (int j = 0; j < W; j++) {
            char ch;
            scanf("%c", &ch);
            //cout << i << " " << j << " " << ch << endl;
            if (ch == '#') {
                is_wall[i][j] = true;
            }
        }
    }
    */
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            //cout << i << " " << j << " " << is_wall[i][j] << endl;
            if (sl[i][j] != '#') {
                if (i - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i-1][j]);
                }
                if (j - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i][j-1]);
                }    
            }
        }
    }    
	printf("%d\n", dp[H-1][W-1]);
	return 0;
}



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

public class Main {
    static StringBuilder sb;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sb = new StringBuilder();

        int n = sc.nextInt();
        TreeSet<Integer> a = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }

        int m = sc.nextInt();
        HashSet<Integer> b = new HashSet<>();
        for (int i = 0; i < m; i++) {
            b.add(sc.nextInt());
        }

        a.removeAll(b);

        Iterator<Integer> it = a.iterator();
        while (it.hasNext()) {
            sb.append(it.next()).append("\n");
        }

        PrintWriter out = new PrintWriter(System.out);
        out.print(sb);
        out.flush();
        
        sc.close();
    }
}



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

void solve(){
  int n, m; cin >> n >> m;
  bool a[n][m];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] = false;
  for(int i = 0; i < n; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int x; cin >> x;
      a[i][x - 1] = true;
    }
  }

  int ans = 0;
  for(int i = 0; i < m; i++){
    int j;
    for(j = 0; j < n; j++){
      if(a[j][i] != true) break;
    }
    if(j == n) ans++;
  }
  cout << ans << endl;
  return;
}

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


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

int main() 
{
  int n;
  int score[1000] = {0};
  int i;
  double sum = 0;
  double ave;
  double ans = 0;
  while(true){
    cin >> n;
    if(n == 0){
      return 0;
    }else{
      for(i = 0;i < n;++i){
        cin >> score[i];
      }
      for(i = 0;i < n;++i){
        sum += score[i];
      }
      ave = sum/n;
      for(i = 0;i < n;++i){
        ans += pow((score[i]-ave),2);
      }
      ans = sqrt(ans/n);
      printf("%lf\n",ans);
      sum = 0;
      ans = 0;
    }
  }
}


Measured memory_bytes: 3200
function main()
  k = parse(Int, readline())
  if k % 2 == 0 return -1 end
  count = 1
  now = mod(7, k)
  while now != 0
    count += 1
    now = mod(7 + now*10, k)
    if count > 10^6; count = -1; break; end
  end
  count
end

println(main())


Measured memory_bytes: 160248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  deque<int> q;
  rep(i,n){
    int a;
    cin>>a;
    if((i+1)%2==1) q.pf(a);//odd
    else q.pb(a);
  }
  if(n%2==0) reverse(all(q));
  rep(i,n){
    int p=q.front();
    q.pop_front();
    cout<<p<<" ";
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 3840
#include <stdio.h>
#include <string.h>
int max(int a,int b){if(a>b)return a;return b;}
int LCS(char a[],char b[])
{
    int m = strlen(a);
	int n = strlen(b);
    int L[m+1][n+1];
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0 || j==0)
                L[i][j] = 0;
            else if(a[i-1] == b[j-1])
                L[i][j] = L[i-1][j-1]+1;
            else
                L[i][j] = max(L[i-1][j],L[i][j-1]);
        }
    }
    //printf("%d\n",L[m][n]);
    // Print All LCS
    int index = L[m][n];
    int t = index;
    char lcs[index+1];
    lcs[index] = '\0';
    int i = m ,j = n;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            lcs[index-1] = a[i-1];
            i--;j--;index--;
        }
        else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
    }
    printf("%s",lcs);
    // End of function
}
int main()
{
	char str1[3010],str2[3010];
	scanf("%s %s",str1,str2);
	//printf("%d %d",len1,len2);
	LCS(str1,str2);
}


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007
# define MX          500

int n;
int a,b;
char s[MX];
int num[MX];

int main()
{
    scanf("%s",s);
    if (s[1]==s[2] && (s[1]==s[0]||s[2]==s[3]))
    {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n,count=0;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  for(ll i=0;i<n;i++)
  {
    for(ll j=i+1;j<n;j++)
    {
      if(a[i]!=a[j])
      {
        for(ll k=j+1;k<n;k++)
        {
          if(a[i]!=a[k] and a[j]!=a[k])
          {
            if(
              a[i]+a[j]>a[k] and
              a[j]+a[k]>a[i] and
              a[i]+a[k]>a[j]
              )
              count++;
          }
        }
      }
    }
  }
  cout<<count<<endl;
}


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

int a[1111], c[1111], d[1 << 12];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int b, x;
		cin >> a[i] >> b;
		for (int j = 0; j < b; j++)
			cin >> x, c[i] |= 1 << x - 1;
	}
	for (int i = 1; i < 1 << n; i++) {
		d[i] = 1e9;
		for (int j = 0; j < m; j++)
			d[i] = min(d[i], a[j] + d[i&~c[j]]);
	}
	cout << (d[(1 << n) - 1] < 1e9 ? d[(1 << n) - 1] : -1) << endl;
	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 ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010


int main(){
	IOS;
	tihs;
	
	string s;cin>>s;
	bool ok=1;
	if(sz(s)%2)ok=0;
	for(ll i=0;i<sz(s);i+=2)if(s[i]!='h')ok=0;
	for(ll i=1;i<sz(s);i+=2)if(s[i]!='i')ok=0;
	if(!ok)cout<<"No";
	else cout<<"Yes";

	return 0;
}

Measured memory_bytes: 764
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    sort(A.rbegin(), A.rend());
    ll sum=0;
    for(auto p: A)sum+=p;
    if(A[M-1]*4*M>=sum)prt("Yes");
    else prt("No");

    return 0;
}



Measured memory_bytes: 3664
s=input()
def judge(s):
    for i in range(len(s)):
        if s[i]!=s[-1-i]:
            return False
    return True

if judge(s) and judge(s[:(len(s)-1)//2]) and judge(s[(len(s)+3)//2-1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060