akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,x;
    ci(n>>x);
  vll A(n+1);
  vll P(n+1);
  A[0]=1;
  P[0]=1;

  FOR(i,1,n+1){
    A[i]=2*A[i-1]+3;
    P[i]=2*P[i-1]+1;
  }

  ll ans=0;

  while(true){
    if(x==1&&n!=0){
      co(0+ans)
      break;
    }
    else if(x==1&&n==0){
      co(1+ans)
      break;
    }

    else if(1<x&&x<=A[n-1]+1){
      n--;
      x--;
    }
    else if(x==A[n-1]+2){
      co(P[n-1]+1+ans)
      break;
    }
    else if(A[n-1]+2<x&&x<=2*A[n-1]+2){
      ans+=P[n-1]+1;
      x-=A[n-1]+2;
      n--;
    }
    else{
      co(2*P[n-1]+1+ans)
      break;
    }
  }
}

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

int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << (n % 2 == 0 ? (n / 2) : (n / 2) + 1);
	return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
C = [input() for i in range(H)]
ans = 0
for i in range(1<<H): #Yes,Noを２進数を結び付ける.<<はビットを左に移動
    for j in range(1<<W):
        cnt = 0
        for x in range(H):
            for y in range(W): #>>でビットを右に戻したときにxの部分が0であればいい
                if ((i>>x)&1 == 0) and ((j>>y)&1 == 0) and C[x][y] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 68228
# C - Traveling
# https://atcoder.jp/contests/abc086/tasks/arc089_a

# dt = ti+1 −ti
# dist = abs(xi+1 − xi)+abs(yi+1 − yi)

# キーポイント: パリティ
# x + y は毎秒ごとに必ず偶奇が入れ替わる。

n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

for i in range(n):
    t,x,y= map(int,input().split())

    dist = abs(x-X) + abs(y-Y)
    dt = (t-T)

    # dist と dt の偶奇は一致する必要あり
    if dist <= dt and dist%2 == dt%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")
    


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
  int n,k; cin>>n>>k;
  int arr[n + 1] = {};
  int pq = k;
  while(k--)
  {
    int a,b; cin>>a>>b;
    a--,b--;
    arr[a] +=1;
    arr[b + 1] -= 1;
  }  
  int cnt = 0;
  for(int i = 0; i < n; i++)
  {
    if(i) arr[i] += arr[i - 1];
  }
  for(int i = 0; i < n; i++) if(arr[i] == pq) cnt++;
    cout<<cnt;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp1[4010][3] = {0}, dp2[4010][3] = {0}, n;
