akhauriyash/Code-Regression huggingface dataset:
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(x,y):
 x,y=r(x),r(y)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=c=0;b=[];k=(n+~m)*2
for v in a:d[r(i)]+=v,;i+=1
if k<1:exit(print(0))
for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1
print(k>len(b)and'Impossible'or c+sum(sorted(b)[:k]))

Measured memory_bytes: 35516
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int n,k;
int a[100];
bool dp[100001];

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

    cin>>n>>k;
    rep(i,n)cin>>a[i];

    rep(i,k+1){
        rep(j,n){
            if(i-a[j]>=0 and !dp[i-a[j]])dp[i]=true;
        }
    }

    cout<<(dp[k]?"First":"Second")<<endl;
    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <stdio.h>

int main(void){
  int l;
  std::cin >> l;
  std::cout << std::setprecision(32) << (double)l*l*l/27;
  return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		System.out.println(findGCD(x, y));
	}

	/**
	 * finds the GCD of x and y
	 */
	public static int findGCD(int x, int y) {
		if (y == 0) {
			return x;
		} else {
			return findGCD(y, x % y);
		}
	}

}



Measured memory_bytes: 26328
#include<stdio.h>

int main(){
	float x;
	
	while(scanf("%f",&x)!=EOF){
		if(x <=48.0)
			printf("light fly\n");
		else if(x>48 && x<=51)
			printf("fly\n");
		else if(x>51 && x<=54)
			printf("bantam\n");
		else if(x>54 && x<=57)
			printf("feather\n");
		else if(x>57 && x<=60)
			printf("light\n");
		else if(x>60 && x<=64)
			printf("light welter\n");
		else if(x>64 && x<=69)
			printf("welter\n");
		else if(x>69 && x<=75)
			printf("light middle\n");
		else if(x>75 && x<=81)
			printf("middle\n");
		else if(x>81 && x<=91)
			printf("light heavy\n");
		else if(x>91)
			printf("heavy\n");
	}
	
	return 0;
	
}


Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;

int n;

ll cou[1010];

void cal(int a)
{
	int c = 2;
	while(a > 1)
	{
		if(a % c == 0)
		{
			cou[c]++;
			a /= c;
		}
		else
		{
			c++;
		}
	}
	return;
}



int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
	    cal(i);
    }

    ll result = 1;
    ll MOD = 1e9 + 7;

    for(int i = 1;i <= n;i++)
    {
	    result = (result * (cou[i] + 1)) % MOD;
    }


    cout << result << endl;
    return 0;



}


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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (n = in()){
    int robo_x, robo_y;
    robo_x = robo_y = 10;
    set<pair<int, int> > gems;
    for (int i = 0; i < n; i++){
      int x, y;
      x = in();
      y = in();
      gems.insert(make_pair(x, y));
    }
    set<pair<int, int> > robos;
    int m = in();
    for (int i = 0; i < m; i++){
      string s;
      int v;
      int d;
      cin >> s >> v;

      if (s == "N") d = 0;
      else if (s == "W") d = 3;
      else if (s == "E") d = 2;
      else d = 1;
      for (int j = 0; j < v; j++){
        robos.insert(make_pair(robo_x, robo_y));
        robo_x += dx[d];
        robo_y += dy[d];
        robos.insert(make_pair(robo_x, robo_y));
      }
    }
    vector<pair<int, int> > mult;
    set_intersection(gems.begin(), gems.end(),
        robos.begin(), robos.end(),
        back_inserter(mult)
        );

    if (mult.size() == gems.size()){
      puts("Yes");
    }
    else puts("No");
  }

  return (0);
}

Measured memory_bytes: 1236
N = int(input())
h = [int(i) for i in input().split()]

dp = [0, abs(h[0]-h[1])]

for i in range(2, N):
    dp.append(min([abs(h[i]-h[i-2])+dp[i-2], abs(h[i]-h[i-1])+dp[i-1]]))

print(dp[N-1])


Measured memory_bytes: 52984
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll a, b, n;
    std::cin >> a >> b >> n;
    ll x = std::min(n, b - 1);
    std::cout << a * x / b - a * (x / b) << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
