akhauriyash/Code-Regression huggingface dataset:
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

int h, w;
string s[102];

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

bool in_range(int x, int n)
{
    return x >= 0 and x <= n-1;
}

void solve()
{
    scn(h); scn(w);

    rep(i, 0, h) 
    cin >> s[i];

    vector<vector<int>> dist(h, vector<int>(w, -1));

    queue<pair<int, int>> q;
    q.emplace(0, 0);

    dist[0][0] = 0;

    while(!q.empty()) {
        int i = q.front().F;
        int j = q.front().S;
        q.pop();

        rep(k, 0, 4) {
            int x = i + dx[k], y = j + dy[k];

            if(in_range(x, h) and in_range(y, w) and s[x][y] != '#' and dist[x][y] == -1) {
                dist[x][y] = dist[i][j] + 1;
                q.emplace(x, y);
            }
        }
    }

    if(dist[h-1][w-1] == -1) {
        prin(-1);
        exit(0);
    }

    int black = 0;

    rep(i, 0, h) {
        for(auto c : s[i])
            black += c == '#';
    }

    // dbg(black, dist[h-1][w-1]);

    int total = (h * w) - black - dist[h-1][w-1] - 1;

    prin(total);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3800
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        int[][] dp = new int[1<<n + 1][1<<m +1];
        for (int i = 0; i < n; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= 1<<n; i++) {
            int[] sum = new int[m];
            int b = 0;
            for (int j = 0; j < n; j++) {
                if((i>>j & 1) == 1){
                    b += c[j];
                    for (int k = 0; k < m; k++) {
                        sum[k] += a[j][k];
                    }
                }
            }
            boolean ok = true;
            for (int j = 0; j < m; j++) {
                if(sum[j] < x){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans = Math.min(ans, b);
            }
        }
        if(ans == Integer.MAX_VALUE) ans = -1;
        System.out.println(ans);
        sc.close();

    }

}


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

#define INF 1001001

char data[][5] = { 	{'.', ',', '!', '?', ' '},
					{'a', 'b', 'c'},
					{'d', 'e', 'f'},
					{'g', 'h', 'i'},
					{'j', 'k', 'l'},
					{'m', 'n', 'o'},
					{'p', 'q', 'r', 's'},
					{'t', 'u', 'v'},
					{'w', 'x', 'y', 'z'} };
int num[] = {5, 3, 3, 3, 3, 3, 4 ,3, 4};

