akhauriyash/Code-Regression huggingface dataset:
N = int(input())
X = list(map(int,input().split()))

dp = [0,abs(X[1] - X[0])]
for x in range(2,N):
  dp.append(min(dp[x-1] + abs(X[x-1]-X[x]),
                dp[x-2] + abs(X[x-2]-X[x])
               )
           )
print(dp[N-1])

Measured memory_bytes: 13928
import itertools
import math


def main():
  n = int(input())
  
  count_753 = 0
  max_digits = int(math.log10(n)) + 2
  cand_753 = ("3", "5", "7")
  
  for digits in range(3, max_digits):
    for dig_753 in itertools.product(cand_753, repeat=digits):
      number_str = "".join(dig_753)
      
      if "7" in number_str and "5" in number_str and "3" in number_str and int(number_str) <= n:
        count_753 += 1
  
  print(count_753)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void nosol () {
  writeln (":(");
}

void main() {
  int n;
  readf (" %d", &n);
  //n = floor (x * 1.08)
  foreach (x; 1 .. n + 1) {
    if ( (x * 108) / 100 == n) {
      writeln (x);
      return;
    }
  }
  nosol ();
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
using namespace std;

int main(){
    int n, i;
    int a;
    string m;
    cin >> n;
    vector<int> S(13, 0);  
    vector<int> H(13, 0);  
    vector<int> C(13, 0);  
    vector<int> D(13, 0);  
    rep(i,n){
        cin >> m >> a;
        if(!m.compare("S")) S[a-1] = 1;
        if(!m.compare("H")) H[a-1] = 1;
        if(!m.compare("C")) C[a-1] = 1;
        if(!m.compare("D")) D[a-1] = 1;
    }
    rep(i,13)if(S[i]==0)cout << "S " << i+1 << endl;
    rep(i,13)if(H[i]==0)cout << "H " << i+1 << endl;
    rep(i,13)if(C[i]==0)cout << "C " << i+1 << endl;
    rep(i,13)if(D[i]==0)cout << "D " << i+1 << endl;
    return 0;
}


Measured memory_bytes: 3156
n = int(input())
p = list(map(int, input().split()))

def get_de(p):
    d, e = [n for i in range(n)], [n for i in range(n)]
    stack1 = []
    stack2 = []
    for i in range(n):
        while stack2 and p[stack2[-1]] < p[i]:
            idx = stack2.pop()
            e[idx] = i

        to_append = []
        while stack1 and p[stack1[-1]] < p[i]:
            idx = stack1.pop()
            d[idx] = i
            to_append.append(idx)

        while to_append:
            stack2.append(to_append.pop())
        stack1.append(i)

    dist1, dist2 = [], []
    for i in range(n):
        dist1.append(d[i] - i)
        dist2.append(e[i] - d[i])
    return dist1, dist2

dist1, dist2 = get_de(p)

dist3, dist4 = get_de(p[::-1])
dist3, dist4 = dist3[::-1], dist4[::-1]

ans = 0
for i in range(n):
    ans += (dist1[i] * dist4[i] + dist2[i] * dist3[i]) * p[i]
print(ans)


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

int main() {
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	
	while (k>0 && b<=a) {
		b *=2;
		k--;
	}

	while (k>0 && c<=b) {
		c *=2;
		k--;
	}

	if (a<b && b<c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k,a,b;
    int ans=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            ans=1;
            break;
        }
    }
    if(ans==1)
        cout<<"OK";
    else
        cout<<"NG";





}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[5005];
bool pref[5005][5005], suff[5005][5005];
// int sum[5005][5005];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    int res = 0;
    for(int i=1;i<=n;i++) scanf("%d", &a[i]), res = min(res+a[i], k);

    pref[0][0] = 1;
    suff[n+1][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(pref[i-1][j]){
                pref[i][min(k, j+a[i])] = 1;
                pref[i][j] = 1;
            }
        }
    }
    for(int i=n;i>=1;i--){
        for(int j=0;j<=k;j++){
            if(suff[i+1][j]){
                suff[i][min(k, j+a[i])] = 1;
                suff[i][j] = 1;
            }
        }
    }

    int ans = 0;
    for(int i=1;i<=n;i++){
        bool ok = 1;

        int sum = 0;
        int ll = k, rr = k-1;
        for(int j=k-1;j>=0;j--){
            if(pref[i-1][j]){
                if(j+a[i] >= k){
                    ok = 0;
                    break;
                }
                int l = k-(j+a[i]);
                int r = k-j-1;

                while(ll > l){
                    ll--;
                    if(suff[i+1][ll]) sum++;
                } 
                while(rr > r){
                    if(suff[i+1][rr]) sum--;
                    rr--;
                }
                if(sum > 0) ok = 0;
                // if(l <= r && sum[i+1][r] - sum[i+1][l-1] > 0) ok = 0;
            }
        }
        for(int j=max(0, k-a[i]);j<=k-1;j++){
            if(pref[i-1][j]) ok = 0;
            if(suff[i+1][j]) ok = 0;
        }
        ans += ok;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 49152
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    auto cells = H * W;
    cells -= w * H;
    cells -= h * W;
    cells += w * h;

    cout << cells << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int fC=0;
		int oC=0,eC=0;
		int t=N;
		while (t-- > 0) {
			int n=sc.nextInt();
			if(n%4==0)
				fC++;
			else if(n%2==0)
				eC++;
			 else 
				 oC++;
		}
		if(eC>0)oC++;
		if(oC-1<=fC||oC==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 48176
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll dp[s.size()+1][13];
    rep(i,s.size()+1)rep(j,13)dp[i][j]=0;
    dp[0][0] = 1;
    rep(i, s.size())
    {
        rep(j, 13)
        {
            if (s[i] == '?')
            {
                rep(k, 10)
                {
                    ll g=(j*10 + k)%13;
                    dp[i + 1][g] += dp[i][j];
                    if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
                }
            }
            else
            {
                ll g=(j * 10 + (s[i] - '0'))%13;
                dp[i + 1][g] += dp[i][j];
                if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 10688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

///////////// 

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,w;
	cin>>n>>w;
	int dp[w+1]={};
	for(int i=0;i<n;++i)
	{
		int v,h;
		cin>>v>>h;
		for(int j=w;j>=0;--j)
		{
			if(j>=v)
			{
				dp[j]=max(dp[j],dp[j-v]+h);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=w;++i)
		ans=max(ans,dp[i]);
	cout<<ans;;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10000000)


def main():
    A, B, C, D = map(int, input().split())
    while(True):
        C = C - B
        if C <= 0:
            print('Yes')
            break
        A = A - D
        if A <= 0:
            print('No')
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define EPS (1e-15)
using namespace std;

int K,R,L;
double P,E,T,ans;

void func(int k,double l,double r,double p){
  double h=(l+r)/2;
  if(l-(T+E)>EPS||T-E-r>EPS)return;
  else if(l-(T-E)>=EPS&&T+E-r>=EPS){
    ans+=p;
    return;
  }
  if(k==K){
    if(E-abs(h-T)>=EPS)ans+=p;
    return;
  }
  if(T<=h){
    func(k+1,l,h,p*(1-P));
    func(k+1,h,r,p*P);
  }else{
    func(k+1,l,h,p*P);
    func(k+1,h,r,p*(1-P));
  }
}

int main(){
  cin>>K>>R>>L>>P>>E>>T;
  func(0,R,L,1);
  printf("%.15f\n",ans);
  return 0;
}

Measured memory_bytes: 1252
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
  N = 50
  K = int(raw_input())
  A = [N - 1 + (K / N)] * N
  K %= N
  for i in xrange(K):
    for j in xrange(N):
      A[j] -= 1
    A[i] += N + 1
  print N
  print ' '.join(map(str, A))

main()

Measured memory_bytes: 28652
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,k,a[N],b[N];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=k;i++)
    {
        bool flag=true;
        memset(b,0,sizeof(b));
        for(int j=1;j<=n;j++)
        {
            int l=max(1,j-a[j]),r=min(n,j+a[j]);
            b[l]++;b[r+1]--;
        }
        for(int j=1;j<=n;j++)
        {
            b[j]+=b[j-1];
            if(b[j]!=a[j]) a[j]=b[j],flag=false;
        }
        if(flag) break;
    }
    for(int i=1;i<=n;i++)
        printf(i==n?"%d\n":"%d ",a[i]);
}


Measured memory_bytes: 5372
//Handstand 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,k;string s;cin>>n>>k>>s;
    deque<char>a;
    int t=0,ans=0;
    bool l=true;
    rep(i,0,n){
        if(s[i]=='0'&&l){
            t++;
            l=false;
        }else if(s[i]=='1')l=true;;
        if(t>k){
            while(a.front()=='1')a.pop_front();
            while(a.front()=='0')a.pop_front();
            t--;
        }
        a.pb(s[i]);
        ans=max(ans,(int)a.size());
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3820
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
ad = Counter(a)
cnt = 0
i = list(ad.keys())
v = list(ad.values())
for x in range(0, len(i)):
    if int(i[x]) <= int(v[x]):
        cnt += int(v[x]) - int(i[x])
    else:
        cnt += int(v[x])
print(cnt)

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

int main(void){
	
	std::string s; 

	std::cin >> s;

	std::cout << 700 + 100 * std::count(s.begin(), s.end(), 'o') << std::endl;


	return 0;
}

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


Measured memory_bytes: 2736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  int P[N];
  for (int i = 0;i < N;i++) {
    cin >> P[i];
  }

  int counter = 0;
  int min = N + 1;
  for (int i = 0;i < N;i++) {
    if (min > P[i]) {
      min = P[i];
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
ll ans;
int n,m;
vector<P> w;
set<int> e;
int main() {
  cin >> n >> m;

  for(int i = 0; i < n; i++) {
    int a,b;
    cin >> a >> b;
    w.push_back(P(b,a));
  }
  for(int i = 1; i <= m; i++) e.insert(i);

  sort(w.begin(),w.end(),greater<P>());

  for(int i = 0; i < n; i++) {
    int tmp = w[i].second;
    auto itr = e.lower_bound(tmp);
    if(itr != e.end()) {
      ans += w[i].first;
      e.erase(itr);
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 5748
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;



int main() {
	std::string s;
	lint k;
	cin >> s >> k;


	//const char char_set[] = "ab";
	// while (true) {

		//int length = rand() % 4 + 1;
		//s = "";
		//for (int i = 0; i < length; i++) {
		//	s += char_set[rand() % 2];
		//}

		//k = rand() % 2 + 1;

		
		lint count = 0;

		lint lCount = 1;
		int li;
		for (li = 1; li < s.length(); li++) {
			if (s[li - 1] == s[li])
				lCount++;
			else
				break;
		}

		lint loopCount = lCount;

		if (loopCount == s.length()) {
			count = (loopCount * k) / 2;
		}
		else {
			lint rCount = 1;
			int ri;
			for (ri = s.length() - 2; ri >= li; ri--) {
				if (s[ri] == s[ri + 1])
					rCount++;
				else
					break;
			}

			if (s[0] == s[s.length() - 1]) {
				count += lCount / 2;
				count += rCount / 2;
				loopCount += rCount;
				count += (loopCount / 2) * (k - 1);
			}
			else {
				count += (int)(lCount / 2) * k;
				count += (int)(rCount / 2) * k;
			}

			lint midCount = 0;
			for (int i = li; i <= ri; i++) {
				if (s[i - 1] == s[i]) {
					i++;
					midCount++;
				}
			}

			count += midCount * k;
		}


		//// Test Code
		//string allText;
		//for (int i = 0; i < k; i++)
		//	allText += s;

		//lint testCount = 0;
		//for (int i = 1; i < length * k; i++) {
		//	if (allText[i] == allText[i - 1]) {
		//		i++;
		//		testCount++;
		//	}
		//}

		//if (count != testCount) {
		//	cout << s << endl;
		//	cout << k << endl;
		//}
	//}
		cout << count;

	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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  int x;cin>>x;
  int ans=1;
  for(int i=2;i<x;i++){
    int a=i*i;
    //べき乗は2乗以上
    while(a<=x){
      ans=max(ans,a);
      a*=i;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    for(int a=1;a<=3500;a++)
    {
        for(int b=1;b<=3500;b++)
            if(4*a*b-n*a-n*b > 0)
                if((n*a*b)%(4*a*b-n*a-n*b) == 0)
                {
                    rc(a << " "<< b << " "<<n*a*b/(4*a*b-n*a-n*b));
                }
    }
}

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

int main() {
  int n,m,x;cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n){
    cin>>c[i];
    rep(j,m)cin>>a[i][j];
  }
  int ans=1e9;
  bool ok1=false;
  rep(bit,1<<n){
    bool ok=true;
    int cnt=0;
    vector<int> vec(m);
    rep(i,n){
    if(bit&(1<<i)){
      cnt+=c[i];
      rep(j,m){
        vec[j]+=a[i][j];
      }
    }
    }
    rep(i,m){
      if(vec[i]<x)ok=false;
    }
    if(ok){
      ans=min(ans,cnt);
      ok1=true;
    }
  }
  if(ok1)cout<<ans<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> v;

int Pow(int a, int b){
    ll res = 1;
    while(b){
        if(b % 2) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

int ans = INT_MAX;
map<int, int> mp;
void rec(int money = N, int cnt = 0){
    if(money == 0){
        ans = min(ans, cnt);
        return;
    }
    if(mp.find(money) != mp.end() && mp[money] <= cnt) return;
    if(ans <= cnt) return;
    mp[money] = cnt;
    for(auto m : v) if(money - m >= 0) rec(money - m, cnt + 1);
    return;
}

int main(void){
    
    scanf("%d", &N);
    v.push_back(1);
    int n;
    for(int i = 1; (n = Pow(6, i)) <= N; ++i) v.push_back(n);
    for(int i = 1; (n = Pow(9, i)) <= N; ++i) v.push_back(n);
    sort(v.begin(), v.end(), greater<int>());
    
    rec();
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    string n;
    cin >> n;
    
    if (n[1]==n[2]) {
        if (n[1]==n[0] || n[1]==n[3]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int i, n, half, db_half;
  int flg = 1;
  char s[100];
  scanf("%s", s);
  
  n = strlen(s);
  half = n / 2;
  
  //回文判定
  for(i = 0; i < half; i++) {
    if (strncmp(&s[i], &s[n - (i+1)], 1) != 0) {
      flg = 0;
  	  break;
    }
  }

  //前半回文判定
  db_half = half / 2; // 1
  for(i = 0; i < db_half; i++) {
    if (strncmp(&s[i], &s[((n-1)/2) - (i+1)], 1) != 0) {
      flg = 0;
  	  break;
    }
  }
  
  //後半回文判定
  for(i = 0; i < db_half; i++) {
    if (strncmp(&s[(n+3)/2 -1 + i], &s[n - (i+1)], 1) != 0) {
      flg = 0;
  	  break;
    }
  }
  

  if (flg == 1)
    printf("Yes");
  else if (flg == 0)
    printf("No");
  
  return(0);
}

Measured memory_bytes: 1724
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s=s()
w = k()
a = []
for i in range(0,len(s),w):
    a.append(s[i])
print("".join(a))


Measured memory_bytes: 10104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long min_diff = a[1] - a[0];
  for (i = 1; i < n - 2; i++) {
    min_diff = min(min_diff, a[i] - a[i - 1]);
  }
  long double result = ((long double)(a[n - 1] + a[n - 2])) / ((long double)(min_diff));
  result = max(result, ((long double)(a[n - 3] + a[n - 4])) / ((long double)(a[n - 1] - a[n - 2])));
  cout << setprecision(12) << result << endl;
  return 0;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;cin >> a >>b >> c >> d;ll t=0;
    while(1)
    {
        if(t==0)
        {
            c-=b;
        }
        else
        {
            a-=d;
        }
        if(a<=0)
        {
            cout << "No";return 0;
        }
        else if(c<=0)
        {
            cout << "Yes";return 0;
        }
        t=!t;
    }
    }

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
using namespace std;
using VI = vector<long>;

class RangeCount {
    const int ST_SIZE = (1 << 20) - 1;
    int n;
    VI data;
    vector<VI> segtree;

    void init(int k, int l, int r) {
        if (r - l == 1) {
            segtree[k].push_back(data[l]);
        } else {
            int lch = k * 2 + 1;
            int rch = k * 2 + 2;
            init(lch, l, (l + r) / 2);
            init(rch, (l + r) / 2, r);
            segtree[k].resize(r - l);

            merge(segtree[lch].begin(), segtree[lch].end(), segtree[rch].begin(), segtree[rch].end(), segtree[k].begin());
        }
    }

    // number of x in [i, j)
    int query(int i, int j, long x, int k, int l, int r) {
        if (j <= l || r <= i) {
            return 0;
        }

        if (i <= l && r <= j) {
            return upper_bound(segtree[k].begin(), segtree[k].end(), x) - segtree[k].begin();
        }

        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }

public:
    RangeCount(VI v) {
        n = v.size();
        data = VI(v);
        segtree = vector<VI>(ST_SIZE);
        init(0, 0, n);
    }

    int exact(int i, int j, long x) {
        return query(i, j, x, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }

    int le(int i, int j, long x) {
        return query(i, j, x, 0, 0, n);
    }

    int lt(int i, int j, long x) {
        return query(i, j, x - 1, 0, 0, n);
    }

    int ge(int i, int j, long x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }

    int gt(int i, int j, long x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x, 0, 0, n);
    }
};

int main() {
  long n, m;
  cin >> n >> m;
  VI mod(n + 1);
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    mod[i + 1] = (mod[i] + a) % m;
  }
  RangeCount cnt(mod);

  long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    ans += cnt.exact(i, n + 1, mod[i]) - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 44544
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10&&i%10000/1000==i%100/10) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define input(n)  ll n; cin >> n
#define DEBUG 0

string solve()
{
    input(H);
    input(W);
    input(N);
    vector<vector<ll>> ans(H, vector<ll>(W));
    ll s = 0;
    for1(i,N) {
        ll a;
        cin >> a;
        for1(j,a) {
            ll h = s / W;
            ll w = s % W;
            if (h % 2 != 0) {
                w = W - w - 1;
            }
            ans[h][w] = i + 1;
            ++s;
        }
    }
    for1(h,H) {
        for1(w,W) {
            if (w != 0) {
                cout << " ";
            }
            cout << ans[h][w];
        }
        cout << endl;
    }

    return "";
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int h,w; cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				cout<<'#';
			}
			cout<<"\n"s;
		}
		cout<<"\n"s;
	}
}


Measured memory_bytes: 3184
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, D, X;
	cin >> N >> D >> X;

	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	int ret = X;
	for(int i=0; i<N; i++){
		for(int j=0; j<D; j+=A[i]){
			ret++;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
n,k=[int(x) for x in input().split()]
s=input()
diff=[0]
for i in range(1,len(s)):
    if s[i]!=s[i-1]:
        diff.append(i)
diff.append(n)
ans=0
for i in range(len(diff)-1):
    if s[diff[i]]=="0":
        if len(diff)-1<2*k+i:
            ans=max(diff[-1]-diff[i],ans)
        else:
            ans=max(diff[2*k+i]-diff[i],ans)
    else:
        if len(diff)-1<2*k+1+i:
            ans=max(diff[-1]-diff[i],ans)
        else:
            ans=max(diff[2*k+1+i]-diff[i],ans)
print(ans)

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

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

  int n, k, q;
  cin >> n >> k >> q;

  vector<int> a(q);
  for (int i = 0; i < q; i++) {
    cin >> a.at(i);
  }

  vector<int> p(n, 0);

  for (size_t i = 0; i < q; i++) {
    int who = a.at(i) - 1;
    p.at(who) += 1;
  }

  for (int i = 0; i < n; i++) {
    p.at(i) = k - (q - p.at(i));
  }

  for (int i = 0; i < n; i++) {
    if (p.at(i) <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1408
fun grundy(nInput: Int, k: Int): Int {
  var n = nInput
  while (true) {
    if (n < k) return 0
    if (n % k == 0) return n / k
    val b = n / k * k
    val c = (n / k) + 1
    n -= Math.max((n - b) / c, 1) * c
  }
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val grundyXor = Array(n, {
    val (a, k) = readLine()!!.split(" ").map(String::toInt)
    grundy(a, k) })
      .reduce(Int::xor)
  println(if (grundyXor == 0) "Aoki" else "Takahashi")
}


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

int main(){
    string s;
    cin >> s;
    set<char> cc;
    int len = s.size();
    bool Yes = true;
    for(int i=0;i<len;i++){
        if(cc.find(s[i]) != cc.end()){
            Yes = false;
            break;
        }else{
            cc.insert(s[i]);
        }
    }
    if(Yes)cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
 
using namespace std;
 
long long ans(vector<long long> v, int b){
  long long sum = 0;
  for(int i = 0; i < v.size(); i++){
    sum += abs(v[i] - b);
  }
  return sum;
}
 
int main(){
  int b;
  vector<long long> v;
  long long a, t, n;
  
  cin >> n;
  for(int i = 0; i < n; i++){ cin >> t; v.push_back(t - i - 1); }
  sort(v.begin(), v.end());
  b = v[n / 2];
  a = ans(v, b);
  cout << a << endl;
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
#define REP(N) for(int i = 0; i < N; i++)
using namespace std;
const int INF = 1e9 + 7;

class State{
  public:
    int step, node, kenkenpa;
    State(int s, int n, int k) { step = s; node = n; kenkenpa = k; }
    bool operator > (const State& s) const { return step > s.step; }
};

int dijkstra(int N, int S, int T, vector< vector<int> >& graph){
  vector< vector<int> > dist(N, vector<int>(3, INF));
  dist[S][0] = 0;
  priority_queue< State, vector<State>, greater<State> > q;
  q.push(State(0, S, 0));
  while(!q.empty()){
    State s = q.top(); q.pop();
    if(dist[s.node][s.kenkenpa] < s.step) continue;
    for(int next : graph[s.node]) {
      int next_kenkenpa = s.kenkenpa == 2 ? 0 : s.kenkenpa + 1;
      if(s.step + 1 >= dist[next][next_kenkenpa]) continue;
      dist[next][next_kenkenpa] = s.step + 1;
      q.push(State(s.step + 1, next, next_kenkenpa));
    }
  }
  return dist[T][0] == INF ? -1 : dist[T][0] / 3;
}

int main(){
  int N, M; cin >>N >>M;
  vector< vector<int> > graph(N, vector<int>());
  REP(M){
    int a, b; cin >>a >>b;
    graph[a - 1].push_back(b - 1);
  }
  int S, T; cin >>S >>T;
  cout <<dijkstra(N, S - 1, T - 1, graph) <<endl;
  return 0;
}


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

int main()
{
    int n, x, t, res = 0;

    cin >> n >> x >> t;

    while (n > 0)
    {
        n = n - x;
        res++;
    }

    cout << res * t << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define DEBUG 0;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){

#ifdef DEBUG
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());
#endif

    int A,B;
    cin >> A >> B;
    int res = 0;

	int kuti = 1;

	while(true)
	{
		if(kuti >= B)
		{
			break;
		}
		kuti += A-1;
		++res;

	}
    cout << res << endl;
	
	return 0;
}



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

using namespace std;

//#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()

const int maxn = 3001;

int dp[maxn][maxn];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string a, b;
    cin >> a >> b;
    string ans;
    for (int i = 1; i <= sz(a); i++) {
        for (int j = 1; j <= sz(b); j++) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
//            cout << dp[i][j] << " ";
        }
//        cout << "\n";
    }
    int i = sz(a);
    int j = sz(b);
//    cout << dp[i][j] << "\n";
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j - 1] + 1 && a[i - 1] == b[j - 1]) {
            ans += a[i - 1];
            i--, j--;
        } else if (dp[i][j] == dp[i][j - 1]) {
            j--;
        } else {
            i--;
        }
    }
    reverse(all(ans));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35456
n = int(input())
c = [[],[],[]]
for x in range(n):
    a_,b_,c_ = [int(x) for x in input().split(" ")]
    c[0].append(a_)
    c[1].append(b_)
    c[2].append(c_)

dp = [0 for x in range(3)]
for i in range(n):
    newdp = [0 for x in range(3)]
    for x in range(3):
        for y in range(3):
            if x != y:
                newdp[y] = max(newdp[y], dp[x] + c[y][i])
    
    dp[0] = newdp[0]
    dp[1] = newdp[1]
    dp[2] = newdp[2]

print(max(dp))



Measured memory_bytes: 16668
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    vector<int> p(n);
    for(int i = 0; i < n; ++i){
      cin >> p[i];
    }
    p.push_back(0);
    vector<int> comb_p;
    for(int i = 0; i < n + 1; ++i){
      for(int j = 0; j < n + 1; ++j){
	if(p[i] + p[j] <= m){
	  comb_p.push_back(p[i] + p[j]);
	}
      }
    }
    sort(comb_p.begin(), comb_p.end());
    comb_p.erase(unique(comb_p.begin(), comb_p.end()), comb_p.end());
    int ans = 0;
    for(int i = 0; i < comb_p.size(); ++i){
      int opp = m - comb_p[i];
      int tmp = comb_p[i] + *(--upper_bound(comb_p.begin(), comb_p.end(), opp));
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
	int A, B, C, i;
	scanf("%d%d%d", &A, &B, &C);
	for(i = 1; i < 10000; i++){
		if((i * A) % B == C){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

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

class UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
public:
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n,a;
	cin>>n>>a;
	int x[100];
	rep(i,n)cin>>x[i];
	rep(i,n)x[i]-=a;
	int cnt=0;
	rep(i,n){
		if(x[i]==0)cnt++;
	}
	int ans=pow(2,cnt)-1;
	int dpp[3000]={},dpm[3000]={};
	dpp[0]=1;dpm[0]=1;
	rep(i,n){
		if(x[i]<0){
			int dpm2[3000]={};
			rep(j,3000){
				if(dpm[j]>0){
					dpm2[j]+=dpm[j];
					dpm2[j-x[i]]+=dpm[j];
				}
			}
			rep(j,3000)dpm[j]=dpm2[j];
		}
		if(x[i]>0){
			int dpp2[3000]={};
			rep(j,3000){
				if(dpp[j]>0){
					dpp2[j]+=dpp[j];
					dpp2[j+x[i]]+=dpp[j];
				}
			}
			rep(j,3000)dpp[j]=dpp2[j];
		}
	}
	int c=0;
	rep(i,1,3000){
		c+=dpp[i]*dpm[i];
	}
	debug(c);
	ans+=c*pow(2,cnt);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i,j,k,len;
	int flg,flg2;
	int cnt=0;
	char a[11];
	char b[21];
	char c[21];
	
	scanf("%s",a);
	len=strlen(a);
	scanf("%d",&n);
	for(k=0;k<n;k++){
		scanf("%s",b);
		for(i=0;i<10;i++){
			b[i+10]=b[i];
		}
		b[20]='\0';
		flg2=0;
		for(i=0;i<20;i++){
			flg=1;
			for(j=0;j<len;j++){
				if(i+j>20){
					flg=0;
					break;
				}
				if(a[j]!=b[i+j]){
					flg=0;
				}
			}
			if(flg==1){
				flg2=1;
			}
		}
		if(flg2==1){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}
	

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

		String S = sc.next();
		long K = sc.nextLong();
		long count = 0;
		char ans = '1';
		if( S.charAt(0)!='1' ){
			ans = S.charAt(0);
		}else{
			for( int i=0; i<S.length(); i++ ){
				if( S.charAt(i)=='1' ){
					count++;
				}else{
					if( count<K ){
						ans = S.charAt(i);
					}
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
  string n;
  cin >>n;
  if(n[0]=='9' || n[1]=='9') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
/**
*	created: 23.08.2020 11:37:07
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> v1, v2;
    rep(i,n) {
        int a; cin >> a;
        if (i % 2 == 0) v1.push_back(a);
        else v2.push_back(a);
    }
    map<int,int> m1, m2;
    rep(i,n/2) {
        m1[v1[i]]++;
        m2[v2[i]]++;
    }
    vector<P> mv1, mv2;
    for (auto p : m1) mv1.push_back(make_pair(p.second,p.first));
    for (auto p : m2) mv2.push_back(make_pair(p.second,p.first));
    sort(rall(mv1));
    sort(rall(mv2));
    if (mv1[0].second != mv2[0].second) cout << n - mv1[0].first - mv2[0].first << endl;
    else if (m1.size() > 1 && m2.size() > 1) {
        int m1 = n - mv1[1].first - mv2[0].first;
        int m2 = n - mv1[0].first - mv2[1].first;
        cout << min(m1,m2) << endl;
    }
    else if (m1.size() == 1 && m2.size() == 1) {
        cout << n/2 << endl;
    }
    else if (m1.size() == 1) {
        int m1 = n - mv2[1].first;
        int m2 = n/2 - mv2[0].first;
        cout << min(m1,m2) << endl;
    }
    else {
        int m1 = n - mv1[1].first;
        int m2 = n/2 - mv1[0].first;
        cout << min(m1,m2) << endl;
    }
    return 0;
}


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

int main(){

  cout << fixed << setprecision(12);
  
  double x1,x2,y1,y2;

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

  double xx = pow(x1-x2,2);
  double yy = pow(y1-y2,2);

  cout << sqrt(xx+yy) << endl;

  return 0;
}



Measured memory_bytes: 3192
#include <cstdio>
int ans = 0, h, w, k;

char ori_arr[6][6];
char arr[6][6];

int chk() {
	int cnt = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cnt += arr[i][j] == '#';
		}
	}
	return cnt == k;
}

int get_ans(int now) {
	if (now == h + w) return chk();
	int case1 = get_ans(now+1);
	int case2;
	int ori[6] = { 0 };
	if (now < h) {
		for (int i = 0; i < w; i++) {
			ori[i] = arr[now][i];
			arr[now][i] = '.';
		}
		case2 = get_ans(now + 1);
		for (int i = 0; i < w; i++) {
			arr[now][i] = ori[i];
		}
	}
	else {
		for (int i = 0; i < h; i++) {
			ori[i] = arr[i][now-h];
			arr[i][now - h] = '.';
		}
		case2 = get_ans(now + 1);
		for (int i = 0; i < h; i++) {
			arr[i][now - h] = ori[i];
		}
	}
	return case1 + case2;
}

int main() {
	scanf("%d %d %d", &h, &w, &k);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			scanf(" %c", &arr[i][j]);
		}
	}
	printf("%d", get_ans(0));
	return 0;
}

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


#define MAX 402

int n;
int c;

int a[MAX];
int b[MAX];

long long int x[MAX];

#define MOD 1000000007
long long int ppow(long long int i, long long int j){
	long long int res = 1LL;
	while (j){
		if ((j & 1LL)){
			res *= i;
			if (res >= MOD){
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD){
			i %= MOD;
		}
	}
	return res;
}

bool dp[MAX][MAX];
long long int sum[MAX][MAX];


long long int S[MAX][MAX];

long long int gt(int xx,int l, int r){
	long long int f = S[xx][r];
	f += MOD;
	if (l){
		f -= S[xx][l - 1];
	}
	f %= MOD;
	return f;
}
int main(){
	cin >> n >> c;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for (int j = 0; j < n; j++){
		scanf("%d", &b[j]);
	}
	for (int i = 0; i <= 400; i++){
		for (int j = 0; j <= 400; j++){
			if (i == 0){
				S[i][j] = 1;
			}
			else{
				S[i][j] = S[i-1][j]*(long long int)(j);
				if (S[i][j] >= MOD){
					S[i][j] %= MOD;
				}
			}
		}
	}
	for (int i = 0; i <= 400; i++){
		for (int j = 1; j <= 400; j++){
			S[i][j] += S[i][j - 1];
			if (S[i][j] >= MOD)S[i][j] %= MOD;
		}
	}
	for (int i = 0; i < n; i++){
		x[i] = a[i];
	}
	dp[0][0] = 1;
	sum[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= c; j++){
			int rest = c - j;
			if (dp[i][j]){
				for (int k = 0; k <= rest; k++){
					sum[i + 1][j+k] += (sum[i][j] * gt(k,a[i],b[i]))%MOD;
					dp[i + 1][j + k] = true;
					if (sum[i + 1][j + k] >= MOD){
						sum[i + 1][j + k] %= MOD;
					}
				}
			}
		}
	}
	printf("%lld\n", sum[n][c]);
	return 0;
}

Measured memory_bytes: 2944
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, n, d, q);
    vector<PII> a(n);
    VI c(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
        c[i] = a[i].first;
    }
    sort(ALL(c));
    c.resize(unique(ALL(c)) - c.begin());
    sort(ALL(a));
    VI b(n + 1);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        b[i + 1] += b[i];
        int h = max(0ll, a[i].second - b[i + 1] * q);
        int r = (h + q - 1) / q;
        ans += r;
        b[i + 1] += r;
        int x = a[i].first + 2 * d;
        auto j = upper_bound(ALL(c), x) - c.begin();
        if (j < n){
            b[j + 1] -= r;
        }
    }
    cout << ans;

    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int nex[201010][26] {};

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string S, T; cin >> S >> T;
    int A = S.size();

    // Sの部分列として各位置を取ったとき
    // その次にa～zをそれぞれ取る場合何文字先の文字が最寄であるか
    S += S;
    for(int j = 0; j < 26; ++j){
        nex[2 * A][j] = 2 * A;
    }
    for(int i = 2 * A - 1; i >= 0; i--) {
        for(int j = 0; j < 26; ++j){
            nex[i][j] = nex[i + 1][j];
        }
        nex[i][S[i]-'a'] = i + 1;
    }

    ll cur = 0;
    for(auto c : T) {
        c -= 'a';
        int x = cur % A;

        if(nex[x][c] == 2 * A){
            cout << "-1" << endl;
            return 0;
        }

        cur += nex[x][c] - x;
    }
    cout << cur << endl;
    return 0;
}



Measured memory_bytes: 21120
from math import ceil


def solve(rounds):
    mx, mn = 3, 2
    if rounds[-1] != 2:
        return (-1,)
    for r in reversed(rounds[:-1]):
        if mx < r:
            return (-1,)
        mn = ceil(mn / r) * r
        mx = mx // r * r + r - 1
    if mn > mx:
        return (-1,)
    return mn, mx


k = int(input())
rounds = list(map(int, input().split()))
print(*solve(rounds))


Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(void) {
    int n, a, b;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else if(n == 2){
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632