akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s,t; cin >> s >> t;
    int n = s.size();
    int m = t.size();

    int ans = INF;
    for(int i=0;i<(n-m+1);i++){
        int temp = 0;
        for(int j=0;j<m;j++){
            if(s[i+j]!=t[j]) temp++;
        }
        ans = min(ans, temp);
    }

    cout << ans << "\n";



    

}


Measured memory_bytes: 3656
#create date: 2020-04-26 08:03

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    h, w = na()
    g = ["#" * (w + 2)]
    for _ in range(h):
        g += ["#" + ns() + "#"]
    g += ["#" * (w + 2)]
    for gi in g:
        print(gi)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;


int main(){
    int N;
    int a;
    int b[100010];
    for (int i = 0; i < 100009; i++) {
		b[i] = 0;
	}

    cin >> N;    

    for(int i = 0; i < N; ++i){
        cin >> a;
        b[a]++;
        b[a + 1]++;
        b[a + 2]++;
    }

    sort(b, b+100010, greater<int>());
    cout << b[0] << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,n;
    cin>>h>>n;
    int sum = 0;
    for(int i=0;i<n;++i)
    {
        int a;
        cin>>a;
        sum+=a;
    }
    if(sum>=h) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main(){
	long int N,D;
	cin >>N>>D;
	long int x,y,count=0;
	rep(i,N){
		cin >>x>>y;
		if(x*x+y*y<=D*D)count++;
	}
	cout << count<<endl;
	return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

string s;
int n;
vector<char>ans;

void print()
{
	REP(i, n)
		cout << ans[i];
	cout << endl;
}

bool check(char f, char r)
{
	ans.clear();
	ans.resize(n);

	ans[0] = f; ans[1] = r;

	for (int i = 1; i < n - 1; i++)
	{
		if (s[i] == 'o')
		{
			if (ans[i] == 'S')
				ans[i + 1] = ans[i - 1];
			else
			{
				if (ans[i - 1] == 'W') ans[i + 1] = 'S';
				else ans[i + 1] = 'W';
			}
		}
		else // if (s[i] == 'x')
		{
			if (ans[i] == 'W') ans[i + 1] = ans[i - 1];
			else
			{
				if (ans[i - 1] == 'W') ans[i + 1] = 'S';
				else ans[i + 1] = 'W';
			}
		}
	}


	if (ans[n - 1] == 'S')
	{
		if (s[n - 1] == 'o')
		{
			if (ans[0] != ans[n - 2]) return false;
		}
		else
			if (ans[0] == ans[n - 2]) return false;
	}
	else // if (ans[n - 1] == 'W')
	{
		if (s[n - 1] == 'o') //Wo
		{
			if (ans[0] == ans[n - 2]) return false;
		}
		else // Wx
			if (ans[0] != ans[n - 2]) return false;
	}

	if (ans[0] == 'S')
	{
		if (s[0] == 'o')
		{
			if (ans[1] != ans[n - 1]) return false;
		}
		else
			if (ans[1] == ans[n - 1]) return false;
	}
	else
	{
		if (s[0] == 'o')
		{
			if (ans[1] == ans[n - 1]) return false;
		}
		else
			if (ans[1] != ans[n - 1]) return false;
	}

	return true;
}

int main()
{
	cin >> n >> s;
	ans.resize(n);

	if (check('S', 'W')) { print(); return 0; }
	if (check('S', 'S')) { print(); return 0; }
	if (check('W', 'W')) { print(); return 0; }
	if (check('W', 'S')) { print(); return 0; }

	cout << -1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define EPS 1e-6
#define inf 1000000000

// MAXIMIZAR f(x) == MINIMIZAR -f(x)
// It is easy to prove ... 

#define _ ios_base::sync_with_stdio(0), cin.tie(0), cin.tie(0), cout.tie(0), cout.precision(15);
#define forn(i, b) for(int i=0; i<int(b); i++)
#define FORC(i, a, b) for(int i=int(a); i<int(b); i++)
#define forc(i, a) for(int i=int(a); i>=0; i--)
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << (#x) << " = " << x << "\n";
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

clock_t t_;

using namespace std;


template<class T> void print(T s){cout << s << "\n";}
template<class T> void emax(T &a, T b){a = (a<b ? b : a);};
template<class T> void emin(T &a, T b){a = (a>b ? b : a);}
template<class T> void printC(T s){ for(auto &x : s){cout << x << " ";} cout << "\n";}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define maxn 200005
#define mod 1000000007

int l[maxn], r[maxn];
int a[maxn];
int gcd(int aa, int b){
    if(!b) return aa;
    return gcd(b, aa%b);
}
int main(int argc, const char * argv[]) {
     
    #ifdef local
    freopen("in", "r", stdin);
    #endif
    t_ = clock();
        
    int n;
    cin >> n;
    for(int i = 1; i<=n; i++){
        cin >> a[i];
    }

    for(int i = 1; i<=n; i++){
        l[i] = gcd(l[i-1], a[i]);
        r[n-i+1] = gcd(r[n-i+2], a[n-i+1]);
    }
//
 //   for(int i = 1; i<=n; i++){
  //      cout << "L " << i << " " << l[i] << endl;
   //     cout << "R " << i << " " << r[i] << endl;
   
 //   }
    int ans = 0;
    for(int i = 1; i<=n; i++){
  //     print(ans);
       emax(ans, gcd(l[i-1], r[i+1]));
    }
    print(ans);
    t_ = clock()-t_;
    cerr << setprecision(9) << fixed << ((float)t_ / CLOCKS_PER_SEC) << endl;

        
    return 0;
}







Measured memory_bytes: 1408
n, x = map(int, input().split())
l, p = [1], [1]
for i in range(n):
    l.append(l[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif x <= l[n - 1] + 1:
        return f(n - 1, x - 1)
    elif x == l[n - 1] + 2:
        return p[n - 1] + 1
    elif x <= 2 * l[n - 1] + 2:
        return p[n - 1] + 1 + f(n-1, x - 2 - l[n - 1])
    else:
        return 2 * p[n - 1] + 1
print(f(n, x))

Measured memory_bytes: 38384
n = int(input())
x = list(map(int,input().split()))

x_sort = sorted(x)
lenth = len(x)
low = x_sort[int(lenth/2)-1]
high = x_sort[int(lenth/2)]

for y in x:
    if y <= low:
        print(high)
    else:
        print(low)

Measured memory_bytes: 30772
my_str = str(input())
new_str = my_str[::-1]
mylist = list(my_str)
newlist = list(new_str)
count = 0

for i in range(0,len(my_str)):
  if mylist[i] == newlist[i]:
    continue
  else:
    count += 1

new_count = -(-count//2)

print(new_count)
      
      
      
  	

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

const int adx[] = { 1,1,1,0,-1,-1,-1,0 };
const int ady[] = { 1,0,-1,-1,-1,0,1,1 };

int add(const int base, const int plus) {
	if (!plus) {
		return base + 1;
	}
	else {
		return 0;
	}
}
//0 :?????????1:??????2:?????????3:??? 4:?????????5:??? 6:?????? 7:??? ???
vector<vector<vector<int>>>get_cumulative_sum(const vector<vector<int>>&field) {
	const int H = field.size();
	const int W = field[0].size();

	vector<vector<vector<int>>>sums(4, vector<vector<int>>(H, vector<int>(W)));

	for (int ny = H - 1; ny >= 0; --ny) {
		for (int nx = 0; nx <W; ++nx) {
			for (int k = 0; k < 3; ++k) {
				sums[k].clear();
			}
			for (int k = 3; k < 4; ++k) {
				int py = ny - ady[k];
				int px = nx - adx[k];
				if (!(px >= 0 && px <W && py >= 0 && py <H))continue;

				sums[k][ny][nx] = add(sums[k][py][px], field[ny][nx]);

			}
		}
	}

	return sums;
}

int getans( vector<int>hs) {
	hs.emplace_back(0);
	stack<pair<int, int>>que;
	que.emplace(-1, 0);
	int ans = 0;
	for (int x = 0; x < hs.size(); ++x) {
		
		if (que.empty()) {
			que.push(make_pair(x, hs[x]));
		}
		else {
			while (!que.empty()) {
				auto p = que.top();
				if (p.second < hs[x]) {
					que.push(make_pair(x,hs[x]));
					break;
				}
				else if (p.second == hs[x]) {
					break;
				}
				else {
					int area = (x - p.first)*p.second;
					ans = max(ans, area);
					que.pop();
					if (!que.empty()) {
						auto np = que.top();
						if (np.second < hs[x]) {
							que.push(make_pair(p.first, hs[x]));
							break;
						}
					}
				}
			}
		}
		
			
	}
	return ans;
}

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>field(H + 2, vector<int>(W + 2,1));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> field[i + 1][j + 1];
		}
	}
	auto vs = get_cumulative_sum(field);
	int ans = 0;
	
	for (int y = 1; y <= H; ++y) {
		vector<int>v;
		for (int x = 1; x <= W; ++x) {
			v.push_back(vs[3][y][x]);
		}
		ans = max(ans, getans(v));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49284
#include<stdio.h>

int main() {
	int S;
	int h, m, s;
	scanf("%d", &S);
	s = S % 60;
	m = (S - s) % (60 * 60)/ 60;
	h = (S - s - m*60)/3600;		
	printf("%d:%d:%d\n", h, m , s);
	return 0;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f;
  long long min,max,sum;
  //vector<vector<int>> A(n, vector<int>(m, 0));
  vector<int> B(26, 0);
  string s;
while(getline(cin,s)){
  
  for(int i=0;i<s.length();i++){
    if(isupper(s.at(i))) B.at(s.at(i) - 'A')++;
    else if (islower(s.at(i))) B.at(s.at(i) - 'a')++;
  }
}
  for(int i=0;i<26;i++){
    cout << char('a' + i) << " : " << B.at(i) << endl;
  }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
 
using namespace std;
 
long long dp[3000][51];
 
int main () {
 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
 
    int N, A; cin >> N >> A;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];
    vector<int> p(N);
    for (int i = 0; i < N; ++i)
        p[i] = A * (i + 1);
    long long ans = 0;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int j = 0; j < N; ++j) 
        for (int k = N*A; k >= 0; --k) 
            for (int z = 1; z < N + 1; ++z) 
                if (k - a[j] + 1 > 0)
                    dp[k][z] += dp[k-a[j]][z-1];     
    for (int i = 1; i < N + 1; ++i)
        ans += dp[A*i][i];
    cout << ans << '\n';
 
    return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
constexpr int N = 100'000, M = 200'000, INF = 1'000'000'000;
int n, m;
int d[N], color[N], w[M], perm[N];
std::vector<std::pair<int, int>> e[N];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> m;
    for (int i = 0; i < n; ++i)
        std::cin >> d[i];
    std::fill(color, color + n, -1);
    std::fill(w, w + m, INF);
    for (int i = 0; i < m; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u;
        --v;
        if (color[u] == -1 && color[v] == -1 && d[u] == d[v]) {
            color[u] = 0;
            color[v] = 1;
            w[i] = d[u];
        }
        e[u].emplace_back(v, i);
        e[v].emplace_back(u, i);
    }
    std::queue<int> que;
    for (int i = 0; i < n; ++i)
        if (color[i] != -1)
            que.push(i);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (auto edge : e[u]) {
            int v, i;
            std::tie(v, i) = edge;
            if (color[v] == -1 && d[v] >= d[u]) {
                color[v] = color[u] ^ 1;
                w[i] = d[v];
                que.push(v);
            }
        }
    }
    std::string s;
    for (int i = 0; i < n; ++i) {
        if (color[i] == -1) {
            std::cout << -1 << "\n";
            return 0;
        }
        if (color[i] == 0) {
            s += 'W';
        } else {
            s += 'B';
        }
    }
    std::cout << s << "\n";
    for (int i = 0; i < m; ++i)
        std::cout << w[i] << "\n";
    return 0;
}


Measured memory_bytes: 12672
<?php
  fscanf(STDIN, "%d %d", $n, $k);
  $ans = 0.0;

  for ($i=1; $i<=$n; $i++) {
    $point = $i;
    $tmp = $n;
    
    while ($point < $k) {
      $point *= 2.0;
      $tmp *= 2.0;
    }
    $ans += (1.0 / $tmp);
  }

  printf("%.14f\n", $ans);
?>

Measured memory_bytes: 4604
#include<stdio.h>
int main(){
  double r,l;
  int i;
  int d[2][4]={{0}};
  while(scanf("%lf %lf",&l,&r)!=EOF){
    if(r<0.2)     d[1][3]++;
    else if(r<0.6)d[1][2]++;
    else if(r<1.1)d[1][1]++;
    else          d[1][0]++;
    if(l<0.2)     d[0][3]++;
    else if(l<0.6)d[0][2]++;
    else if(l<1.1)d[0][1]++;
    else          d[0][0]++;
  }
  for(i=0;i<4;i++){
    printf("%d %d\n",d[0][i],d[1][i]);
  }
  return 0;
}

Measured memory_bytes: 628
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() == 2) {
            if (s.charAt(0) == s.charAt(1)) System.out.println(1 + " " + 2);
            else System.out.println(-1 + " " + -1);
            return;
        }
        for (int i = 0; i + 3 <= s.length(); i++) {
            String sub = s.substring(i, i + 3);
            if (check(sub)) {
                System.out.println((i + 1) + " " + (i + 3));
                return;
            }
        }
        System.out.println(-1 + " " + -1);
    }
    public static boolean check(String s) {
        if (s.charAt(0) == s.charAt(1)) return true;
        if (s.charAt(1) == s.charAt(2)) return true;
        if (s.charAt(2) == s.charAt(0)) return true;
        return false;
    }
}

Measured memory_bytes: 29720
def wf(c):
    d = {}
    for i in range(10):
        for j in range(10):
            d[(i,j)] = c[i][j]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if d[(i,j)] > d[(i,k)] + d[(k,j)]:
                    d[(i,j)] = d[(i,k)] + d[(k,j)]
    e = {}
    for i in range(10):
        e[i] = d[(i,1)]
    return e


def solve(H, W, c, A):
    d = wf(c)
    mp = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] != -1:
                mp += d[A[i][j]]
    return mp


