akhauriyash/Code-Regression huggingface dataset:
/*
    飲んだ魔剤で家が建つ。
    created at: 
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];

    map<string, int> memo;
    for (int i = 0; i < n; i++) 
        memo[s[i]]++;

    int maxv = 0;
    for (const auto &x : memo)
        if (maxv < x.second) maxv = x.second;

    for (const auto &x : memo)
        if (maxv == x.second) cout << x.first << endl;

    return 0;
}


Measured memory_bytes: 26752
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        int answer = 0;

        boolean add_flg = true;
        int sum = 0;
        int target = 0;
        for (int i = A; i <= N; i++) {
            sum = 0;
            add_flg = true;
            target = i;

            while (target > 0) {
                sum += target % 10;
                target /= 10;
                if (sum > B) {
                    add_flg = false;
                    break;
                }
            }
            if (add_flg && sum >= A) {
                answer += i;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
class SegTree
  attr_accessor(:node, :op, :e, :offset)
  
  def initialize(n, op, e)
    @op = op
    @e = e

    ofs = 1
    while ofs < n
      ofs <<= 1
    end
    
    @node = Array.new((ofs << 1) - 1, @e) # 0-indexed
    @offset = ofs # log2(n).ceil
  end

  def update(i, x) # 一点更新
    i += @offset - 1
    @node[i] = x
    
    while i > 0
      i = (i - 1) >> 1
      @node[i] = @op.call(@node[(i << 1) + 1], @node[(i << 1) + 2])
    end
  end

  def query(l, r) # [l, r)
    l += @offset - 1
    r += @offset - 1

    res = @e
    while l < r
      if l & 1 == 0
        res = @op.call(res, @node[l])
      end
      if r & 1 == 0
        res = @op.call(res, @node[r - 1])
      end
      l = l >> 1
      r = (r - 1) >> 1
    end
    return res
  end
end

m = 3 * (10 ** 5)
chmax = -> (x, y) { (x > y)? x : y }
n, k = $stdin.readline.chomp.split.map(&:to_i)
seg = SegTree.new(m + 1, chmax, 0)

res = 0
n.times do
  a = $stdin.readline.to_i
  l = [0, a - k].max
  r = [m, a + k].min
  t = seg.query(l, r + 1) + 1
  res = (res < t)? t : res
  seg.update(a, t)
end
puts res


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

using namespace std;

//#define MULTITEST
//#define _DEBUG

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n;
li a[N];

bool read() {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n) {
		scanf("%lld", &a[i]);
	}
	return true;
}

void solve() {
	vector<li> s(n + 1, 0);
	forn(i, n) {
		s[i + 1] = (s[i] + a[i]) % MOD;
	}

	li ans = 0;
	forn(i, n - 1) {
		ans = (ans + a[i] * ((s[n] - s[i + 1] + MOD) % MOD) % MOD) % MOD;
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	//ios::sync_with_stdio(false);
  	//cin.tie(0);
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while (tc--) {
		read();
#else
	while (read()) {
#endif
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif

	}
	}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[5];
    for (int i = 0; i < 5; ++i)
        cin >> a[i];
    sort(a, a + 5);
    int k;
    cin >> k;
    if (a[4] - a[0] > k)
        cout << ":(";
    else
        cout << "Yay!";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int N;
	cin >> N;
	for (ll i = 100000; i>=1; i--) {
		if ( (ll)i * i <= N) {
			cout << (ll)i * i;
			break;
		}
	}
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    println!("{}",
        if s[2] == s[3] && s[4] == s[5] {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val L = Array.fill(N)(sc.nextInt)

    val max = L.max
    val sum = L.sum - max
    if (sum > max) "Yes" else "No"
  }
}


Measured memory_bytes: 25932
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define INF 1e15
#define NASH 1e9+7
#define MAXN 200005
using namespace std;
ll a,b,c;
int main(){
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<" "<<b<<endl;
}
/*
*/

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