char a[40010];
int che(int x, int y) {
	if (a[(x+y)/2] != a[x] && a[(x+y)/2] != a[y]) return 1;
	return 0;
}
int main(){
	scanf("%d", &n);
	scanf("%s", a+1);
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < 3; j++) dp1[i][j] = dp1[i-1][j];
		if (a[i] == 'R') dp1[i][0] = dp1[i-1][0] + 1;
		else if (a[i] == 'G') dp1[i][1] = dp1[i-1][1] + 1;
		else dp1[i][2] = dp1[i-1][2] + 1;
	}
	for (int i = n; i >= 1; i--) {
		for (int j = 0; j < 3; j++) dp2[i][j] = dp2[i+1][j];
		if (a[i] == 'R') dp2[i][0] = dp2[i+1][0] + 1;
		else if (a[i] == 'G') dp2[i][1] = dp2[i+1][1] + 1;
		else dp2[i][2] = dp2[i+1][2] + 1;
	}
	ll s = 0;
	for (int i = 2; i <= n-1; i++) {
		if (a[i] == 'R') {
			s = s + dp1[i-1][1]*dp2[i+1][2] + dp1[i-1][2]*dp2[i+1][1];
		}
		else if (a[i] == 'G') {
			s = s + dp1[i-1][0]*dp2[i+1][2] + dp1[i-1][2]*dp2[i+1][0];
		}
		else {
			s = s + dp1[i-1][0]*dp2[i+1][1] + dp1[i-1][1]*dp2[i+1][0];
		}
	}
	for (int i = 1; i <= n-2; i++) {
		for (int j = i+2; j <= n; j++) {
			if (a[i] != a[j] && (i+j)%2 == 0 && che(i, j)) {
				s--;
			}
		}
	}
	printf("%lld\n", s);
	return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,cnt=0;
	cin>>a;
	map<string,bool> b;
	for (int i=0;i<a;i++)
	{
		string c;
		cin>>c;
		if (!b[c])
		{
			cnt++;
			b[c]=true;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 19064
#include <cstdio>
#include <math.h>
using namespace std;
int main(){

        double r,a,c;
        scanf("%lf",&r);

        a = (double)r * (double)r * M_PI;
        c = 2 * M_PI * (double)r;
        printf("%lf %lf\n",a,c);

}


Measured memory_bytes: 2712
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, M;

  std::map<std::string, int> map1, map2;

  std::set<std::string> set;

  std::string s;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> s;

    map1[s] ++;

    set.insert(s);
  }

  std::cin >> M;

  for (int i = 0; i < M; i ++) {
    std::cin >> s;

    map2[s] ++;

    set.insert(s);
  }

  int cp = 0;
  
  for (const auto& i : set) {
    int c = map1[i] - map2[i];

    if (c > cp)
      cp = c;
  }

  std::cout << cp << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    char s[100001];
    cin >> s;

    Int dp[100001][13];
    Int len = strlen(s);
    Int inf = 1e9+7;

    dp[0][0] = 1;
    for(Int i=0; i<len; i++){
        if(s[i] != '?'){
            Int num = s[i]-'0';
            for(Int k=0; k<13; k++){
                dp[i+1][(k*10 + num)%13] += dp[i][k];
            }
        }else{
            for(Int j=0; j<10; j++){
                for(Int k=0; k<13; k++){
                    dp[i+1][(k*10 + j)%13] += dp[i][k];
                }
            }
        }
        for(Int j=0; j<13; j++){
            dp[i+1][j] %= inf;
        }
    }

    cout << dp[len][5] << endl;

    return 0;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  if(a == 'H') {
    cout << b << endl;
  } else {
    if(b == 'H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    int[] d = na(n);
    
    Arrays.sort(d);
    
    System.out.println(d[n/2] - d[n/2 - 1]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 34112
#include <stdio.h>

int main(void){
	int a = 0;
	int b = 0;
	int x = 0;
	int i = 0;
	while(scanf("%d %d", &a, &b) != EOF){
	
	x = a + b;
	
	for(i = 0; x>0; i++){
		x = x / 10;
	}
		
	printf("%d\n", i);

	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	sort.Ints(h)
	min := int(10e9)
	for i:=0;i<n-k+1;i++ {
		min = int(math.Min(float64(h[i+k-1] - h[i]), float64(min)))
	}
	fmt.Println(min)
}

Measured memory_bytes: 7168
k = int(input())
if k%2 == 0:
  print(-1)
  exit()
if k%5 == 0:
  print(-1)
  exit()
s = 0
a = 7
for i in range(k+1):
  s = (s+a)%k
  if s == 0:
    print(i+1)
    exit()
  a = (a*10)%k
print(-1)
  
    
    

Measured memory_bytes: 63272
#include <iostream>
#include <vector>
#include <string>
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n); 
    for(int i=0;i<n;i++) cin >> a[i];
    ll res1=0; ll res2=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i] > a[j]) res1++;
        }
        if(k>1){
            for(int k=0;k<n;k++){
            if(a[i] > a[k]) res2++;
            }
        }
    }
    ll ans = (res1*k) % MOD + res2*((k*(k-1)/2) % MOD) % MOD;
    cout << ans % MOD;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
// 区間加算、区間最大クエリ
template <typename F,typename T>
struct DST{
  T identity;
  F merge;
  int size;
  vector<T> dat,delay;
  
  DST(F f,T id):merge(f),identity(id){}

