akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC123A
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            var lst = new List<int>();
            for(int i = 0; i < 5; i++)
            {
                int a = int.Parse(Console.ReadLine());
                lst.Add(a);

            }
            int k = int.Parse(Console.ReadLine());
            bool ok = true;
            /*for(int j = 0; j < 4; j++)
            {
                if (lst[j + 1] - lst[j] > k)
                {
                    ok = false;
                }
            }*/

            

            if (lst[4]-lst[0]<=k)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int H, W;
int s[50][50];
int d[50][50];

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

int bfs(int sx = -1, int sy = -1, int gx = -1, int gy = -1) {
    queue<P> que;
    que.push(P(sx, sy));

    while (!que.empty()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy)
             break;

        rep(k, 8) {
            int nx = p.first + dx[k], ny = p.second + dy[k];

            if (inside(nx, ny) && s[nx][ny] != 0 && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

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

    while (cin >> W >> H, W) {
        rep(i, H) {
            rep(j, W) {
                cin >> s[i][j];
                d[i][j] = INF;
            }
        }

        int ans = 0;
        rep(i, H) {
            rep(j, W) {
                if (d[i][j] == INF && s[i][j] == 1) {
                    bfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3180
# include <bits/stdc++.h>
using namespace std;
int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r<0 || x+r>W || y-r<0 || y+r>H){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3116
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int gcd(int a,int b){
    if(a==0||b==0)return max(a,b);
    int mi=min(a,b);int ma=max(a,b);
    int c=ma%mi;
    return gcd(mi,c);
}

int A,B,C,D;
int ans=0;
int mod=1000000007;
signed main(){
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    int g=gcd(C,D);
    g=(int)(D*C/g);
    ans=(int)(B/C)+(int)(B/D)-(int)(B/g);

    ans-=(int)( (A-1)/C )+(int)( (A-1)/D )- (int)( (A-1)/g);

    printf("%lld\n",(B-A+1)-ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  long n,k;
  scanf("%ld %ld", &n, &k);

	long answer;

	long diff_a ,diff_b;

	if (n > k) {
		diff_a = n-k;
		diff_a = diff_a%k;
		diff_b = k-diff_a;
		answer = diff_a;
		if (diff_b < diff_a) {
			answer = diff_b;
		}
	}
	if (n == k) {
		answer = 0;
	}
	if (n < k) {
		diff_a = n;
		diff_b = k-diff_a;
		answer = diff_a;
		if (diff_b < diff_a) {
			answer = diff_b;
		}
	}

	printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int K;
  cin>>K;
  int seven = 7;
  int ans = -1;
  for(int i=1;i<=K;++i) {
    if(seven%K==0) {
      ans = i;
      break;
    }
    seven *= 10;
    seven += 7;
    seven %= K;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll n;
    cin>>n;
    vector<ll> v(n,0),m(n,0);
    ll tmp;
    ll count =0;
    rep(i, n) cin>>m[i];
    reverse(alll(m));
    ll lasttmp=0;
    rep(i, n) {
        tmp=m[i];
        if(tmp < lasttmp - 1){
            pr(-1);
            return 0;
        }
        if(tmp == lasttmp-1) {
            lasttmp=tmp;
            continue;
        }
        else {
            count+=tmp;
            lasttmp=tmp;
        }
    };
    if(lasttmp != 0) pr(-1);
    else pr(count);
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string ABCD; cin >> ABCD;
  string ans = "";
  ans += ABCD[0];
  int value = ABCD[0]-'0';

  //0:+, 1:-
  REP(b,1<<3) {
    string ans = "";
    ans += ABCD[0];
    int value = ABCD[0]-'0';
    REP(i,3) {
      if (!(b&(1<<i))) {
        ans += "+";
        ans += ABCD[i+1];
        value += ABCD[i+1]-'0';
      }
      else {
        ans += "-";
        ans += ABCD[i+1];
        value -= ABCD[i+1]-'0';
      }
    }
    if (value == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}

Measured memory_bytes: 3600
s = gets.chomp
t = gets.chomp
ss = s.size
ts = t.size

(ss - ts + 1).times do |i|
  range = (ss - ts - i)..(-1 - i)

  if s[range].each_char.with_index.all? { |c, idx| c == '?' ? :t : c == t[idx] }
    s[range] = t

    puts s.tr('?', 'a')
    exit
  end
end

puts :UNRESTORABLE

Measured memory_bytes: 1788
N = int(input())
A = list(map(int,input().split()))
  
def chk(arr, n): 
  
    s = dict() 
    max_ele = -10**9
    for i in range(n):
        if arr[i] not in s: 
            s[arr[i]] = 1
        else:
            s[arr[i]] += 1
        max_ele = max(max_ele, arr[i]) 
      
    res = dict() 
    for i in range(n):
        for j in range(arr[i] * 2,  
                        max_ele + 1, arr[i]): 
                
            if (j in s.keys()): 
                res[j] = 1
    p = 0
    for i in arr:
        if i not in res.keys() and s[i] == 1:
            p += 1
    return(p)
  
print(chk(A, N) )


Measured memory_bytes: 134068
def bellman_ford(start, edges)
  dist = Array.new(V + 1, Float::INFINITY)
  dist[start] = 0

  V.times do |i|
    update = false

    edges.each do |from, to, cost|
      if dist[to] > dist[from] + cost
        dist[to] = dist[from] + cost
        update = true

        dist[to] = -Float::INFINITY if i == V - 1
      end
    end

    break unless update
  end

  dist
end

V, E, r = gets.split.map(&:to_i)

edges = []

E.times do
  edges << gets.split.map(&:to_i)
end

dist = bellman_ford(r, edges)

if dist.any? { |d| d == -Float::INFINITY }
  puts 'NEGATIVE CYCLE'
else
  V.times do |i|
    if dist[i] == Float::INFINITY
      puts 'INF'
    else
      puts dist[i]
    end
  end
end



Measured memory_bytes: 8904
#include<stdio.h>
#define N 100000

int partition(int [], int , int ); 

int main(){
  
  int A[N], n, i, q;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  q = partition(A, 0, n-1);

  for(i=0;i<n;i++){

    if(i){
      printf(" ");
    }

    if(i==q){
      printf("[");
    }
    
    printf("%d", A[i]);

    if(i==q){
      printf("]");
    }
  }
  printf("\n");

  return 0;
}
int partition(int A[], int p, int r){
  int x, i, j, t;
  
  x = A[r];
  i = p - 1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  
  return i+1;
}

Measured memory_bytes: 992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	rep(i, 0, n)cin >> w[i];
	int min = 1000000;
	rep(i, 1, n) {
		int sumb = 0;
		int suma = 0;
		rep(j, 0, i)sumb += w[j];
		rep(j, i, n)suma += w[j];
		int ans = abs(sumb - suma);
		if (ans <= min)min = ans;
	}
	cout << min << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	s := min([]int{a, b, c})
	l := max([]int{a, b, c})
	m := a + b + c - s - l

	for _, v := range []int{s, m, l} {
		if v%2 == 0 {
			fmt.Println(0)
			return
		}
	}
	fmt.Println(s * m)
}

func min(a []int) int {
	result := math.MaxInt64
	for _, v := range a {
		if result > v {
			result = v
		}
	}
	return result
}

func max(a []int) int {
	result := math.MinInt64
	for _, v := range a {
		if result < v {
			result = v
		}
	}
	return result
}


Measured memory_bytes: 512
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut q2: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    let mut cnt = 1;
    while !rems.is_empty() {
        if let Some(s_idx) = q2.pop_front() {
            cnt += s_idx;
            r2.remove(&s_idx);
        }
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = r2.iter().next() {
            q2.push_back(r);
        }
    }
    if cnt > 1e18 as usize{
        println!("{}", "hoge");
    }
    println!("{}", ans);
}


Measured memory_bytes: 27576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a[200010],s[200010],u[100010];
ll count(int l,int r)
{
	int mid=l+r>>1;
	if(l==r)
		return 0;
	int tot=0;
	ll ans=0;
	for(int i=mid+1;i<=r;i++)
		u[tot++]=s[i];
	sort(u,u+tot);
	for(int i=l;i<=mid;i++)
		if(s[i]<=u[tot-1])
			ans+=u+tot-lower_bound(u,u+tot,s[i]);
	ans+=count(l,mid);
	ans+=count(mid+1,r);
	return ans;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]-=k;
	}
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]+a[i];
	printf("%lld",count(0,n)); 
}

Measured memory_bytes: 4224
def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    
    left = [[-1]*W for _ in range(H)]
    right = [[-1]*W for _ in range(H)]
    up = [[-1]*W for _ in range(H)]
    down = [[-1]*W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                if j == 0:
                    left[i][j] = 0
                else:
                    left[i][j] = left[i][j-1] + 1
                if i == 0:
                    up[i][j] = 0
                else:
                    up[i][j] = up[i-1][j] + 1

            if S[-1-i][-1-j] == '.':
                if j == 0:
                    right[-1-i][-1-j] = 0
                else:
                    right[-1-i][-1-j] = right[-1-i][-1-(j-1)] + 1
                if i == 0:
                    down[-1-i][-1-j] = 0
                else:
                    down[-1-i][-1-j] = down[-1-(i-1)][-1-j] + 1

    ans = 0
    temp = [0] * W
    for i in range(H):
        for j in range(W):
            temp[j] = left[i][j] + right[i][j] + down[i][j] + up[i][j] + 1
        ans = max(ans, max(temp))
    print(ans)

main()

Measured memory_bytes: 307720
def main():
    N, L = list(map(int, input().split()))
    A = list(map(int, input().split()))
    max_len_knot, max_len = - 1, 0
    for i in range(N - 1):
        if A[i] + A[i + 1] > max_len:
            max_len_knot = i
            max_len = A[i] + A[i + 1]
    if max_len < L:
        print('Impossible')
    else:
        print('Possible')
        for i in range(max_len_knot):
            print(i + 1)
        for i in range(N - 2, max_len_knot, -1):
            print(i + 1)
        print(max_len_knot + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> road(n);
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        road[a]++;
        road[b]++;
    }
    rep(i,0,n){
        cout<<road[i]<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
arr = [int(j) for j in input().split()]
ans = 0
arr.sort()
for i in range(len(arr)):
	for j in range(i+1, len(arr)):
		for k in range(j+1, len(arr)):
			if arr[i] + arr[j] > arr[k] and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
				ans += 1


print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int a[1000006][26], b[1000006], d[1000006][26], e[1000006], f[1000006];

int main() {
    ios::sync_with_stdio(false);
    e[1] = -1;
    int n, o = 1;
    ll z = 0;
    string s;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        reverse(s.begin(), s.end());
        int c = 1;
        for (int j = 0; j < s.length(); j++) {
            if (!a[c][s[j] - 'a']) a[c][s[j] - 'a'] = ++o, e[o] = s[j] - 'a';
            c = a[c][s[j] - 'a'];
        }
        b[c] = 1;
    }
    for (int i = o; i; i--) {
        if (b[i]) f[i] = 1;
        for (int j = 0; j < 26; j++) if (a[i][j]) {
            f[i] += f[a[i][j]];
            for (int k = 0; k < 26; k++) d[i][k] += d[a[i][j]][k];
        }
        if (i > 1) d[i][e[i]] = f[i];
    }
    for (int i = 1; i <= o; i++) {
        for (int j = 0; j < 26; j++) if (b[a[i][j]]) {
            for (int k = 0; k < 26; k++) z += d[a[i][k]][j];
        }
        //for (int j = 0; j < 26; j++) cout << d[i][j] << ' '; cout << '\n';
    }
    cout << z - n << '\n';
}



Measured memory_bytes: 215996
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

		int N = sc.nextInt();
		map.put(111, 999);
		map.put(119, 991);
		map.put(199, 911);
		map.put(999, 111);
		map.put(991, 119);
		map.put(911, 199);
		map.put(919, 191);
		map.put(191, 919);

		System.out.println(map.get(N));
	}
}

Measured memory_bytes: 21588
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<complex>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
const ll INF=1000000000000;
const ll mod=1000000007;

ll  MOD(ll  a,ll  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b,ll c)
{
    return max(c,max(a,b));
}
ll min3(ll a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);//%mod;
        y = y>>1;
        x = (x*x);//%mod;
    }
    return res;//%mod;
}
ll  power1(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res%mod;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x)
{
    return power1(x,mod-2);
}
int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> grid(h);
    for(int i=0;i<h;i++)
    {
        cin>>grid[i];
    }
    vector<vector<ll>> dp(h);
    for(int i=0;i<h;i++)
    {
        dp[i].resize(w,0);
    }
    dp[0][0]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(grid[i][j]=='#')
            {
                dp[i][j]=0;
            }
            else
            {
                if(i>0)
                {
                    dp[i][j]+=dp[i-1][j];
                    dp[i][j]=dp[i][j]%mod;
                }
                if(j>0)
                {
                    dp[i][j]+=dp[i][j-1];
                    dp[i][j]=dp[i][j]%mod;
                }
            }
        }
    }
    cout<<dp[h-1][w-1];
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

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

int main(){
    int n;
    ll W;
    cin >> n >> W;
    vector<int>w(n),v(n);
    rep(i,n)cin >> w[i] >> v[i];
    Fill(dp,1LL<<60);
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=100000;j++){
            dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
            if(dp[i][j]!=(1LL<<60)){
                dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<=100000;i++){
        if(dp[n][i]<=W){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

class Program{

  static int n, k;
  static int ans = 0;

  static int Main() {

    string[] nyu = Console.ReadLine().Split(' ');
    n = int.Parse(nyu[0]);
    k = int.Parse(nyu[1]);

    int[] a = new int[n];
    string[] nya = Console.ReadLine().Split(' ');

    if ((n-1) % (k-1) == 0) {
      ans = (n-1) / (k-1);
    } else {
      ans = (n-1) / (k-1) + 1;
    }

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a[3];
    int tot=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;

}


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


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


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

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

  std::string S;

  int Q, T, F;

  char C;

  std::cin >> S >> Q;

  std::deque<char> deque(ALL(S));

  bool flipped = false;
  
  for (int q = 0; q < Q; q ++) {
    std::cin >> T;

    if (T == 1) {
      flipped = ! flipped;
    }
    else {
      std::cin >> F >> C;

      if (F == 1) {
        if (! flipped) {
          deque.push_front(C);
        }
        else {
          deque.push_back(C);
        }
      }
      else {
        if (! flipped) {
          deque.push_back(C);
        }
        else {
          deque.push_front(C);
        }
      }
    }
  }

  if (! flipped) {
    for (const auto& c : deque)
      std::cout << c;
    std::cout << std::endl;
  }
  else {
    for (auto it = deque.rbegin(); it != deque.rend(); ++ it)
      std::cout << *it;
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 976
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};

int main(){
    int n; cin >> n;
    vector<ll> a(n),ans(n);
    rep(i,n) cin >> a[i];
    int k = n/2;
    for(int i=0;i<n;i+=2){
        ans[k] = a[i];
        k++;
    }
    k = n/2 - 1;
    for(int i=1;i<n;i+=2){
        ans[k] = a[i];
        k--;
    }
    if(n % 2 == 0){
        rep(i,n) cout << ans[i] << " ";
    }else{
        for(int i=n-1;i>=0;i--) cout << ans[i] << " ";
    }
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl factorize(ll n) {
  vvl ret;
  for(ll i = 2; i * i <= n; i++) {
    ll c = 0;
    while(n % i == 0) n /= i, c++;
    if(c!=0) ret.push_back(vll{i, c});
  }
  if(n != 1) ret.push_back(vll{n, 1});
  return ret;
}

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl d = factorize(n);
  ll ans = 0;
  for(auto v:d){
    ll x = 1;
    while((x*(x+1))/2<=v[1]) x++;
    ans += x-1;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3196
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

int findGrundy(int a, int k)
{
  if (a < k)
    return 0;
  if (a%k==0)
    return a/k;
  else
  {
    int mul = ceil(((a%k)*1.0)/(a/k+1));
    return findGrundy(a-mul*(a/k+1),k);
  }
}


void solve()
{
  int n;
  cin >> n;
  vi a(n);
  vi k(n);
  repz(i,n)
    cin >> a[i] >> k[i];

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans ^= findGrundy(a[i],k[i]);
  }

  if (ans > 0)
  {
    cout << "Takahashi" << endl;
  }
  else
  {
    cout << "Aoki" << endl;
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, ans;
vector<ll> digits;
int main()
{
	scanf("%lld", &n);
	while (n)
	{
		digits.push_back(n % 10);
		n/=10;
	}
	reverse(digits.begin(), digits.end());
	ll sum = 0;
	for (int i = 0; i < digits.size(); i++)
	{
		ll am = sum + digits[i]-1 + (digits.size()-i-1)*9;
		ans = max(ans, am);
		sum += digits[i];
	}
	ans = max(ans, sum);
	printf("%lld\n", ans);
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n;
  bool flag = true;
  cin >> n;
  vector<int> v(n);
  REP(i,n)cin >> v[i];
  ll pre = v[0]-1;
  for(ll i = 1;i < n;i++){
    if(v[i]-1 >= pre){
      pre = v[i]-1;
    }else if(v[i] >= pre){
      pre = v[i];
    }else{
      flag = false;
    }
  }
  if(flag)cout << "Yes";
  else cout << "No";


  return 0;
}


Measured memory_bytes: 768
while True:
    try:
        a=list(map(int,input().split()))
        if a[0]==0:
            pass
        else:
            
            for i in range(a[1]):
                print('#',end='')
            print()
            for j in range(a[0]-2):
                print('#',end='')
                for w in range(a[1]-2):
                    print('.',end='')
                print('#')
            for k in range(a[1]):
                print('#',end='')
            print()
            print()
        
    except:
        break;


Measured memory_bytes: 7004
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2*(1e5 + 5);

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

    ll i, j, k=0, t, n, m, a[maxn];

    cin>>n>>m;

    for ( i = 0; i < m; i++)
    {
        cin>>a[i];
        k+=a[i];
    }

    if(k>n)cout<<-1<<endl;
    else
    {
        
        cout<<n-k<<endl;
    }
    
    


    return 0;
}

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

using namespace std;

typedef long long ll;

const int MX = (1<<21);

int n , K , arr[MX] , mn = MX;

int main(){
    cin>>n>>K;
    for(int j = 1 ; j <= n ; j++){
        cin>>arr[j];
        mn = min(mn , arr[j]);
    }
    int ans = 0;
    for(int j =1  ; j <= n ; j++){
        if(arr[j] == mn){
            int fromleft = 0 , fromright = 0;
            for(int i = j ; i > 1 ; i -= (K - 1)){
                ++ans;
                if(i - K + 1 <= 0){
                    fromleft = i - 1;
                    break;
                }
            }
            for(int i = j ; i < n ; i += K - 1){
                ++ans;
                if(i + K - 1 > n){
                  fromright = n - i;
                  break;
                }
            }
      //      cout<<fromleft<<' '<<fromright<<endl;
            if(fromleft + fromright > 0 && fromleft + fromright <= K && fromleft > 0 && fromright > 0)
                --ans;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 640
S = str(input())
n = int(len(S))
ans = [str(0) for i in range(n)]
cntLo = 0
cntRo = 0
cntLe = 0
cntRe = 0
for i in range(n-1):
    if S[i] == "R" and S[i+1] == "L":
        j = 1
        k = 1
        while i-j >= 0 and S[i-j] == "R":
            if j % 2 == 0:
                cntRe += 1
            else:
                cntRo += 1
            j += 1
        while i+1+k <= n-1 and S[i+1+k] == "L":
            if k % 2 == 0:
                cntLe += 1
            else:
                cntLo += 1
            k += 1
        ans[i] = str(cntRe + cntLo+1)
        ans[i+1] = str(cntRo + cntLe+1)
        cntLo = 0
        cntRo = 0
        cntLe = 0
        cntRe = 0
print(" ".join(ans))

Measured memory_bytes: 49036
def parse(s,p,q,r)
    case s[0]
    when "0"
        return 0
    when "1"
        return 1
    when "2"
        return 2
    when "P"
        return p
    when "Q"
        return q
    when "R"
        return r
    when "-"
        return 2 - parse(s[1...s.length],p,q,r)
    when "("
        index = 1
        level = 0
        while index < s.length
            if s[index] == "("
                level += 1
            elsif s[index] == ")"
                level -= 1
            elsif s[index] == "*" && level == 0
                a = parse(s[1...index],p,q,r)
                b = parse(s[(index+1)...s.length],p,q,r)
                return 0 if a == 0 || b == 0
                return 2 if a == 2 && b == 2
                return 1
            elsif s[index] == "+" && level == 0
                a = parse(s[1...index],p,q,r)
                b = parse(s[(index+1)...s.length],p,q,r)
                return 0 if a == 0 && b == 0
                return 2 if a == 2 || b == 2
                return 1
            end
            index += 1
        end
        return -1
    end
end
loop do
    s = gets.chomp
    break if s == "."
    ans = 0
    3.times do |p|
        3.times do |q|
            3.times do |r|
                if parse(s,p,q,r) == 2
                    ans += 1
                end
            end
        end
    end
    puts ans
end

Measured memory_bytes: 6124
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
xs = list(map(int, input().split()))
G = [set() for _ in range(N+1)]
es = []
for i in range(M):
    u, v = sorted(map(int, input().split()))
    if xs[u-1] == xs[v-1]:
        G[v].add(u)
        G[u].add(v)
    elif xs[u-1] > xs[v-1]:
        G[u].add(v)
    else:
        G[v].add(u)
    es.append((u,v))
xs,d,cc = sorted([(x,i+1) for i, x in enumerate(xs)]),{},{}
for i in range(N):
    if not G[i+1]:
        print(-1)
        sys.exit()
for x, u in xs:
    if u in cc:
        continue
    cc[u] = 1
    for c in G[u]:
        if c in cc:
            cc[u] = 1-cc[c]
    S = [u]
    while S:
        q = S.pop()
        for c in G[q]:
            d[tuple(sorted([q,c]))] = x
            if c in cc: continue
            S.append(c)
            cc[c] = 1-cc[q]
print("".join("BW"[cc[i]] for i in range(1,N+1)))
for i in range(M):
    print(d[es[i]])

Measured memory_bytes: 140796
n = gets.chomp.to_i(10)

obj = {}
prev = ""
for i in 0...n do
  s = gets.chomp
  if (i > 0 && s[0] != prev[-1]) || obj[s] then
    puts "No"
    break
  end
  obj[s] = true
  prev = s
    
  if i == n - 1 then
    puts "Yes"
  end
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()


void solve(){
  ll n;
  cin >> n;
  ll c=26;
  ll l=0;
  
  if(n<=26) {
    cout << char('a'+n-1) << endl;
    return;
  }
  
  while(n>0){
   n-=c;
   c*=26;
   l++; 
  }
   n+=c/26-1;
  string ans="";
  
  while(l--){
   ans+=char(n%26+'a');
    n/=26;
  }
  reverse(all(ans));
  cout << ans << endl;
 
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3584
object Main extends App {

  val sc = new java.util.Scanner(System.in);
  val n = sc.nextInt();
  val ab = Array.fill(n - 1)((sc.nextInt() - 1, sc.nextInt() - 1));

  val nodes = Array.fill[List[Int]](n)(Nil);

  ab.foreach { case (a, b) =>
    nodes(a) = b :: nodes(a);
    nodes(b) = a :: nodes(b);
  }

  val colorCount = nodes.map(_.size).max;

  val flag = Array.fill[Boolean](n)(false);
  val parentColor = Array.fill[Int](n)(0);

  var que = List(0);
  var colors = scala.collection.mutable.Map.empty[(Int, Int), Int];

  while (!que.isEmpty) {
    val v = que.head;
    que = que.tail;
    flag(v) = true;
    var c = 1;
    nodes(v).foreach { u =>
      if (!flag(u)) {
        if (parentColor(v) == c) {
          c = c + 1;
        }
        colors((u, v)) = c;
        colors((v, u)) = c;
        parentColor(u) = c;
        que = u :: que;
        c = c + 1;
      }
    }
  }

  println(colorCount);
  ab.foreach { t =>
    println(colors(t));
  }

}

Measured memory_bytes: 93876
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int k;
	long long int res = 0;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		res += i;
	}
	cout << res << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double theta1 = 2.0 * M_PI * (H + M / 60.0) / 12.0;
	double theta2 = 2.0 * M_PI * M / 60.0;
	double theta = abs(theta1 - theta2);
	double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 4212
using System;

namespace ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8832
<?php
fscanf(STDIN, "%d", $n);

for ($i=0; $i < $n ; $i++) {
    fscanf(STDIN, "%s", $s);
    $v[] = $s;
}
$count = array_count_values($v);
$max = max($count);
$keys = array_keys($count, $max);
sort($keys);

foreach ($keys as $key) {
    echo $key . "\n";
}


Measured memory_bytes: 37360
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    var s string
    if sc.Scan() {
       s = sc.Text()
       }
    if (s[0] == s[1]) && (s[1] == s[2]) {
      fmt.Println("No")
    } else {
      fmt.Println("Yes")
    }  
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		int b1 = 0, b2 = 0, b4 = 0;
		for(int i = 0 ; i < N ; i++) {
			a[i] = sc.nextInt();
			if(a[i] % 4 == 0) {
				b4++;
			} else if(a[i] % 2 == 0) {
				b2++;
			} else {
				b1++;
			}
		}
		if(b2 == 0) {
			if(b1 <= b4 + 1) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if(b1 <= b4) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 50308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var ab = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            Console.WriteLine((ab[0] + ab[1]) % 24);

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

#define int long long
int mod = 1e9 + 7;
int const maxn = 1e5 + 5;
int dp[maxn];

int st(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        int c = st(x, y / 2);
        return c * c % mod;
    }
    return x * st(x, y - 1) % mod;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = k; i >= 1; --i) {
        int cnt = 1 + (k - i) / i;
        int goal = st(cnt, n);
        for (int j = 2 * i; j <= k; j += i) {
            goal -= dp[j];
            if (goal < 0) goal += mod;
        }
        ans += goal * i;
        ans %= mod;
        dp[i] = goal;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define endl 			"\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define w(x)            int x; cin>>x; while(x--)
////////////////////
void iPhone() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//////////////////
//////////////////
int32_t main()
{
	//////////////////////////////////////input/////
	//iPhone();//////////////////////////////fast/////
	//////////////////////////////////////output////
	fast
	int n;
	cin >> n;
	int h[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int dp[n + 1];
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
/*input
4 2
1 2 -3 -4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=8e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
ll mult(ll a,ll b){
    a%=MOD;
    b%=MOD;
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
int arr[maxn];
bool cmp(int a,int b){
    return abs(a)<abs(b);
}
ll inv(int x){
    return mypow(x,MOD-2);
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,k;
    cin>>n>>k;
    bool an=1; 
    REP(i,n){
        cin>>arr[i];
        if(arr[i]>=0) an=0;
    }
    sort(arr,arr+n,cmp);
    reverse(arr,arr+n);
    ll ans=1;
    if(an and k%2){
        reverse(arr,arr+n);
        REP(i,k) ans=mult(ans,arr[i]);
    }
    else{
        ll sn=0,sp=0;
        REP(i,k){
            if(arr[i]>0) sp=arr[i];
            if(arr[i]<0) sn=arr[i];
            ans=mult(ans,arr[i]);
        }
        if(ans<0){
            ll neg=0,pos=0;
            for(int i=k;i<n;i++){
                if(!neg and arr[i]<0) neg=arr[i];
                if(!pos and arr[i]>0) pos=arr[i]; 
            }
            if(!sp or (sn and pos and pos*sp>neg*sn)){
                ans=mult(ans,-inv(abs(sn)));
                ans=mult(ans,pos);
            }
            else if(sp and neg){
                ans=mult(ans,inv(sp));
                ans=mult(ans,neg);
            }
        }
    }   
    ans+=MOD;
    ans%=MOD;
    cout<<ans;
}

Measured memory_bytes: 4388
//ALDS1_14_A
#include <iostream>
#include <string>
using namespace std;

int main(){
	string T, P;

	cin>>T;
	cin>>P;
	
	if(T.length() >= P.length())
		for(int i=0;i<=T.length()-P.length();i++)
			if(T.substr(i, P.length()) == P)
				cout<<i<<endl;

	return 0;
}

Measured memory_bytes: 1196