divs = []
maxA = sum(A)
for i in range(1, int(maxA ** 0.5) + 1):
    if maxA % i == 0:
        divs.append(i)
        divs.append(maxA // i)

divs.sort(reverse=True)

for d in divs:
    rest = [a % d for a in A]
    rest.sort(reverse=True)
    restSum = sum(rest) // d
    cnt = 0
    for i in range(restSum):
        cnt += d - rest[i]
    if cnt <= K:
        print(d)
        exit()


Measured memory_bytes: 41708
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (1<<18);

int m, k;
bool vis[N];
VI res, bla;

int main() {
  init_ios();
  cin >> m >> k;
  if (m == 0) {
    if (k > 0) {
      cout<<"-1\n";
      return 0;
    }
    cout<<"0 0\n";
    return 0;
  }
  if (m == 1 && k >= 1) {
    cout<<"-1\n";
    return 0;
  }
  if (k == 0) {
    for (int i = 0; i < (1<<m); ++i)
      cout<<i<<" "<<i<<" ";
    cout<<"\n";
    return 0;
  }
  if (k >= (1<<m)) {
    cout<<"-1\n";
    return 0;
  }
  PII el;
  for (int i = 1; ; ++i)
    if (i != k) {
      el = {i, k^i};
      break;
    }
  vis[el.ST] = vis[el.ND] = true;
  res.PB(el.ND);
  res.PB(el.ST);
  for (int i = 0; i < (1<<m); ++i)
    if (!vis[i] && i != k)
      res.PB(i);
  res.PB(k);
  for (int i = (int)res.size()-2; i >= 2; --i)
    res.PB(res[i]);
  res.PB(el.ST);
  res.PB(el.ND);
  res.PB(k);
  for (int x: res)
    cout<<x<<" ";
  cout<<"\n";
}

Measured memory_bytes: 3060
/*
g++ -std=c++11 -o2 -Wall sound_hound_B.cpp.cpp -o ./out/sound_hound_B.cpp.out
./out/sound_hound_B.cpp.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

constexpr ll INF = 10000000000000000;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int w;
  cin >> w;
  int n = s.size();
  for (int i = 0; i < n; i += w) {
    putchar(s[i]);
  }
  putchar('\n');
}


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

int main(){
  char s[5];
  if(fgets(s,5,stdin) == NULL){
      printf("fgets error\n");
      exit(1);
  }
    int streak = 0, maxstreak= 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R'){
            streak++;
            if(streak > maxstreak)maxstreak = streak;
        }else{
            streak = 0;
        }
    }
    printf("%d\n",maxstreak);
}

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

#define ll long long int
#define pb push_back
#define pob pop_back
#define vl vector<ll>
#define mp make_pair
#define sz size()
#define fast ios::sync_with_stdio(0)
#define maxx 100005
#define edge pair<ll,ll>
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦
 
int main()
{
	ll k;
	ll n;
	cin>>k>>n;
	ll i;
	ll a[n];
	for(i=0;i<n;i++) cin>>a[i];
	a[n]=a[0]+k;
	ll p=0;
	ll dis[n];
	for(i=0;i<n;i++)
	{
		dis[i]=abs(a[i]-a[i+1]);
	}
	sort(dis,dis+n);
	ll sum=0;
	for(i=0;i<n-1;i++)
	{
		sum+=dis[i];
	}
	cout<<sum<<endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,i,a,b;
    string s;
    i=a=b=0;
    cin>>s;
    n=s.length( );
    while(i<n) {
      if(i%2==0) {
        if(s[i]=='0')
          a++;
        else
          b++;
      }
      else {
        if(s[i]=='1')
          a++;
        else
          b++;  
      }
      i++;
    }
    cout<<min(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3


def solve(n, k, info):
    all_set = set(range(1, n + 1))
    sub_set = set()
    for _, bs in info:
        sub_set.update(bs)
    rest_set = all_set - sub_set
    return len(rest_set)


def main():
    n, k = (int(z) for z in input().split())
    info = []
    for _ in range(k):
        d = int(input())
        bs = [int(z) for z in input().split()]
        info.append((d, bs))
    print(solve(n, k, info))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1000000000000000007LL;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int a, b, n;
    cin >> n >> a >> b;

    // 簡略化のため a <= b となるように交換する
    if (a > b)
        swap(a, b);

    int ans = INF;
    // 差が偶数 → そのまま近づくように勝つ 負ける
    if (abs(a - b) % 2 == 0)
    {
        ans = abs(a - b) / 2;
    }
    else
    // 差が奇数 → どちらかが1卓で勝つorN卓で負けるして差を偶数にする
    // ex. 100 2 7 は4ゲーム
    {

        {
            int aa = a, bb = b;
            int step1 = a - 1 + 1; // A が1卓で勝つまでのゲーム数
            aa = 1;
            bb = b - step1; // その後同じ卓で合うまでのゲーム数
            int step2 = abs(aa - bb) / 2;

            ans = min(step1 + step2, ans);
        }
        {
            int aa = a, bb = b;
            int step1 = n - b + 1; // B がN卓で負けるまでのゲーム数
            aa = a + step1;
            bb = n; // その後同じ卓で合うまでのゲーム数
            int step2 = abs(aa - bb) / 2;

            ans = min(step1 + step2, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,time,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def cal(T):
    res = 0
    last = [0] * 26
    for day in range(D):
        t = T[day]; t -= 1
        last[t] = 0
        res += s[day][t]
        for i in range(26):
            if i == t: continue
            last[i] += 1
            res -= c[i] * last[i]
    return res
def check_change(td,tq):
    global score,res
    old_q = res[td]
    res[td] = tq
    now = cal(res)
    if now > score:
        score = now
    else:
        res[td] = old_q

start_time = time.time()
n = 26
D = inp()
c = inpl()
s = []
max_s = []
for i in range(D):
    tmp = inpl()
    mx = 0; ind = -1
    for j in range(n):
        if tmp[j] > mx:
            mx = tmp[j]
            ind = j
    max_s.append(ind+1)
    s.append(tmp)

last = [0] * n
res = [-1] * D
for d in range(D):
    ans = -1
    mx = -INF
    for i in range(n):
        now = s[d][i]
        for j in range(n):
            if i == j: continue
            now -= s[d][j] * (last[j]+1)
        if now > mx:
            mx = now
            ans = i
    res[d] = ans+1
    for j in range(n):
        last[j] += 1
        if j == ans: last[j] = 0
score = cal(res)
# print(now_score)
for i in range(D):
    if res[i] == max_s[i]: continue
    check_change(i,max_s[i])

while time.time() - start_time < 1.83:
    td,tq = random.randrange(0,D), random.randrange(1,n+1)
    check_change(td,tq)

for x in res:
    print(x)

Measured memory_bytes: 88300
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int in[105];
int cnt1[1024];
int in2[105][15];
int main() {
	int N, i, j, k;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 0; j < 10; j++) {
			int t;
			scanf("%d", &t);
			in[i] |= t << j;
		}
	}
	for (i = 1; i <= N; i++) for (j = 0; j <= 10; j++) scanf("%d", &in2[i][j]);
	for (i = 0; i < 1024; i++) for (j = 0; j < 10; j++) if (i & (1 << j)) cnt1[i]++;

	int ans = -INF;
	for (i = 1; i < 1024; i++) {
		int s = 0;
		for (j = 1; j <= N; j++) s += in2[j][cnt1[i&in[j]]];
		ans = max(ans, s);
	}
	return !printf("%d\n", ans);
}

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

int main() {
  int N, K, x, sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    sum += min(2 * x, 2 * (K - x));
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#define rep(i, n) for (int i=0; i<(n); i++)
using namespace std;
static const int N=100000;
static const int NIL=-1;

int n,m,q;
vector<int> G[N];
int color[N];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r]=c;
  while (!S.empty()) {
    int u=S.top();
    S.pop();
    rep(i, G[u].size()) {
      int v=G[u][i];
      if (color[v]==NIL) {
        color[v]=c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id=1;
  rep(i, n) color[i]=NIL;
  rep(u, n) {
    if (color[u]==NIL) dfs(u, id++);
  }
}

int main() { 
  cin>>n>>m;
  rep(i, m) {
    int s,t; cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  assignColor();
  cin>>q;
  vector<int> X(q), Y(q);
  rep(i, q) cin>>X[i]>>Y[i];
  rep(i, q) {
    if (color[X[i]]==color[Y[i]]) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}


Measured memory_bytes: 8992
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#include<memory>

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
using ll = long long int;

using Graph=vector<vector<int>>;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

#include<random>
const int mod=1e9+7;

vector<vector<ll>>memo(51,vector<ll>(51));
vector<vector<ll>>sums(51,vector<ll>(51));

void init(){
    for(int i=1;i<=50;++i){
        for(int j=1;j<=i;++j){
            ll answer=1;
            for(int k=0;k<j;++k){
                answer*=i-k;
                answer/=k+1;
            }
            memo[i][j]=answer;
        }
    }
    for(int i=0;i<=50;++i){
        for(int j=1;j<=50;++j){
            if(j!=1)sums[i][j]+=sums[i][j-1];
            sums[i][j]+=memo[i][j];
        }
    }
    //WHATS(sums)
}
vector<int> simulate(vector<int>v,int K){
    while(K--){
        auto nv(v);
        vector<int>pluss(v.size()+1);
        for(int i=0;i<v.size();++i){
            int l=max(0,i-v[i]);
            int r=min(int(v.size()),i+v[i]+1);
            pluss[l]++;
            pluss[r]--;
        }
        int sum=0;
        for(int i=0;i<v.size();++i){
            sum+=pluss[i];
            nv[i]=sum;
        }
        v=nv;
        //WHATS(v);
    }
    return v;
    
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie();
    int N,K;cin>>N>>K;
    vector<int>v(N);
    for(int i=0;i<N;++i){
        cin>>v[i];
    }
    auto xx=simulate(v,min(K,100));
    for(int i=0;i<N;++i){
        cout<<xx[i]<<' ';
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 6452
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
      ans += B[i]
    else: 
      ans += min(B[i],A[i] + A[i + 1])
      A[i + 1] = max(0,A[i + 1] - B[i] + A[i])
print(ans)    
         

Measured memory_bytes: 82020
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << 0.5 << endl;
  }
  else {
    double ans = ((N / 2 + 1.0) / N);
    cout << fixed << setprecision(16);
    cout << ans << endl;
  }
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    ll ans=0;
    rep(i,n){
        cin>>a[i];
        ans+=a[i];
    }
    cout<<ans-n<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
using namespace std;
bool vis[100005];
int h[100005],n,m,a,b,c;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",h+i);
	}
	for(int i=1;i<=m;++i){
		scanf("%d%d",&a,&b);
		if(h[a]>=h[b])vis[b]=true;
		if(h[a]<=h[b])vis[a]=true; 
	}
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			++c;
		} 
	}
	printf("%d\n",c);
	return 0;
}


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

int main() {
    int N,C,s,t,c,r=0;
    cin >> N >> C;
    vector<vector<int>> tt(100010, vector<int>(C,0));
    set<int> p;

    rep(i,N) {
        cin >> s >> t >> c;
        tt.at(--s).at(--c) += 1;
        tt.at(t).at(c) += 1;
    }

    rep(i,100010) {
        rep(j,C)
            if(tt.at(i).at(j)%2)
                if(p.count(j))
                    p.erase(j);
                else
                    p.insert(j);
        r = max(r, (int)p.size());
    }

    cout << r << endl;
}

Measured memory_bytes: 15104
#include <iostream>



int main(){
	int data[3];
	int tmp;

	std::cin >> data[0] >> data[1] >> data[2];
	for (int i = 0; i < 3; i++){
		for (int j = 2; j > 0 + i; j--){
			if (data[j] < data[j - 1]){
				tmp = data[j];
				data[j] = data[j - 1];
				data[j - 1] = tmp;
			}
		}
	}
	std::cout << data[0] << " " << data[1] << " " << data[2] << "\n";

	return 0;
}

Measured memory_bytes: 1168
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

const FACT_MAX: usize = 300000;
const MOD: i64 = 998244353;

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };

    #[allow(unused)]
    pub static RFACT: Vec<i64> = {
        let mut rfac = vec![1; FACT_MAX+1];
        rfac[FACT_MAX] = FACT.with(|fact| {
            pow_mod(fact[FACT_MAX], MOD-2, MOD)
        });

        for i in (0..FACT_MAX).rev() {
            rfac[i] = (rfac[i+1] * (i+1) as i64) % MOD;
        }
        rfac
    }
}

#[allow(dead_code)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m {
        return 0;
    }

    FACT.with(|fact| {
        RFACT.with( |rfact| {
            fact[n] * rfact[n-m] % MOD * rfact[m] % MOD
        })
    })
}

fn solve(n: u64, a: u64, b: u64, k: u64) ->  u64 {

    let mut ans = 0;

    for i in 0..n+1 {

        if k < i*a {
            continue
        }

        if (k - (i*a)) % b > 0 {
            continue
        }

        let j = (k-(i*a)) / b;
        ans += (combi(n as usize ,i as usize) * combi(n as usize,j as usize)) % MOD;
        ans %= MOD;
    }

    ans as u64
}

fn main() {
    let (n, a, b, k) = parse_line!(u64, u64, u64, u64);

    println!("{}", solve(n,a,b,k));
}

#[test]
fn solve_test() {
    assert_eq!(solve(4,1,2,5), 40);
    assert_eq!(solve(2,5,6,0), 1);
    assert_eq!(solve(90081, 33447, 90629, 6391049189), 577742975);
}


Measured memory_bytes: 12540
N,M=map(int,input().split())

n = 10**5
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                
dic={some:0 for some in prime}

def prime_factorization(N):
    for some in prime:
        if N%some==0:
            while N%some==0:
                N=N//some
                dic[some]+=1
        else:
            pass
    if N!=1:
        dic[N]=1
prime_factorization(M)   

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

def combi(a,b,n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(mod)

P=1
a=find_power(10**5+1000,10**9+7)
b=find_inv_power(10**5+1000)
for some in dic.values():
    P*=combi(a,b,some+N-1,N-1,10**9+7)
    P=P%(10**9+7)
print(P)

Measured memory_bytes: 20200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=200005;

int a,b,c;
ll k;

int main(){
	int i;
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	if (k&1ll) printf("%d\n",b-a);
	else printf("%d\n",a-b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int x;
		
		x = sc.nextInt();
		
		System.out.println(x*x*x);
    }

             
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17172
N=int(input())
A=list(map(int,input().split()))
m=1000
k=0
mi=A[0]
ma=A[0]
for i in range(1,N):
    if A[i]>A[i-1]:
        k,m=divmod(m,A[i-1])
        m+=A[i]*k
print(m)

Measured memory_bytes: 9180
#include<stdio.h>
int main(void)
{
	int a,b;
	for(;;)
	{
		scanf("%d",&a);
		if(a==0)
			return 0;
		b=0;
		for(;a!=1;)
		{
			if(a%2==0)
				a/=2;
			else
				a=a*3+1;
			b++;
		}
		printf("%d\n",b);
	}
}

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

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

    if (S == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B, C = MAP()
if len(set([A, B, C])) == 2:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5844
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n,q;
int p[MAX],cost[MAX];

void init(){
  FOR(i,0,n){ p[i]=i;cost[i]=0; }
}

pii f(int a){
  if(p[a]==a)return mp(a,0);
  pii res=f(p[a]);
  res.s+=cost[a];
  p[a]=res.f;
  cost[a]=res.s;
  return res;
}

void relate(int a,int b,int c){
  pii d=f(a),e=f(b);
  p[d.f]=e.f;
  cost[d.f]=c-d.s+e.s;
}

void diff(int a,int b){
  pii d=f(a),e=f(b);
  if(d.f!=e.f)cout<<"?"<<endl;
  else cout<<d.s-e.s<<endl;
}

int main()
{
  cin>>n>>q;
  init();
  FOR(i,0,q){
    int a,b,c,d;
    cin>>a;
    if(a==0){
      cin>>b>>c>>d;
      relate(b,c,d);
    }
    else {
      cin>>b>>c;
      diff(b,c);
    }
  }
  return 0;
}


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

using namespace std;

int main() {
  int x;
  cin >> x;
  unordered_set<int> S;
  while (true) {
    if (S.count(x)) {
      cout << S.size() + 1;
      break;
    }

    S.insert(x);
    if (x % 2 == 0) {
      x /= 2;
    } else {
      x = 3 * x + 1;
    }
  }

  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> T(N, 0), A(N, 0);
    for (int i = 0; i < N; i++) { cin >> T[i] >> A[i]; }

    ll t = T[0], a = A[0];
    for (int i = 0; i < N; i++) {
        ll n = (A[i] + a - 1) / A[i];
        n = max(n, (T[i] + t - 1) / T[i]);
        t = T[i] * n;
        a = A[i] * n;
    }
    cout << (t + a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

void solve() 
{
    int h,w;cin>>h>>w;
    int m[h][w];
    queue<pair<int,int> >q;
    REP(i,h)REP(j,w){
        char x;cin>>x;
        if(x=='#')q.push({i,j});
        m[i][j]=(x=='#'?1:0);
    }
    int ans=0;
    while(!q.empty()){
        int y=q.front().first,x=q.front().second;q.pop();
        ans=max(ans,m[y][x]);
        REP(i,4){
            int x2=x+dx[i],y2=y+dy[i];
            if(y2<0||y2>=h||x2<0||x2>=w)continue;
            if(m[y2][x2]==0)m[y2][x2]=m[y][x]+1,q.push({y2,x2});
        }
    }
    cout<<ans-1<<endl;
}

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

Measured memory_bytes: 12304
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    int t[N+1],x[N+1],y[N+1];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<=N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=0;i<N;i++){
        int check,T;
        check=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        T=t[i+1]-t[i];
        if(check>T){
            puts("No");
            return 0;
        }
        else if((T-check)%2==1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
int main(){
    string s;
    cin>>s;
    a=s.size();
  b=0;
  c=0;
    for(int i=0;i<a;i++){
      if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
        b++;
      ans=fmax(b,ans);
      }
      else{
        b=0;
      }
}
  cout<<ans<<endl;
}

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

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    // ax + by = c
    // dx + ey = f
    static void Calc(float a, float b, float c, float d, float e, float f) {
        var deno = a * e - b * d;

        var x = (c * e - b * f) / deno;
        var y = (a * f - c * d) / deno;
        Console.WriteLine("{0:f3} {1:f3}", x, y);
    }

    static void Main() {
        string s;
        while ((s = ReadLine()) != null) {
            var xs = s.Split().Select(int.Parse).ToArray();
            Calc(xs[0], xs[1], xs[2], xs[3], xs[4], xs[5]);
        }
    }
}

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

using namespace std;

using ll = long long;

// https://kopricky.github.io/code/String/kmp.html
// res に文字列 text の中にある検索文字列 pattern のすべての一致箇所の開始位置が入る(0_indexed).
class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;

    KMP(const string& s) : pattern(s), plen((int)pattern.size()), table(plen+1) {
        table[0] = -1;
        int j = -1;
        for (int i = 0; i < plen; i++) {
            while (j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if (pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }

    void search(const string& text, vector<int>& res) {
        int head = 0, j = 0, tlen = (int)text.size();
        while (head + j < tlen){
            if (pattern[j] == text[head + j]) {
                if (++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    string s2 = "";
    while (s2.size() < t.size()) s2 += s;
    string s3 = s2 + s2 + s2 + s2;
    KMP kmp(t);
    vector<int> ids;
    kmp.search(s3, ids);
    
    if (ids.empty()) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> memo(s3.size(), -1);
    for (int i = 0; i < ids.size(); i++) memo[ids[i]] = i;

    int n = s.size();
    int m = t.size();
    vector<int> used(ids.size(), false);
    int ans = 0;
    for (int i = 0; i < ids.size(); i++) {
        if (used[i]) continue;
        used[i] = true;
        int src = ids[i];
        int dst = src;
        for (int j = src + m; j < s3.size(); j += m) {
            if (memo[j] == -1) break;
            dst = j;
            used[memo[j]] = true;
        }

        int hoge = n - src % n;
        int foo = dst % n + 1;
        int dis = dst - src + m;
        int rest = dis - hoge - foo;
        if (rest >= n) {
            cout << -1 << endl;
            return 0;
        } else {
            ans = max(ans, dis / m);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

vector<pair<int, int> > CountOfPlace;

bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {
	if (p1.second == p2.second) {
		return p1.first < p2.first;
	}
	return p1.second > p2.second;
}

int main() {
	int n, m, num;
	vector<pair<int, int> >::iterator pos;

	while (cin >> n >> m, n) {
		CountOfPlace.clear();
		for (int j = 0; j < m; ++j) {
			CountOfPlace.push_back({ j,0 });
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				cin >> num;
				CountOfPlace[j].second += num;
			}
		}
		sort(CountOfPlace.begin(), CountOfPlace.end(), cmp);
		pos = CountOfPlace.begin();
		cout << pos->first + 1;
		while (++pos != CountOfPlace.end()) {
			cout << " " << pos->first + 1;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    a /= g;
    return a*b;
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll h,ans = 0,tmp = 2;
    cin >> h;
    if(h == 1){
        cout << 1 << endl;
        return 0;
    }
    while(h > 0){
        h /= 2;
        ans += tmp;
        tmp *= 2;
        if(h == 1) break;
    }
    cout << ans+1 << endl;
    return 0;
}


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

constexpr ll INF = 2e18;
constexpr ll invalid = -1;

ll lcm(ll a, ll b) {
    ll g = __gcd(a, b);
    a /= g;
    if(a > INF / b) {
        return invalid;
    }
    return a * b;
}

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<double> p(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i] /= 100;
    }

    double res = 0;
    for(int S = 1; S < 1 << n; ++S) {
        int cnt = 0;
        double q = 1;
        for(int i = 0; i < n; ++i) {
            if((S >> i) & 1) {
                cnt++;
                q *= p[i];
            }
        }

        ll t = 1;
        for(int i = 0; i < n; ++i) {
            if((S >> i) & 1) {
                t = lcm(t, a[i]);
            }
            if(t == invalid) {
                break;
            }
        }
        if(t != invalid) {
            if(cnt & 1) {
                res += q * (m / t);
            } else {
                res -= q * (m / t);
            }
        }
    }

    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 3256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN(s);
  Yes(s[0]==s[2]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    int n,k;
    cin>>n>>k;
    vector<int>arr(n);
    for(auto& i:arr)
    cin>>i;
    ll ans=0;
    sort(arr.begin(),arr.end());
    for(int i=0;i<k;i++)
    ans+=arr[i];
    cout<<ans<<endl; 
}


Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int M = in.nextInt();
            int[] a = in.nextIntArray(A);
            int[] b = in.nextIntArray(B);

            int min = 0;
            min += IntStream.of(a).min().getAsInt();
            min += IntStream.of(b).min().getAsInt();
            for (int i = 0; i < M; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                int c = in.nextInt();
                min = Math.min(a[x - 1] + b[y - 1] - c, min);
            }
            out.println(min);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 52684
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  int N, K;
  cin >> N >> K;
  int t;
  rep(i,N)
    cin >> t;
  cout << 1+ceil(double(N-K)/(K-1)) << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256