akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vi A(M);
    cin >> A;

    int num[10] = {-1, 2,5,5,4,5,6,3,7,6};

    auto cmp = [](const string &a, const string &b) {
        if (sz(a) != sz(b)) {
            return sz(a) < sz(b);
        }
        return a < b;
    };

    vector<string> dp(N + 10, "#");
    dp[0] = "";
    rep(i, 0, N + 1) {
        if (dp[i] == "#") continue;
        rep(j, 0, M) {
            string tmp = dp[i] + to_string(A[j]);
            if (cmp(dp[i + num[A[j]]], tmp)) {
                dp[i + num[A[j]]] = tmp;
            }
        }
    }
    cout << dp[N] << endl;
    return (0^_^0);
}



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

int main() {
  int s;
  cin >> s;
  int s1 = s/100;
  int s2 = s-s1*100;
  string ans;
  
  if((s1<=12 && s2<=12) && (s1>0 && s2>0))
    ans = "AMBIGUOUS";
  else if((s1>12 && s2<=12 && s2>0) || (s1==0 && s2<=12 && s2>0))
    ans = "YYMM";
  else if((s1<=12 && s2>12 && s1>0) || (s1<=12 && s2==0 && s1>0))
    ans = "MMYY";
  else
    ans = "NA";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<regex>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>

#pragma warning(disable:4996)
using namespace std;

constexpr int MAXN = 3000005;

int N;
vector<int>var(MAXN);

inline int GetWin(int x,int y) {
	return x == y ? x : abs(x - y);
}

int GetAns(int x,int y) {
	if (x + 1 == y) {
		return GetWin(var[x], var[y]);
	}
	int mid = (x + y) >> 1;
	int left = GetAns(x,mid);
	int right = GetAns(mid+1,y);
	return GetWin(left,right);
}

int main() {
	scanf("%d",&N);
	N = 1 << N;
	for (int i = 1; i <= N; ++i) {
		scanf("%d",&var[i]);
	}
	printf("%d\n", GetAns(1, N));
	return 0;
}

Measured memory_bytes: 12032
// Triangle
// ITP1_10_b
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c float64
	var s float64
	var L, S, h float64
	var cd int
	var crad float64

	fmt.Scanf("%f %f %d", &a, &b, &cd)
	crad = float64(cd) * math.Pi / 180.0

	c = math.Sqrt(a*a + b*b - 2.0*a*b*math.Cos(crad))

	L = a + b + c

	s = (a + b + c) / 2.0
	S = math.Sqrt(s * (s - a) * (s - b) * (s - c))

	h = S * 2.0 / a

	fmt.Printf("%.5f\n", S)
	fmt.Printf("%.5f\n", L)
	fmt.Printf("%.5f\n", h)
}


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

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


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

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

        if(X<='Z') cout << 'A' << endl;
        if(X>='a') cout << 'a' << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 1e3 + 10;


void yes(){
   cout<<"Yes";
   // exit(0);
}

void no(){
   cout<<"No";
   // exit(0);
}


int n, m;

#define y1 decfce
int x1, y1, x2, y2;

char a[N][N];

int32_t main(){_
   
   cin >> n >> m;

   cin >> x1 >> y1;
   cin >> x2 >> y2;

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= m; ++j)
      {
         cin >> a[i][j];
      }
   }


   vector<vector<int>> ans(n+1, vector<int>(m + 1, inf));
   deque<array<int, 3>> ms;
   ans[x1][y1] = 0;
   ms.push_back({0, x1, y1});

   int ret = inf; 

   while(!ms.empty()){
      
      auto it = ms.front();
      ms.pop_front();

      int X = it[1], Y = it[2], cost = it[0];

      if (X == x2 and Y == y2){
         smin(ret, cost);
      }

      if (X + 1 <= n and a[X+1][Y] == '.' and ans[X+1][Y] > ans[X][Y]){
         ans[X+1][Y] = ans[X][Y];
         ms.push_front({ans[X][Y], X + 1, Y});
      }

      if (X - 1 >= 1 and a[X-1][Y] == '.' and ans[X-1][Y] > ans[X][Y]){
         ans[X-1][Y] = ans[X][Y];
         ms.push_front({ans[X][Y], X - 1, Y});
      }

      if (Y + 1 <= m and a[X][Y+1] == '.' and ans[X][Y+1] > ans[X][Y]){
         ans[X][Y+1] = ans[X][Y];
         ms.push_front({ans[X][Y], X, Y+1});
      }

      if (Y - 1 >= 1 and a[X][Y-1] == '.' and ans[X][Y-1] > ans[X][Y]){
         ans[X][Y-1] = ans[X][Y];
         ms.push_front({ans[X][Y], X, Y-1});
      }


      for (int i = -2; i <= 2; ++i)
      {
         for (int j = -2; j <= 2; ++j)
         {
            int nx = X + i;
            int ny = Y + j;
            if (nx == X and ny == Y){
               continue;
            }
            if (nx >= 1 and nx <= n and ny >= 1 and ny <= m and a[nx][ny] == '.' and ans[nx][ny] > cost + 1){
               ans[nx][ny] = cost + 1;
               ms.push_back({cost + 1, nx, ny});
            }
         }
      }

   }

   if (ret == inf){
      ret = -1;
   }

   cout<<ret;//ans[x2][y2];

   return 0;
}

