akhauriyash/Code-Regression huggingface dataset:
s = gets
t = gets
S = s.chomp.split("")
T = t.chomp.split("")
 
def match?(k)
  T.each_with_index do |_, i|
    if S[i+k] != T[i] && S[i+k] != '?'
      return false
    end
  end
  true
end
 
def fill(k)
  ans = S.dup
  T.each_with_index do |item, i|
    ans[k+i] = T[i] if ans[k+i] == '?'
  end
  ans.each_with_index do |item, i|
    ans[i] = 'a' if ans[i] == '?'
  end
  ans
end
 
ret = 'UNRESTORABLE'
for k in (0..(S.size-T.size))
  if match?(k)
    ret = fill(k).join
  end
end
puts ret

Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	std::string str; cin >> str;
	int a; cin >> a;
	for (int i = 0; i < str.length(); i += a) {
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int N, D; cin >> N >> D;
  vvi x(N, vi(D));
  rep(i,N)rep(j,D) cin >> x[i][j];
  int count = 0;
  rep(i,N){
    rep2(j, i+1, N){
      float l = 0; 
      rep(k,D) l += pow(x[i][k]-x[j][k],2);
      l = sqrt(l);
      if(floor(l)==l) count++;
    }
  }
  cout << count << endl;  
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	LL N, X;
	cin >> N >> X;

	LL res = N, a = X, b = N - X;
	while ( a )
	{
		res += b / a * a * 2;
		LL na = b % a, nb = a;
		a = na;
		b = nb;
	}
	cout << res - b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int rooms[4][3][10] = {0};
	int n;
	int i, j, k;
	int b, f, r, v;
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
//		printf("%d %d %d %d", b, f, r, v);
		rooms[b-1][f-1][r-1] += v;
	}

	for (i = 0; i < 4; ++i) {
		for (j = 0; j < 3; ++j) {
			for(k = 0; k < 10; ++k) {
				printf(" %d", rooms[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3)
			printf("####################\n");
	}
		
	return 0;
}

Measured memory_bytes: 612
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int k,len;
	char s[101];
	scanf("%d",&k);
	scanf("%s",s);
	len=strlen(s);
	if(len>k)	{
		s[k]='\0';
		printf("%s...\n",s);
	}
	else printf("%s\n",s);
	return 0;
}

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

int main(void){
    int a[3];

    for(int i = 0; i < 3; i++)
        cin >> a[i];

    sort(a, a + 3);

    if(a[0] == 5 && a[1] == 5 && a[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 888
// Aizu 1346: Miscalculation
// 2017.9.19 bal4u@uu

#include <stdio.h>

char buf[102], *p;

long long term()
{
	long long x = *p++ - '0';
	while (1) {
		if (*p == '*') p++;	else break;
		x *= *p++ - '0';
	}
	return x;
}

long long multiFirst()
{
	long long x = term();
	while (1) {
		if (*p == '+') p++; else break;
		x += term();
	}
	return x;
}

long long left2right()
{
	long long x;
	int y, op;
	
	x = *p++ - '0';
	while (*p) {
		op = *p++, y = *p++ - '0';
		if (op == '*') x *= y;
		else           x += y;
	}
	return x;
}

int main()
{
	int k;
	long long a;
	char *ans[4] = { "I", "M", "L", "U" };

	scanf("%s%lld", buf, &a); k = 0;
	p = buf; if (multiFirst() == a) k |= 1;
	p = buf; if (left2right() == a) k |= 2;
	puts(ans[k]);
	return 0;
}

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

int n;
int cnt[MAX];

int main(){
	scanf ("%d",&n);
	REP(i,n-1){
		int a;
		scanf ("%d",&a);
		cnt[a-1]++;
	}
	REP(i,n) printf ("%d ",cnt[i]);
	puts ("");
	
	return 0;
}


Measured memory_bytes: 4492
import collections
 
N = int(input())
Sum = 0
lists = []
for i in range(N):
    s = str(input())
    s_list = list(s)
    s_list.sort()
    m = "".join(s_list)
    lists.append(m)
c = collections.Counter(lists)
set_lists = list(set(lists))
for i in range(len(set_lists)):
    n = c[str(set_lists[i])]
    Sum += n * (n - 1) // 2
lists.sort()
print(Sum)

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


int main(){
    ll a,b,k;
    cin >> a >> b >> k;
  	ll r = k - a;
    a = max(0LL,a-k);
    b = min(b,b-r);
  	b = max(0LL,b);
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){
    int N,H,W;
    cin>>N>>H>>W;
    cout<<(N-H+1)*(N-W+1)<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int x, y, z, t;
	scanf("%d", &x);
	scanf("%d", &y);
	//printf("%d\n", x);
	z = x*y;
	t = (x+y)*2;
	printf("%d ", z);
	printf("%d\n", t);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    int sum = 0, minv = 1000, maxv = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      maxv = max(maxv, s);
      minv = min(minv, s);
      sum += s;
    }
    sum -= maxv + minv;
    cout << sum / (n - 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long max,min;
		max = 0;
		min = 1000000001;
		for(int i=0;i<N;i++) {
			long a = sc.nextLong();
			if(a<min)
				min = a;
			if(a>max)
				max = a;
		}
		System.out.println(max-min);
	}
}


Measured memory_bytes: 21972
<?php
$n=trim(fgets(STDIN));

$ai=array('S'=>0,'H'=>1,'C'=>2,'D'=>3);
$ia=array('S','H','C','D');

$fl=array(52);
for($i=0;$i<52;$i++){$fl[$i]=1;}

for($i=0;$i<$n;$i++){
  list($a,$b)=explode(' ',trim(fgets(STDIN)));
  $fl[$ai[$a]*13+$b-1]=0;
}

$o='';
for($i=0;$i<52;$i++){
  if($fl[$i]){
    $o.=$ia[floor($i/13)].' '.($i%13+1).PHP_EOL;
  }
}

print $o;

Measured memory_bytes: 15308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;
typedef std::pair<ll, int> P;

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

using namespace std;

int main(){
  ll N;
  ll num_trans[5];
  //ll num_exist[6];
  cin >> N;
  ll min_trans = 10000000000000000;
  for (int i = 0; i < 5; i++) {
    cin >>num_trans[i];
    min_trans = min(min_trans, num_trans[i]);
  }

  if (min_trans >= N) cout << 5;
  else {
    ll ans = (N - N % min_trans) / min_trans + 4;
    if (N % min_trans != 0) ans++;
    cout << ans;
  }
  

  
}


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

// -----------------------------------------------------------------------------

void solve() {
    string s; cin >> s;
    vector<char> v[2];
    int q; cin >> q;
    int r = 0;
    for (int i = 0; i < q; ++i) {
        int t; cin >> t;
        if (t == 1) {
            r ^= 1;
        }
        else {
            int f; cin >> f;
            --f;
            f ^= r;
            char c; cin >> c;
            v[f].push_back(c);
        }
    }
    reverse(v[0].begin(), v[0].end());
    vector<char> ans;
    for (auto &c: v[0]) ans.push_back(c);
    for (auto &c: s) ans.push_back(c);
    for (auto &c: v[1]) ans.push_back(c);
    if (r) reverse(ans.begin(), ans.end());
    for (auto &c: ans) cout << c;
    cout << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}


Measured memory_bytes: 1480
class Queue:
    def __init__(self):
        self.items = []
 
    def enqueue(self, item):
        self.items.insert(0, item)
 
    def dequeue(self):
        return self.items.pop()
 
    def size(self):
        return len(self.items)
 
    def self(self):
        return self.items
 
s = raw_input()
t = raw_input()
q = Queue()
 
j = 0
S = list(s)
L = len(s)
while j < L :
    q.enqueue(S[L - (j + 1)])
    j += 1
 
flag = False
i = 0
while i < q.size():
    x = q.dequeue()
    q.enqueue(x)
    if (list(t) == q.self()):
        flag = True
        break
    i += 1
 
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a[100];
	memset(a,0,sizeof(a));
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=99;i++)
		a[i]=a[i-1]+a[i-2];
	int n;
	cin>>n;
	cout<<a[n];
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;
int main() {
	IO
	cin>>n>>m;
	if(!(n<10&&m<10))
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<n*m<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s,w = inpm()
ans = 'safe'
if s <= w:
    ans = 'unsafe'
print(ans)

Measured memory_bytes: 31212
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct RUP{
  int n;
  vector<int> dat,laz;
  const int def=INT_MAX;
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
    laz.clear();
    laz.resize(2*n-1,-1);
  }
  inline void eval(int len,int k){
    if(laz[k]<0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=laz[k];
      laz[k*2+2]=laz[k];
    }
    dat[k]=laz[k];
    laz[k]=-1;
  }
  void update(int a,int b,int x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=x;
      return;
    }
    eval(r-l,k);
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  void update(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int query(int a){
    return query(a,a+1,0,0,n);
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  RUP rup(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(!f){
      int s,t,x;
      cin>>s>>t>>x;
      rup.update(s,t+1,x);
    }else{
      int u;
      cin>>u;
      cout<<rup.query(u)<<endl;
    }
  }
  return 0;
}

/*
verified on 2017/07/12
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D
*/

Measured memory_bytes: 7004
K, N = map(int, input().split())
nums = list(map(int, input().split()))

before = 0
max_n = 0
for num in nums:
  dist = num - before
  max_n = max(max_n, dist)
  before = num
max_n = max(max_n, K-nums[-1]+nums[0])
print(K-max_n)

Measured memory_bytes: 99940
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

//#define __int64 long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
	string s;
	int k;
	
	cin >> s >> k;
	
    rep(i,s.length()){
		int need = (('z' + 1) - s[i]) % 26;
		if(need <= k){
			s[i] = 'a';
			k -= need;
		}
    }
	
	s[s.length()-1] = 'a' + ((s[s.length()-1] - 'a') + (k % 26)) % 26;
	
	cout << s << endl;
	
	
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	static int cnt;
	
	public static void insertSort(int [] arr, int n, int g) {
		for(int i = g; i < n; i++) {
			int v = arr[i];
			int j = i - g;
			
			while(j >= 0 && arr[j] > v) {
				arr[j + g] = arr[j];
				j = j - g;
				cnt++;
			}
			
			arr[j + g] = v;
		}
	}
	
	public static void shell(int [] arr, int n) {
		int m = 0; 
		int s = 1;
		
		while((n/s) > 0) {
			s *=2;
			m++;
		}
		
		int [] G = new int [100];
		
		for(int k = 0,t = 1; k < m; k++){
			G[k] = n/t;
			t *= 2;
		}

		for(int i = 0; i < m;i++){
			insertSort(arr ,n, G[i]);
		}
		
		System.out.println(m);
		
		for(int i = 0; i < m; i++){
			if(i != m-1){
				System.out.print(G[i] + " ");
			}else{
				System.out.print(G[i] + "\n");
			}
		}
		System.out.print(cnt + "\n");
		
		for(int i = 0; i < n; i++){
			System.out.println(arr[i]);
		}
	}
	
	
	public static void main(String [] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		int [] arr = new int [n];
		
		for(int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		
		shell(arr, n);
		
		
	}

}



Measured memory_bytes: 299208
//Rahul kumar//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 10000007
#define mod 1000000007
#define pb push_back
#define f(i,a,n) for(int i=a;i<n;i++)
#define vecti vector<int>
#define pairi pair<int,int>
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define lb lower_bound
#define ub upper_bound

int power(int a,int n)
{
    if(n==0)
    return 1;
    else if(n==1)
    return a;
    else
    {
        int r=power(a, n/2);
        if(n%2==0)
        return r*r;
        else return a*r*r;
         
    }
}
void sieve(int n) 
{
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
  
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p]==true) 
        {  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p << " "; 
} 

int main()
{
    fast
    ll n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        int x,l;
        cin>>x>>l;
        v.push_back({x+l,x-l});
    }
    sort(v.begin(),v.end());
    int cnt=0,pre=INT_MIN;
    for(auto it : v)
    {
        int x=it.first;
        int y=it.second;
        if(y>=pre) {
            cnt++;
            pre=x;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;

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

    // 1列ごとにロボットの距離を加算していけば良い
    // 初期座標 A:x=0 B:x=K
    int distance = 0;
    for (int i=0; i < N; i++) {
        int x_i;
        cin >> x_i;

        if (abs(x_i - 0) < abs(x_i - K)) {
            // A を使う
            distance += abs(x_i - 0);
        } else {
            distance += abs(x_i - K);
        }
    }
    cout << distance * 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+b-c-d<0){
    puts("Right");
  }else if(a+b-c-d==0){
    puts("Balanced");
  }else{
    puts("Left");
  }
  return 0;
}

Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a = list(map(int, input().split()))
x = list(map(lambda x: int(x)-a, input().split()))
size = max(1, sum(abs(item) for item in x))
# 0: 
dp = [[0]*(2*size+1) for _ in range(n+1)]
dp[0][size+1] = 1
for i in range(1,n+1):
    xx = x[i-1]
    for j in range(2*size+1):
        dp[i][j] = dp[i-1][j]
        if 0<=j-xx<2*size+1:
            dp[i][j] += dp[i-1][j-xx]
print(dp[n][size+1]-1)

Measured memory_bytes: 69416
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  cout << 800 * n - 200 * (n / 15) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin >>H>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >>A[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  if(H<=sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

int n;
char s[maxm];
int a[maxm];

int calc()
{
    int res = 0;
    for(int i = 1; i <= n; i++) if(((n - 1) & (i - 1)) == (i - 1))
        res ^= a[i];
    return res;
}

void work()
{
    cin >>n;
    cin >>(s + 1);
    for(int i = 1; i <= n; i++) a[i] = s[i] - '1';

    int cnt[3] = {0};
    for(int i = 1; i <= n; i++) cnt[a[i]]++;

    int tmp = 1;
    if(cnt[1] == 0)
    {
        tmp = 2;
        for(int i = 1; i <= n; i++) a[i] = !!a[i];
    }
    else
    {
        for(int i = 1; i <= n; i++) a[i] = (a[i] & 1) ^ 1;
    }

//    for(int i = 1; i <= n; i++) cout <<a[i]; cout <<endl;

    cout <<calc() * tmp <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

int main(int argc, char *argv[]){
  long long W,H,x,y;
  cin>>W>>H>>x>>y;
  double ans=(W*H)/2.0;
  if(2*x==W&&2*y==H){
    cout<<fixed<<setprecision(10)<<ans<<" "<<1<<endl;
  }
  else{
    cout<<fixed<<setprecision(10)<<ans<<" "<<0<<endl;
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int N;
vector<pair<double,pair<double,double> > >datas;
pair<double,double> rui[200];
double calc(int lef,int rig){//添字lef~rigのベクトルの和
	double sumx,sumy;
	if(lef>rig){
		sumx=rui[rig+1].first+rui[N].first-rui[lef].first;
		sumy=rui[rig+1].second+rui[N].second-rui[lef].second;
	}else{
		sumx=rui[rig+1].first-rui[lef].first;
		sumy=rui[rig+1].second-rui[lef].second;
	}
	//cout<<lef<<" "<<rig<<" "<<sumx<<" "<<sumy<<" "<<sqrt(sumx*sumx+sumy*sumy)<<endl;
	return sqrt(sumx*sumx+sumy*sumy);
}
int main(){
	cin>>N;
	double nowx=0.0,nowy=0.0;
	rui[0]=mp(nowx,nowy);
	rep(i,N){
			
			double x,y;
			cin>>x>>y;
			double theta=atan2(y,x);
			//if(y<0)theta+=acos(-1.0);
			
			datas.pb(mp(theta,mp(x,y)));
			
	}
	sort(all(datas));
	rep(i,N){
		//cout<<datas[i].first<<" "<<datas[i].second.first<<" "<<datas[i].second.second<<endl;
		nowx+=datas[i].second.first;
		nowy+=datas[i].second.second;
		//cout<<nowx<<" "<<nowy<<endl;
		rui[i+1]=mp(nowx,nowy);

	}
	double ans=0.0;
	rep(lef,N)rep(rig,N){
		//計算
		//if(ans<calc(lef,rig))cout<<lef<<" "<<rig<<endl;
		ans=max(calc(lef,rig),ans);
	}
	printf("%.15lf\n",ans);
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N, t, x, y, i, flg=0;

    scanf("%d", &N);

    for(i=0; i<N; i++){
        scanf("%d %d %d", &t, &x, &y);
        if((t < x+y) || (t % 2 != (x+y) % 2))
            flg = 1;
    }

    if(flg == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
words = lambda t : list(map(t, input().split()))
n = int(input())
s = input()

zo = []
zcnt = 0
ocnt = 0
for c in s:
    if c == "#":
        zo.append(1) #black
        ocnt += 1
    else:
        zo.append(0) #white
        zcnt += 1

#print(zcnt,ocnt)
minans = min(ocnt,zcnt)
zcnttill = 0
ocnttill = 0
for i in range(0,n):
    if zo[i] == 0:
        zcnttill += 1
    else:
        ocnttill += 1
    minans = min(minans, ocnttill + (zcnt - zcnttill))

print(minans)


Measured memory_bytes: 5096
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll A;
	double B;

	scanf("%lld %lf",&A,&B);
	ll b = B*100+0.5;

	A *= b;
	A /= 100;

	printf("%lld\n",A);

	return 0;
}


Measured memory_bytes: 3820
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

string f(lint N) {
	vector<char>al(26);
	al = {'z','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' };
	string ans;
	while (1) {
		if (N == 0) {
			reverse(ans);
			return ans;
		}
		ans.push_back(al[N % 26]);
		N =(N-1)/26;
	}
}

int main() {
	lint N;
	cin >> N;
	cout << f(N) << endl;
}

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

def is_prime(n):
  if n == 1:
    return False
  for i in range(2,int(n**0.5)+1):
    if n % i == 0:
      return False
  return True

p = []
for i in range(2, 55555+1):
  if is_prime(i) and i % 5 == 1:
    p.append(i)

print(*p[:N])

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	string s, t;
	int a, b, c;
	cin >> s >> t;
	cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << endl;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        xyp: [(isize, isize, usize); n],
    }
    let mut cost = vec![INF; n + 1];
    let m = 2usize.pow(n as u32);
    let mut ch = vec![vec![INF; m]; n];
    let mut cv = vec![vec![INF; m]; n];
    for i in 0..n {
        for x in 0..m {
            ch[i][x] = xyp[i].0.abs() as usize;
            cv[i][x] = xyp[i].1.abs() as usize;
            for j in 0..n {
                if x & 1 << j > 0 {
                    ch[i][x] = min(ch[i][x], (xyp[i].0 - xyp[j].0).abs() as usize);
                    cv[i][x] = min(cv[i][x], (xyp[i].1 - xyp[j].1).abs() as usize);
                }
            }
            ch[i][x] *= xyp[i].2;
            cv[i][x] *= xyp[i].2;
        }
    }
    for x in 0..3usize.pow(n as u32) {
        let mut c = 0;
        let mut y = x;
        let mut zh = 0;
        let mut zv = 0;
        for i in 0..n {
            if y % 3 == 0 {
                c += 1;
                zh |= 1 << i;
            } else if y % 3 == 1 {
                c += 1;
                zv |= 1 << i;
            }
            y /= 3;
        }
        let mut s = 0;
        for i in 0..n {
            s += min(ch[i][zh], cv[i][zv]);
        }
        cost[c] = min(cost[c], s);
    }
    for i in 0..=n {
        println!("{}", cost[i]);
    }
}


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

int main() {
    int A, B;
    char op;
    cin >> A >> op >> B;
    int ans = 0;
    if(op == '+') {
        ans = A + B;
    }
    if(op == '-') {
        ans = A - B;
    }
    cout << ans << endl; 
}

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

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

#define N 10
int C[N][N];

const int INF = 1<<30;


int main(){
    int h, w;
    cin >> h >> w;
    rep(i, N) rep(j, N) cin >> C[i][j];
    vector<vector<int>> A(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> A[i][j];

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
            }
        }
    }
    
    // 
    ll ans = 0;
    rep(i,h) rep(j,w){
        if (A[i][j] == -1) continue;
        ans += C[ A[i][j] ][1];
    }
    cout << ans << endl;
}



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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A + B <= 2 * C) {
        int cost = A * X + B * Y;
        cout << cost << endl;
    }
    else {
        if (X <= Y) {
            int numAB = 2 * X;
            int cost1 = C * numAB + B * (Y - X); 
            numAB = 2 * Y;
            int cost2 = C * numAB;
            int cost = min(cost1, cost2);
            cout << cost << endl;
        }
        else {
            int numAB = 2 * Y;
            int cost1 = C * numAB + A * (X - Y); 
            numAB = 2 * X;
            int cost2 = C * numAB;
            int cost = min(cost1, cost2);
            cout << cost << endl;
        }
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        mp[a]++;
    }

    int r = 0;
    for (auto& p : mp) {
        r += p.second < p.first ? p.second : p.second - p.first;
    }

    cout << r << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

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

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int A, B, C;
  int K;

  cin >> A >> B >> C >> K;

  // main procedure
  int double_count = 0;
  while(B <= A) {
    B *= 2;
    double_count++;
  }

  while(C <= B) {
    C *= 2;
    double_count++;
  }
  // output
  cout << ((double_count <= K) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3644
n,m=map(int,input().split())
h=list(map(int,input().split()))
A=[[] for i in range(n)]
for i in range(m) :
    a,b=map(int,input().split())
    A[a-1].append(h[b-1])
    A[b-1].append(h[a-1])

count=0
for i in range(n) :
    if A[i]==[] :
        count+=1
    elif max(A[i])<h[i] :
        count+=1
    else :
        continue

print(count)    



Measured memory_bytes: 22984
using System;
using System.Linq;

    class Program
    {
        static int Gcd(int a,int b)
        {
            if (a < b)
            {
                var t = a;
                a = b;
                b = t;
            }
            if (b == 0) return a;
            return Gcd(b, a % b);
        }

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var inArr = new int[N + 2];
            var pref = new int[N + 2];
            var suf = new int[N + 2];

            var inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            for (var i = 1;i<=N;i++)
            {
                inArr[i]= inputs[i-1];
                pref[i]= Gcd(pref[i - 1], inArr[i]);
            }

            for (var i = N; i >= 1; i--)
            {
                suf[i] = Gcd(suf[i + 1], inArr[i]);
            }
            var max = 0;
            for (var i = 1; i <=N; i++)
            {
                max = Math.Max(max, Gcd(pref[i - 1], suf[i + 1]));
            }
            Console.WriteLine(max);
        }
    }

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


void solve(int N, vi& _a) {
    vi a(N); rep(i,N) a[i] = _a[i];
    ll sum = 0, f = 1;
    rep(i,N-1) {
        sum += f * a[i];
        f = -f;
    }
    vll b(N);
    b[0] = sum + a[N-1];
    for (int i=1; i<N; ++i) {
        b[i] = a[i-1]*2 - b[i-1];
    }
    rep(i,N){
        printf("%lld%c", b[i], (i==N-1)?'\n':' ');
    }
}

int main() {
    vi a;
    int N = loadvec(a);
    solve(N,a);
    return 0;
}


Measured memory_bytes: 3968
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

long long N;
long long K;
const long long N_MAX = 100001;
long long x[N_MAX];
long long idx;
long long ans = 1000000000001;
long long tmp1, tmp2, tmp;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < N - K + 1; i++) {
		tmp1 = abs(x[i]) + abs(x[i + K - 1] - x[i]);
		tmp2 = abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]);
		tmp = min(tmp1, tmp2);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

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

int main() {
	int n, k, i, j, b;
	long double p = 0.0;
	cin >> n >> k;
	for (i = 1; i <= n; i++) {
		b = i;
		for (j = 0; b < k; j++)
			b *= 2;
		p += ((long double)1 / (long double)n) * ((long double)1 / (long double)pow(2, j));
	}
	cout << setprecision(10) << p;
	return 0;
}

Measured memory_bytes: 256
data = Array.new(6,0)
gets.to_i.times do
  height = gets.to_f
  index = ((height-160)/5).to_i
  if index <= 0
    data[0] += 1
  elsif 5 <= index
    data[5] += 1
  else
    data[index] += 1
  end
end
data.each_with_index{ |d,i| puts "#{i+1}:"+"*"*d }

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 100005;

int a[N], b[N];

signed main()
{
	IO_OP;
	
	int n, m, v, p;
	cin >> n >> m >> v >> p;
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a, a+n);
	for(int i=0;i<n;i++)
		b[i] = a[i] + (i ? b[i-1] : 0);	
	int ans = 0, k = 0;
	for(int i=0;i<n;i++) {
		int j = i;
		while(i < n && a[i] == a[j]) i++;
		int cnt = i - j;
		i--;
		int x = a[i] + m;
		while(k < n && a[k] <= x) k++;
		if(n-k > p-1) continue;
		int buf = p-1 - (n-k);
		if(n-k >= v) {
			ans += cnt;
			continue;
		}
		int cv = v - (n - k) - buf - i - 1;
		if(cv <= 0) {
			ans += cnt;
			continue;
		}
		int l = i + 1, r = k - 1 - buf;
		if(r < l) continue;
		if((r - l + 1) * x >= cv * m + b[r] - (l ? b[l-1] : 0))
			ans += cnt;
	}
	cout << ans << endl;
}





Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
char c[100005];
vector <int> vec;

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%s",c+1);
	int n;
	n=strlen(c+1);
	if(c[n]=='1' || c[n-1]=='0') over("-1\n");
	if(c[1]=='0') over("-1\n");
	for(int i=1;i<=n-1;i++)
	{
		if(c[i]!=c[n-i]) over("-1\n");
	}
	for(int i=1;i<=n;i++)
	{
//		cout<<c[i]<<endl;
//		if(c[i]==1) cout<<i<<endl;
		if(c[i]=='1') vec.push_back(i);
	}
	for(int i=1;i<vec.size();i++)
	{
		printf("%d %d\n",vec[i-1],vec[i]);
		for(int j=vec[i-1]+1;j<vec[i];j++)
		{
			printf("%d %d\n",vec[i],j);
		}
	}
	for(int i=vec[vec.size()-1]+1;i<=n;i++)
	{
		printf("%d %d\n",vec[vec.size()-1],i);
	}
	return 0;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if (A == B && B != C) {
    COUT("Yes");
    return 0;
  }
  if (B == C && B != A) {
    COUT("Yes");
    return 0;
  }
  if (A == C && B != C) {
    COUT("Yes");
    return 0;
  }
  COUT("No");

  return 0;
}

Measured memory_bytes: 256
import sys
S = list(input())
Ans_list=['k','e','y','e','n','c','e']
Ans = 'NO'
for i in range(len(S)):
    for j in range(i,len(S),+1):
        
        if (S[:i:]+S[j::]) == Ans_list:
           Ans = 'YES'
           print(Ans)
           sys.exit()
print(Ans)


Measured memory_bytes: 3060