  void eval(int k,int l,int r){
    if(delay[k] != 0){
      dat[k] += delay[k];
      if(k<size-1){
	delay[2*k+1] += delay[k];
	delay[2*k+2] += delay[k];	
      }
      delay[k]=0;
    }
  }

  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
    delay.resize(size*2-1,0);    
  }

  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int a,int b,T x,int k,int l,int r){
    eval(k,l,r);

    if(r<=a||b<=l) return ;
    if(a<=l&&r<=b){
      delay[k] += x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l) return identity;

    if(a<=l&&r<=b) return dat[k];
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }

  void all_eval(){
    rep(i,2*size-1){
      eval(i,0,0);
    }
  }

  T get(int k){ return dat[size-1+k];}
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    cout << "************************\n";
    index = 0;
    num = 1;
    while(index<size){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    cout << "************************\n";      
  }


  
};
int main()
{
  int n,m; cin >> n >> m;
  vector<int> l(m), r(m);
  vector<ll> a(m);
  rep(i,m) {
    cin >> l[i] >> r[i] >> a[i];
    //    l[i]--;
  }

  auto f = [&](ll a,ll b){ return max(a,b);};
  ll id = 0;
  DST<decltype(f),ll> dst(f,id);
  dst.init(n);
  
  vector<vector<pair<int,ll>>> p(n+1);
  rep(i,m) {
    p[r[i]].push_back({l[i], a[i]});
  }

  rep1(i,n) {
    ll x = dst.query(0, i, 0, 0, dst.size);
    ll sum = 0;
    for(auto j: p[i]) {
      int left = j.first;
      ll aa = j.second;
      sum += aa;
      dst.update(left, i, aa, 0, 0, dst.size);
    }
    dst.update(i, i+1, x+sum, 0, 0, dst.size);
  }

  ll res = 0;
  chmax(res, dst.query(0, dst.size, 0, 0, dst.size));
  cout << res << "\n";
  
  return 0;
}



Measured memory_bytes: 22528
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
const int N = 109;
int n,w,value[N],weight[N];
long long dp[N][100009];

long long solve(int i,int w){
    if(i>=n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    if(weight[i]>w)
        return dp[i][w]=solve(i+1,w);
    else{
        return dp[i][w] = max(solve(i+1,w),solve(i+1,w-weight[i])+value[i]);
    }
}


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

    memset(dp,-1,sizeof(dp));

    cin>>n>>w;
    for(int i=0;i<n;i++)
        cin>>weight[i]>>value[i];

    cout<<solve(0,w);
    return 0;
}


Measured memory_bytes: 85376
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
      .map(|e| e.parse().ok().unwrap()).collect()
}

fn format_output(xs: &Vec<i32>) -> String {
    xs.iter()
        .map(|x| x.to_string())
        .collect::<Vec<String>>()
        .join(" ")
}