def main():
    H, W = list(map(int, input().split(' ')))
    c = []
    for i in range(10):
        c.append(list(map(int, input().split(' '))))
    A = []
    for i in range(H):
        A.append(list(map(int, input().split(' '))))

    ans = solve(H, W, c, A)
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll              long long int
#define ull             unsigned long long int
#define mod             1000000007 
#define pb              push_back
#define mp              make_pair
#define count_1(n)      __builtin_popcountll(n) //set bits
#define fr              first
#define sc              second

bool isPrime(ll n) {

  if (n == 1) {
    return false;
  }

  for (ll i = 2; i*i <=n; i++) {
    if (n % i == 0) return false;
  }

  return true;
}

 
   
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     
    x = x % p;  
                
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    return -1; 
} 



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        ll n;
        cin>>n;
        if(n==0)
            cout<<1;
            
        else
            cout<<0;
    
    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b)cout<<"Alice";
	if(a<b)cout<<"Bob";
	if(a==b)cout<<"Draw";
	cout<<endl;
    return 0;
}

Measured memory_bytes: 384
//    _____                   _                       _
//   / ____|                 | |                     (_)
//  | (___   ___  _ __     __| | ___ _ __    ______ _ _
//   \___ \ / _ \| '_ \   / _` |/ _ \ '_ \  |_  / _` | |
//   ____) | (_) | | | | | (_| |  __/ |_) |  / / (_| | |
//  |_____/ \___/|_| |_|  \__,_|\___| .__/  /___\__,_|_|
//                                  | |
//                                  |_|