Measured memory_bytes: 12720
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    for (int i = 0; i < n / 2; i++){
        if (s[i] != s[n-i-1]){
            flag = false;
        }
    }
    for (int i = 0; i < (n / 2) / 2; i++){
        if (s[i] != s[n/2-i-1]){
            flag = false;
        }
    }
    for (int i = (n + 3) / 2; i < n; i++){
        if (s[i] != s[n-i-1]){
            flag = false;
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int X;
    cin >> X;

    int ans = 0;
    for (int i = 2; i <= X; ++i)
    {
        int j;
        for (j = 2; pow(i, j) <= X; ++j);
        if (j > 2)
        {
            ans = MAX(ans, pow(i, j - 1));
        }
    }

    if (ans == 0) ans = 1;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
k = int(input())

lunlun = [i for i in range(1, 10)]

for i in lunlun:
    stri = str(i)
    if stri[-1] == '0':
        tmp = stri + '0' 
        lunlun.append(int(tmp))
        tmp = stri + '1'
        lunlun.append(int(tmp))
        if len(lunlun) >= k:
            print(lunlun[k-1])
            exit()
    elif stri[-1] == '9':
        tmp = stri + '8'
        lunlun.append(int(tmp))
        tmp = stri + '9'
        lunlun.append(int(tmp))
        if len(lunlun) >= k:
            print(lunlun[k-1])
            exit()
    else:
        tmp = stri + str(int(stri[-1]) - 1)
        lunlun.append(tmp)
        tmp = stri + str(int(stri[-1]))
        lunlun.append(tmp)
        tmp = stri + str(int(stri[-1]) + 1)
        lunlun.append(tmp)
        if len(lunlun) >= k:
            print(lunlun[k-1])
            exit()

Measured memory_bytes: 9964
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    if len(b)<2:
        b.append(0)
        b.append(0)
    if len(g)==0:
        g.append(0)
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])

Measured memory_bytes: 19176
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[3005];
int f[3005][3005];
int n;

int F(int u,int v)
{
  if(u==v){
            if((n)%2) f[u][v]=a[u];
            else f[u][v]=-a[u];
          }
  if(f[u][v]) return f[u][v];
  if((u+v)%2!=n%2)
  f[u][v]=max(F(u,v-1)+a[v],F(u+1,v)+a[u]);
  else
  f[u][v]=min(F(u,v-1)-a[v],F(u+1,v)-a[u]);
  return f[u][v];
}