fn main() {
    let n: usize = read();
    let mut xs: Vec<i32> = read_vec();

    for i in 1..n {
        println!("{}", format_output(&xs));

        let v = xs[i];
        let mut j = (i - 1) as i32;
        while j >= 0 && xs[j as usize] > v {
            xs[(j + 1) as usize] = xs[j as usize];
            j -= 1;
        };
        xs[(j + 1) as usize] = v;
    };

    println!("{}", format_output(&xs));
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
using P = pair<ll,ll>;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, a, b) for (ll i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const ll INF = 1000000000000000000;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  // cout << a.max_size() << endl;
  ll ans = 1;
  ll tmp;
  rep(i,n) {
    cin >> a[i];
    // cin >> tmp;
    // if (tmp == 0) {
    if (a[i] == 0) {
      ans = 0;
      cout << ans << endl;
      return 0;
    }
    // ans *= tmp;
    // if (ans > INF) ans = INF + 1;
  }
  rep(i, n){
    // cin >> tmp;
    // ans *= tmp;
    // ans *= a[i];
    // cout << ans << endl;
    if (a[i] <= INF/ans) {
      // ans = -1;
      ans *= a[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
int cnt,a,b;
ll a1[100001],a2[100001];
void display(vector<int> arr, int n){
    cnt++;
    int c1=0,c2=0;
    for(int i=0;i<n;i++)
    {
        if(a1[i]==arr[i])
            c1++;
        if(a2[i]==arr[i])
            c2++;
    }
    if(c1==n)
        a=cnt;
    if(c2==n)
        b=cnt;
//cout<<a<<" "<<b<<endl;
    // cout<<abs(a-b)<<endl;

}

int main()
{
    //Obtaining length of array
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
        cin>>a1[i];
    for(int i=0;i<n;i++)
        cin>>a2[i];


    vector<int> arr(n);


    for(int i=1,j=0; i<=n; i++){
        arr[j++]=i;
    }

    do{

        display(arr, n);
    }while(next_permutation(arr.begin(), arr.end()));
    //cout<<a<<" "<<b<<endl;
    cout<<abs(a-b)<<endl;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
XY =  [list(map(int, input().split())) for _ in range(N)]
if N==1:
    print(1)
    exit()
vecs = [  (x[0]-y[0], x[1]-y[1]) for y in XY   for x in XY]
pattern = list(set(vecs))
pattern.remove((0,0))
pattern2 = tuple(pattern)
qty = map(lambda x: vecs.count(x), pattern2)
data = zip(qty, pattern)
data2 = list(data)
data2.sort()
d = int(data2[-1][0])
print(N-d)

Measured memory_bytes: 3568
H,W = map(int,input().split())
array = []
for i in range(H):
    array.append(list(str(input())))
flag = 0
for j in range(H):
    k = 0
    for k in range(W):
        if array[j][k] == "#":
            if j == 0 and k == 0:
                if array[j+1][k] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif j == 0 and k == W-1:
                if array[j+1][k] == "." and array[j][k-1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif j == H-1 and k == 0:
                if array[j-1][k] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif j == H-1 and k == W-1:
                if array[j-1][k] == "." and array[j][k-1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif j == 0:
                if array[j+1][k] == "." and array[j][k-1] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif j == H-1:
                if array[j-1][k] == "." and array[j][k-1] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif k == 0:
                if array[j-1][k] == "." and array[j+1][k] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            elif k ==W-1:
                if array[j-1][k] == "." and array[j+1][k] == "." and array[j][k-1] == ".":
                    flag = 1
                    break
                else:
                    pass
            else:
                if array[j-1][k] == "." and array[j+1][k] == "." and array[j][k-1] == "." and array[j][k+1] == ".":
                    flag = 1
                    break
                else:
                    pass
            
        else:
            pass
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int solve(int k,int v){
	if(k==1)return 1;
	int res=0;
	for(int i=0;i*k*k<=v;i++)res+=solve(k-1,v-k*k*i);
	return res;
}
int main(){
	int n;
	for(;cin>>n,n;){
		cout<<solve(15,n)<<endl;
    	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

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

int digit(ll n) {
	ll d = 0;
	while (1) {
		d++;
		n /= 10;
		if (n == 0) {
			break;
		}
	}
	return d;
}

int main() {
	ll N; cin >> N;
	ll minv = 1 << 23;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll a = N / i;
			ll F = (digit(a) > digit(i)) ? digit(a) : digit(i);
			minv = (minv > F) ? F : minv;
		}
	}

	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	s = input()
	print(len(zip(s)) - 1)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 70252
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int n;cin>>n;
  int max=1;
  for(int i=0;i<n;i++){
    if(pow(2,i)<=n&&pow(2,i+1)>n)max=pow(2,i);
  }
  cout<<max<<endl;
  return 0;
}


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

int main(){
  int x, stack[100], i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      stack[i-2] = stack[i-2] + stack[i-1];
      i -= 1;
    } else if ( s[0] == '-' ){
      stack[i-2] = stack[i-2] - stack[i-1];
      i -= 1;
    } else if ( s[0] == '*' ){
      stack[i-2] = stack[i-2] * stack[i-1];
      i -= 1;
    } else {
      x = atoi(s);
      stack[i] = x;
      i++;
    }
  }
  printf("%d\n", stack[0]);
  return 0;
}

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

int main(int argc, char const *argv[]) {
        int H1, M1, H2, M2, K;
        cin >> H1 >> M1 >> H2 >> M2 >> K;
        int time = 60 * (H2 - H1) + M2 - M1 - K;

        cout << time << endl;
        return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	str := scanString(sc)
	if all9(str[1:len(str)]) {
		return int(str[0]-'0') + 9*(len(str)-1)
	}
	return int(str[0]-'0'-1) + 9*(len(str)-1)
}

func all9(str string) bool {
	for i := 0; i < len(str); i++ {
		if str[i] != '9' {
			return false
		}
	}
	return true
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
import sys
import heapq
import math

def main():
    a, b, h, m = map(int, input().split())
    angle = (math.pi / 30) * m - (m * math.pi / 360 + h * math.pi / 6)
    if angle < 0:
        angle = -angle
    ans = math.sqrt(a * a + b * b - 2 * b * a * math.cos(angle))
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 62820
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int a, b, c, f = 0;
    cin >> c >> a >> b;
    repp(j, 1, 2000) if(j*c <= b && j*c >= a) f = 1;

    if(f) cout << "OK";
    else cout << "NG";
}

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

Measured memory_bytes: 3600
n = $stdin.gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
ans = 0
arr.sort!

if arr.length <= 2
  puts "0"
  exit
end


0.step(arr.length-1) do |a|
  a.step(arr.length-1) do |b|
    b.step(arr.length-1)do |c|
      if arr[a] != arr[b] && arr[b] != arr[c] && arr[c] != arr[a]
        if arr[a] < arr[b]+arr[c] && (arr[b]-arr[c]).abs < arr[a]
          ans += 1
        end
      end
    end
  end
end
puts ans

Measured memory_bytes: 14332
#include<stdio.h>
int main(void)
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(x-r<0||x+r>w||y-r<0||y+r>h) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll n,m;cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
// 2020-09-29 19:03:15
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
const int MX = 100010;
const ll inf = 1e18;
struct E {
  int from, to;
  vector<ll> cost;
  E(int from_, int to_, vector<ll> cost_) : from(from_), to(to_), cost(cost_) {}
};
vector<E> G[MX];
ll dist[2][MX];
void answer() {
  int n, m;
  vector<int> s(2);
  cin >> n >> m >> s[0] >> s[1];
  s[0]--;
  s[1]--;
  rep(i, m) {
    int u, v;
    vector<ll> c(2);
    cin >> u >> v >> c[0] >> c[1];
    u--;
    v--;
    G[u].emplace_back(E(u, v, c));
    G[v].emplace_back(E(v, u, c));
  }
  using Q = pair<ll, int>;  // cost to
  rep(k, 2) {
    rep(i, n) dist[k][i] = inf;
    priority_queue<Q, vector<Q>, greater<Q> > que;
    que.emplace(0, s[k]);
    while (!que.empty()) {
      auto [c, u] = que.top();
      que.pop();
      if (dist[k][u] <= c) continue;
      dist[k][u] = c;
      for (const auto& e : G[u]) {
        if (c + e.cost[k] < dist[k][e.to]) {
          que.emplace(c + e.cost[k], e.to);
        }
      }
    }
  }
  priority_queue<Q, vector<Q>, greater<Q> > res;
  rep(i, n) res.emplace(dist[0][i] + dist[1][i], i);
  rep(i, n) {
    while (res.top().second < i) res.pop();
    cout << ll(1e15) - res.top().first << '\n';
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

#define int long long

string s;

signed main(){
    cin >> s;
    int n = s.size();

    int ans = 0;
    int now = 0;

    bool c = false;

    for(int i = n-1;i >= 0;i--){
        if(s[i] == 'A'){
            if(c){
                now = 0;
                c = false;
            }
            ans += now;
        }else if(s[i] == 'B'){
            if(c){
                now++;
            }else{
                now = 0;
            }
            c = false;
        }else{
            if(c == false){
                c = true;
            }else{
                now = 0;
                c = true;
            }
        }
    }

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



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

void print(int x[], int n)
{
	for(int i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
}

int main()
{
	ios::sync_with_stdio(false);

	string s1, s2;
	cin >> s1 >> s2;
	int n = s1.length(), m = s2.length();
	int dp[n+1][m+1];
	for(int i = 0; i <= n; i++)
	{
		for(int j = 0; j <= m; j++)
		{
			if(i*j==0)
				dp[i][j]=0;
			else if(s1[i-1]==s2[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	// for(int i = 0; i <= n; i++)
	// 	print(dp[i], m+1);
	int i = n, j = m;
	string s = "";
	while(i > 0 && j > 0)
	{
		if(s1[i-1]==s2[j-1])
		{
			i--;
			j--;
			s = s1[i]+s;
		}
		else if(dp[i-1][j] > dp[i][j-1])
			i--;
		else
			j--;
	}
	cout << s << endl;

	return 0;
}

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

ll knapsack(vector<ll> &val,vector<ll> &wt,ll W,ll n,vector<vector<ll>> &dp)
{
    if(n==0 || W==0)
        return dp[n][W]=0;
    if(dp[n][W]!=-1)
        return dp[n][W];
   
    if(wt[n-1]<=W)
        return dp[n][W]=max(val[n-1]+knapsack(val,wt,W-wt[n-1],n-1,dp),knapsack(val,wt,W,n-1,dp));
   
    else
        return dp[n][W]=knapsack(val,wt,W,n-1,dp);
   
}

int main()
{
    ll n,W;
    cin>>n>>W;
    vector<ll>wt(n),val(n);
    for(ll i=0;i<n;i++)
    cin>>wt[i]>>val[i];
	vector<vector<ll>>dp(n+1,vector<ll>(W+1,-1));
    cout<<knapsack(val,wt,W,n,dp);
    cout<<endl;
    return 0;

}

Measured memory_bytes: 82968
#include <bits/stdc++.h>
#include <unordered_map>
 
using namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
const int32_t INFint = 1e9;
const ll INFll = 1e18;
#define MOD 1000000007ll
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
 
#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
#define For(i, a, b) for (ll i = a; i < b; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define gint(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define setZero(a,n) for(int i=0;i<n;i++) a[i]=0;
#define printArray(a,s,e) for(int i=s;i<e;i++) {cout << a[i] << " ";} cout << endl;
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------- 
int32_t main(){fast;
	

	int t;
	// cin >> t;
	t = 1;
	while(t--){
		int n;
		cin >> n;
		int arr[n][3];
		for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin >> arr[i][j];

		int dp[n][3];
		for(int i=0;i<3;i++) dp[0][i] = arr[0][i];

		for(int i=1;i<n;i++){
			dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0]);
		}

		cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	}
}







Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

vector<int> E[100000];
using P = pair<char,char>;//ope, X/Y
vector<P> V;

int dfs(int v, int pre, int x, int y, int val, bool ismax){//?????°???????????????????????????
    switch(V[v].first){
        case '&':
            val&=(V[v].second=='X'?x:y);
            break;
        case '|':
            val|=(V[v].second=='X'?x:y);
            break;
        case '^':
            val^=(V[v].second=='X'?x:y);
            break;
        default:
            val=0;
            break;
    }
    int ret;
    if(E[v].size()==1&&v){
        ret=val;
    }else{
        if(ismax){
            ret=-(1<<16);
            for(auto to:E[v]){
                if(to!=pre) ret=max(ret,dfs(to,v,x,y,val,!ismax));
            }
        }else{
            ret=(1<<16);
            for(auto to:E[v]){
                if(to!=pre) ret=min(ret,dfs(to,v,x,y,val,!ismax));
            }
        }
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    V.emplace_back(' ','X');
    for(int i=1;i<N;i++){
        string o;
        cin>>o;
        V.emplace_back(o[3],o[4]);
    }
    for(int i=0;i<N-1;i++){
        int u,v;
        cin>>u>>v;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    int memo[16][16];//[x][y]
    for(int x=0;x<16;x++){
        for(int y=0;y<16;y++){
            memo[x][y]=dfs(0,-1,x,y,0,true);
            // cout<<memo[x][y]<<endl;
        }
    }
    for(int i=0;i<M;i++){
        int X,Y;
        cin>>X>>Y;
        //?????§????????¨A=(0,0),B=(0,1),C=(1,0),D=(1,1)???4??????????????????(A?????\?????????????????????????????????)
        int cnt=3,x=0,y=0;
        int A,B,C,D;
        A=B=C=D=-1;
        for(int j=15;j>=0;j--){
            bool bx,by;
            bx=X&(1<<j);
            by=Y&(1<<j);
            if(!bx&&!by){//A
                if(!~A){
                    A=cnt;
                    cnt--;
                }
            }else if(!bx&&by){//B
                if(!~B){
                    B=cnt;
                    y|=(1<<cnt);
                    cnt--;
                }
            }else if(bx&&!by){//C
                if(!~C){
                    C=cnt;
                    x|=(1<<cnt);
                    cnt--;
                }
            }else{//D
                if(!~D){
                    D=cnt;
                    x|=(1<<cnt);
                    y|=(1<<cnt);
                    cnt--;
                }
            }
        }
        A=!!(memo[x][y]&(1<<A));
        B=!!(memo[x][y]&(1<<B));
        C=!!(memo[x][y]&(1<<C));
        D=!!(memo[x][y]&(1<<D));
        int ans = 0;
        for(int j=0;j<16;j++){
            bool bx,by;
            bx=X&(1<<j);
            by=Y&(1<<j);
            if(!bx&&!by){//A
                ans|=(A<<j);
            }else if(!bx&&by){//B
                ans|=(B<<j);
            }else if(bx&&!by){//C
                ans|=(C<<j);
            }else{//D
                ans|=(D<<j);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 16484
def main():
	N = int(input())
	T, A = map(int, input().split())
	H = list(map(int, input().split()))

	lst = [1000] * N

	for i in range(N):
		lst[i] = abs(T - H[i] * 0.006 - A)

	print(lst.index(min(lst)) + 1)


  
if __name__ == "__main__":
  	main()

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

int main(){
	string s;
	string t;
	cin>>s;
	cin>>t;
	vector<string> v;
	for(int i=0;i<s.size()-t.size()+1;i++){
		bool flag=true;
		string t2=s;
		for(int j=0;j<t.size();j++){
			if(t2[i+j]=='?')t2[i+j]=t[j];
			if(t2[i+j]!='?'&&t2[i+j]!=t[j]){
				flag=false;
				break;
			}
		}
		if(flag){
			for(int j=0;j<t2.size();j++){
				if(t2[j]=='?'){
					t2[j]='a';
				}
			}
			v.push_back(t2);
		}
	}
	if(v.size()==0){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	sort(v.begin(),v.end());
	cout<<v[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def main():
    k = int(input())

    ans = 0
    c = list(itertools.combinations_with_replacement(range(1,k+1), 3))
    for elem in c:
        n_gcd = gcd_list(list(elem))
        length = len(set(elem))
        if length == 1:
            k = 1
        elif length == 2:
            k = 3
        elif length == 3:
            k = 6
        ans += k * n_gcd 
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 192724
n,k = map(int,input().split())
p = list(map(int,input().split()))
ave = []
ans = 0
tmp = 0

for i in range(n):
  ave.append((p[i]+1)/2)

for j in range(n):
  tmp += ave[j]
  if j >= k:
    tmp -= ave[j-k]
    
  ans = max(ans,tmp)


print(ans)

Measured memory_bytes: 24804
#include <iostream>
using namespace std;
int main(void){
    int a , b , c , d , sum = 0;
    cin >> a >> b >> c >> d;
    if( a >= b ) sum += b;
    else sum += a;
    if(c >= d) sum += d;
    else sum += c;
    
    cout << sum << endl;

    return 0;
}

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

using namespace std;

int main(){
    long long n, maxw;
    cin >> n >> maxw;
    long long val[n];
    long long wt[n];
    for(int i=0;i<n;i++) cin >> wt[i] >> val[i];
    long long dp[n+1][maxw+1];
    long long w=0;
    memset(dp, 0, sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxw;j++){
            long long maxwithoutcurr=dp[i-1][j];
            long long maxwithcurr=0;
            if(j>=wt[i-1]){
                maxwithcurr=val[i-1];
                long long rem=j-wt[i-1];
                maxwithcurr+=dp[i-1][rem];
            }
            dp[i][j]=max(maxwithoutcurr, maxwithcurr);
        }
    }
    cout << dp[n][maxw];
}


Measured memory_bytes: 79104
//おまじない
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
//#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000000;

map<pair<int,int>,int> m;
vector<vector<int> > v(maxn);
int cm = 0;
int cnt[maxn]={0};
int F[maxn],T[maxn];
int vc[maxn]={0};
bool used[maxn]={0};
int ans[maxn];
int n;

int main(){
    
    cin >> n;
    rep(i,n-1){
        int f,t;cin >> f>>t;
        f--;t--;
        F[i]=f;T[i]=t;
        v[t].push_back(f);
        v[f].push_back(t);
        cnt[t]++;cnt[f]++;
        cm = max(cm,max(cnt[t],cnt[f]));
    }
    
    queue<int> que;
    que.push(0);
    used[0]=true;
    vc[0]=0;
    
    while(!que.empty()){
        int arg = que.front();que.pop();
        int argc = vc[arg];
        int c = 1;
        rep(j,v[arg].size()){
            int nv = v[arg][j];
            if(!used[nv]){
                if(argc==c)c++;
                vc[nv]=c;
                //cout << arg<<"から"<<nv<<"へ,argcは"<<argc<<",vcは"<<vc[arg]<<endl;
                m[make_pair(nv,arg)]=c;
                m[make_pair(arg,nv)]=c;
                que.push(nv);
                used[nv]=true;
                //cout <<arg<<"と"<<nv<<"の間の色は"<<c<<",頂点"<<nv<<"の引き継いだ色は"<<vc[nv]<<endl;
                c++;
            }
        }
    }
    
    rep(i,n-1){
        ans[i]=m[make_pair(F[i],T[i])];
    }
    
    cout << cm<<endl;
    rep(i,n-1){
        cout << ans[i]<<endl;
    }
    
    return 0;
}


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

int main(){
 int n,k,x,y;
  cin>>n>>k>>x>>y;
  
  int fee=0;
  if(n<=k){
    fee=x*n;
  }else{
    fee=x*k;
    fee+=y*(n-k);
  }
  
  cout<<fee<<endl;
  return 0;
}

Measured memory_bytes: 3552
N, D = (int(a) for a in input().split())
X2Y2 = [[int(a) ** 2 for a in input().split()] for b in range(N)]
X2, Y2 = [list(i) for i in zip(*X2Y2)]

c = 0
DD = D ** 2
for i in range(N):
    if X2[i] + Y2[i] <= DD:
        c += 1
print(c)

Measured memory_bytes: 59348
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#define ll long long

using namespace std;

ll gcd(ll a, ll b) {
    ll  tmp, r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  } else if (a==b) {
      return a;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main(void) {
    ll n;
    ll a[200000];
    scanf("%lld", &n);
    for (ll i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }

    ll ans = 10000000000;
    ll dummy;

    for (ll i=0; i<n-1; i++) {
        dummy = gcd(a[i], a[i+1]);
        ans = min(ans, dummy);
    }
    if (n>=2) {
        printf("%lld\n", ans);
    }else {
        printf("%lld\n", a[0]);
    }

}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{   int k,i,j,l;long long int s=0;
  cin>>k;
 for(i=1;i<=k;i++)
 {
    for(j=1;j<=k;j++)
    {
        for(l=1;l<=k;l++)
        {
           s+= __gcd(__gcd(i,j),__gcd(j,l));
        }
    }
     
 }
 cout<<s;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i,n){
        bool match = true;
        for(int j = i; j < n; ++j){
            if(s[j] != t[j-i]){
                match = false;
                break;
            }
        }
        if(match){
            cout << 2*n - (n - i) << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

class UnionFindTree {
public:
  UnionFindTree(int n) : tree(n, -1) {}
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (-tree[x] < -tree[y]) std::swap(x, y);
    tree[x] += tree[y]; tree[y] = x;
  }
  int find(int x) {
    return tree[x] < 0 ? x : tree[x] = find(tree[x]);
  }
  bool same(int x, int y) {
    if (find(x) == find(y))
      return true;
    else
      return false;
  }
  std::vector<int> tree;
};

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> p(n);
  UnionFindTree uft(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    std::cin >> x >>y;
    --x, --y;
    uft.unite(x, y);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (uft.same(i, p[i]))
      ++cnt;
  }
  std::cout << cnt << std::endl;
}


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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x=0, y, z, s=0, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for(i=n-1; i>=0; i--)
    {
        if(x%2==0)
            s+=a[i];
        else 
            s-=a[i];
        x++;
    }
    cout << s << endl;
}


Measured memory_bytes: 3552
import heapq


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    q = []
    for x in a:
        heapq.heappush(q, -x)

    for i in range(m):
        x = heapq.heappop(q)
        x /= 2
        heapq.heappush(q,x)

    answer = 0
    for x in q:
        answer += int(-x//1)
    print(answer)



Measured memory_bytes: 14184