#include <bits/stdc++.h>
#define nmax 100005
#define oo 10000000007
#define mod 1000000007
#define reset(x) memset(x, 0, sizeof x)
#define F first
#define S second
#define sonin cin
#define sonout cout
#define debug(x) cout << "Loli -> " << #x << " : " << x << "\n"
#define debugAry(x, a, b, y) for(int y = a; y<=b; y++) cout << #x << "[" << y << "]" << " -> " << x[y] << "\n"
#define filename ""
#define fileNX freopen(filename".inp", "r", stdin); freopen(filename".out", "w", stdout);
#define fileN freopen(filename".inp", "r", stdin);
#define fileX freopen(filename".out", "w", stdout);
#define toiuuhoa ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(a) (int) a.size()
#define FOU(x,a,b) for (lli x=a;x<=b;x++)
#define FOD(x,a,b) for (lli x=a;x>=b;x--)
#define FOA(a,b) for(auto &a:b)
#define ALLvec(a) a.begin(),a.end()
#define REU(x,a,b) for (lli x=a;x<b;x++)
#define RED(x,a,b) for (lli x=a;x>b;x--)
#define AutoCinAry(a,b,x) for(int a = 1; a<=b; a++) cin >> x[i];
#define dembit1(x) __builtin_popcount(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define EL cout << "\n";
#define EX exit(0);
#define Ary(x, i, j, a) x[(i - 1) * a + j]
#define epsinon 1e-8
#define Son_onii_chan main
#define times double stime = clock();
#define gettime cerr << "Time executed: " << (clock() - stime) / CLOCKS_PER_SEC * 1000 << "ms.\n";
using namespace std;
typedef int lli;
typedef long double ldo;
typedef double dou;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
typedef vector<pii> vpi;
typedef deque<lli> dqll;