const int inf=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
  string s;
  cin>>s;
  int n=s.size();
  cout<<"ABC"<<s<<endl;

  return 0;
  }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n, m, l, s, t;
void solve() {
	s--;
	vector < vector<ll>> d(n);
	rep(i, n) {
		d[i].resize(n, INF);
		d[i][i] = 0;
	}
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		d[a][b] = d[b][a] = min(d[b][a],(ll)c);
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	vector<ll> e(l);
	vector<int> k(l);
	rep(i, l) {
		cin >> k[i] >> e[i]; k[i]--;
	}
	vector<vector<ll>> dp;
	vector<vector<bool>> used;
	dp.resize(1 << l); used.resize(1 << l);
	rep(i, (1 << l)) {
		dp[i].resize(l, INF); used[i].resize(l, false);
	}
	queue<P> q;
	rep(i, l) {
		dp[(1<<i)][i] = d[s][k[i]];
		q.push({(1<<i),i});
	}
	while (!q.empty()) {
		P p = q.front(); q.pop();
		int sp = p.first; int id = p.second;
		rep(j, l) {
			if (sp&(1 << j))continue;
			ll nd = dp[sp][id] + d[k[id]][k[j]];
			int ns = sp ^ (1 << j);
			dp[ns][j] = min(dp[ns][j], nd);
			if (!used[ns][j]) {
				used[ns][j] = true; q.push({ ns,j });
			}
		}
	}
	int ans = 0;
	rep(i, (1 << l)) {
		int cnt = 0;
		ll csum = 0;
		rep(j, l) {
			if (i&(1 << j)) {
				cnt++;
				csum += e[j];
			}
		}
		rep(j, l) {
			//cout << i << " " << j << " " << dp[i][j] << endl;
			ll sum = csum+dp[i][j] + d[k[j]][s];
			if (sum <= t) {
				//cout << i << " " << j << " " << dp[i][j] << endl;
				ans = max(ans, cnt);
			}
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n >> m>>l>>s>>t, n) {
		solve();
	}
	//stop
	return 0;
}



Measured memory_bytes: 19776
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N, D,count = 0;
    cin >> N >> D;
    int X[N][D];
    for(int i = 0; i < N;i++){
        for(int j = 0; j< D; j++){
            cin >> X[i][j];
        }
    }
    double tmp = 0;
    for(int i = 0; i < N; i++){
        for(int k = i+1; k < N; k++){
            for(int j = 0; j < D; j++){
                tmp += pow(abs(X[i][j] - X[k][j]), 2);
            }
            tmp = sqrt(tmp);
            if(ceil(tmp) == floor(tmp)) count++;
            tmp = 0;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


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


def main():
    N, M = get_inputs(int)

    ans = N * (N - 1) // 2 + M * (M - 1) // 2
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 13564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int now=0,t=0;
  while(1){
    now+=a;
    if(now>=60*t+c){
      cout<<60*t+c<<endl;
      break;
    }
    now+=b;
    if(now==60*t+c){
      cout<<now<<endl;
      break;
    }
    if(now>60*t+c)t++;
    if(now%60==0){
      cout<<-1<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
am = 0
for i, b in enumerate(B):
    a = A[i]-am
    if a < 0:
        count += A[i]
        a = 0
    else:
        count += A[i]-a
    n = a-b
    if n < 0:
        count += a
        am = b-a
    else:
        count += a-n
        am = 0
i += 1
a = A[i]-am
if a < 0:
    count += A[i]
else:
    count += A[i]-a
print(count)


Measured memory_bytes: 18476
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextLong();
    long x[] = new long[n];
    long y[] = new long[n];
    for(int i=0 ; i<n ; i++){
      x[i] = sc.nextLong();
      y[i] = sc.nextLong();
    }
    long Dis = d*d;
    int ans = 0;
    for(int i=0 ; i<n ; i++){
      long kyori = (x[i]*x[i]) + (y[i]*y[i]);
      if(kyori<=Dis){
        ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 64460
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Integer> map = new TreeMap<>();
		int max = 0;
		for(int i = 0;i < N;i++){
			String S = sc.next();

			if(map.containsKey(S)){
				map.put(S, map.get(S)+1);
			}else{
				map.put(S, 1);
			}
			if(max < map.get(S))max = map.get(S);
		}
		sc.close();

		for(Map.Entry<String, Integer> ent : map.entrySet()){
			if(ent.getValue()==max){
				System.out.println(ent.getKey());
			}
		}

	}

}

Measured memory_bytes: 76332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

long long gcd(long long a, long long b)
{
    if (a < b)
    {
        long long temp = a;
        a = b;
        b = temp;
    }

    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;

    long long ans_a = a - (a / c) - (a / d) + (a / lcm(c, d));
    long long ans_b = b - (b / c) - (b / d) + (b / lcm(c, d));

    long long ans = ans_b - ans_a;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char p[3];
    char t[3];
    int i=3,j=0,tag=0;
    while(i>0){
        scanf(" %c",&p[j]);
        j++;
        i--;
    }i=3;j=0;
    while(i>0){
        scanf(" %c",&t[j]);
        j++;
        i--;
    }
    for(j=0;j<=2;j++){
        if(p[j]!=t[j]) continue;
        else tag++;
    }
    printf("%d\n",tag);
    return 0;
}


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

const int MAX_N = 1000100;
const int INF = 1e9 + 100;

int N,Q,a,r[MAX_N],S[MAX_N];
pii s[MAX_N];
string query;
vector<int> leader,score;

int check(int x){
  int l = -1, r = INF;
  while(r-l>1){
    int m = (l+r)/2, p = -1;
    int num = 0;
    rep(i,score.size()){
      int L = lower_bound(S,S+N,score[i]-m) - S;
      num += max(0,L-(p+1));
      int R = upper_bound(S,S+N,score[i]) - S - 1;
      p = R;
    }
    num += N-(p+1);
    if(num<=x)r = m;
    else l = m;
  }
  return r;
}

int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(0);
  cin >> N >> Q;
  rep(i,N)cin >> s[i].first, s[i].second = i;
  sort(s,s+N);
  rep(i,N)r[s[i].second] = i, S[i] = s[i].first;

  rep(hoge,Q){
    cin >> query >> a;
    if(query == "ADD"){
      leader.push_back(a-1);
    }else if(query == "REMOVE"){
      rep(i,leader.size()){
	if(leader[i] == a-1){
	  leader.erase(leader.begin()+i);
	  break;
	}
      }
    }else{
      score.resize(leader.size());
      rep(i,score.size())score[i] = S[r[leader[i]]];
      sort(score.begin(),score.end());

      int r = check(a);
      if(r>=INF-1)cout << "NA" << endl;
      else cout << r << endl;
    }
  }
}

Measured memory_bytes: 16872
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX


int pp(int i)
{
    return i*i*i*i*i;
}

void solve()
{
   int x;
   cin >> x;
   for(int i=-1000; i<=1000; i++)
    rep(j,-1000, 1000)
    {
        if(pp(i)-pp(j)==x)
        {
            cout << i << " " << j << endl;
                    return;

        }
    }
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3688
read n
read -a a
h=0
c=0
m=0
for x in ${a[@]}
do
    if((h<x))
    then
        if((m<c))
        then
            m=$c
        fi
        c=0
    else
        c=$((c+1))
    fi
    h=$x
done
echo $((m>c?m:c))


Measured memory_bytes: 31876
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


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

int calc(string a, string b){
    int c = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] != b[i])  c++;
    }
    return c;
}
void solve(){
    string s, t;
    cin >> s >> t;
    int ans = s.size();
    for (int i = 0; i <= s.size() - t.size(); i++){
        ans = min(ans, calc(s.substr(i, t.size()), t));
        // cout << i << " " << ans << endl;
    }
    cout << ans;
} 
signed main(){  
//   freopen("output.txt", "r", stdin);
//   freopen("tt.txt", "w", stdout);
    // flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
		if(tc != t) cout << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
ll dp[100001][13];//i文字目時点であまりj

int main()
{
	string s;
	cin>>s;
	fill(dp[0],dp[100001],0);
	dp[0][0]=1;
	for(int i=0;i<s.size();i++)
	{
		for(int j=0;j<13;j++)
		{
			int tmp=j*10;
			if(s[i]!='?')
			{
				tmp+=s[i]-'0';
				tmp=(tmp+13)%13;
				dp[i+1][tmp]+=dp[i][j];
				dp[i+1][tmp]%=MOD;
			}else{
				for(int k=0;k<10;k++)
				{
					tmp=j*10+k;
					tmp=(tmp+13)%13;
					dp[i+1][tmp]+=dp[i][j];
					dp[i+1][tmp]%=MOD;
				}
			}
		}
	}
	ll ans=dp[s.size()][5]%MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10624
'''input
2
1000000000 1000000000
'''


N=int(input())
A=list(map(int, input().split()))

def gcd(a, b):
	if b==0:
		return a
	else:
		return gcd(b, a%b)


# a,b=1071, 1029
# print(gcd(a, b))

L=[0]*(N+1)
R=[0]*(N+1)
M=[0]*N

for i in range(N):
	L[i+1]=gcd(L[i],A[i])
# print(L)

for i in range(N):
	R[-i-2]=gcd(R[-i-1], A[-i-1])

# R.reverse()
# print(R)

for i in range(N):
	M[i]=gcd(L[i],R[i+1])

print(max(M))

Measured memory_bytes: 14436
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	bool vis[n+1]={0};
	ll count[n+1]={0};
	for(int i=0;i<m;i++)
	{
	    string s;
	    cin>>a;
	    cin>>s;
	    if(s=="AC")
	    vis[a]=1;
	    else if(s=="WA" && !vis[a])
	    count[a]++;
	}
	int cou=0;
	for(int i=1;i<=n;i++)
	{
	    if(!vis[i])
	    continue;
	    cou++;
	    b+=count[i];
	}
	cout<<cou<<" "<<b;
}

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

int main() {
    //input
    int a[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x, y;
    cin >> x >> y;
    cout << (a[x]-a[y] == 0 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int di(int x,int y){
  if(x>=y){
    return x-y;
  }
  else{
    return y-x;
  }
}
int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  string ans ="Yay!";
  vector<int> A(5);
  A = {a,b,c,d,e};
  for(int i=0; i<4 ;i++){
    for(int j=i+1 ; j<5  ; j++){
      if(di(A.at(i),A.at(j)) > k  ){
        ans =":(";
        break;
      }
    }
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n + 1);
    ll sum = 0;
    map<ll, int> mp;
    REP(i, 1, n+1) {
        ll x;
        cin >> x;
        a[i] = x + i;
        mp[i - x]++;
        b[i] = i - x;
        if (a[i] == b[i]) sum--;
    };
    sort(b.begin(), b.end());

    REP(i, 1, n+1) {
        // int t = upper_bound(b.begin(), b.end(), a[i]) - lower_bound(b.begin(), b.end(), a[i]);
        // sum += t;
        sum += mp[a[i]];
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 28976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S; cin>>S;

    int64_t cntA=0,ans=0;
    rep(i,0,S.size()-1){
        if(S.at(i)=='A'){
            cntA++;
        }else{
            if(S.at(i)=='B' && S.at(i+1)=='C'){
                ans+=cntA;
                i++;
            }else{
                cntA=0;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ShekharN
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] A = IntStream.range(0, n).map(i -> in.nextInt()).toArray();
            int[] B = IntStream.range(0, n).map(i -> in.nextInt()).toArray();
            int sum = 0;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                sum += A[i];
                ans = Math.max(ans, sum) + B[i];
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



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

int main(){
  int n,m;
  int s[1001][1001];
  int p[1001];

  while(1){
    cin>>n>>m;
    if(n+m==0)break;

    for(int i=0;i<m;i++) p[i]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin>>s[i][j];
	if(s[i][j]) p[j]++;
      }
    }

    //  for(int i=0;i<m;i++) cout<<p[i]<<endl;
    int count=0;
    while(1){
      bool flag=0;
      int max=-1;
      int ans;
      for(int i=0;i<m;i++){
	if(max<p[i]){
	  max=p[i];
	  ans=i;
	  flag=1;
	}
      }
      if(flag==0)break;
      if(count!=0)cout<<" ";
      cout<<ans+1;
      p[ans]=-1;
      count++;
    }
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 5072
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n){
    if(n % 2 == 1 || n == 0){
        cout << 0 << endl;
        return ;
    }
    i64 fiv = 0;
    i64 m = 10;
    while(m <= n){
        fiv += n / m;
        m *= 5;
    }
    cout << fiv << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
l = list(map(int,input()))
#print(l)
if l[0] <l[1]:
  a= str(l[0]+1)
  print(a*3)
elif l[0]>l[1]:
  print(str(l[0])*3)
else:
  if l[1] >= l[2]:
    print(str(l[0])*3)
  else:
    b= str(l[0]+1)
    print(b*3)
    

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

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

    vector<int> xx = x;
    sort(xx.begin(), xx.end());

    for (int remove = 0; remove < n; ++remove){
        auto pos = lower_bound(xx.begin(), xx.end(), x[remove]);
        int rpos = pos - xx.begin();

        int median = 0;
        if (rpos <= (n/2-1)) {
            median = xx[(n/2)];
        } else {
            median = xx[n/2-1];
        }

        cout << median << endl;

    }

    return 0;
}

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

int main() {
char n[9];
  rep(i, 9){
    cin>>n[i];}
  cout<<n[0]<<n[4]<<n[8]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n;
		int i,j,k,l;
		int count;
		
		while(scan.hasNextInt()){
			n = scan.nextInt();
			count = 0;
			
			for(i=0;i<=9;i++){
				for(j=0;j<=9;j++){
					for(k=0;k<=9;k++){
						for(l=0;l<=9;l++){
							if(n == i+j+k+l){
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
			
		}
		
		scan.close();
	}
}

Measured memory_bytes: 18832
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    S = SI()
    ans = 0
    tmp = 0
    for s in S:
        if s in 'ACGT':
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)

    return ans

print(main())

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n + 1);
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v <= n) {
          d[v]++;
        } else {
          break;
        }
      }
    }
  }

  rep(i, n) cout << d[i + 1] << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    deque<ll> p;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        if (i % 2 == 0)
        {
            p.push_back(a);
        }
        else
        {
            p.push_front(a);
        }
    }
    if (n % 2 == 0)
    {
        for (ll i = 0; i < n; i++)
        {
            cout << p[i];
            if (i != n - 1)
            {
                cout << ' ';
            }
        }
    }
    else
    {
        for (ll i = n - 1; i >= 0; i--)
        {
            cout << p[i];
            if (i != 0)
            {
                cout << ' ';
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int par[100010]; //親
int siz[100010]; //根ノードiの木に含まれる要素数。iが根ノード出ない場合無意味な値となる。

//n要素で初期化
void init(int n) {
	for(int i = 0;i < n;i++) {
		par[i] = i;
		siz[i] = 1;
	}
}

//木の根を求める
int find(int x) {
	if(par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//ｘとｙの属する集合を併合
void unite(int x,int y) {
	x = find(x);
	y = find(y);
	if(x == y) {
		return;
	}
	if(siz[x] < siz[y]) {
		swap(x,y);
	}
	par[y] = x;
	siz[x] += siz[y];
}

//ｘとｙが同じ集合に属するか否か
bool same(int x,int y) {
	return find(x) == find(y);
}

int size(int x) {
	return siz[find(x)];
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> vec[100010];
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        for(int j = 0;j < A;j++) {
            int B;
            cin >> B;
            B--;
            vec[B].push_back(i);
        }
    }
    init(N);
    for(int i = 0;i < M;i++) {
        int A = vec[i].size();
        for(int j = 0;j < A - 1;j++) {
            unite(vec[i].at(j),vec[i].at(j + 1));
        }
    }
    bool ret = true;
    for(int i = 0;i < N - 1;i++) {
        if(same(i,i + 1) == false) {
            ret = false;
        }
    }
    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define N 100005
using namespace std;
#define low(x) (x&(-(x)))
const int mod=1e9+7;
int dpa[N],dpb[N];
int va[N],vb[N];
vector<int> posA,posB;//position were is not 0
int init;
int sum(int *x,int k){
	int ret=0;
	for(;k;k-=low(k)) ret=(ret+x[k])%mod;
	return ret;
}
void add(int *x,int k,int val){
	for(;k<N;k+=low(k)) x[k]=(x[k]+val)%mod;
}
void addtoA(int pos,int val){
	va[pos]=(va[pos]+val)%mod;posA.push_back(pos);add(dpa,pos,val);
}
void addtoB(int pos,int val){
	vb[pos]=(vb[pos]+val)%mod;posB.push_back(pos);add(dpb,pos,val);
}
void clearA(){
	for(int i=0;i<posA.size();i++){
		int x=posA[i];add(dpa,x,-va[x]);va[x]=0;
	}
	posA.clear();
}
void clearB(){
	for(int i=0;i<posB.size();i++){
		int x=posB[i];add(dpb,x,-vb[x]);vb[x]=0;
	}
	posB.clear();
}

int n;
long long A,B,s[N],lastA[N],lastB[N];
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	for(int i=1;i<=n;i++) scanf("%lld",&s[i]);
	
	int p=0;
	for(int i=1;i<=n;i++){
		while(s[p+1]+A<=s[i]) p++;
		lastA[i]=p;
	}
	p=0;
	for(int i=1;i<=n;i++){
		while(s[p+1]+B<=s[i]) p++;
		lastB[i]=p;
	}
	
	addtoA(1,1);
	for(int i=1;i<=n;i++){
		int tempA=sum(dpa,lastA[i]+1),tempB=sum(dpb,lastB[i]+1);
		if(lastA[i]!=i-1) clearB();
		if(lastB[i]!=i-1) clearA();
		addtoB(i,tempA);addtoA(i,tempB);
	}
	
	int ans=((sum(dpa,n)+sum(dpb,n))%mod+mod)%mod;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 5108
/* 
    Author : Jeff Ahn
    Fri 19 Jun 2020 05:04:39 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
int pre[12][1010];
string g[12];
int R, C, k;

inline int get(int r1, int c1, int r2, int c2) {
  return pre[r2][c2] - pre[r1][c2] - pre[r2][c1] + pre[r1][c1];
}

signed main() {
  fastio;
  cin >> R >> C >> k;
  
  rep(r, R) { 
    cin >> g[r];
    rep(c,  C) {
      g[r][c] -= '0';
    }
  }

  memset(pre, 0, sizeof(pre));
  rep(r, R) { 
    rep(c, C) {
      pre[r + 1][c + 1] = pre[r][c+1] + pre[r+1][c] - pre[r][c] + g[r][c];
    }
  }

  int res = 0x3f3f3f3f;
  for (int tri = 0; tri < (1 << (R-1)); tri++) {
    vector<int> segs;
    int cuts = 0;
    segs.pb(0);
    for (int r = 0; r < R-1; r++) {
      if (tri & (1 << r)) {
        segs.pb(r + 1);
        cuts++;
      }
    }
    segs.pb(R);
    //for (auto c : segs) cout << c << " "; cout << endl;
    bool badd = false;
    int vcut = 0;
    for (int c = 1; c <= C; c++) {
      bool bad = false;
      for (int hcut = 0; hcut + 1 < segs.size(); hcut++) {
        /* cout << "(" << segs[hcut] << ", " <<  vcut << ") ";
        cout << "( " << segs[hcut + 1] << ", " << c << ") " << endl;
        */
        assert(segs[hcut] < segs[hcut + 1]);
        int cnt = get(segs[hcut], vcut, segs[hcut + 1], c);
        //cerr << cnt << endl;
        if (cnt > k) {
          bad = true;
          break;
        }
      }
      if (bad && c - vcut <= 1) {
        badd = true;
        break;
      } 
      else if (bad) {
        vcut = c - 1;
        c--;
        // cout << vcut << " " << c << endl;
        cuts++;
      }
    }
    if (!badd)
      res = min(res, cuts);
  }
  cout << res << endl;
}


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

using namespace std;

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

int main(void)
{
	int n, m;
	while(1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<vector<int>> data(1261, vector<int>(m + 1, 0));
		int r;
		cin >> r;
		int b;
		vector<int> a(r), t(r), s(r);
		rep(i, r) cin >> t[i] >> b >> a[i] >> s[i];
		int p = 0;
		for (int k = 540; k <= 1260; k++) {
		   data[k] = data[k - 1];
		   while(k - 1 == t[p]) {
			   if (s[p]) data[k][a[p]]++;
			   else data[k][a[p]]--;
			   p++;
		   }
		}
		int q;
		cin >> q;
		rep(i, q) {
			int tstart, tend;
			cin >> tstart >> tend;
			int l;
			cin >> l;
			int ans = 0;
			for (int k = tstart + 1; k <= tend; k++) {
				if (data[k][l]) {
					ans++;
					// cout << " " << k << endl;
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 50564
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    long long n;
    cin >> n;
    string type;
    double money,ans=0;
    for(int i=0; i<n; i++){
        cin >> money >> type;
        ans+=(type=="JPY"?1:380000)*money;
    }
    printf("%.8f\n",ans);
    return 0;
}


Measured memory_bytes: 256
# abc 137
n = int(input())
l = list(map(int,input().split()))
mx = l[0]
for i in range(1,n):
    if mx <= l[i]:
        mx = l[i]
    elif mx == l[i] + 1:
        mx = l[i] + 1
    elif mx > l[i] + 1:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 63856
"""
n = int(input())*100
x = n%108

if x <=12:
	print(n//108)
else:
	print(":(")
	"""
a = []
for i in range(2):
	a.append(list(map(int,input().split())))
if a[0][0] is not a[1][0]:
	print("1")
else:
	print("0")

Measured memory_bytes: 2940
#include <iostream>
#include <map>
using namespace std;
map<long long,int> mp;
int main(){
    long long i,n; cin >> n;
    int ans = 0;
    for(i=2;i*i<=n;i++){
        while(n%i==0){
            n /= i;
            mp[i]++;
        }
    }
    if(n!=1) mp[n]++;
    for(auto x:mp){
        int y = x.second;
        for(i=1;i<=60;i++){
            y -= i;
            if(y<0) break;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n, k;
	cin >> n >> k;
	cin >> s;
	s[k-1] -= 'A' - 'a';
	cout << s;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int h,w;
while(1){
scanf("%d %d",&h,&w);if(h==0&&w==0)break;
int d=h*h+w*w;
int max=d+1;
int n[151][4]={};
for(int i=1;i<151;i++)
for(int j=i+1;j<151;j++){
	if(i*i+j*j==d&&i>h){n[i][0]=i*i+j*j;n[i][1]=i;n[i][2]=j;break;}
else if(i*i+j*j>d){n[i][0]=i*i+j*j;n[i][1]=i;n[i][2]=j;break;}
}
//printf("%d",n[4][0]);
for(int i=1;i<151;i++)
for(int j=150;j>i;j--)
if(n[j][0]<n[j-1][0]){
	int t=n[j-1][0];n[j-1][0]=n[j][0];n[j][0]=t;
	int tt=n[j-1][1];n[j-1][1]=n[j][1];n[j][1]=tt;
	int ttt=n[j-1][2];n[j-1][2]=n[j][2];n[j][2]=ttt;
}
for(int i=1;i<151;i++)
for(int j=150;j>i;j--)
if(n[j][0]==n[j-1][0]&&n[j][1]<n[j-1][1]){
	int t=n[j-1][0];n[j-1][0]=n[j][0];n[j][0]=t;
	int tt=n[j-1][1];n[j-1][1]=n[j][1];n[j][1]=tt;
	int ttt=n[j-1][2];n[j-1][2]=n[j][2];n[j][2]=ttt;
}


int xx=0,xxx=0;
for(int i=1;i<151;i++)
	if(n[i][0]!=0){xx=n[i][1];xxx=n[i][2];break;}
printf("%d %d\n",xx,xxx);
}
return 0;
}

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

typedef long long ll;

ll const MOD = 1000000007;

ll mult(ll a, ll b){
    return ( (a%MOD) * (b%MOD) ) % MOD;
}

ll fExp(ll b, ll e){
    if (e == 0) return 1;
    if (e == 1) return b;
    ll x = fExp(b, e/2);
    if (e & 1) return mult(b, mult(x, x));
    return mult(x,x);
}

ll inv(ll num){
    return fExp(num, MOD-2);
}

ll fat(ll x){
    ll resp = 1;
    for (ll i=1; i<=x; i++) resp = mult(resp, i);
    return resp;
}

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

    ll x,y;
    cin >> x >> y;
    if ( (x + y)%3 != 0 || min(x,y)*2 < max(x,y)){
        cout << "0\n";
        return 0;
    }

    ll a = (x+y)/3;
    ll b = (a*2) - max(x,y);

    ll num = fat(a);
    ll den = mult(fat(b), fat(a - b));

    ll resp = mult(num, inv(den));
    cout << resp << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  string s;
  cin >> s >> k;
  int start = 1;
  for (int i = 0; i < (int) s.size(); i++) {
    if (s[i] == '1') {
      continue;
    }
    start = i + 1;
    break;
  }
  if (k < start) {
    cout << 1 << '\n';
    return 0;
  }
  cout << s[start - 1] << '\n';
  return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
l = [[int(i) for i in input().split()] for j in range(M)]

middles1 = []
middles2 = []
ans = "IMPOSSIBLE"

for i in l:
    if i[0] == 1 and i[1] == N:
        ans = "POSSIBLE"
    elif i[0] == 1:
        middles1.append(i[1])
    elif i[1] == N:
        middles2.append(i[0])

if len(set(middles1) & set(middles2)) > 0:
    ans = "POSSIBLE"

print(ans)


Measured memory_bytes: 48584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

using namespace std;

vector<int> z_func(string &s) {
    int n = (int) s.size();
    vector<int> ret(n, 0);
    int l = 0;
    int r = -1;
    for (int i = 1; i < n; ++i) {
        if (l <= i && i <= r) {
            ret[i] = min(r - i + 1, ret[i - l]);
        }
        while (ret[i] + i < n && s[i + ret[i]] == s[ret[i]]) {
            ret[i]++;
        }
        if (i + ret[i] - 1 >= r) {
            l = i;
            r = i + ret[i] - 1;
        }
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int s, w;
    cin >> s >> w;
    if (s > w) {
        cout << "safe\n";
    } else {
        cout << "unsafe\n";
    }
    return 0;
}


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

int main()
{
	int a[5],k;
	for(int i=0; i<5; i++)
		cin>>a[i];
	cin>>k;
	int flag=1;
	for(int i=0; i<5; i++)
		for(int j=0; j<5; j++)
			if(abs(a[i]-a[j])>k)
			{
				flag=0;
				break;
			}
	if(flag)
		printf("Yay!\n");
	else
		printf(":(\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
 
using namespace std;
 
typedef long long LL;
typedef unsigned int UI;
 
#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
 
#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;
 
 
int main(int argc, const char * argv[]) {
 
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	LL A,B;
	LL ans = 0;
 
	cin >> A >> B;
 
	if(A>=13){
		ans=B;
	}else if(A>=6 && A<=12){
		ans = B/2;
	}else{
		ans=0;
	}
 
	cout << ans << endl;
 
	return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <deque>

using namespace std;

typedef long long ll;

int cnt[26];
int main() {
	string S;
	cin >> S;
	for (char c : S) {
		cnt[c - 'a']++;
	}
	ll res = 0;
	for (int i = 0; i < 26; i++) {
		for (int j = i + 1; j < 26; j++) {
			res += (ll)cnt[i] * cnt[j];
		}
	}
	res++;
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 640
import itertools

N,M=map(int,input().split())
sw=[list(map(int,input().split())) for _ in range(M)]
p=[int(x) for x in input().split()]
ans=0

for i in itertools.product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in sw[j][1:]:
            j_on_cnt+=i[k-1]
        if j_on_cnt%2!=p[j]:
            ok=False
            break
    if ok:
        ans+=1
print(ans)

Measured memory_bytes: 3064