akhauriyash/Code-Regression huggingface dataset:
def main():
  N, K, C=map(int, input().split())
  S = input()[::-1]
  
  R=[0]*K
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      R[k]=N-n
      k+=1
      n += C
    n+=1
  R=R[::-1]
  
  S=S[::-1]
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 == R[k]:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  
if __name__=='__main__':
  main()


Measured memory_bytes: 18200
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/


/*
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
*/

int main(){
    string s;
    int k;
    cin >> s;
    cin >> k;
    vector<string> subs;
    for(int i=0;i<k;i++){
        for(int j=0;j<s.size()-i;j++){
            subs.push_back(s.substr(j,i+1));
        }
    }
    sort(subs.begin(),subs.end());
    subs.erase(unique(subs.begin(),subs.end()),subs.end());//sortとuniqueで重複要素を消す
    cout<<subs[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    vector<ll> res;
    ll base = 1;
    auto s = [](ll n) -> ll {
        ll res = 0;
        while (n > 0) {
            res += n % 10;
            n /= 10;
        }
        return res;
    };
    auto f = [&s](ll n) -> double { return (double)(n) / s(n); };

    for (int i = 0; i < 15; ++i) {
        for (int j = 1; j < 150; ++j) {
            res.push_back(base * (j + 1) - 1);
        }
        base *= 10;
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    for (ll i = 0; i < (ll)res.size(); i++) {
        for (ll j = i + 1; j < (ll)res.size(); j++) {
            if (f(res[i]) > f(res[j])) {
                res.erase(res.begin() + i--);
                break;
            }
        }
    }
    rep(i, K) { cout << res[i] << endl; }

    return 0;
}

Measured memory_bytes: 384
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
 
a = int(input())
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

Measured memory_bytes: 2940
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, count ;
  long long int ans = 0 ;
  cin >> N ;
  long long int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  sort(A,A+N) ;
  int now = N - 1 ;
  for(int i=0;i<N-1;i++){
    if(i % 2 == 1){
      now-- ;
    }
    ans += A[now] ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n,m;
    cin>>n>>m;

    ll ans=0;
    if(2*n<=m){
        ans+=n;
        m-=2*n;
        ans+=m/4;
    }
    else{
        ans+=m/2;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll n,i,ara[100009];
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&ara[i]);
    }
    sort(ara,ara+i);
    if(ara[n/2]==ara[n/2+1])
    {
        printf("0\n");
    }
    else
    {
        printf("%lld\n",ara[n/2+1]-ara[n/2]);
    }
    return 0;
}

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

#define N_MAX 256
#define L_MAX 10

char ids[N_MAX][L_MAX+1];

int main(void)
{
    int n, m, i, opened = 0; char buf[L_MAX+1];

    scanf("%d%*c", &n);
    for(i=0; i<n; i++) gets(ids[i]);

    scanf("%d%*c", &m);
    while(m--)
    {
        gets(buf);

        for(i=0; i<n; i++)
            if(!strcmp(buf, ids[i]))
            {
                printf("%s %s\n",
                       (opened = !opened)? "Opened by": "Closed by",
                       buf);
                break;
            }

        if(i==n) printf("Unknown %s\n", buf);
    }

    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define endl "\n"
const int mod = 1e9+7;
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int power(int a,int b){ int res=1; a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

int main()
{	
	sync
	int n;
	cin >> n;
	ll a[n][3];
	for(int i = 0; i < n; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	for(int i = 1; i < n; i++)
	{
		a[i][0] += max(a[i-1][1], a[i-1][2]);
		a[i][1] += max(a[i-1][0], a[i-1][2]);
		a[i][2] += max(a[i-1][0], a[i-1][1]);
	}
	cout << max(max(a[n-1][0], a[n-1][1]), a[n-1][2]);
	return 0;
}

Measured memory_bytes: 2560
import itertools
import math

N = int(input())
Fac = math.factorial(N)
x = []
y = []
X = []
Y = []
leng = []
tmp = 0
for i in range(N):
    tmp = list(map(int,input().split()))
    x.append(tmp[0])
    y.append(tmp[1])
for i in itertools.permutations(x):
    X.append(i)
for i in itertools.permutations(y):
    Y.append(i)
for i in range(Fac):
    try:
        leng.append(((((X[i][0]-X[i][1]) ** 2) + ((Y[i][0]-Y[i][1]) ** 2)) ** 0.5))
    except:
        pass
tmp = 0
for i in range(Fac):
    tmp += leng[i]
tmp *= (N-1)
ans = tmp / Fac
print(ans)

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

int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(s==u){
    cout<<a-1<<" "<<b;
  }else{
    cout<<a<<" "<<b-1;
  }
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
  
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

ll f(ll a, ll b) {
    ll cnt = (a - 1);
    b -= (a - 1);
    a = 1;
    cnt++;
    b--;
    cnt += (b - a) / 2;
    return cnt;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) {
        cout << (b - a) / 2 << "\n";
    } else {
        cout << min(f(a, b), f(n - b + 1, n - a + 1)) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    inp = []
    for i in range(n):
        inp.append(list(input()))
    
    sq_max = [[0 for i in range(n + 1)] for j in range(n + 1)]
    
    for y in range(n):
        for x in range(n):
            if inp[y][x] == ".":
                sq_max[y + 1][x + 1] = min(sq_max[y][x + 1], sq_max[y + 1][x], sq_max[y][x]) + 1
            else:
                sq_max[y + 1][x + 1] = 0
    ans = max(map(max, sq_max))
    print(ans)



Measured memory_bytes: 49748
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
}


Measured memory_bytes: 21844
// https://atcoder.jp/contests/abc097/tasks/arc097_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int l, K;
char f;
string c, s;
set<string> p;
set<char> sc;

int main()
{
  cin >> s >> K;
  l = s.length();
  REP(i, l)
  {
    sc.insert(s[i]);
  }

  for (auto &scc : sc)
  {
    if (K <= p.size())
      break;
    REP(i, l)
    {
      if (s[i] == scc)
      {
        FOR(j, 1, min(l - i, K) + 1)
        {
          p.insert(s.substr(i, j));
        }
      }
    }
  }

  int i = 0;
  for (auto &q : p)
  {
    i++;
    if (i == K)
    {
      cout << q << '\n';
      break;
    }
  }

  return 0;
}


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

using ll = long long;
const ll INF = (ll)1e18 + 9;

int main()
{
  ll N, K;
  std::cin >> N >> K;

  std::vector<ll> vh(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vh[i];
  }

  std::sort(vh.begin(), vh.end());

  ll ans = INF;
  for (ll i = 0; i < N - K + 1; i++) {
    ans = std::min(ans, vh[K+i-1] - vh[i]);
  }

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


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

typedef long long ll;
const int maxn = 2e5 + 3;
const ll mo = 1e9 + 7;

int n, m, p[maxn], clk, lk[maxn], la[maxn], lr[maxn], d[maxn], cs[maxn];
ll ans;
std::vector<int> E[maxn];
std::vector<int> dla[maxn];

void dfs(int u) {
    la[u] = clk;
    lk[clk++] = u;
    dla[d[u]].push_back(la[u]);
    int cd12 = (p[u] ? 1 : 0) + (p[p[u]] ? 1 : 0) + cs[p[u]];
    if(cd12 >= m) {
        puts("0");
        exit(0);
    }
    ans = ans * ll(m - cd12) % mo;
    for(auto &&v : E[u]) {
        if(v == p[u])
            continue;
        p[v] = u;
        d[v] = d[u] + 1;
        dfs(v);
        cs[u] += 1;
    }
    lr[u] = clk;
}

int main() {
    ans = 1;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        E[u].push_back(v);
        E[v].push_back(u);
    }
    dfs(1);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 22272
n=int(input())
a=list(map(int,input().split()))
rgb=[0,0,0]

res=1
for each in a:
  res*=rgb.count(each)
  if rgb[0] == each: rgb[0] += 1
  elif rgb[1] == each: rgb[1] += 1
  elif rgb[2] == each: rgb[2] += 1
  res %= 1000000007
print(res)

Measured memory_bytes: 52908
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,k,x,y;
    vector<ll>u,v,w;
    map<ll,ll>m,mp;
    set<ll>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    for(i=0;i<n;i++)
    {
        u.push_back(i+1+v[i]);
        s.insert(i+1+v[i]);
        w.push_back((i+1)-v[i]);
    }
    for(i=0;i<n;i++)
    {
        m[u[i]]++;
        mp[w[i]]++;
    }
    ll sum=0;
    for(auto p:s)
    {
       if(m[p]!=0&&mp[p]!=0)
       {
           sum+=m[p]*mp[p];
       }
    }
    cout<<sum<<endl;

    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int mean = (a+b) / 2;
    int amari = (a+b) % 2;
    if(amari == 0) cout << mean << endl;
    else cout << mean + 1 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(void) {
  string str;
  int k;
  set<string> s;
  cin >> str >> k;
  for (int i = 1; i <= 100; i++) {

    for (int j = 0; j < str.length(); j++) {
      
      if (str.length() - j < i)
        continue;
      s.insert(str.substr(j, i));
    }
  }
  auto itr = s.begin();
  if (k != 1) {
    for (int i = 0; i < k - 1; i++) {
      ++itr;
    }
  }

  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 66560
import copy

S = input()
K = int(input())
S_list = list(S)

if len(S_list) == 1:
    print(K//2)
else:
    for i in range(1, len(S_list)):
        if S_list[i-1] == S_list[i]:
            S_list[i] = "change"
    S1_count = S_list.count("change")

    if S_list[0] == S_list[-1]:
        S2_list = list(S)
        S2_list[0] = "change"
        for i in range(1, len(S2_list)):
            if S2_list[i-1] == S2_list[i]:
                S2_list[i] = "change"
        S2_count = S2_list.count("change")
        if S2_list[-1] == S_list[0]:
            print(S1_count + (K-1)*S2_count)
        else:
            print((((K//2)+1)*S1_count) + ((K//2)*S2_count))
    else:
        print(K * S1_count)

Measured memory_bytes: 3444
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

use rand::prelude::*;

const CN: usize = 26;

fn calc(cv: &[isize], sv: &[Vec<isize>], tv: &[usize]) -> isize {
    let mut last = vec![0; CN];
    let mut res = 0;
    for i in 0..sv.len() {
        let t = tv[i];
        res += sv[i][t];
        last[t] = i + 1;
        for j in 0..CN {
            res -= cv[j] * (i + 1 - last[j]) as isize;
        }
    }
    res
}

fn main() {
    input! {
        d: usize,
        cv: [isize; CN],
        sv: [[isize; CN]; d],
    };

    let mut rng = rand::thread_rng();
    let mut tv = (0..d)
        .into_iter()
        .map(|_| rng.gen::<usize>() % CN)
        .collect::<Vec<_>>();
    let mut res = calc(&cv, &sv, &tv);
    for _ in 0..10000 {
        let di = rng.gen::<usize>() % d;
        let q = rng.gen::<usize>() % CN;
        let old = tv[di];
        tv[di] = q;
        let p = calc(&cv, &sv, &tv);
        if p > res {
            res = p;
        } else {
            tv[di] = old;
        }
    }
    println!("{}", tv.into_iter().map(|x| x + 1).join("\n"));
}


Measured memory_bytes: 2764
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) throws Exception {
		Main main = new Main();
		main.run();
	}

	void run() {
		int n = in.nextInt();
		List<Integer> nums = in.nextIntList(n);
		int[] a = nums.stream().map(i -> new int[]{i, Integer.MIN_VALUE, Integer.MAX_VALUE})
				.reduce(new int[]{Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE},
						(ints, integer) -> new int[]{Math.max(ints[0], integer[0] - ints[1]), Math.min(ints[1], integer[0])});
		System.out.println(a[0]);
	}
}

class FastReader {
	private InputStream in = System.in;
	private byte[] buf = new byte[1024];
	private int charNum;
	private int charLen;
	private StringBuilder sb = new StringBuilder();

	public int read() {
		if (charLen == -1)
			throw new InputMismatchException();
		if (charNum >= charLen) {
			charNum = 0;
			try {
				charLen = in.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (charLen <= 0)
				return -1;
		}
		return buf[charNum++];
	}

	public String next() {
		int c = read();
		while (isWhitespace(c)) {
			c = read();
		}
		sb.setLength(0);
		do {
			sb.appendCodePoint(c);
			c = read();
		} while (!isWhitespace(c));
		return sb.toString();
	}

	public char[] nextCharArray() {
		return next().toCharArray();
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int[] nextIntArray(int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++)
			array[i] = nextInt();
		return array;
	}

	public List<Integer> nextIntList(int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++)
			array[i] = nextInt();
		return Arrays.asList(array);
	}

	public int[][] nextIntArray2D(int n, int m) {
		int[][] array = new int[n][m];
		for (int i = 0; i < n; i++)
			array[i] = nextIntArray(m);
		return array;
	}

	public List<int[]> nextIntsList(int n, int m) {
		List<int[]> list = new ArrayList<int[]>(n);
		for (int i = 0; i < n; i++)
			list.add(nextIntArray(m));
		return list;
	}

	public long nextLong() {
		int c = read();
		while (isWhitespace(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isWhitespace(c));
		return res * sgn;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public double[] nextDoubleArray(int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++)
			array[i] = nextDouble();
		return array;
	}

	public boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int i=-1,c=0,max=-2590;
    while(s[++i]!='\0'){

        if (s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){

            c++;

        }
        else{

            if (c>max)max=c;
            c=0;

        }

    }
    if (c>max)max=c;

    cout<<max<<endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
 
int m,ans;
string s;
int a[30];
vector<int> v;
bool f;
 
int stoi(string s){
  int res=0,k=1;
  for(int i=(int)s.size()-1;i>=0;i--){
    res += k*(s[i]-'0');
    k *= 10;
  }
  return res;
}
 
int parse(string s){
  //cout << ans << " " << s << endl;
  if(f)return 0;
  if(s[0]=='(')return parse(s.substr(1,(int)s.size()-2));
  if('A'<=s[0] && s[0] <= 'Z'){
    if(s.size()>1 && s[1] == '='){
      int tmp = parse(s.substr(2,(int)s.size() - 2));
      if(tmp==-1)return -1;
      a[s[0]-'A'] = tmp;
      return tmp;
    }else if(s.size()==1){
      return a[s[0]-'A'];
    }else{
      v.push_back(-2);
      return (int)v.size()-1;
    }
  }else{
    if(s[0] == 'm'){
      int tmp = stoi(s.substr(7,(int)s.size()-8));
      if(ans+tmp>m)tmp = 0;
      v.push_back(tmp);
      ans += tmp;
      return (int)v.size()-1;
    }else if(s[0] == 'c'){
      int tmp = parse(s.substr(6,(int)s.size()-7));
      if(tmp==-1 || v[tmp]==-1)return -1;
      if(v[tmp]==-2){
    f = true;
    return 0;
      }
      if(ans+v[tmp]<=m){
    v.push_back(v[tmp]);
    ans += v[tmp];
      }else{
    v.push_back(0);
      }
      return (int)v.size()-1;
    }else{
      int tmp = parse(s.substr(5,(int)s.size()-6));
      if(tmp==-1 || v[tmp]==-1)return -1;
      if(v[tmp]==-2){
    f = true;
    return 0;
      }
      ans -= v[tmp];
      v[tmp] = -1;
      return 0;
    }
  }
}
 
int main(){
  cin >> m;
  ans = 0;
 
  for(int i=0;i<26;i++)a[i] = 0;
  v.clear(); v.push_back(-1);
 
  while(cin >> s){
    f = false;
    if(parse(s)<0){
      cout << "Error\n";
      return 0;
    }
  }
 
  //cout << ans << endl;
  set<int> s;
  for(int i=0;i<26;i++)s.insert(a[i]);
  for(set<int>::iterator it=s.begin();it!=s.end();it++)
    if(v[(*it)]>0)ans -= v[(*it)];
 
  cout << ans << endl;
}

Measured memory_bytes: 1256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string s;
	cin>>s;
	cout<<"2018"<<s.substr(4)<<endl;
}


Measured memory_bytes: 256
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    a, b, x = map(int, input().split())
    print(b//x-((a-1)//x))
 
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#C bit
import numpy as np

N, M, X = list(map(int, input().split()))
C = []
A = np.zeros((N, M), dtype=int)

for i in range(N):
    temp = list(map(int, input().split()))
    C.append(temp[0])
    A[i, :] = temp[1:]

result = -1
for i in range(1 << N):
    reading_books = np.zeros((M), dtype=int)
    cost = 0
    for j in range(N):
        if not (i >> j) & 1:
            continue
        cost += C[j]
        reading_books += A[j, :]
    if all(reading_books >= X):
        if result == -1:
            result = cost
        else:
            result = min(cost, result)


print(result)

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

using namespace std;
#define DIM  107
#define DIM2 2097152
#define INF 10E16
#define MAXN 107
#define LG 18
#define MODULO 1000000007
typedef long long  ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pll parr[DIM];
//typedef ll table[DIM][DIM2];
//typedef ll arr2[DIM2];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};
ll n,A[DIM][DIM],D[DIM2],P[22];
ll F(ll mask) {
    if (D[mask]!=-1)return D[mask];
    ll num = __builtin_popcount(mask),res = 0;
    ll mask2 = mask;
    ll man = 1;
    while(mask2>0){
        ll r= mask2%2,x = P[man-1];
        mask2/=2;
        if (r==1 && A[num][man]==1)
            res+=F(mask-x);
        res%=MODULO;
        man++;
    }
    D[mask] = res;
    return res;
}
int main()

{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)cin >> A[i][j];
	ll mask = 0;
	for (int i = 0; i < n; i++) {
		mask += pow(2, i);
		P[i] = pow(2,i);
	}
	memset(D,-1,sizeof(D));
	D[0] = 1;
	cout << F(mask) << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define sz(x) (int)x.size()
#define db(x) cerr << #x << ": " << x << "\n";

int N, M, X;
int L[15][15];
int R[15];

int solve(int ind, int sol) {
    if(ind >= N) {
        bool val = true;
        for(int i=1; i<=M; i++) {
            if(R[i] < X)
                val = false;
        }
        return val ? sol : INT_MAX;
    } else {
        int r1 = solve(ind+1, sol);

        for(int i=1; i<=M; i++)
            R[i] += L[ind][i];
        int r2 = solve(ind+1, sol+L[ind][0]);
        for(int i=1; i<=M; i++)
            R[i] -= L[ind][i];

        return min(r1, r2);
    }
}

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

    cin >> N >> M >> X;

    for(int i=0; i<N; i++) {
        cin >> L[i][0];
        for(int j=1; j<=M; j++)
            cin >> L[i][j];
    }

    int r = solve(0, 0);
    cout << (r == INT_MAX ? -1 : r) << '\n';
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <bitset>
#include <limits>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
// all_of

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#endif

int N;
LL A[50];
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
		A[i] -= N - 1;
	}

	LL ans = 0;
	LL* it;
	while (it = max_element(A, A + N), *it > 0) {
		LL P = (*it - 1) / N + 1;
		REP(i, 0, N) {
			if (&A[i] == it) {
				A[i] -= P * N;
			} else {
				A[i] += P;
			}
		}
		ans += P;
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

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

char _left[] = "qwertasdfgzxcvb";


int main()
{
	string str;
	while(cin >> str,str != "#")
	{
		int ans = 0;
		int hand = -1;
		REP(i,str.size())
		{
			bool flag = false;
			REP(j,15)
			{
				if(str[i] == _left[j])
				{
					if(hand == 0)
					{
						ans++;
					}
					hand = 1;
					flag = true;
				}
			}
			if(!flag)
			{
				if(hand == 1)ans++;
				hand = 0;
			}
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i, s, t) for(re int i = s; i <= t; ++ i)
#define drep(i, s, t) for(re int i = t; i >= s; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
int n, m, a[maxn];
il bool cmp(int a, int b) {
	return a > b;
}
il int doit(int x, int y) {
	int ans = 0;
	while(a[x + 1] == y) ans ^= 1, ++ x;
	return ans;
}
int main() {
	//file(a);
	n = read();
	rep(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1, cmp);
	int nx = 0;
	while(1) {
		if(a[nx + 1] < nx + 1) break;
		++ nx;
	}
	if(((a[nx] - nx) & 1) || doit(nx, nx)) printf("First");
	else printf("Second");
	return 0;
}

Measured memory_bytes: 640
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        a:[i64;n],
    }
    //
    //奇数は偶数個
    let mut odds = a.iter().filter(|&x| x % 2 == 1).count();
    yn(odds % 2 == 0);
}
pub fn yn(ans: bool) {
    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main()
{
    int i, j, n, k;
    cin >> n >> k;
    long long int dp[n + 2], a[n + 2];
    for (i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (i = 2; i < n; i++)
    {
        dp[i] = 100000000000;
        for (j = i-1; j >= i - k; j--)
        {      if(j>=0)
            { dp[i] = min(dp[i], dp[j] + max(a[i]-a[j],a[j]-a[i])); }
        }
    }
   // for(i=0; i<n; i++)
    cout << dp[n-1]<<" ";

    return (0);
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c;
int main() {
    cin >> a >> b >> c;
    if (c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  rep(i,5) scanf("%d",&a[i]);
  rep(i,5){
    if(a[i]==0) printf("%d\n",i+1);
  }
  
  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  

vector<int>v,cost;
int n,k;

lli func(int si)
{
    vector<bool>vis(n,false);
    vector<int>p;
    while(!vis[si])
    {
        vis[si]=true;
        p.push_back(si);
        si=v[si];
    }
    vector<int>p1;
    int f=0;
    for(int i=0;i<p.size();i++)
    {
        if(f==1)
            p1.push_back(p[i]);
        else
        {
            if(p[i]==si)
            {
                f=1;
                p1.push_back(p[i]);
            }   
        }
    }
    p.erase(p.begin());
    vector<lli>cum;
    lli t=0;
    for(int i=0;i<p.size();i++)
    {
        t+=cost[p[i]];
        cum.push_back(t);
    }
    lli ans=cum[0];
    if(k<=cum.size())
    {
        for(int i=1;i<k;i++)
            ans=max(ans,cum[i]);
        return ans;
    }
    k-=p.size();
    lli prev=cum[0],curr=cum[cum.size()-1];
    //cout << "curr=" << curr << endl;
    for(int i=0;i<cum.size();i++)
        prev=max(prev,cum[i]);
    cum.clear();
    t=0;
    p=p1;
    for(int i=0;i<p.size();i++)
    {
        t+=cost[p[i]];
        cum.push_back(t);
    }
    ans=cum[0];
    if(k<=cum.size())
    {
        for(int i=1;i<k;i++)
            ans=max(ans,cum[i]);
        return max(prev,curr+ans);
    }
    int l=cum.size();
    if(cum[l-1]<=0)
    {
        for(int i=0;i<l;i++)
            ans=max(ans,cum[i]);
        return max(prev,curr+ans);
    }
    int q=k/l,r=k%l;
    lli a1=q*cum[l-1];
    if(r>0)
    {
        lli t=cum[0];
        for(int i=0;i<r;i++)
            t=max(t,cum[i]);
        a1+=t;
    }
    lli a2=(q-1)*cum[l-1];
    t=cum[0];
    for(int i=0;i<l;i++)
        t=max(t,cum[i]);
    a2+=t;
    return max(max(prev,curr+a1),curr+a2);
}

int main()
{
    cin >> n >> k;
    int k1=k;
    v.resize(n);
    cost.resize(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        v[i]-=1;
    }
    for(int i=0;i<n;i++)
        cin >> cost[i];
    lli ans=func(0);
    for(int i=1;i<n;i++)
    {
        k=k1;
        ans=max(ans,func(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n),b(n);
 vector<mp> c(n);
 for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
 for(ll i=0;i<n;i++) c[i] = mp(a[i],b[i]);
 sort(a.begin(),a.end() );
 sort(b.begin(),b.end() );
 if( n%2 == 1 ){
  ll left = a[n/2];
  ll right = b[n/2];
  cout<<right-left+1<<endl;
 }else{
  ll leftl = a[(n-1)/2];
  ll leftr = a[n/2];
 // double aa =  ( (double)(leftl+leftr) )/2;
  ll rightl = b[(n-1)/2];
  ll rightr = b[n/2];
  //double bb = ( (double)(rightr+rightl) )/2;
  //cout<< (ll)( (bb-aa)*2 ) + 1 <<endl;
  cout<<rightr+rightl-leftr-leftl+1<<endl;
 }

    return 0;
}


Measured memory_bytes: 9592
from itertools import product
import numpy as np

n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
ca = np.array(ca)

ans = 10**7
for buy in product(range(2),repeat = n):
    
    buy = np.array(buy)
    judge = (np.dot(buy,ca[:,1:]) >= x).all()
    if judge:
        ans = min(ans, np.dot(ca[:,0],buy))
    
if ans == 10**7: ans = -1
print(ans)

Measured memory_bytes: 27296
package main

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

var (
	N int
	a []int
)

// var w = bufio.NewWriter(os.Stdout)

func main() {
	readVariables()
	dfs(a, -1, 0)
	// print(a)
}

func dfs(arr []int, depth int, max int) {
	if depth == N-1 {
		print(arr)
		return
	}
	for i := 0; i <= max; i++ {
		arg := make([]int, N)
		copy(arg, arr)
		arg[depth+1] = i
		// fmt.Println(arg)
		if i < max {
			dfs(arg, depth+1, max)
		} else {
			dfs(arg, depth+1, max+1)
		}
	}
}

func print(arr []int) {
	// fmt.Println(arr)
	b := make([]byte, len(arr))
	for i := 0; i < len(arr); i++ {
		b[i] = byte('a' + arr[i])
	}
	fmt.Println(string(b))
}

func readVariables() {
	N = nextInt()
	a = make([]int, N)
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 5760
# 集合の要素の管理は不要
# ある値がどこに属しているかが把握できれば良い
class Set
	attr_writer :overwrite

	def head
		return self unless @overwrite

		t = @overwrite.head
		@overwrite = t if t
		return @overwrite
	end
end

n, q = gets.split.map(&:to_i)

affiliation = {}
n.times {|i| affiliation[i] = Set.new}

q.times do
	com, x, y = gets.split.map(&:to_i)
	set_x = affiliation[x].head
	set_y = affiliation[y].head

	case com
	when 0
		unless set_x == set_y
			set_x.overwrite = set_y.overwrite = Set.new
		end
	when 1
		p set_x == set_y ? 1 : 0
	end
end



Measured memory_bytes: 8928
import java.io.BufferedReader;
import java.io.InputStreamReader;
   
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int t = Integer.parseInt(line);
           
         System.out.print(t+":");
           
    while (t % 2 == 0) {
      System.out.print(" ");
      System.out.print(2);
      t /= 2;
    }
    for (int i = 3; i * i <= t; i += 2) {
      while (t % i == 0) {
        System.out.print(" ");
        System.out.print(i);
        t /= i;
      }
    }
    if (t > 1){
    System.out.print(" ");
    System.out.print(t);
              }
    System.out.println();
    }
}

Measured memory_bytes: 24404
import qualified Data.Map as M
import Data.List (sort)
import Control.Monad (replicateM, mapM)

compress :: (Eq a) => [a] -> [[a]]
compress [] = []
compress [x] = [[x]]
compress (x1:xs@(x2:_)) = if x1 == x2 then (x1:y):ys else [x1]:y:ys
    where (y:ys) = compress xs

main = do
    [n, k, q] <- map read . words <$> getLine :: IO [Int]
    a <- map read <$> replicateM q getLine :: IO [Int]
    let cnt = M.fromList . map (\x -> (head x, length x)) . compress $ sort a
    let result = map ((\x -> if x > 0 then "Yes" else "No") . (+ (k-q)) . val .(\x -> M.lookup x cnt)) [1..n]
    mapM putStrLn result
    where
        val (Just x) = x
        val Nothing = 0

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	for(int i = k; i < n; i++){
		if(a[i] > a[i-k]){
			coY();
		} else{
			coN();
		}
	}
}


Measured memory_bytes: 3996
import sys


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

def lcm(x, y):
    return (x * y) // gcd(x, y)

n=list(map(int,input().split()))
s=list(input())
t=list(input())

l=lcm(n[0],n[1])
p=lcm(l//n[0],l//n[1])


i=0
a=p//(l//n[0])
b=p//(l//n[1])
k=min(n[0],n[1])
while (i*a<n[0]) and (i*b<n[1]) :
    if s[i*a]!=t[i*b]:
        print("-1")
        sys.exit()
    i += 1
    
print(l)

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

using namespace std;

constexpr int mk = 100013;

int dp[mk][2];

int other(int player) {
    return (player+1) % 2;
}

void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];

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

    function<int(int, int)> calc_dp = [&] (int pile, int player) {
        if (pile <= 0) {
            return other(player);
        }
        if (dp[pile][player] != -1) {
            return dp[pile][player];
        }

        bool lost = true;
        int best = other(player);
        for (int i = 0; i < n; ++i) {
            if (v[i] <= pile) {
                lost = false;
                if (player == 0) {
                    best = min(best, calc_dp(pile-v[i], other(player)));
                } else {
                    best = max(best, calc_dp(pile-v[i], other(player)));
                }
            }
        }
        if (lost) {
            dp[pile][player] = other(player);
        } else {
            dp[pile][player] = best;
        }

        return dp[pile][player];
    };

    int winner = calc_dp(k, 0);
    if (winner == 0) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }   
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 16868
a=input()
b=input()
if len(a)==len(b):
  if a>b:
    print("GREATER")
  elif a<b:
    print("LESS")
  else :
    print("EQUAL")
else :
  if len(a)>len(b):
    print("GREATER")
  else:
    print("LESS")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll st=1;
  ll ans=0;
  rep(i,n){
    if(a[i]==st){
      st++;
      continue;
    }
    else ans++;
  }
  if(st==1){
    cout << -1 << endl;
  }
  else cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const* argv[]) {
	string S;
	cin >> S;
	vector<string> key = {
			"dreamer",
			"dream",
			"eraser",
			"erase",
		};
	reverse(S.begin(), S.end());
	while (S.length() > 0) {
		bool stringFlag = false;
		for (int i = 0; i < key.size(); i++) {
			bool charFlag = true;
			// cout << "***" << key[i] << endl;
			for (int j = key[i].length() - 1; j >= 0; j--) {
				// cout << S[key[i].length() - j - 1] << " " << key[i][j] << endl;
				if (S[key[i].length() - j - 1] != key[i][j]) {
					charFlag = false;
					break;
				}
			}
			if (charFlag) {
				S = S.substr(key[i].length());
				stringFlag = true;
				break;
			}
		}
		if (!stringFlag) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

int main() {
  int n, ans = 0;
  scanf("%d\n", &n);
  char s[5005]; int a[n][n];
  scanf("%s", s);
  for (int i=0; i<n; i++) {
    a[i][i] = n-i;
  }
  for (int i=0; i<n; i++) {
    int j = i+1, k = 0;
    while (j<n) {
      while (j+k<n && s[i+k]==s[j+k]) k++;
      a[i][j] = k;
      if (k==0) {
        j++;
        continue;
      }
      int l = 1;
      while (j+l<n && l+a[i][l+i]<k) {
        a[i][j+l] = a[i][i+l];
        l++;
      }
      j+=l;
      k-=l;
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      if (a[i][j]>j-i) a[i][j] = j-i;
      ans = (ans < a[i][j]) ? a[i][j] : ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 97792
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let mut a: String = read();
    let mut b: String = read();
    let _a: Vec<char> = a.chars().collect();
    let _b: Vec<char> = b.chars().collect();
    if (a.len() < b.len()) {
        println!("LESS");
    } else if (a.len() > b.len()) {
        println!("GREATER");
    } else {
        let mut great = 0;
        let mut less = 0;
        for i in 0..a.len() {
            if (great > 0 || less > 0) {
                continue;
            }
            if (_a[i] > _b[i]) {
                println!("GREATER");
                great += 1;
            } else if (_a[i] < _b[i]) {
                println!("LESS");
                less += 1;
            }
        }
        if (great == 0 && less == 0) {
            println!("EQUAL");
        }
    }
}


Measured memory_bytes: 2136
n = int(input())
p = [int(input()) for _ in range(n)]

lst = [0] * (n + 1)
for num in p:
    bfo = lst[num - 1]
    if bfo == 0:
        lst[num] = -1
    elif bfo < 0:
        lst[num] = num - 1
        lst[num - 1] -= 1
    elif bfo > 0:
        lst[num] = bfo
        lst[bfo] -= 1
print(n + min(lst))


Measured memory_bytes: 89684