lli x;
int Son_onii_chan(){
    //fileNX
    toiuuhoa
    sonin >> x;
  	sonout << (x == 0 ? 1 : 0);
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	bool ans=false;
	cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]=='C') ans=true;
		if (ans==true&&s[i]=='F') {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
    ll n,k,p=0,j=0;
    cin>>n>>k;
    ll a[n+2];
    a[n+1]=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i]>=k) {p=max(i-1LL,1LL);break;}
        if(a[i]+a[i+1]>=k) {j=i;break;}
    }
    if(p || j){
        cout<<"Possible"<<endl;
        if(p){
        for(int i=1;i<p;i++) cout<<i<<"\n";
        for(int i=n-1;i>=p;i--) cout<<i<<"\n";
        }
        else{
            for(int i=1;i<j;i++) cout<<i<<"\n";
            for(int i=n-1;i>j;i--) cout<<i<<"\n";
            cout<<j<<"\n";
        }
    }
    else cout<<"Impossible";
    return 0;
}

Measured memory_bytes: 1536
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

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

int main(void){
    int a,b,c,temp;
    cin >> a>>b>>c;
    if(a>b) swap(a, b);
    if(b>c) swap(b, c);
    if(a>b) swap(a, b);
    cout <<a<<" "<<b<<" "<<c<<endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll a, b;
  cin >> a >> b;
  cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 3140
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void insert(int k);
Node* find(int k);
void delete(int k);
void inOrder(Node *x);
void preOrder(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(x);

		}else if(com[0]=='p'){
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else if(com[0]=='f'){
			scanf("%d",&x);
			if(find(x)!=NIL)printf("yes\n");
			else printf("no\n");
		}else{
			scanf("%d",&x);
			delete(x);
		}
	}
	return 0;
}

void insert(int k){
	Node *y=NIL, *x=root, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=NIL;	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==NIL)root=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