main()
{


  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  cout<<F(0,n-1);
 // cout<<f[0][0]<<endl;
}


Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll x;
    cin>>x;
    for(ll a=-120;a<=120;a++){
        for(ll b=-120;b<=120;b++){
            if(pow(a,5)-pow(b,5)==x){
                cout<<a<<" "<<b;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	//freopen("input.txt","r",stdin);
	ll a,b,n;
	cin>>n>>a>>b;
	ll m=n/(a+b);
	
	ll ans;
	if(n>0) ans=m*a;
	else ans=0;
	
	n-=m*(a+b);
	if(n>a) ans+=a;
	else ans+=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int N,M;
    cin>>N>>M;
    vector<int>s(M),c(M),ans(5,-1);
    for(int i=0;i<M;i++){
        cin>>s[i]>>c[i];
    }
    for(int i=0;i<M;i++){
        if(ans[s[i]-1]!=-1&&ans[s[i]-1]!=c[i]){
            cout<<-1<<endl;
            exit(0);
        }
        ans[s[i]-1]=c[i];
    }
    for(int i=1;i<N;i++){
        if(ans[0]==-1){
            ans[0]=1;
        }
        if(ans[i]==-1){
            ans[i]=0;
        }
    }
    if(ans[0]==0&&N!=1){
        cout<<-1<<endl;
        exit(0);
    }
    if(M==0&&N==1){
        cout<<0<<endl;
        exit(0);
    }
    if(M==0&&N==2){
        cout<<10<<endl;
        exit(0);
    }
    if(M==0&&N==3){
        cout<<100<<endl;
        exit(0);
    }

    
    
    for(int i=0;i<N;i++){
        cout<<ans[i];
    }
    
    
}

Measured memory_bytes: 256
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <limits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5;
const int oo = 1e9;
const double pi = acos(-1);
int main() {
	//freopen("src.txt", "r", stdin);
	ll n;
	cin >> n;
	cout << n*(n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int a, b, h;
    cin>>a>>b>>h;
    cout<<((a+b)*h)/2<<endl;
	return 0;
}

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

unsigned long long dp[100001],g[100001],p[100001];

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>p[i]>>g[i];
}
for(int i=1;i<=n;i++){
for(int j=m;j>=p[i];j--){
dp[j]=max(dp[j],dp[j-p[i]]+g[i]);
}
}
cout<<dp[m];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x){
	if(x<2)return false;
  for(int i=2;i<=x/i;++i){
  	if(x%i==0)return false;
  }
  return true;
}
int main(){
  int x; cin>>x;
for(int i=x;;i++){
	if(isprime(i)){
    	cout<<i<<endl;
      break;
    }
}
return 0;
}

Measured memory_bytes: 256
//CODEFORCES:-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18
#include<bits/stdc++.h>
using namespace std;

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pb push_back
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
#define foo for(int i=1;i<=n;i++)
#define mod 1000000007


void solve(){
    string s;
    cin>>s;
    unsigned ll sum=0;

    for(int i=0;i<s.length();i++){
        sum+=(s[i]-'0');
    }
    if(sum%9==0)cout<<"Yes";
    else cout<<"No";
    br;
}

int main(){
	#ifdef home
        assert(freopen(TASK".in","r",stdin));
        assert(freopen(TASK".out","w",stdout));
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin>>t;
    // while(t-->0)
    solve();

    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif

    return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int l = scan.nextInt();
		int r = scan.nextInt();
		int d = scan.nextInt();
		int count = 0;
		
		for(int i=l;i<=r;i++) {
			if(i % d == 0) {
				count++;
			}
		}
		System.out.println(count);

	}

}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int64> a(n);
  REP(i,n)cin >> a[i];
  FOR(i,k,n){
    Yes(a[i-k] < a[i]);
  }
  return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <vector>