int main(void)
{
	int n;
	cin >> n;
	while (n--){
		string str, ret = "";
		bool flag = false;
		cin >> str;
		int cnt = -1, now = -1;
		for (int i = 0; i < (int)str.length(); i++){
			if (str[i] == '0' && flag){
				ret += data[now-1][cnt % num[now-1]];
				cnt = -1;
				now = -1;
				flag = false;
			}
			else if (str[i] != '0'){
				now = str[i] - '0';
				cnt++;
				flag = true;
			}
		}
		cout << ret << endl;
	}

	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i = 0; i < H;i++){
    cin >> vec.at(i);
  }
  
  for(int j = 0;j < W + 2; j++){
    cout << '#';
  }
  cout << endl;
  
  for(int i = 0; i < vec.size(); i++){
    cout << '#' << vec.at(i) << '#' << endl;
  }
  
  for(int j = 0;j < W + 2; j++){
    cout << '#';
  }
  cout << endl;
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void) {
	int H, W;
	cin >> H >> W;

	int correct = H + W - 1;
	int cnt = 0;
	for (int i = 1; i <= H; i++) {
		char tmp[8];
		cin >> tmp;
		for (int j = 0; j < W; j++) {
			if (tmp[j] == '#') cnt++;
		}
	}
	if (cnt == correct) cout << "Possible";
	else cout << "Impossible";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define pii pair<int,int>
#define fr first
#define se second
#define ll long long 
#define pbc(x) __builtin_popcount(x)
IL int read(){int x;int _w=scanf("%d",&x);return x;}
IL void write(int x){printf("%d\n",x);}
#define int long long
template<typename T>IL void debug(T x){cerr<<x;return;}
const int maxn=1e5+10;
int n,a[maxn];
#undef int
int main(){
#define int long long
	n=read();
	rep(i,1,n)a[i]=read();
	sort(a+1,a+1+n);
	int l=1,r=n,ans=0;
	if(n%2==0){
		int mid=n/2;
		ans-=a[mid];
		repd(i,mid-1,1)ans-=a[i]*2;
		ans+=a[mid+1];
		rep(i,mid+2,n)ans+=a[i]*2;
	}else {
		int ans1=0,ans2=0;
		int mid=n/2+1;
		ans1-=a[mid];ans1-=a[mid-1];
		repd(i,mid-2,1)ans1-=a[i]*2;
		rep(i,mid+1,n)ans1+=a[i]*2;
		ans2+=a[mid];ans2+=a[mid+1];
		rep(i,mid+2,n)ans2+=a[i]*2;
		repd(i,mid-1,1)ans2-=a[i]*2;
		ans=max(ans1,ans2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int n;
    cin >> n;
    int count = 0;
    int ans = 0;

    vector<int> h(n);
    for(int i = 0; i < n; ++i)cin >> h.at(i);

    for(int i = 0; i < n; ++i){
        if(i == n-1){
            ans = max(count, ans);
            count  = 0;
        }
        else if(h.at(i) >= h.at(i+1)){
            ++count;
            }
        else{
            ans = max(count, ans);
            count  = 0;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VVI ncr;
vector<pair<in,VI> > w;
void genw(){
  VI aw(200);
  for(in i=2;i<sz(aw);++i){
    in tw=0;
    for(in s=2;s<=i;s+=2){
      tw+=ncr[i][s];
      tw=min(tw,in(1e13));
    }
    aw[i]=tw;
    if(tw<1e13)
      w.PB(MP(tw,VI(i,0)));
  }
  VI vr;
  for(in a=1;a<=30;++a){
    for(in b=1;b<=30;++b){
      for(in c=1;c<=30;++c){
	for(in d=1;d<=30;++d){
	  in tw=aw[a+c]+aw[b+d];
	  if(tw>1e13)
	    continue;
	  bool ok=1;
	  for(in i=1;i<=min(a,c);++i){
	    if(!ok)
	      break;
	    for(in j=1;j<=min(b,d);++j){
	      if(double(ncr[a][i])*ncr[b][j]*ncr[c][i]*ncr[d][j]>1e13){
		ok=0;
		break;
	      }
	      tw+=ncr[a][i]*ncr[b][j]*ncr[c][i]*ncr[d][j];
	    }
	  }
	  if(!ok)
	    continue;
	  if(tw>=1e13)
	    continue;
	  vr.clear();
	  forn(x,a)
	    vr.PB(0);
	  forn(x,b)
	    vr.PB(1);
	  forn(x,c)
	    vr.PB(0);
	  forn(x,d)
	    vr.PB(1);
	  w.PB(MP(tw,vr));
	}
      }
    }
  }
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  w.resize(209);
  ncr.resize(209,VI(209));
  forv(i,ncr){
    ncr[i][i]=ncr[i][0]=1;
    for(in j=1;j<i;++j){
      ncr[i][j]=min(in(1e13),ncr[i-1][j-1]+ncr[i-1][j]);
    }
  }
  VI ans;
  in nxt=1;
  genw();
  sort(all(w));
  reverse(all(w));
  in mw;
  forv(i,w){
    if(w[i].first==0)
      continue;
    if(w[i].first>n)
      continue;
    n-=w[i].first;
    mw=0;
    forv(j,w[i].second){
      mw=max(mw,w[i].second[j]);
      ans.PB(nxt+w[i].second[j]);
    }
    nxt+=mw+1;
    --i;
  }
  cout<<sz(ans)<<endl;
  forv(i,ans)
    cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 135164
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
s = input()
print(s[0],end = "")
print(s[1],end = "")
print(s[2],end = "")


Measured memory_bytes: 9028
<?php

$nmb = explode(' ', trim(fgets(STDIN)));
$n = $nmb[0];
$m = $nmb[1];
$c = $nmb[2];
$b = explode(' ', trim(fgets(STDIN)));

$count = 0;
for($i=0; $i<$n; $i++){
  $a = explode(' ', trim(fgets(STDIN)));
  
  $s = 0;
  for($j=0; $j<$m; $j++){
    $s += $a[$j]*$b[$j];
  }
  
  if ($s+$c > 0) $count++;
}

echo $count;

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int  long long 
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=2e5+5; 
const int M=1e9+7;
void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int cnt=0;
	while(a>0 && c>0){
		if(cnt%2==0)
		{
			c-=b;
		}
		else
		{
			a-=d;
		}
		cnt++;
	}
	if(a>0)
	cout<<"Yes";
	else
	cout<<"No";
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  long count = 0, base = 0;
  int size = S.size();
  for(int i = 0; i < size; i++){
    if(S.at(i) == '?'){
      if(i - 1 >= 0){
        if(S.at(i - 1) == 'P'){
          S.at(i) = 'D';
          continue;
        }
      }
      if(i + 1 < size){
        if(S.at(i + 1) == 'D')S.at(i) = 'P';
        else if(S.at(i + 1) == '?')S.at(i) = 'P';
        else S.at(i) = 'D';
        continue;
      } else S.at(i) = 'D';
    }
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
set<string> words;

int main() {
	cin >> N;
	string S;
	cin >> S;
	words.insert(S);
	for (ll n = 1; n < N; n++) {
		string news;
		cin >> news;
		if (words.find(news) != words.end()) {
			cout << "No" << endl;
			return 0;
		}
		words.insert(news);
		if(S.back() != news[0]) {
			cout << "No" << endl;
			return 0;
		}
		S = news;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;
cin>>n;
string ans;
while(n)
{
	n--;
	int x=n%26;
	char c='a'+x;
	ans=c+ans;
	n/=26;
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3644
using System;

class P
{
public static void Main()
{
            //?????????????????????
            var x = Console.ReadLine().Split(' ');

            //?????????????????°?????????
            int a = Int32.Parse(x[0]);
            int b = Int32.Parse(x[1]);

            //double??§??????
            double A = Double.Parse(x[0]);
            double B = Double.Parse(x[1]);

            //d:a/b(??´??°)
            int d = a / b;
            //r:a/b?????????(??´??°)
            int r = a % b;
            //f:a/b(???????°???°?????°)
            double f = A / B;

            //??????
            Console.WriteLine("{0} {1} {2:f5}", d, r, f);
}
}

Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;

  ll ans = (n / (a+b) )*a;
  ll mod = n%(a+b);
  ans += min( mod, a );

  cout << ans << endl;
}


Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    ll a[n+10];
    REP(i,n) cin >> a[i+1];
    a[0]=0;
    rep(i,n){
        a[i+1]+=a[i];
    }
    ll ans=INF;
    for(int i=2;i<n-1;i++){ // iは２番目の仕切り
        int *p1,*p2,s;
        p1=lower_bound(a+1,a+i+1,a[i]/2+1); // 1~iに分けられた時の1番目の仕切りをa[i]/2に近いところを選ぶ
        p2=lower_bound(a+i+1,a+n+1,(a[n]+a[i])/2+1); // i~n
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                s=max({*p1,a[i]-*p1,*p2-a[i],a[n]-*p2})-min({*p1,a[i]-*p1,*p2-a[i],a[n]-*p2}); // j,kでp1.p2の周辺を探る・・賢い
                ans=min(ans,s);
                p1--;
            }
            p1+=2;
            p2--;
        }
    }

    cout<<ans<<endl;


    
}


Measured memory_bytes: 1792
let id x = x
let (a,b) = Scanf.scanf "%d %d\n" (fun a b -> (a,b))

let a' = if a = 1 then 14 else a
let b' = if b = 1 then 14 else b

let ans = if a' > b' then "Alice" else
            if b' > a' then "Bob" else "Draw"

let () = Printf.printf "%s\n" ans

Measured memory_bytes: 384
import sys
from collections import deque
input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    
    
    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for i in range(h):
        s.append("##" + input().replace("\n", "") + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))
    
    
    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[ch][cw] = 0
    
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    not_yet = deque([(ch, cw)])
    one_time = deque([])
    
    while len(not_yet) > 0:
        x, y = not_yet.popleft()
        one_time.append((x, y))
        for (p, q) in move:
            if ans[x+p][y+q] == -1:
                not_yet.append((x+p, y+q))
                ans[x+p][y+q] = ans[x][y]
                
        if len(not_yet) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.popleft()
                for i in range(x2-2, x2+3):
                    for j in range(y2-2, y2+3):
                        if ans[i][j] == -1:
                            ans[i][j] = ans[x2][y2]+1
                            not_yet.append((i, j))
                            
                      
    print(ans[dh][dw])
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 93056
#include <iostream>
#include <algorithm>
static const int MAX = 200000;

using namespace std;

int main(int argc, const char * argv[]) {
  int R[MAX], n;
  
  cin >> n;
  for(int i = 0; i < n; i++) cin >> R[i];
  
  int maxv = -2000000000;
  int minv = R[0];
  
  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  
  cout << maxv << endl;
  
  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int main() {
	int n;
	cin >> n;
	vector<double> vs(n);
	vector<double> os(n);
	rep(i, n) {
		cin >> vs[i];
	}
	rep(i, n) {
		cin >> os[i];
	}
	vector<int> visit;
	rep(i, n) visit.push_back(i+1);

	ll id1 = -1, id2 = -1;
	ll index = 0;
	do {
		index++;
		{
			if (id1 < 0) {
				bool ok = true;
				rep(i, n) {
					if (vs[i] != visit[i]) ok = false;
				}
				if (ok) {
					id1 = index;
				}
			}
		}
		{
			if (id2 < 0) {
				bool ok = true;
				rep(i, n) {
					if (os[i] != visit[i]) ok = false;
				}
				if (ok) {
					id2 = index;
				}
			}
		}
	} while (std::next_permutation(visit.begin(), visit.end()));
	cout << abs(id2- id1) << endl;
	return 0;
}


Measured memory_bytes: 3768
import numpy as np
N = int(input())
max_z = -np.Inf
min_z = np.inf
max_w = -np.Inf
min_w = np.inf
for _ in range(N):
    x, y = map(int, input().split())
    z = x + y
    w = x - y
    max_z = max(max_z, z)
    min_z = min(min_z, z)
    max_w = max(max_w, w)
    min_w = min(min_w, w)
print(max(max_z-min_z, max_w-min_w))

Measured memory_bytes: 27120
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A)
	for i := 0; i < 4; i++ {
		fmt.Scan(&B)
		if B < A {
			A = B
		}
	}

	ans := N/A + 5
	if N%A == 0 {
		ans--
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i = 0; i < 3; i++){
    cin >> a[i];
  }
  sort(a,a+3);
  reverse(a,a+3);
  int count = 0;
  if((a[1]-a[2])% 2== 0){
    count+= a[0]-a[1];
    count+= (a[1]-a[2])/2;
  }
  else{
    count+= a[0]-a[1];
    count+= 2+(a[1]-a[2])/2;
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll cnt[30];
ll mul(ll a,ll b){
  return (a*b)%MOD;
}
ll add(ll a,ll b){
  ll ret = a+b;
  if (ret >= MOD) ret -= MOD;
  return ret;
}
int main(){
  IOS();
  ll n;
  cin >> n;
  string s;
  cin >> s;
  REP (i,n) {
    cnt[s[i]-'a']++;
  }

  ll ans = 0;
  REP (i,n) {
    ll tmp = 1;
    REP (j,26) {
      if (j == s[i]-'a') continue;
      tmp = mul(tmp,cnt[j]+1);
    }
    cnt[s[i]-'a']--;
    ans = add(ans,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>

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

using namespace std;
//
//dp[時間][状態]

int dp[32][65537];
int a[32];
int b[32];

int bitCount(int bits)
{
	int r = 0, k=1;
	rep(i,16){
		if(bits&k)r++;
		k=k<<1;
	}
	return r;
}


int main(void){
	int n, c;
	while(scanf("%d %d", &n, &c), n+c!=0){
		rep(i,32)rep(j,65537)dp[i][j] = -1;
		rep(i,32)a[i] = -1;
		rep(i,32)b[i] = -1;
		
		rep(i,n){
			int l = 0;
			int t;
			rep(j,16){
				scanf("%d", &t);
				l |= ((1<<(15-j))*t);
			}
			a[i] = l;
		}
		
		rep(i,c){
			int l = 0;
			int t;
			rep(j,16){
				scanf("%d", &t);
				l |= ((1<<(15-j))*t);
			}
			b[i] = l;
		}
		dp[0][a[0]] = 0;
		int nF;
		rep(i,n)rep(j,65537){
			if(dp[i][j] != -1){
				rep(k, c){
					nF = (((j^b[k])&j)|a[i+1]);
					dp[i+1][nF] = max(dp[i+1][nF], dp[i][j]+bitCount(j&b[k]));
				}
			}
		}
		
		int ans = -1;
		rep(i,65537){
			ans = max(ans,dp[n-1][i]);
		}
		
		printf("%d\n", ans);
		
	}
	
	return 0;
}

Measured memory_bytes: 9380
import math
n = int(input())
food_list = list(map(int, input().split()))
satis_list = list(map(int, input().split()))
moreS_list = list = list(map(int, input().split()))

total = sum(satis_list)

for i in range(n-1):
    if food_list[i] + 1 == food_list[i+1]:
        total += moreS_list[food_list[i]-1]
print(total)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,w=0,t=0,r=0;
    cin>>n;
    int i=1;
    string s;
    while(i<=n)
    {
        cin>>s;
        if(s=="AC")
        {
            a++;
        }
        if(s=="WA")
        {
            w++;
        }
        if(s=="TLE")
        {
            t++;
        }
        if(s=="RE")
        {
            r++;
        }
        i++;

    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s1 second
const ll INF=(1LL<<60)-1;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const char &i, char &j)
{
    
    return i > j;
    
}

void solve()
{
   li a;
   cin>>a;
   a=a+a*a+a*a*a;
   cout<<a;
    
    
    
    
}
int main()
{
    FAST_IO;
    li t;
    t=1;
    while(t--)
    solve(),cout<<endl;
    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	set<string>st;
	st.insert(s);
	For(i,n-1){
		string d;
		cin>>d;
		if(st.count(d)!=0){
			cout<<"No"<<endl;
			return 0;
		}
		st.insert(d);
		if(s.back()!=d[0]){
			cout<<"No"<<endl;
			return 0;
		}
		s=d;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)
#define roop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int i,j;

int main(void) {
  string s;
  cin>>s;
  rep(i,s.size()){
    if(s.substr(i,11)=="dreameraser")i+=10;
    else if(s.substr(i,10)=="dreamerase")i+=9;
    else if(s.substr(i,7)=="dreamer")i+=6;
    else if(s.substr(i,5)=="dream")i+=4;
    else if(s.substr(i,6)=="eraser")i+=5;
    else if(s.substr(i,5)=="erase")i+=4;
    else{cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int i, ii, iii, n, m, cnt= 0, cnt2= 0, f;
    long long int x[3][1000], sum[8][1000] = {}, ans = 0, max[8] = {};
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++)
        scanf("%lld%lld%lld", *x + i, x[1] + i, x[2] + i);
    for (i = 0; i < 8; i++)
        for (ii = 0; ii < 3; ii++)
            for (iii = 0; iii < n; iii++)
            {
                if ((i >> ii) % 2)
                    sum[i][iii] += x[ii][iii];
                else
                    sum[i][iii] -= x[ii][iii];
            }
    for (i = 0; i < 8; i++)
    {
        f = 1;
        while (f)
        {
            f = 0;
            for (ii = 0; ii < n - 1; ii++)
            {
                if (sum[i][ii] < sum[i][ii + 1])
                {
                    f = 1;
                    sum[i][ii] ^= sum[i][ii + 1];
                    sum[i][ii + 1] ^= sum[i][ii];
                    sum[i][ii] ^= sum[i][ii + 1];
                }
            }
        }
    }
    for (i = 0; i < 8; i++)
        for (ii = 0; ii < m; ii++)
            max[i] += sum[i][ii];
    for (i = 0; i < 8; i++)
        if (ans < max[i])
            ans = max[i];
    printf("%lld", ans);
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	vector<int> a(M+1);
	vector<long long> ans(N+1);
	int loop;
	if(M){
		for(loop=0;loop<M;loop++){
			cin >> a[loop];
			if(loop&&a[loop]==a[loop-1]){
				ans[0]=0;
				cout << ans[0] << endl;
				return 0;
			}
		}
	}else{
		a[0]=-1;
	}
	ans[0]=1;
	if(a[0]!=1){
		ans[1]=1;
		loop=0;
	}else{
		ans[1]=0;
		loop=1;
	}
	int loop2=2;
	for(;loop<M;loop++){
			for(;loop2<a[loop];loop2++){
				ans[loop2]=(ans[loop2-1]+ans[loop2-2])%1000000007;
			}
			ans[loop2]=0;
			loop2++;
	}
	for(;loop2<=N;loop2++){
		ans[loop2]=(ans[loop2-1]+ans[loop2-2])%1000000007;
	}
	cout << ans[N] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

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

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


int main() {

	int n,sum=0,tmp;

	bool flag = true;
	int cnt = 0;

	cin >> n;
	vector<int>num(n);
	vector<bool>ch(n, true);

	rep(i, 0, n) {
		cin >> num[i];
		sum += num[i];
		if (num[i] % 10 == 0) {
			ch[i] = false;
			cnt++;
		}
	}

	tmp = sum;

	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}

	if (cnt == n) {
		cout << "0" << endl;
		return 0;
	}
	
	int ma = -1;

	rep(i, 0, n) {
		tmp = sum;
		tmp -= num[i];
		if (tmp % 10 != 0) {
			ma = max(ma, tmp);
		}
	}

	cout << ma << endl;


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

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

int main(){
    ll x;
    ll x500,x5;
    cin >> x;
    x500 = x / 500;
    x -= x500 *500;

    x5 = x/5;
    ll ans = 0;
    ans = x500 * 1000 + x5 * 5;
    cout << ans << endl; 


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long

#define pa pair<int,int>
#define int long long

using namespace std;

int inf=(1ll<<40);
struct seg_rangeupd_getpoint{
	//       1
	//   2        3
	// 4   5   6    7
	
	
	private:
	public:
	
	// (1<<15)=32768
	// 1<<16 = 65536
	// 1<<17 = 131072
	// 1<<18 = 262144
	
	int cor=(1<<17);
	
	vector<int> vec;
	void shoki1(){
		vec.resize(2*cor+3, inf);
	}
	void shoki2(){
		vec[1]=(1ll<<31)-1;
		//初期値
	}
		
	void chien(int k,int l,int r){
		if(l+1<r)if(vec[k]!=inf){
			vec[2*k]=vec[k];
			vec[2*k+1]=vec[k];
			vec[k]=inf;
		}
	}
	
	void rangeupd(int a,int b,int w, int k=1,int l=0,int r=-3){
		//[a,b)を wに変更
		if(r<0) r=cor;
		if(a<=l && r<=b){
			vec[k]=w;
			return ;
		}
		if(r<=a || b<=l){
			return ;
		}
		chien(k,l,r);
//	cout<<k<<" "<<l<<" "<<r<<endl;
		rangeupd(a,b,w,k*2,l,(l+r)/2);
		rangeupd(a,b,w,k*2+1,(l+r)/2,r);
		return ;
	}
	
	// [a,b)
	// k-th node
	// k no kukanha [l,r)
	int getpoint(int x){
		x+=cor;
		int ans=0;
		while(1){
			if(x==0) break;
			if(vec[x]!=inf) ans=vec[x];
			x/=2;
		}
		
		return ans;
		
	}
	
	void pre(){
		for(int i=1;i<2*cor;i++){
			cout<<vec[i]<<" ";
			if(((i+1)&(-(i+1)))==i+1) cout<<endl;
		}
	}
	
};

//[a,b)にxを一様加算 rangeadd(a,b,x)
//[a,b)の和 getsum(a,b)

signed main(){
seg_rangeupd_getpoint SE;
	
	SE.shoki1();
//	for(int i=0;i<SE.cor;i++){
//		SE.vec[i+SE.cor]=i;
//	}
	SE.shoki2();
	
	
	int n,q;
	cin>>n>>q;
	
	for(int i=0;i<q;i++){
	int d,a,b,c;
		cin>>a;
		
		if(a==0){
			cin>>b>>c>>d;
			
			SE.rangeupd(b,c+1,d);
		}
		else{
			cin>>b;
			
			cout<<SE.getpoint(b)<<endl;
		}
		//SE.pre();
	}
	return 0;
}





Measured memory_bytes: 4780
n = int(input())
a = [int(input()) for _ in range(n)]
if 2 not in a:
    print(-1)
    quit()
else:
    t = a.index(2)
    s = 1
    count = 0
    while count <= 10**6:
        s = a[s-1]
        count += 1
        if s == 2:
            print(count)
            quit()
print(-1)

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int H,W;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W;
	vector<string> board(H);
	FOR(i,0,H){
		cin >> board [i];
	}

	vector<string> red(H,string(W,'.')),blue(H,string(W,'.'));
	FOR(i,0,H){
		FOR(j,0,W){
			if(board [i] [j] == '#'){
				red [i] [j] = blue [i] [j] = '#';
			}
			else if(i == 0 || (j % 2 == 0 && i != H - 1)){
				red [i] [j] = '#';
			}
			else{
				blue [i] [j] = '#';
			}
		}
	}

	FOR(i,0,H){
		cout << red [i] << endl;
	}
	cout << endl;
	FOR(i,0,H){
		cout << blue [i] << endl;
	}

	return 0;
}


Measured memory_bytes: 1536
n = int(input())
pattern = ['S', 'H', 'C', 'D']
cards = [[False for i in range(13)] for j in range(4)]

for _ in range(n):
    x, y = input().split()
    cards[pattern.index(x)][int(y)-1] = True

for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(pattern[i], j+1)



Measured memory_bytes: 5604
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a = inint()
b = inint()
c = inint()
x = inint()

ans = 0

for i in range(a+1):
    for k in range(b+1):
        for j in range(c+1):
            if 500*i + 100*k + 50*j == x:
                ans += 1

print(ans)

Measured memory_bytes: 67616
S = str(input())
child_num = [1]*len(S)
for i in range(len(S)- 2):
    if S[i] == 'R':
        if S[i + 1] == 'R':
            child_num[i + 2] += child_num[i]
            child_num[i] = 0
for i in range(len(S) - 2):
    if S[len(S) - i -1] == 'L':
        if S[len(S) - i - 2] == 'L':
            child_num[len(S) - i - 3] += child_num[len(S) - i -1]
            child_num[len(S) - i - 1] = 0
print(*child_num)

Measured memory_bytes: 6400
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define f first
#define s second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int,int>> vii;
typedef vector<pair<ll,ll>> vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

ll ppow(ll x,ll y,ll mod) {
    ll res=1;
    while(y) {
        if(y&1) res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

bool check(string s) {
    int n=s.size();
    for (int i=0;i<n/2;++i) {
        if (s[i] != s[n-1-i])
            return 0;
    }
    return 1;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s; cin >> s;
    int n=s.size();
    if (check(s.substr(0,(n-1)/2)) && check(s.substr((n+3)/2-1,n-(n+3)/2+1)) && check(s))
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = a-1;
    if(a<=b)ans++;
    cout << ans << endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector < pair<ll, ll> > C(N);
	for (ll ii = 0; ii < N; ++ii){
		ll A, B;
		cin >> A >> B;
		C[ii] = make_pair(A, B);
	}
	sort(C.begin(), C.end());

	ll ans = 0;
	ll rem = M;
	for (ll ii = 0; ii < N; ++ii){
		ll hon = min(rem, C[ii].second);
		rem -= hon;
		ans += hon * C[ii].first;
		if (rem == 0){
			break;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int n, p, cnt;
    cin >> n;

    cnt = 0;
    vector<int> v(n);
    REP(i, n){
        cin >> p;
        if(p != i + 1)cnt++;
    }
    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
for i in range(k):
    a, b = map(int, input().split())
    if min(a, b, n-a+1, n-b+1)%3 == 0:
        print(3)
    elif min(a, b, n-a+1, n-b+1)%3 == 1:
        print(1)
    else:
        print(2)


Measured memory_bytes: 5612
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))

B = [0]*N
for i in range(N):
    if i%2 == 0:
        B[0] += A[i]
    else:
        B[0] -= A[i]

for i in range(1,N):
    B[i] = 2*(A[i-1]-B[i-1]//2)

for b in B:
    print(b)

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////

	int n;
	cin>>n;

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

	dp[1] = abs(A[1] - A[0]);
	
	for(int i = 2; i < n; ++i) dp[i] = min(abs(A[i] - A[i-1]) + dp[i-1], abs(A[i] - A[i-2]) + dp[i-2]);

	cout<<dp[n-1];

  return 0;
}

Measured memory_bytes: 1024
a,b=map(int,input().split())
List=[]
for i in range(b):
  p,q=map(int,input().split())
  List.append([p,q])
List=sorted(List,key=lambda x:x[1])
ans=0
l=1
for i in range(b):
  if List[i][0]>=l:
    ans+=1
    l=List[i][1]
print(ans)

Measured memory_bytes: 22108
l, r = map(int, input().split())

x = [i % 2019 for i in range(l, min(r+1, l+2019+1))]
x.sort()

ans = 2019
for i in range(len(x)):
    for j in range(i+1, len(x)):
        ans = min(ans, (x[i] * x[j]) % 2019)

print(ans)


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

int swap19(int x) {
	if (x == 9) {
		return 1;
	} else if (x == 1) {
		return 9;
	} else {
		return x;
	}
}

int main(int argc, char *argv[])
{
    int target;
	int hun, ten, one;

	cin >> target;
	hun = target / 100;
	ten = (target % 100) / 10;
	one = target % 10;

	hun = swap19(hun);
	ten = swap19(ten);
	one = swap19(one);

	target = hun * 100 + ten * 10 + one;
	cout << target;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n;
  while(cin>>n, n){
    char a,b,c; // ????§????????????????????????????
    scanf(" %c %c %c", &a, &b, &c);
    a-='A'; b-='A'; c-='A';
    vector<vector<double> > prev(3, vector<double>(3,0)), nxt(3,vector<double>(3));
    prev[a/3][a%3]=1;
    rep(i,n){
      rep(j,3) fill(all(nxt[j]), 0);
      rep(x,3) rep(y,3) if(prev[x][y]>0){
        const int dx[]={-1,0,0,1}, dy[]={0,-1,1,0};
        rep(k,4){
          int nx = x+dx[k], ny=y+dy[k];
          if(nx<0 || ny<0 || nx>=3 || ny>=3 || nx*3+ny==c) nxt[x][y] += prev[x][y]/4.;
          else nxt[nx][ny] += prev[x][y]/4.;
        }
      }
      swap(prev, nxt);
    }

    printf("%.6f\n", prev[b/3][b%3]);
  }
  return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <math.h>
#include <bitset>
#include <fstream>
#define int long long
#define D double
using namespace std;
int INF = 1e18;
signed main()
{
    int n, k;
    cin >> n >> k;
    int v[n][2];
    for (int i=0; i < n; i++){
        cin >> v[i][0];
        cin >> v[i][1];
    }
    vector<int> numbers;
    for (int i=0; i < n; i++){
        numbers.push_back(i);
    }
    int ans = 0;
    for (int bit=40; bit >= 0; bit--){
        vector<int> newn;
        int nn = 1LL << bit;
        int b_and = nn & k;
        if (b_and == 0){
            for (int i=0; i < numbers.size(); i++){
                int var = numbers[i];
                int bb = v[var][0] & nn;
                if (bb == 0) newn.push_back(var);
            }
        }
        else{
            int th = 0;
            for (int i=0; i < numbers.size(); i++){
                int var = numbers[i];
                newn.push_back(var);
                int bb = v[var][0] & nn;
                if (bb == 0) th += v[var][1];
            }
            ans = max(ans, th);
        }
        numbers = newn;
    }
    int th = 0;
    for (int i=0; i < numbers.size(); i++){
        th += v[numbers[i]][1];
    }
    ans = max(ans, th);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4576
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a+b+c>=22) puts("bust");
	else puts("win");
	return 0;
}


Measured memory_bytes: 256
while True:
  (m, f, r) = input().rstrip('\r\n').split(' ')
  m = int(m)
  f = int(f)
  r = int(r)
  if m == -1 and f == -1 and r == -1:
    break

  if m == -1 or f == -1:
    print('F')
    continue

  mf = m + f

  if 80 <= mf:
    print('A')
  elif 65 <= mf and mf < 80:
    print('B')
  elif 50 <= mf and mf < 65:
    print('C')
  elif 30 <= mf and mf < 50:
    if 50 <= r:
      print('C')
    else:
      print('D')
  else:
    print('F')



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

int main(){

  int i,len,sum;
  char str[1001];

  while(1){
    scanf("%s",&str);
    if(str[0]=='0') break;
    sum=0;
    len=strlen(str);
    for(i=0;i<len;i++){
      sum+=str[i]-'0';
    }
    printf("%d\n",sum);
  }
  return 0;
}


Measured memory_bytes: 536
package main

import (
	"fmt"
)

func main() {
	var n, cnt int
	var input_data []int
	done := false
	fmt.Scan(&n)
	
	for i := 0; i < n; i++ {
		var in int
		fmt.Scan(&in)
		input_data = append(input_data, in)
	}

	for !done {
		for i := 0; i < n; i++ {
			if v := input_data[i]; v == 0 || v % 2 != 0 {
				done = true
			} else {
				input_data[i] /= 2
			}
		}

		if ! done {
			cnt++
		}
	}
	
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int N,K;
int c[26];

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    string str;
    cin>>str;
    c[ str[0]-'A' ]++;
  }
  int ans=0;
  while(1){
    sort(c,c+26);
    reverse(c,c+26);
    bool flg=true;
    for(int i=0;i<K;i++){
      if(c[i]==0)flg=false;
      c[i]--;
    }
    if(!flg)break;
    ans++;
  }

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


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

int main(){
  int n;
  cin >> n;
  string s[n];
  //map<Keyの型, Valueの型> 変数名;
  map<string, int> ans;
  int count=0;
  for(int i=0;i<n;i++){
    string x;
    cin >> s[i];
    x=s[i];
    if(ans[x]!=1){
      ans[x]=1;
      count+=1;
    }
  }
  //cout << ans[0] <<endl;
  cout << count << endl;
}

Measured memory_bytes: 25480