Node* find(int k){
	Node* p=root;

	while(p!=NIL){
		if(p->key==k){
			return p;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}

	return NIL;
}

void delete(int k){
	Node *tgt=find(k),*del,*ch;

	if(tgt->left==NIL || tgt->right==NIL){
		del=tgt;
	}else{
		del=tgt->right;
		while(del->left!=NIL)del=del->left;
	}

	if(del->left!=NIL){
		ch=del->left;
	}else{
		ch=del->right;
	}
	if(ch!=NIL)	ch->parent=del->parent;

	if(del->parent==NIL){
		root=ch;
	}else{
		if(del==del->parent->left){
			del->parent->left=ch;
		}else{
			del->parent->right=ch;
		}
	}

	if(del!=tgt)tgt->key=del->key;

	free(del);
	return;
}

void inOrder(Node* x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node* x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}



Measured memory_bytes: 20464
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong D,T,S;
    cin >> D >> T >> S ;
    if(ceil((double)D/(double)S)<=T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
def main():
    import sys
    from bisect import bisect
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    m=map(int,b.read().split())
    c=[0]*(n+1)
    z=sorted(zip(m,m),key=itemgetter(0))
    y=[x for x,_ in z]
    s=b=0
    for i,(x,h)in enumerate(z):
        c[i]+=b
        b=c[i]
        h-=b
        t=-h//a
        if t<0:
            b-=t*a
            c[bisect(y,x+d+d)]+=t*a
            s-=t
    print(s)
main()

Measured memory_bytes: 55880
N, M = list(map(int, input().split()))
Plist = []
L = []
for i in range(M):
	P, Y = list(map(int, input().split()))
	L.append([Y, P, i])
	Plist.append(P)

L = sorted(L)
PL = [0 for i in range(N)]
ML = [0 for i in range(M)]
for i in range(M):
	PL[L[i][1] - 1] += 1
	ML[L[i][2]] = PL[L[i][1] - 1]


for i in range(M):
	plen = len(str(Plist[i]))
	ansP = "0" * (6 - plen) + str(Plist[i])
	mlen = len(str(ML[i]))
	ansM = "0" * (6 - mlen) + str(ML[i])
	print(ansP + ansM)

Measured memory_bytes: 30092
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(){
  char str[100];
  int i;
  srand((unsigned int) time(0));

  scanf("%s", str);
  //printf("%s\n", str);
  i = rand() % (strlen(str)-2);
  printf("%c%c%c\n", str[i],str[i+1],str[i+2]);


  return 0;
}


Measured memory_bytes: 1708
# https://atcoder.jp/contests/arc066/tasks/arc066_a/

n = int(input())
nums = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 1
d = {}
if n % 2 == 1:
    for i in range(0, n, 2):
        d[i] = 0
    d[0] += 1
else:
    for i in range(1, n, 2):
        d[i] = 0
f = True
for num in nums:
    if num not in d:
        print(0)
        break
    d[num] += 1
else:
    for v in d.values():
        if v != 2:
            print(0)
            break
    else:
        ans = pow(2, n // 2, mod)
        print(ans)

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

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt[n];
    fill(cnt, cnt+n, 0);
    for (int i=0, ai; i<n-1; i++) {
        cin >> ai;
        cnt[ai-1]++;
    }
    for (auto &ci:cnt) cout << ci << '\n';
    return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  if (n % 2 == 0) {
    p(floor(((double) n - 1) / 2));
  } else {
    p(floor((double) n / 2));
  }
}

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

int main() {
    char str1[201], str2[101], str3[101];
    
    scanf("%s%s",str1,str3);
    strcpy(str2, str1);
    strcat(str1, str2);
    
    if ( strstr(str1, str3) == NULL ) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 2120
import itertools

S = input()

in_list = list(S)
a, b, c, d = list(S)

op_list = list(itertools.product(['+', '-'], repeat=3))

for o in op_list:
    f = []
    for i, v in enumerate(in_list):
        f += v
        if i >= len(in_list) - 1: break
        f += o[int(i)]
    f_str = ''.join(f)
    total = eval(f_str)
    if total == 7:
        f_str += '=7'
        break
print(f_str)

Measured memory_bytes: 3064
void main(){
	int n, m;
	readf("%d %d", &n, &m);
	// nC2 を考えればいい
	(n*(n-1)/2 + m*(m-1)/2).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2740
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100, MAXI = 100001, D = 9;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 100, flag = 1;
//     cout << tc << "\n";
//     int n = 1;

//     while (tc--)
//     {
    	
//     	int n = rand()%N + 1, m = rand()%N + 1;

//     	int a[n][m];
//     	for(int i=0;i<n;i++)
//     	{
//     		for(int j=0;j<m;j++)
//     		{
//     			int flag = rand()%4;
//     			if(flag==0)
//     				a[i][j] = -1;
//     			else
//     				a[i][j] = rand()%MAXI;
//     		}
//     	}

//     	a[n-1][0] = rand()%MAXI;

//     	cout << n << " " << m << "\n";
//     	for(int i=0;i<n;i++){
//     		for(int j=0;j<m;j++)
//     			cout << a[i][j] << " ";
//     		cout << "\n";
//     	}

//     	cout << "~\n";
//     }
 
//     return 0;
// }
 
 
//  int n, a[N];

// int MEM(int ind, vector<int> &v)
// {
// 	if(ind==n)
// 	{
// 		// o(n)
// 	}

// 	int ans = 0;
// 	if(a[ind]==-1)
// 	{
// 		for(int i=0;i<n;i++)
// 		{
// 			if(i!=ind)
// 			{
// 				v[ind] = i;
// 				ans += MEM(ind+1, v);
// 				if(ans>=mod)
// 					ans %= mod;
// 			}
// 		}
// 	}
// 	else
// 		ans = MEM(ind+1, v);

// 	return ans;

// }
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 200005


// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	cout.tie(NULL);

	int  a, b;
	cin >> a >> b;
	cout << a * b;

    return 0;
 
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<pair<int, int>> V(N - 1);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    V.at(i) = {a, b};
  }
  map<int, int> MA;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    MA[a] += b;
  }
  Dijkstra<long> D(N + 1);
  D.add(0, 1, MA[1]);
  for (auto v : V) {
    D.add(v.first, v.second, MA[v.second]);
    D.add(v.second, v.first, MA[v.first]);
  }
  D.solve(0);
  for (int i = 1; i < N + 1; i++) {
    cout << D.dist.at(i) << "\n";
  }
}

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

int main() {
  int N;
  cin >> N;
  cout << fixed << std::setprecision(10);
  if (N == 1){
    cout << (double)1 << endl;
  }
  else if (N % 2 == 0){
    cout << (double)1 / 2 << endl;
  }
  else {
    cout << (double)((int)(N / 2) + 1) / N << endl;

  }
}


Measured memory_bytes: 256
def make01mask(start, len):
    mask = start
    for i in range(0, len - 1):
        if mask[i] == "0":
            mask += "1"
        else:
            mask += "0"
    return mask


# XOR演算して1の数を返す
def maskxor(bit, mask, digits):
    type = '0' + str(digits) + 'b'
    # print(format(int(bit, 2) ^ int(mask, 2), type))
    # print(str(format(int(bit, 2) ^ int(mask, 2), type)).count("1"))

    return (format(int(bit, 2) ^ int(mask, 2), type)).count("1")


#ビット列で入力される
bin_str = str(input())
bitdigits = len(bin_str)

#print(bin_str)
#print(make01mask("0", bitdigits))
#print(make01mask("1", bitdigits))

start0 = maskxor(bin_str, make01mask("0", bitdigits), bitdigits)
start1 = maskxor(bin_str, make01mask("1", bitdigits), bitdigits)

if start0 > start1:
    print(start1)
else:
    print(start0)

Measured memory_bytes: 3496
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()

int main(){
	string s;
	bool ok=1;
	cin>>s;
	if((ll)s.size()%2==1)ok=0;
	for(int i=0;i<s.size();i+=2){
		if(not(s[i]=='h'&&s[i+1]=='i'))ok=0;
	}
	cout<<(ok?"Yes":"No")<<endl;
}


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

typedef struct
{
  string name;
  int E, S;
} Artist;

const int MAX_NM = 100;

int LIMIT, N, M, X;
Artist secret[MAX_NM], standard[MAX_NM];

short int memo1[101][101][1001], memo2[101][3][1001];
void solve2(int i, int sec, int money, int ans)
{
  if (memo2[i][sec][money] >= ans)
    return;

  memo2[i][sec][money] = ans;
  if (i < N) {
    if (money+secret[i].E <= LIMIT && sec+1 <= 2)
      solve2(i+1, sec+1, money+secret[i].E, ans+secret[i].S);
    solve2(i+1, sec, money, ans);
  }
}

void solve1(int i, int std, int money, int ans)
{
  if (memo1[i][std][money] >= ans)
    return;

  memo1[i][std][money] = ans;
  if (i < M) {
    if (money+standard[i].E <= LIMIT)
      solve1(i+1, std+1, money+standard[i].E, ans+standard[i].S);
    solve1(i+1, std, money, ans);
  }
}

int main()
{
  while (cin >> LIMIT >> N >> M >> X) {
    if (LIMIT == 0 && N == 0 && M == 0 && X == 0)
      break;

    for (int i = 0; i < N; ++i)
      cin >> secret[i].name >> secret[i].E >> secret[i].S;
    for (int i = 0; i < M; ++i)
      cin >> standard[i].name >> standard[i].E >> standard[i].S;

    for (int i = 0; i < 1001; ++i) {
      for (int j = 0; j < 101; ++j) {
	for (int k = 0; k < 101; ++k)
	  memo1[j][k][i] = -1;
	for (int k = 0; k < 3; ++k)
	  memo2[j][k][i] = -1;
      }
    }
    solve1(0, 0, 0, 0);

    vector<short int> memo(LIMIT+1, -1);
    for (int k = 0; k <= M; ++k)
      for (int i = X; i <= M; ++i) {
	for (int j = 0; j <= LIMIT; ++j)
	  memo[j] = max(memo[j], memo1[k][i][j]);
    }

    for (int i = 0; i <= LIMIT; ++i) {
      if (memo[i] != -1)
	solve2(0, 0, i, memo[i]);
    }

    short int ans = 0;
    for (int k = 0; k <= N; ++k) {
      for (int i = 1; i < 3; ++i) {
	for (int j = 0; j <= LIMIT; ++j)
	  ans = max(ans, memo2[k][i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 20000
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#define ff first
#define ss second
#define ll long long
using namespace std;
int a[16], x[16][16], y[16][16], honests[16];
int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        for(int j = 0; j < a[i]; j++) {
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans = 0;
    for(int mask = 1; mask < (1 << n); mask++) {
        int curans = 0;
        for(int i = 0; i < n; i++) {
            if(mask & (1 << i)) {
                honests[i] = 1;
                curans++;
                //cout<<i<<" ";
            }
        }
        bool p = 1;
        for(int i = 0; i < n; i++) {
            if(honests[i]) {
                for(int j = 0; j < a[i]; j++) {
                    if(y[i][j] == 0 && honests[x[i][j] - 1] == 1) {
                        p = 0;
                        break;
                    }
                    if(y[i][j] == 1 && honests[x[i][j] - 1] == 0) {
                        p = 0;
                        break;
                    }
                }
                if(p == 0)
                    break;
            }
        }
        //cout<<": "<<p<<endl;
        if(p == 1)
            ans = max(ans, curans);
        for(int i = 0; i < n; i++)
            honests[i] = 0;
    }
    cout<<ans;
}
/*
 9 2
 6 19 3 4 4 2 6 7 8
 1 7 21
 1 5 18
 1 3 14
 1 1 8
 0 8 38
 0 6 36
 0 4 32
 0 2 26
 */


Measured memory_bytes: 256
def main():
    # n = int(input())
    # t, a = map(int, input().split())
    # h = list(map(int, input().split()))
    s = input()
    mini = 10**10
    for i in range(len(s)-2):
        mini = min(mini, abs(int(s[i:i+3]) - 753))

    print(mini)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61416
/*
17D8101031C 杉山　祥吾 ID:keisei334 C
*/

#include<stdio.h>
#define N 500000

int cnt=0;

int a[N];

void merge(int left,int mid,int right){
  int L[N/2];
  int R[N/2];
  int i,j,idx;
	
  for(i=left;i<=mid;i++)
    L[i-left]=a[i];
	
	
  for(i=mid+1;i<=right;i++)
    R[i-mid-1]=a[i];

  i=0;  j=0;  idx=left;
	
  while(i<=(mid-left) && j<=(right-mid-1)){
    if(L[i] < R[j])
      a[idx++]=L[i++];
			
    else 
      a[idx++]=R[j++];
			
    cnt++;
  }
	
  while(i<=(mid-left)){
    a[idx++]=L[i++];
    cnt++;
  }
	
  while(j<=(right-mid-1)){
    a[idx++]=R[j++];
    cnt++;
  }	
}

void mergeSort(int left,int right){
  int mid=(left+right)/2;
	
  if(left < right){
    mergeSort(left,mid);
    mergeSort(mid+1,right);
    merge(left,mid,right);
  }
}

int main(){
	int n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	mergeSort(0,n-1);
	
	for(i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n-1]);
	
	printf("%d\n",cnt);
	
	return 0;
	
}

/*実行結果

*/



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

vector<int> v(pow(2,18)+1,0),w(pow(2,18)+1,0);
vector<vector<int>> dp(1024,vector<int>(1e5+1,0));

int dfs(int V,int W,int C){
  if(W<0){
    return 0;
  }
  if(V<1024){
    return dp[V][W]+C;
  }
  int s=dfs(V/2,W-w[V],C+v[V]),t=dfs(V/2,W,C);
  return max(s,t);
}

int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> v[i+1] >> w[i+1];
  }
  for(int i=1;i<1024;i++){
    for(int j=1;j<1e5+1;j++){
      if(i>N){
        continue;
      }
      if(j>=w[i]){
        dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
      }
      else{
        dp[i][j]=dp[i/2][j];
      }
    }
  }
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int V,W;
    cin >> V >> W;
    cout << dfs(V,W,0) << endl;
  }
}


Measured memory_bytes: 406948
i = list(map(int, input().split()))
k = i[0]
n = i[1]
a_list = list(map(int, input().split()))

ans = 0
for num in range(n-1):
    distance = a_list[num+1] - a_list[num]
    if distance > ans:
        ans = distance

distance_2 = k+a_list[0]-a_list[n-1]
if distance_2 > ans:
    print(k - distance_2)
else:
    print(k - ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
typedef long long ll;
ll n,m;
string s;
int main(){
  cin >> s;
  string d="No";
  if(s[2]==s[3]&&s[4]==s[5]) d="Yes";
  cout << d;
}

Measured memory_bytes: 256
module Main where

import System.Environment

ans :: Integer -> Integer -> Integer -> Integer
ans x k d = 
	case x >= k * d of
		True -> x - k * d
		False -> min (abs (x - k' * d)) (x - (k' - 2) * d)
	where 	k'' = x `div` d
		k'  = case k'' `mod` 2 == k `mod` 2 of
			True -> k''
			False -> k'' + 1

main :: IO ()
main = do
	(x:k:d:_) <- fmap (map read . words) $ getLine
	putStrLn . show $ ans (abs x) k d

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}

inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 55;
const int M_MAX = 25;
int N,M;
vector<vector<PII> > G(N_MAX);
typedef struct{
  int s,t;
  vector<int> route;
}Paths;
vector<Paths> v(M_MAX);

bool dfs(int id, int ver, int p, int g){
  if(ver == g)return true;
  for(const PII &pii : G[ver]){
    int u = pii.first;
    int eid = pii.second;
    if(u==p)continue;
    if(dfs(id,u,ver,g)){
      v[id].route.emplace_back(eid);
      return true;
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N;
  rep(i,N-1){
    int x,y;cin >> x >> y;
    if(x>y)swap(x,y);
    G[x].push_back(PII(y,i));
    G[y].push_back(PII(x,i));
  }

  cin >> M;
  rep(id,M){
    cin >> v[id].s >> v[id].t;
    dfs(id,v[id].s, 0, v[id].t);
    reverse(all(v[id].route));
  }

  ll ans = 1;
  int n = N-1;
  rep(i,n) ans *= 2ll;
  repp(S,1,1<<M){
    int num = 0;
    vector<bool> used(N-1,false);
    rep(id,M){
      if(S>>id&1){
        ++num;
        for(int& eid : v[id].route)used[eid] = true; 
      }
    }
    int count = 0;
    rep(eid,N-1) if(used[eid])++count;
    n = N-1-count;
    ll calc = 1;
    rep(i,n)calc *= 2ll;
    if(num&1) ans -= calc;
    else ans += calc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		int Inf = (int) 1e9;
		
		int[][] dp = new int[2][];
		for(int i=0;i<2;i++){
			dp[i] = new int[N + 1];
			for(int j=0;j<=N;j++){
				dp[i][j] = -Inf;
			}
		}
		dp[0][0] = 0;
		for(int i=0;i<N;i++){
			if(i == 0){
				dp[0][1] = 1;
				if(N >= 2) dp[1][2] = 1;
				continue;
			}
			for(int j=0;j<2;j++){
				if(dp[j][i] == -Inf) continue;
				if(j == 0){
					if(i + 2 <= N){
						dp[1][i + 2] = Math.Max(dp[1][i + 2], dp[j][i] + 1);
					}
					if(i > 0 && S[i-1] != S[i]){
						dp[0][i + 1] = Math.Max(dp[0][i + 1], dp[j][i] + 1);
					}
				} else {
					if(i + 1 <= N){
						dp[0][i + 1] = Math.Max(dp[0][i + 1], dp[j][i] + 1);
					}
					if(i > 1 && i + 1 < N && !(S[i-2] == S[i] && S[i-1] == S[i+1])){
						dp[1][i + 2] = Math.Max(dp[1][i + 2], dp[j][i] + 1);
					}
				}
			}
		}
		
		int ans = 0;
		ans = Math.Max(dp[0][N], dp[1][N]);
		Console.WriteLine(ans);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13408
inpl = lambda: list(map(int,input().split()))
N = int(input())
H = inpl()
cur = 0
cur_step = 0
longest = 0
for h in H:
    prev = cur
    cur = h
    if cur <= prev:
        cur_step += 1
    else:
        longest = max(longest, cur_step)
        cur_step = 0
else:
    longest = max(longest, cur_step)

print(longest)

Measured memory_bytes: 14252
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM

readIntLines :: IO [Int]
readIntLines = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

type Map = IM.IntMap Int

get :: Int -> Map -> Int
get key m = fromMaybe 0 $ IM.lookup key m

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

record :: [Int] -> Map -> Map
record [] m = m
record (a:as) m = record as $ countUp a 1 m

solve :: [Int] -> Int -> Int -> Map -> [Int]
solve [] _ _ _ = []
solve (i:is) k q m = score : solve is k q m
  where score = k - q + get i m

main :: IO ()
main = do
  [n, k, q] <- map read . words <$> getLine :: IO [Int]
  as <- readIntLines
  mapM_ (putStrLn . (\n -> if n > 0 then "Yes" else "No")) $ solve [1..n] k q $ record as IM.empty

Measured memory_bytes: 17532
from collections import defaultdict as di
import sys
range = xrange
input = raw_input

n = int(input())
if n == 1:
    print 1
    sys.exit()
pairs = []
for _ in range(n):
    x,y = [int(x) for x in input().split()]
    pairs.append((x,y))

diff = di(int)
for i in range(n):
    for j in range(n):
        if i != j:
            x1,y1 = pairs[i]
            x2,y2 = pairs[j]
            diff[x1-x2,y1-y2] += 1

maxi = max(diff[key] for key in diff)
print n - maxi

Measured memory_bytes: 31212