bool find(const std::vector<int> &found, int number) {
  for (auto old_number : found) {
    if (old_number == number) {
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> numbers;
  for (int i = 0; i < n; ++i) {
    int input;
    std::cin >> input;
    numbers.push_back(input);
  }
  std::vector<int> found;
  int cnt = 0;
  for (auto number : numbers) {
    if (!find(found, number)) {
      found.push_back(number);
      ++cnt;
    }
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int m[n],a[n],b[n];
      for(int i=0;i<n;i++)
	{
	  cin>>m[i]>>a[i]>>b[i];
	}
      for(int i=0;i<n-1;i++)
	for(int j=i+1;j<n;j++)
	  if(a[i]>a[j])
	    {
	      swap(a[i],a[j]);
	      swap(m[i],m[j]);
	      swap(b[i],b[j]);
	    }
      vector<int> now;
      int sum=0;
      bool flag=true;
      for(int i=0;i<n;i++)
	{
	  now.push_back(i);
	  sum+=m[i];
	  for(int j=0;j<now.size();j++)
	    {
	      if(b[now[j]]<=a[i])
		{
		  sum-=m[now[j]];
		  now.erase(now.begin()+j);
		  j--;
		}
	    }
	  if(sum>150)
	    {
	      flag=false;
	      break;
	    }
	}


      if(flag)
	cout<<"OK"<<endl;
      else
	cout<<"NG"<<endl;

    }

}

Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var A = cin.scanlong;
        int K = cin.nextint;

        WriteLine(A.Sum() - A.Max() + (A.Max() << K));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
#define lim 100001
#define pi 3.14159265

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

double newPrecision(double n)
{
    return floor(pow(10, 250) * n) / pow(10, 250);
}

ll f( ll arr[], ll rec[], ll pos, ll n){
    if(pos>=(n-3))
        return abs(arr[n-1] - arr[pos]);
    if(rec[pos]!=-1)
        return rec[pos];
    return rec[pos] = min(
               abs(arr[pos] - arr[pos + 1]) + f(arr, rec, pos + 1, n),
               abs(arr[pos] - arr[pos + 2]) + f(arr, rec, pos + 2, n)
               );
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    ll arr[t];
    for (ll i = 0; i < t; i++)
    {
        cin >> arr[i];
    }
    ll rec[t];
    memset(rec, -1, sizeof(rec));
    cout << f(arr,rec,0,t);

    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;
 
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderset;
 
const int N=2e5+5;
 
 
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long double x,y,a,b;
    cin>>x>>y>>a>>b;
    long double de=(a*30+b/2)-b*6;
    if(de<0) de=-de;
    if(de>=180) de=360-de;
    long double val=cos(de*3.14159265359/180.0);
    long double res=sqrt(x*x+y*y-2*x*y*val);
    cout<<fixed<<setprecision(10)<<res;
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
#define ri(x) scanf("%d", &x)
#define FORR(i, a, b) for(int i = a; i > b; i -= 1)
#define FOR(i, a, b) for(int i =a; i < b; i += 1)
#define pb push_back
#define ll long long int
#define vi vector<int>
#define MAXN 5005
#define INF 10000000000004
using namespace std;
int n, H[MAXN], P[MAXN];
vi a;
ll dp[MAXN][MAXN];

void read(){
	ri(n);
	FOR(i, 0, n)
	{
		ri(H[i]); ri(P[i]);
		a.pb(i);
	}
}

bool comp(int i, int j){
	return H[i] + P[i] < H[j] + P[j];
}


ll DP(int i, int k)
{
	if(i < 0 && k > 0) return INF;
	if(k == 0) return 0;
	if(dp[i][k] != -1) return dp[i][k];
	
	ll with = DP(i-1, k-1);
	ll without = DP(i-1, k);
	
	if( with <= H[a[i]])
		dp[i][k] = min(with + P[a[i]], without);
	else
		dp[i][k] = without;
		
	return dp[i][k]; 
}

int main() {
	read();
	FOR(i, 0, n) FOR(j, 0, n+1) dp[i][j] = -1;
	sort(a.begin(), a.end(), comp);
	FORR(k, n, -1)
	{
		ll e = DP(n-1, k);
		if(DP(n-1, k) != INF)
		{
			printf("%d\n",k);
			break;
		}
	}
	return 0;
}

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

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

	string ans = "No";
	for( int i = 1; i < 10; i++ ) {
		for( int j = 1; j < 10; j++ ) {
			if( i * j == N ) {
				ans = "Yes";
			}
		}
	}

	cout << ans << endl;
}


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

using namespace std;

int main() {
    string S, getData;
    cin >> S;

    int ans = 0, min = 999999;
    string s1, s2, s3;

    for (int i = 0; i < S.length() - 2; ++i) {
        s1 = S.at(i);
        s2 = S.at(i + 1);
        s3 = S.at(i + 2);
        getData = s1 + s2 + s3;
        ans = abs(stoi(getData) - 753);
        if (min > abs(ans)) {
            min = ans;
        }
    }

    cout << abs(min) << endl;

}

Measured memory_bytes: 3600
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n: usize = read();
    let mut f = vec![0; n + 1];
    for x in 1..200 {
        for y in 1..200 {
            for z in 1..200 {
                let t = x * x + y * y + z * z + x * y + y * z + z * x;
                if t <= n {
                    f[t] += 1;
                }
            }
        }
    }
    for i in 1..n + 1 {
        println!("{}", f[i]);
    }
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int e[110];

int main(){
  cin>>a>>b>>c>>d;
  for(int i=a;i<=b;i++){
    e[i]++;
  }
  for(int i=c;i<=d;i++){
   e[i]++;
  }
  int cont=0;
  for(int i=0;i<101;i++){
    if(e[i]==2)cont++;
  }
  if(cont==0){
    cout<<0<<endl;
    return 0;
  }
  cout<<cont-1<<endl;
}

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

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	string ans;
	if (a <= x && x <= a + b) {
		ans = "YES";
	} else {
		ans = "NO";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

s = list(s)

v = list(set(s))

if len(v) == 2:
    j1 = True

    if s.count(v[0]) == 2 and s.count(v[1]) == 2:
        j2 = True
else:
    j1 = False

if j1 and j2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>

# define REP(i,n) for(int i=0; i<n; i++)
# define MAX_N 100005

using namespace std;

int par[MAX_N];
int rnk[MAX_N];

void init(int n){
	//cout << "init" << endl;
	REP(i,n){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	//cout << "find " << x << endl;
	//printf("find(%d), par[%d] = %d\n", x, x, par[x]);
	if (par[x] == x){
		return x;
	}else{
		par[x] = find(par[x]);
		return par[x];
	}
}

void unite(int x, int y){
	//cout << "unite " << x << " " << y << endl;
	x = find(x);
	y = find(y);
	if (x==y) return;
	//cout << x << " " << y << endl;
	
	if (rnk[x]<rnk[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if (rnk[x]==rnk[y]) rnk[x]++;
	}
}

bool same(int x, int y){
	//cout << "same" << x << " " << y << endl;
	return (find(x)==find(y));
}

int main(){
	int n, m, p[MAX_N], x[MAX_N], y[MAX_N], ans;
	
	cin >> n >> m;
	for (int i=1; i<=n; i++){
		cin >> p[i];
	}
	REP(i,m){
		cin >> x[i] >> y[i];
	}
	ans = 0;
	
	init(n+1);
	
	REP(i,m){
		unite(p[x[i]], p[y[i]]);
		//cout << same(p[x[i]], p[y[i]]) << endl;
		/*REP(k,n){
			printf("%d par:%d, rnk:%d\n", k+1, par[k+1], rnk[k+1]);
		}
		printf("find(1) = %d, par[1] = %d\n", find(1), par[1]);*/
	}
	
	for (int i=1; i<=n; i++){
		//cout << same(i,p[i]) << "\n";
		if (same(i,p[i])) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mx=3002;
ll dp[mx][mx];
//bool vis[mx][mx];
ll arr[mx];

ll solve(int L,int R){
    if(dp[L][R]!=0){
        return dp[L][R];
    }
    if(L==R){
        dp[L][R]=arr[L];
        return dp[L][R];
    }

    dp[L][R]=max(arr[L]-solve(L+1,R),arr[R]-solve(L,R-1));
    return dp[L][R];
}


int main(){
    int n;
    cin>>n;
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        cout<<solve(1,n);

}


Measured memory_bytes: 70144
#include <stdio.h>          // printf(), scanf()

#define MAX_N 20
#define MAX_V 50000
#define min(a, b) ((a) < (b) ? (a) : (b))

static const int INF = 100000000;

int
main(int argc, char** argv)
{
	int c[MAX_N + 1];
	int t[MAX_V + 1];
	int v, n;
	int i, j;

	scanf("%d %d", &v, &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &c[i]);

	for (i = 1; i <= MAX_V; ++i)
		t[i] = INF;

	t[0] = 0;
	for (i = 0; i < n; ++i)
	{
		for (j = c[i]; j <= v; ++j)
			t[j] = min(t[j], t[j - c[i]] + 1);
	}

	printf("%d\n", t[v]);
	return 0;
}

Measured memory_bytes: 792
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int A[N];
  double data1 = 0;
  double data2 = 1;
  for (int i = 0; i < N;i++){
    cin >> A[i];
    data2 *= A[i];
  }
  for (int i = 0; i < N; i++)
  {
    data1 += data2 / A[i];
  }
  cout << data2 / data1 << endl;
}


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

using namespace std;

int main() {
    int N, prev, next;
    long res = 0;

    cin >> N;
    cin >> prev;
    if (prev != 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int n = 1; n < N; n++) {
        cin >> next;
        if (prev + 1 < next) {
            cout << -1 << endl;
            return 0;
        }
        if (prev + 1 == next) res += 1;
        else res += next;
        prev = next;
    }

    cout << res << endl;

    return 0;
}

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

string x,y;
int ans,i;
int main(){
	cin >> x;
	cin >> y;
	for(i=0; i<y.length(); i++){
		if(x[i] != y[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3832
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll R;
  cin >> R;
  double ans = 2 * M_PI * R;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

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

bool check(char c)
{
	switch (c) {
		case 'A':
			return 1;
		case 'C':
			return 1;
		case 'G':
			return 1;
		case 'T':
			return 1;
		default:
			return 0;		
	}
	return 0;
}

int main()
{
	string s;
	cin >> s;
	int max = 0;
	int tmp = 0;
	for(int t =0; t < s.length(); t++)
	{
		if(check(s[t])) tmp++;
		else {
			if( tmp > max ) max = tmp;
			tmp =  0;
		}
	}
	if( tmp > max ) max = tmp;
	cout << max << endl;
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

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

  int n, d, x; cin >> n >> d >> x;
  for(int i=0;i<n;++i) {
    int tmp; cin >> tmp;
    x++;
    x += (d-1) / tmp;
  }
  cout << x << endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

struct S {
  ll cost;
  ll value;
  bool operator<(const S& s) const {
    // return cost > s.cost;
    if (cost != s.cost) {
      return cost > s.cost;
    }
    return value > s.value;
  }
};

ll N, A, B, C, D;

ll abso(ll x) { return x < 0 ? -x : x; }

void solve() {
  DBG(N);

  map<ll, ll> prev;
  map<ll, ll> seen;
  seen[N] = 0;

  priority_queue<S> que;
  que.push({0, N});

  while (!que.empty()) {
    S here = que.top();
    que.pop();
    DBG(here.cost, here.value, que.size(), seen.size());
    if (here.value == 0) {
      ll x = here.value;
      while (x != N) {
        DBG(x);
        x = prev[x];
      }
      cout << here.cost << endl;
      break;
    }
    auto push = [&prev, &seen, &que, &here](ll cost, ll value) {
                  if (value < 0) return;
                  S there = {here.cost + cost, value};
                  auto it = seen.find(there.value);
                  if (it != seen.end() && it->second <= there.cost) {
                    return;
                  }
                  seen[there.value] = there.cost;
                  prev[there.value] = here.value;
                  que.push(there);
                };
    if (here.value % 2 == 0) {
      push(A, here.value / 2);
    }
    if (here.value % 3 == 0) {
      push(B, here.value / 3);
    }
    if (here.value % 5 == 0) {
      push(C, here.value / 5);
    }

    for (ll d = -4; d <= 4; ++d) {
      ll value = here.value + d;
      ll mods[] = {2, 3, 5};
      REP(i, 3) {
        ll m = mods[i];
        if (here.value % m != 0 && value % m == 0 && abso(d) < m) {
          push(D * abso(d), value);
        }
      }
    }

    /*
    if (here.value % 2 != 0) {
      push(D, here.value - 1);
      push(D, here.value + 1);
    }
    if (ll d = here.value % 3; d != 0) {
      push(D * d, here.value - d);
      push(D * (3 - d), here.value + (3 - d));
    }
    if (ll d = here.value % 5; d != 0) {
      push(D * d, here.value - d);
      push(D * (5 - d), here.value + (5 - d));
    }
    */

    if (D * here.value > 0) {
      push(D * here.value, 0);
    }
  }
}

int main() {
  int T;
  cin >> T;
  REP(t, T) {
    cin >> N >> A >> B >> C >> D;
    solve();
    // if (t == 2) break;
  }
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int count = 0;

  for(int i=A; i<=B; i++){
    int n1 = i%10;
    int n2 = i/10%10;
    int n4 = i/1000%10;
    int n5 = i/10000%10;
 	if(n1 == n5 && n2 == n4)count++;
  }
  
  cout << count << endl;
 
}

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

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    int min_index = 0;
    double min = 2e5;
    for (int i = 0; i < N; i++) {
        if (abs(T - H[i] * 0.006 - A) < min) {
            min = abs(T - H[i] * 0.006 - A);
            min_index = i;
        }
        
    }

    cout << min_index + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    //long long int S[200010];
    //long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    //ans=std::pow(10,18);
    flag=false;
    cin >>N;
    
        
            cout <<N*N <<endl;
        
    

    
    

    return 0;
    
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define eps 1e-8
#define MX 305

int n;
int G[MX][MX];

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                scanf("%d",&G[i][j]);
        LL ans =0;
        bool ok=1;
        for (int i=1;i<=n;i++)
        {
            for (int j=1;j<=n;j++)
            {
                if (i==j) continue;
                bool need=1;
                for (int k=1;k<=n;k++)
                {
                    if (k==i||k==j) continue;
                    if (G[i][j]>G[i][k]+G[k][j])  ok=0;
                    if (G[i][j]==G[i][k]+G[k][j]) need=0;
                }
                if (need) ans+=G[i][j];
            }
        }
        if (ok) printf("%lld\n",ans/2);
        else printf("-1\n");

    }
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N,K;
	cin>>N>>K;
	vector<int>v(N+1,0);
	for(int i=0;i<K;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int A;
			cin>>A;
			v[A]++;
		}
	}
	int i=1,cont=0;
	sort(v.begin(),v.end());
	while(v[i]==0 && i<v.size()){
		cont++;
		i++;
	}
	cout<<cont;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(int&a,int b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;

signed main()
{
	int X,Y;cin>>X>>Y;
	for (int i = 0; i <= X; ++i) {
		int turu = i, kame = X - i;
		if (turu*2+kame*4 == Y) {
			puts("Yes");
			return 0;
		}
	}

	puts("No");
}




Measured memory_bytes: 3620
i,j,n,x,y,a,b,map[30][30];
main()
{
  char c,t;
  for(;scanf("%d",&n),n;puts(n?"No":"Yes"))
    {
      for(i=0;i<30;i++)
	for(j=0;j<30;j++)
	  map[i][j]=0;
      for(j=n;j--;map[x][y]=1)
	  scanf("%d%d",&x,&y);
      scanf("%d",&j);
      getchar();
      for(a=b=10;j--;)
	{
	  i=c=0;
	  while((t=getchar())!='\n')
	    if(t>='0' &&t<='9')
	      i=i*10+t-'0';
	    else if(t>'A' && t<'Z')
	      c=t;
	  for(;i--;)
	    {
	      c-'N'||b++;
	      c-'E'||a++;
	      c-'S'||b--;
	      c-'W'||a--;
	      if(map[a][b]==1)
		  map[a][b]=0,n--;
	    }
	}
    }
  exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int R, C;
  string S[128];
  int hash[1 << 16];
  for(int i = 0; i < 1 << 16; i++) hash[i] = __builtin_popcount(i);
 
  cin >> R >> C;
  for(int i = 0; i < R; i++) cin >> S[i];
 
  vector< int > latte(1 << C, -1);
  latte[0] = 0;
  const int mask = (1 << C) - 1;
  for(int y = 0; y < R; y++) {
    for(int x = 0; x < C; x++) {
      vector< int > malta(1 << C, -1);
      for(int j = 0; j < 1 << C; j++) {
        if(latte[j] == -1) continue;
 
        auto ch = [&](int &a, int b)
        {
          a = max(a, b);
        };
 
        const int beet = hash[j & ((1 << x) - 1)];
        if(beet + C - x > S[y].size()) ch(malta[j & ~(1 << x)], latte[j]);
        if(beet < S[y].size()) {
          int point = 0;
          if(x && (j >> (x - 1)) & 1) {
            if(beet && S[y][beet] == S[y][beet - 1]) ++point;
          }
          if(y && (j >> x) & 1) {
            int pos = (int) S[y - 1].size() - hash[j >> x];
            if(pos >= 0 && S[y - 1][pos] == S[y][beet]) ++point;
          }
          ch(malta[j | (1 << x)], latte[j] + point);
        }
      }
      latte = malta;
    }
  }
  cout << *max_element(begin(latte), end(latte)) * 2 << endl;
}

Measured memory_bytes: 3684
#include <iostream>
    #include <vector>
    #include <algorithm>
     
    using namespace std;
     
    #define FOR(i, n) for(int i = 0; i < (int) n; i++)
    #define all(v) v.begin(), v.end()
    #define F first
    #define S second
     
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pii;
     
    const ll MOD = 1e9+7;
     
    int main(){
    	ios::sync_with_stdio(false); cin.tie(0);
     
    	ll a, b; cin >> a >> b;
     	
    	if(a == 1 || b == 1)
    		cout << "1\n";
    	else
    		cout << (a*b+1)/2 << '\n';
     
    	return 0;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    lli n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
satisfaction = 0
for i in range(n):
    # print(i)
    # print(a[i])
    b_number = a[i]
    # print('b_number = ' + str(b_number-1))
    # print(b[b_number-1])
    satisfaction += b[b_number - 1]
    if i == 0:
        j = i
    else:
        if a[i] == a[j] + 1:
            c_number = a[j]
            satisfaction += c[c_number - 1]
        j = i
print(satisfaction)
    # if j + 1 == i:
    #     satisfaction += c[]
    # j = i
    # satisfaction += b[i+1]
    # if i = :
    #     satisfaction += c[i]


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string s, t;
    ll Maxim=0;
    cin>>N>>s>>t;
    rep(i, s.size()){
        bool ok=true;
        reps(j, i, s.size()){
            if(s[j]!=t[j-i]) ok=false; //out<<i<<sp<<j<<endl;
        }
        if(ok) Maxim=max(Maxim, (ll)s.size()-i);
    }
    cout<<2*N-Maxim<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n, k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i = n-1; i >= k; --i)
using namespace std;

int main(){
  long long int n, ans = 0;
  cin >> n;
  vector<long long int> a(n), b(n), c;
  rep(i,n,0) cin >> a[i];
  
  drep(i,n,0){
    long long int k = i+1;
    if(n / k == 1) b[i] = a[i];
    else{
      long long int lf = 0;
      rep(j,n/k+1,2) lf += b[j*k-1];
      int f = lf % 2;
      if(f == 0) b[i] = a[i];
      else b[i] = (1 - a[i]) % 2;
    }
    if(b[i] == 1){
      ans++;
      c.push_back(k);
    }
  }
  cout << ans << endl;
  rep(i,c.size(),0) cout << c[i] << " ";
  cout << endl;
}

Measured memory_bytes: 4980
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;
int main() {
	string s;
	cin >> s;

	size_t ans = s.size();

	for (size_t i = 0; i < s.size() - 1; i++) {
		if (s[i] != s[i+1]) {
			ans = min(ans, max(i + 1, s.size() - i - 1));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N ;
    int value;
    
    
    cin >> N;
    vector<int> P(N);
    int minimum = N;
    int ans =0;
    for (int i =0; i < N; i++){
        cin >> P.at(i);
    }

    for (int i =0; i < N; i++){
        value = P.at(i);
        if (value <= minimum){
            ans += 1;
            minimum = value;
        }
    }

    cout << ans << endl;
}


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

int main(void) {
    int N,alice = 0,bob = 0;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    for(int i=0;i<N;i++) {
        if(i%2) alice+= a[i];
        else bob += a[i];
    }

    cout << abs(alice - bob) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    map<int,int> counter;
    rep(i,N){
        counter[A[i]]++;
    }

    ll count = 0;
    for(auto c : counter){
        if (c.second > 1){
            count += (c.second-1);
        }
    }
    
    ll cnt = (count+1)/2;

    cout << N - (cnt*2) << endl;
}

Measured memory_bytes: 8236
n = input()
n = int(n)
a = input().split()
a = [int(aa) for aa in a]

ans = 10000000000000000

l = -100000000000
r =  100000000000

for count in range(100):
    mid1 = 1 * (r - l) // 3 + l
    mid2 = 2 * (r - l) // 3 + l
    temp1 = 0
    temp2 = 0
    for i in range(n):
        temp1 += abs(a[i] - (mid1 + i + 1))
        temp2 += abs(a[i] - (mid2 + i + 1))
    if temp1 < temp2:
        r = mid2
    else:
        l = mid1
for b in range(l, r + 1):
    temp = 0
    for i in range(n):
        temp += abs(a[i] - (b + i + 1))
    ans = min(ans, temp)
print(ans)

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

int N;
vector<int> H, DP;

int recur(int I) {
    if(DP[I] != -1) return DP[I];
    DP[I] = min(abs(H[I+1] - H[I]) + recur(I+1), abs(H[I+2] - H[I]) + recur(I+2));
    return DP[I];
}

int main() {
    cin >> N;
    H.resize(N);
    DP.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        DP[i] = -1;
    }
    DP[N-1] = 0;
    DP.push_back(1000000);
    cout << recur(0) << endl;
}

Measured memory_bytes: 3324