akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int A[1000000], n;
 
/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}
 
int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2236
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;
use std::iter::FromIterator;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: u32 = read();
    let w: u32 = read();
    let img: Vec<String> = (0..h).map(|_| read::<String>()).collect();

    for i in 0..2 * h {
        println!("{}", img[(i / 2) as usize]);
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
   
   
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
 
  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
   
  cout << (f?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int r, g;
  cin >> r >> g;
  cout << 2 * g - r << endl;
}


Measured memory_bytes: 384
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int r; cin >> r;
    ld ans = (ld)r * 2.0 * pi;
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <cmath>
#include <vector>


using namespace std;



int main()
{
	unsigned long long	inNum, sum = 0;

	cin >> inNum;

	for (unsigned long long l = 1; l <= inNum; l++)
	{
		if (l % 3 == 0)
		{
			continue;
		}

		if (l % 5 == 0)
		{
			continue;
		}

		sum += l;
	}

	cout << sum;

}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int l = S.length();
    if(l%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    if(S.substr(0, l/2) != S.substr(l/2, l/2)){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    long long n,k;
    cin >> n >> k;
    int mx = 100010;
    vector<long long> res(mx, 0);
    for (int i = 0;i < n;i++){
        long long a, b;
        cin >> a >> b;
        res[a] += b;
    }

    long long ans = 0;
    for (int i = 1;i < 100010;i++){
        ans += res[i];
        if (ans >= k){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4028
n,a,b,*H=map(int,open(0).read().split())
l,r=0,10**9
while r-l>1:
	x=0
	m=(l+r)//2
	s=m*b
	for h in H:
		x-=min(0,(h-s)//-(a-b))
	if x>m:
		l=m
	else:
		r=m
print(r)

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vl = vector<ll>;
using VVl = vector<Vl>;
const ll INF = 1e18;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

void solve() {
  int N, M, X;
  cin >> N >> M >> X;
  Vl c(N);
  VVl a(N, Vl(M));
  rep(i, 0, N) {
    cin >> c[i];
    rep(j, 0, M) cin >> a[i][j];
  }

  ll ans = INF;
  for (int b = 0; b < (1 << N); b++) {
    bitset<12> bs(b);
    Vl t(M, 0);
    ll sum = 0;

    rep(i, 0, N) {
      if (bs.test(i)) {
        sum += c[i];
        rep(j, 0, M) { t[j] += a[i][j]; }
      }

      bool ok = true;
      rep(j, 0, M) if (t[j] < X) {
        ok = false;
        break;
      }
      if (ok) ans = min(ans, sum);
    }
  }
  cout << ((ans == INF) ? -1 : ans) << endl;
}

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

Measured memory_bytes: 3548
N = int(input())

A_list = [0] * N
B_list = [0] * N
C_list = [0] * N

for i in range(N):
    a, b, c = map(int, input().split())
    A_list[i] = a
    B_list[i] = b
    C_list[i] = c

dp = [[0, 0, 0] for j in range(N)]

for i in range(N):
    if i == 0:
        dp[0][0] = A_list[0]
        dp[0][1] = B_list[0]
        dp[0][2] = C_list[0]
    else:
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A_list[i]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B_list[i]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C_list[i]

print(max(dp[N - 1]))


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

int main() {
	int A, B;
  	cin >> A >> B;
    int C = 0;
  	for(int i = A; i <= B; i++){
    	if(i / 10000 == i % 10){
        	if(i % 10000 / 1000 == i % 100 / 10){
            	C += 1;
            }
        }
    }
  	cout << C << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    int absmin = 1000;

    for (int i = 0; i <= 50; i++){
        bool flag1 = false;
        bool flag2 = false;
        for (int j = 0; j < N; j++){
            if (X - i == p[j]){
                flag1 = true;
            }
            if (X + i == p[j]){
                flag2 = true;
            }
        }
        if (flag1 == false){
            cout << X - i << endl;
            return 0;
        }else if(flag2 == false){
            cout << X + i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 



void solve()
{
	int h1 , h2 , m1 , m2 ;
	cin>>h1>>m1>>h2>>m2 ;
	 int k  ;
	 cin>>k;
	 if(h1==h2){
	 	cout<<m2-m1-k<<endl;
	 }
	 else{
	 	int ti =  60-m1 + m2 ; 
	 	h1++;
	 	ti += (h2-h1)*60;
	 	cout<<ti-k<<endl;
	 }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3756
#include <stdio.h>

int main(void) {

  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double)a / (double)b;
    printf("%d %d %.5f\n", d, r, f);
 
  return 0;
 
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

const char *dates[] = {
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday"
};

const int dateOfMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int main()
{
	int month, day, date;

	while ( true )
	{
		date = 2;

		cin >> month >> day;

		if ( month == 0 )
		{
			break;
		}

		for ( int i = 0; i < month - 1; i++ )
		{
			date += dateOfMonth[i];
		}

		date += day;

		cout << dates[ date % 7 ] << endl;
	}

	return 0;
}

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

int main(){
  int l,r,d,ans=0;
  cin >> l >> r >> d;
  rep(i,r-l+1){
    if((i+l)%d == 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <string.h>
#include <algorithm> 
#include<vector>
#include<map>
#define ll long long int
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   /* ll n,x,y,i,j,a,k=0,b=0,sum=0;

	cin >> n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		sum+=a;
		k+=1-a*2;
		if(k<0)k=0;
		if(b<k)b=k;
	}
	if(b==0) cout << sum-1;
	else cout << sum+b;
	return 0;*/
ll n,k,i,s=0;
cin>>n>>k;
ll a[n];
for(i=0;i<n;i++)
{
	cin>>a[i];
}
sort(a,a+n);
for(i=0;i<k;i++)
{
	s+=a[i];
}
cout<<s;
}



Measured memory_bytes: 3652
//Template
 
// By LD :)
//Includes
#include <vector> 
#include <queue>
#include <map> 
#include <set>
#include <utility> //Pair
#include <algorithm>
#include <sstream> // istringstream>> ostring stream<<
#include <iostream> 
#include <iomanip> 
#include <unordered_map>
//setbase - cout << setbase (16); cout << 100 << endl; Prlls 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prlls xxx77
//setprecision - cout << setprecision (4) << f << endl; Prlls x.xxxx
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
 
//I want to code the solutions as fast as possible)
typedef long long ll;
typedef vector <ll> vi;
typedef vector <vi> vvi;
typedef vector <string> vs;
typedef pair<ll, ll > pii;
typedef vector <ll> vll;
typedef stringstream ss;
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define sc(n) scanf("%d", &n)
#define fast ios_base:: sync_with_stdio(false)
#define llt(arr, x) memset(arr, x, sizeof(arr))
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, a, b) for(ll i = a; i <= b; i++)
#define revrep(n, i) for(ll i = n - 1; i >= 0; i--)
#define revrepp(i, b, a) for(ll i = b; i >= a; i--)
#define all(a)  a.begin(), a.end() 
#define rall(a)  a.rbegin(), a.rend() 
#define ESP (1e-9)
 
//String Utilities 
bool isl(char c){ 
  return (c >= 'a' && c <= 'z'); 
}
bool isu(char c){ 
  return (c >= 'A' && c <= 'Z'); 
}
bool isa(char c){ 
  return (isl(c) || isu(c)); 
}
bool isn(char c){ 
  return (c >= '0' && c <= '9'); 
}
bool isan(char c){ 
  return (isa(c) || isn(c)); 
}
bool isv(char c){ 
  return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); 
}
string tolow(string s){ 
  rep(i, s.sz) if(isu(s[i])) s[i] = s[i] -'A' + 'a'; return s; 
}
string toup(string s){ 
  rep(i, s.sz) if(isl(s[i])) s[i] = s[i] - 'a' + 'A'; return s;
}
 
//It all starts here ;)
 
//End Template
const ll N = 2e5 + 7;
const ll mod = 1e9 + 7;
const int logN = 20;
//Frequently used functions
ll gcd(ll a,ll b){
  if(a == 0){
    return b;
  }
  return gcd(b % a, a);
}
ll mpow(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1){
      res = (res * a) % mod;
    }
    b = b >> 1;
    a = (a * a) % mod;
  }
  return res % mod;
}
bool co(pair<int,pair<int,int>> &a, pair<int,pair<int,int>> &b){
  return a.ff < b.ff;
}
vs tokens(string s){
  stringstream ss;
  vs tt;
  ss.clear();
  ss << s;
  char str[s.sz + 10];
  strcpy(str, s.c_str()); 
  char *token = strtok(str, " -,/");
  while(token != NULL){
    string xy(token);
    tt.pb(xy);
    token = strtok(NULL, " -,/");
  }
  return tt;
}
ll modular_inv(ll a, ll b){
  ll b0 = b, t, q;
  ll x0 = 0, x1 = 1;
  if (b == 1) return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0) x1 += b0;
  return x1;
}
//Main program 
int main(){
  /*#ifndef ONLINE_JUDGE
  freopen("k1in.txt","r",stdin);
  freopen("k1out.txt","w",stdout);
  #endif*/
  cout << fixed << showpoint << setprecision(16); fast;
  int n;
  cin >> n;
  if(n <= 999){
    cout << "ABC";
  }else{
    cout << "ABD";
  }
  cout << endl;
} 

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

const int max_n = 1e5 + 5;

char s[105][105];

int n = 100, m = 100;

int main() {
	make2(a, b);
	FOR(i,0,100) {
		FOR(j,0,100) {
			if ( i < 50) s[i][j] = '.';
			else s[i][j] = '#';
		}
	}
	a--; b--;
	FOR(i,0,25) {
		FOR(j,0,50) {
			if (b > 0) {
				s[2*i][2*j] = '#';
				b--;
			}
		}
	}
	FOR(i,27,50) {
		FOR(j,0,50) {
			if (a > 0) {
				s[2*i][2*j] = '.';
				a--;
			}
		}
	}
	FOR(i,0,100) s[i][100] = '\0';
	printf("100 100\n");
	FOR(i,0,100) {
		printf("%s\n", s[i]);
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int M = 3e5 + 50;
int a[M][65] = {0};
int main(){
	int n;
	scanf("%d",&n);
	int l = 0;
	for(int i = 0; i < n; i++){
		ll shu;
		scanf("%lld",&shu);
		int wz = 0;
		for(int j = 0; j < 60; j++){
			if(shu&(1LL<<j))
				a[i][j] = 1;
//			wz++;
//			shu>>=1LL;
		}
		l = max(l,wz);
	}
	ll sum = 0;
	for(int i = 0; i <= 64; i++){
		ll z,o;
		z = o = 0;
		long long q = 1LL<<i;
		q%=mod;
		for(int j = n-1; j>=0;j--){
			if(a[j][i]){
				sum+=z;
				o+=q;
				o%=mod;
			}
			else{
				sum+=o;
				z+=q;
				z%=mod;
			}
			sum%=mod;
		}
//		for(int j = 0; j < n;  j++){
//			if(a[j][i])
//				z++;
//			else
//				o++;
//		}
//		sum+=(z*o)%mod*q%mod;
		sum%=mod;
	}
	printf("%lld\n",sum);
	return 0;
}


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

struct edge{
	ll length;
	int count;
};

bool whichIsLonger(struct edge left,struct edge right){
	return left.length > right.length;
}

int main()
{
	int n;
	cin>>n;
	map<int,int> edgeMap;
	rep(i,n){
		ll num;
		cin>>num;
		if( edgeMap.count(num) == 0){
			edgeMap.insert(make_pair(num,1));
		}else{
			edgeMap[num]++;
		}
	}
	vector<struct edge> vec;
	for(auto iter = edgeMap.begin(); iter != edgeMap.end(); iter++){
		struct edge temp;
		temp.length = iter->first;
		temp.count = iter->second;
		vec.push_back(temp);
	}
	sort(vec.begin(),vec.end(),whichIsLonger);
	ll l1 = 0;
	ll l2 = 0;
	for(auto iter = vec.begin(); iter != vec.end(); iter++){
		if( l2 != 0) break;
		if(iter->count >= 4 && l1 == 0){
			l1 = iter->length;
			l2 = iter->length;
		}

		if(iter->count >= 2){
			l2 = l1;
			l1 = iter->length;
		}
	}
	cout<<l1 * l2<<endl;
	return 0;
}



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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long long> h(n);
  long long sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  for (int i = 0; i < n-k;i++){
    sum += h.at(i);
  }
  cout << sum;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, '%d %d', $N, $K);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = 0;
$sum = 0;
$pre = 0;
for ($i = 0; $i < $N - $K + 1; $i++) {
    $cur = ($p[$i + $K - 1] + 1) / 2;
    if ($i == 0) {
        for ($j = 0; $j < $K; $j++) {
            $sum += ($p[$j] + 1) / 2;
        }
    } else {
        $sum += $cur - $pre;
    }
    if ($max < $sum) {
        $max = $sum;
    }
    $pre = ($p[$i] + 1) / 2;
}
echo $max . PHP_EOL;

Measured memory_bytes: 27120
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  VAR(string, s);

  int len = (int)s.length();
  i64 res = 0;
  for (int bit = 0; bit < (1 << (len - 1)); ++bit) {

    i64 num = 0;
    for (int i = 0; i < len; ++i) {

      num = 10 * num + (s[i] - '0');

      if (bit & (1 << i)) {
        res += num;
        num = 0;
      }
    }

    res += num;
  }

  OUTL(res);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){

  int a,b;
  char op;


  while(1){

    scanf("%d %c %d", &a, &op, &b);



    if(op == '+'){
      printf("%d\n",a+b);
    }

    else  if(op == '-'){
      printf("%d\n",a-b);
    }

    else  if(op == '*'){
      printf("%d\n",a*b);
    }

    else if (op == '/'){
      printf("%d\n",a/b);
    }
    else  break;
  }
  
  return 0;
}

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

bool check(long long a,long long b,long long c)
{
	if(a+b > c && a+c > b && b+c > a)
		return true;
	else
		return false;
}
int main()
{
	int count=0;
	int n;
	cin>>n;
	long long int *l= new long long[n];
	for(int i=0;i<n;i++)
		cin>>l[i];
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && check(l[i],l[j],l[k]) )
					count++;
			}
		}
	}
	cout<<count;
	delete l;
	return 0;
}


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

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


int main() { 
    int N, count = 0;
    cin >> N;
    vector<long long> L(N);
    rep(i, N){
        cin >> L.at(i);
    }

    for(int i = 0; i < N - 2; ++i) {
        for (int j = i+1; j < N - 1; ++j) {
            for (int k = j+1; k < N; ++k) {
                // cout << i << j << k << " : ";
                vector<long long> p = {L[i], L[j], L[k]};
                sort(p.begin(), p.end());
                // cout << p[0] << p[1] << p[2] << endl;
                auto result = unique(p.begin(), p.end());
                p.erase(result, p.end());
                // cout << p[0] << endl;
                if (p.size() == 3) {
                    if (p[2] < p[0] + p[1]) {
                        // cout << i+1 << j+1 << k+1 << " : "<< p[0] << p[1] << p[2] << endl;
                        ++count;
                    }
                }
            }
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3636
s = gets.strip

words = ['dream', 'dreamer', 'erase', 'eraser']

until s.empty? do
    reduced = false
    words.map do |w|
        if s[-w.size, w.size] == w
            s = s[0..-w.size - 1]
            reduced = true
            break
        end
    end

    unless reduced
        puts 'NO'
        exit 0
    end
end

puts 'YES'

Measured memory_bytes: 56144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    int N;cin>>N;
    vector<vector<int> > G(N);
    for(int i=0;i<N-1;++i){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> visited(N,-1);
    queue<pii> que;
    visited[0]=0;
    visited[N-1]=1;
    que.push(pii(0,0));
    que.push(pii(N-1,1));
    while(!que.empty()){
        pii p=que.front();que.pop();
        int s=p.first,pl=p.second;
        for(auto t:G[s]){
            if(visited[t]==-1){
                visited[t]=pl;
                que.push(pii(t,pl));
            }
        }
    }
    int fn=0,sn=0;
    for(int i=0;i<N;++i){
        if(visited[i]==0) fn++;
        else sn++;
    }
    cout<<(fn>sn?"Fennec":"Snuke")<<endl;
    return 0;
}


Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define ll long long
#define MAXN 100010
using namespace std;
ll N;
ll A[3][MAXN];
ll pre[2][MAXN];
int main() {
	cin >> N;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
		sort(A[i], A[i] + N);
	}
	for (int i = 1; i >= 0; i--) {
		for (int j = N - 1; j >= 0; j--) {
			if (i) pre[i][j] = pre[i][j + 1] + N - (upper_bound(A[i + 1], A[i + 1] + N, A[i][j]) - A[i + 1]);
			else {
				ll t =  (upper_bound(A[i + 1], A[i + 1] + N, A[i][j]) - A[i + 1]);
				pre[i][j] = pre[i][j + 1] + pre[i + 1][t];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += pre[0][i];
	}
	cout << pre[0][0] << "\n";
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; i++) cin >> a[i];
ll maxi = a[0];
ll ans = 0;
for (ll i = 0; i < n; i++) {
    ans += max(maxi - a[i],0LL);
    chmax(maxi, a[i]);
}
cout << ans << endl;
}

Measured memory_bytes: 4836
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    ll A[n+1], B[m+1];
    rep(i,1,n+1)	cin>>A[i];
    rep(i,1,m+1)	cin>>B[i];
    ll j=m;
    A[0]=0;B[0]=0;
    ll s1=0,s2=0;
    ll ans=0;
    rep(i,0,m+1)	s2+=B[i];
    rep(i,0,n+1){
    	s1+=A[i];
    	if(s1>k)	break;
    	ll y = k-s1;
    	while(s2>y){
    		s2-=B[j];
    		j--;
    	}
    	ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}

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

int N;
int a[110][110]={{0}};
int d[110][5]={{0}};
int T=1;

void dfs(int cur);

int main(){
        cin >> N;
        for(int i=0; i<N; i++){
                int v,n;
                cin >> v;
                cin >> n;
                for(int j=0; j<n; j++){
                        int V;
                        cin >> V;
                        a[v-1][V-1]=1;
                }
        }
        for(int i=0; i<N; i++){
                if(!d[i][0])dfs(i+1);
        }
        for(int i=0; i<N; i++){
                cout << i+1 << " ";
                for(int j=0; j<2; j++){
                        cout << d[i][j];
                        if(!j)cout << " ";
                }
        cout << endl;
        }
}


void dfs(int cur){
        d[cur-1][0]=T;
        T++;
        //cerr << "visiting_" << cur << " " << T << endl;
        for(int i=0; i<N; i++){
                if(a[cur-1][i] && !d[i][0])dfs(i+1);
        }
        d[cur-1][1]=T;
        T++;
        if(cur>1)cur--;
}

Measured memory_bytes: 1208
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
	ll N;
	cin >> N;
	ll p = 1;
	for (ll i = 0; i < N; i++) {
		p *= (i + 1);
		p = p%mod;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string N;


signed main(){
    cin >> N;

    if(N[0] == '7') cout << "Yes" << endl;
    else if(N[1] == '7') cout << "Yes" << endl;
    else if(N[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){

   int n,x,i,j,k,l;

   int c;

   while(1){

       c = 0;
     
     scanf("%d %d",&n,&x);

    if(n==0&&x==0) break;

  for(i=1;i<=n;i++){

   for(j=i+1;j<=n;j++){

     for(k=j+1;k<=n;k++){

        l = i + j + k;

      if(x==l)

         c++;


        }

     }

   }

  printf("%d\n",c);

 }

   return 0;

}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

vector<ll> ans(100500);
vector<vector<pii>> g(100500);

void dfs(int i, int p, ll pari) {
  ans[i] = pari;

  for (auto&& j : g[i]) {
    if (j.first != p) {
      dfs(j.first, i, pari^j.second);
    }
  }
}

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

  int n;
  cin >> n;
  rep(i, n-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g[u].push_back(pii(v, w%2));
    g[v].push_back(pii(u, w%2));
  }

  dfs(0, -1, 0);

  rep(i, n) {
    cout << ans[i] << endl;
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<double> t(n+2, 0.0), v(n+2, 0.0);
    vector<double> l(n+2, 0.0), r(n+2, 0.0);
    for(int i = 1; i <= n; i++) cin >> t[i];
    for(int i = 1; i <= n; i++) cin >> v[i];

    // 速度が一定である区間[l,r]
    for(int i = 2; i < n+2; i++) l[i] = l[i-1] + t[i-1];
    for(int i = 1; i < n+2; i++) r[i] = r[i-1] + t[i];

    vector<double> sv;
    for(double x = 0; x <= r[n+1]; x += 0.5) {
        double mn = 1e9+1;
        for(int i = 0; i < n+2; i++) {
            // [0,l], [l,r], [r, T]での最小値が制限
            if(x < l[i]) mn = min(mn, v[i] + (l[i] - x));
            if(l[i] <= x && x <= r[i]) mn = min(mn, v[i]);
            if(r[i] < x) mn = min(mn, v[i] + (x - r[i]));
        }
        sv.push_back(mn);
    }

    double ans = 0;
    for(int i = 1; i < sv.size(); i++) {
        ans += 0.25 * (sv[i] + sv[i-1]);
    }

    printf("%lf", ans);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll dst[N];
bool vis[N];
const ll inf = 1e18;
int main(){
    int k;
    cin>>k;
    for(int i=0;i<=k;i++)dst[i] = inf;
    priority_queue<pair<ll,int> > pq;
    for(int i=1;i<=9;i++){
        dst[i] = i;
        pq.push({-i,i});
        vis[i] = true;
    }
    while(!pq.empty()){
        int node = pq.top().second;
       // cout<<pq.top().first<<" "<<pq.top().second<<endl;
        pq.pop();

        for(int i=0;i<=9;i++){
            int nx = (node*10+i)%k;
            if(dst[nx]>dst[node]+i){
               dst[nx] = dst[node]+i;
               pq.push({-dst[nx],nx});
            }
         //   cout<<node<<" "<<nx<<" "<<dst[nx]<<" "<<i<<" "<<endl;

        }
    }
    cout<<dst[0]<<endl;
    return 0;
}


Measured memory_bytes: 8228
#include<bits/stdc++.h>
using namespace std;
bool vis[2000005];
int main()
{
    int s;
    scanf("%d",&s);
    vis[s]=true;
    for(int i=2;;i++)
    {
        if(s%2==0) s=s/2;
        else s=s*3+1;
        if(!vis[s]) vis[s]=true;
        else {cout<<i;break;}
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
string s;
int n, a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  FOR(i, 0, n){
    if(s[i] == '('){
      a++;
    }else if(a == 0){
      b++;
    }else{
      a--;
    }
  }
  FOR(i, 0, b) cout << '(';
  cout << s;
  FOR(i, 0, a) cout << ')';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
no = 0
n = len(s)
for i in range(n):
    if s[i] != s[n-1-i]:
        no = 1
# print(no)
for i in range((n-1)//2):
    # print(s[i] , s[(n-1)//2-1-i])
    if s[i] != s[(n-1)//2-1-i]:
        no = 1
# print(no)
j = 0
for i in range((n+3)//2-1, n):
    # print(s[i] ,s[n-1-j])
    if s[i] != s[n-1-j]:
        no = 1
    j += 1
if no == 1:
    print("No")
else:
    print("Yes")

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

int main(){
	int N;
	int A[100000] = {0};
	int B;
	int flag = 0;

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> B;
		A[B]++;
		if(A[B]>2 || A[0]>1)
			flag = 1;
	}

	if(flag == 1){
		cout << 0 << endl;
		return 0;
	}
	int per=1;
	for(int i=0;i<N/2;i++){
		per*=2;
		per%=1000000007;
	}
	cout << per << endl;
	return 0;
}


Measured memory_bytes: 640
import sys,re
for e in sys.stdin:
 s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e.strip())])
 for i in '0123456789'[s:]:
  if eval(e.replace('X',i).replace('=','==')):print(i);break
 else:print('NA')


Measured memory_bytes: 6564
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		if( K<=A ){
			System.out.println(K);
		}
		if( K>A && K<=A+B ){
			System.out.println(A);
		}
		if( K>A+B ){
			System.out.println(A+(K-A-B)*(-1));
		}
	}
}

Measured memory_bytes: 35752
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[110][110];
int f[110][110];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    memset(f,31,sizeof(f));
   	int n=read(),m=read();
   	f[1][1]=0;
   	for(int i=1;i<=n;i++)
   	{
   		scanf("%s",ss[i]+1);
   		for(int j=1;j<=m;j++)
   		{
   			if(j>1)
   			{
   				if(ss[i][j]!=ss[i][j-1])f[i][j]=min(f[i][j],f[i][j-1]+1);
   				else f[i][j]=min(f[i][j],f[i][j-1]);
   			}
   			if(i>1)
   			{
   				if(ss[i][j]!=ss[i-1][j])f[i][j]=min(f[i][j],f[i-1][j]+1);
   				else f[i][j]=min(f[i][j],f[i-1][j]); 				
   			}
   		}
   	}
   	if(ss[1][1]=='#')f[n][m]++;
   	if(ss[n][m]=='#')f[n][m]++;
   	pr2(f[n][m]/2);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
N = len(S)
K = INT()

A = []
cur = S[0]
cnt = 1
for i in range(1, N):
    if S[i-1] == S[i]:
        cnt += 1
    else:
        A.append((S[i-1], cnt))
        cnt = 1
A.append((S[N-1], cnt))

if len(A) == 1:
    print(N*K//2)
    exit()

change = 0
for s, cnt in A:
    change += cnt // 2

if S[0] == S[N-1] and A[-1][1] % 2 == 1 and A[0][1] % 2 == 1:
    print((change+1)*K-1)
else:
    print(change*K)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>

const int INF = 0x3f3f3f3f;

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d", &n);
    std::vector<int> x(n);
    for (int k = 0; k != n; k++) {
        scanf("%d", &x[k]);
    }
    int ans = INF;
    for (int i = -100; i != 201; i++) {
        int tmp = 0;
        for (int j = 0; j != n; j++) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = std::min(tmp, ans);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

const int NMAX = 1e5 + 11;

int  n, h[NMAX], mem[NMAX];
bool vis[NMAX];

inline int dh(int i, int j) { return (int)abs(h[i] - h[j]); }

int dp(int i)
{
    int &ans = mem[i];

    if (i == n - 1)
        return 0;
    if (vis[i])
        return ans;
    vis[i] = true;
    ans    = dp(i + 1) + dh(i, i + 1);
    if (i + 2 < n)
        ans = min(ans, dp(i + 2) + dh(i, i + 2));
    return ans;
}

int main(void)
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    cout << dp(0) << endl;

    return 0;
}


Measured memory_bytes: 4224
N, X = map(int, input().split())
pcnt = [0] * (N+1)
fcnt = [0] * (N+1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
	pcnt[i+1] = pcnt[i]*2+1
	fcnt[i+1] = fcnt[i]*2+3

def func(l=N, x=X):
	if (l == 0):
		if (x >= 1):
			return 1
		else:
			return 0
	if (x <= 1):
		return 0
	if (x < fcnt[l-1]+2):
		return func(l-1, x-1)
	elif (x == fcnt[l - 1] + 2):
		return pcnt[l-1]+1
	else:
		return pcnt[l-1]+1+func(l-1, x-fcnt[l-1]-2)

print(func())


Measured memory_bytes: 3188
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll mod=1e9+7;
const ll maxn=1e3+10,maxp=10110;

string s;
vector <int> st;
int ans;

int main(){
	FAST_IO;
	cin>>s;
	for(int i=0;i<s.len();i++){
		if(s[i]=='R'){
			if(st.empty()||st.back()==i-1){
				st.pb(i);	
			}else{
				ans=max(ans,(int)st.size());
				st.clear();
				st.pb(i);
			}
		}
	}
	ans=max(ans,(int)st.size());
	cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
  int a, b, c, i, x=0;
  scanf("%d %d %d", &a, &b, &c);
  for(i=a ; i<=b ; i++){
    if(c%i == 0) x++;
  }
  printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 1852
// AtCoder Beginner Contest 130
// https://atcoder.jp/contests/abc130
import * as fs from "fs";

const stdin = fs.readFileSync("/dev/stdin", "utf8");
const split = stdin.split("\n");
Main(split);

function Main(inputLines: string[]) {
  const tmp = inputLines[0].split(" ");
  const input = tmp.map(ele=>Number(ele));
  Sub(input[0], input[1]);
}
function Sub(X: number, A: number) {
  if (X < A) {
    console.log(0);
  } else {
    console.log(10);
  }
}


Measured memory_bytes: 7500
#include <iostream>
#include <math.h>
#include <vector>
#include <map>

using namespace std;


int main() 
{
	int m,n;
	cin>>n>>m;
	vector<int> counts;
	long long total;
	for(int i=0;i<n;++i){
		int c ;
		cin>>c;
		total+=c;
		counts.push_back(c);
	}

	
	float v = (float)1/(float)(4*m);
	long long current = 0;
	
	for(int i=0;i<n;++i){
		float vv = (float)counts[i]/(float)total;
		
		if(vv >= v){

			current+=1;
		}
	}

	if(current>=m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}


}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 100000
#define INF 1000000000

int main(int argc, char const* argv[])
{
	int ans=0, i;
	char s[3], t[3];
	scanf("%s%s",s,t);
	for(i=0; i<3; i++) {
		if(s[i]==t[i]) ans++;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main(){
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  int anum,bnum;
  anum=bnum=0;
  anum=c/b;
  bnum=a/d;
  if(c%b!=0)anum++;
  if(a%d!=0)bnum++;
  if(anum>bnum){
   	cout << "No" << endl; 
  }else{
   cout << "Yes" << endl; 
  }
}

Measured memory_bytes: 3076
n=int(input())
lst=list(map(int,input().split()))
lst.sort()
x=lst[-1]
z=x/2
y=float('inf')
min_dif=100000000000
for w in lst:
    if abs(w-z)<min_dif:
        min_dif=abs(w-z)
        y=w
print(x,y)

Measured memory_bytes: 14428
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int dp[100000+1][100];

int main() {
  int N; cin>>N;
  vector<int> coins(1,1);
  for(int i = 6; i <= N; i *= 6) {
    coins.push_back(i);
  }
  for(int i = 9; i <= N; i *= 9) {
    coins.push_back(i);
  }
  sort(coins.begin(), coins.end());
  int M = coins.size();
  //  cout << M << endl;                                                                
  //  REP(i,M) cout << coins[i] << "," ; cout << endl;                                  
  for(int i = 0; i < M; i++) dp[0][i] = 0;
  for(int i = 1; i <= N; i++) dp[i][0] = i;
  for(int i = 1; i <= N; i++) {
    //    cout << i << "=" ;                                                            
    for(int j = 1; j < M; j++) {
      dp[i][j] = dp[i][j-1];
      if(i >= coins[j]) {
        dp[i][j] = min(dp[i][j], 1+dp[i-coins[j]][j]);
      }
      //  cout << dp[i][j] << ":";                                                      
    }
    //    cout << endl;                                                                 
  }
  int ans = N;
  for(int i = 0; i < M; i++) {
    ans = min(ans, dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 39424