akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    int k, t;
    readlnTo(k,t);
    auto a = readInts();
    auto m = reduce!(max)(0, a);
    writeln(max(0, m-1-(a.sum-m)));
}



Measured memory_bytes: 364
let n = Int(readLine()!)!
    var r: Int = 0
    
    var num = readLine()!.split(separator: " ").compactMap{Int($0)}
    
    var ns = num[0]
    
    for _ in ns ... num[1] {
      
      if ns % n == 0 {
        print("OK")
        r += 1
        break
      }
      ns += 1
    }
    if r == 0 {
    print("NG")
    }

Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef double flt;
const int MAXN = 100000 + 10;
const flt eps = 1e-12;

int vw[MAXN], pf[MAXN], vf[MAXN], th[MAXN];
int N, pw;

flt calc(flt W) {
  flt cost = W * pw;
  for (int i = 0; i < N; ++ i) {
    flt need = th[i] - W * vw[i];
    if (need <= eps) continue;
    flt f = need / vf[i];
    cost += f * pf[i];
  }
  return cost;
}

int main() {
  while (scanf("%d", &N) == 1 && N) {
    scanf("%d", &pw);
    for (int i = 0; i < N; ++ i) {
      scanf("%d%d%d%d", vw + i, pf + i, vf + i, th + i);
    }
    flt left = 0, right = 200;
    for (int _ = 0; _ < 100; ++ _) {
      flt m1 = (left + left + right) / 3.0;
      flt m2 = (left + right + right) / 3.0;
      flt c1 = calc(m1), c2 = calc(m2);
      if (c1 < c2) right = m2;
      else left = m1;
    }
    printf("%.10f\n", calc(left));
  }
  return 0;
}

Measured memory_bytes: 2768
from collections import defaultdict
Liner = defaultdict(lambda: [])
def inpl(): return [int(i) for i in input().split()]
import sys
N, M = inpl()
for _ in range(M):
    a, b = inpl()
    Liner[a].append(b)
    Liner[b].append(a)
if not Liner[1]:
    print('IMPOSSIBLE')
    sys.exit()
for i in Liner[1]:
    if N in Liner[i]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 51260
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")
    };
}

const MOD: i64 = 1000000007;

fn main() {
    input!{
        n: i64,
        k: i64,
    };

    let mut ans = 1;
    for i in 1..=n+1-k {
        let d = i * (i - 1) / 2;
        ans = (ans + n * i - d * 2 + 1) % MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    vl v(3);rep(i,3)cin >> v[i];
    sort(all(v));
    ll ans=0;
    ans+=v[2]-v[1];
    ans+=(v[1]-v[0]+1)/2;
    if((v[1]-v[0])%2)ans++;
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int skipnum = 0;
  int endnum = 0;

  for(int i=1; i<=N; i++){
    int sum = i*(i+1)/2;
    if(sum >= N){
      skipnum = sum - N;
      endnum = i;
      break;
    }
  }
  for(int i = 1; i < skipnum; i++){
    cout << i << endl;
  }
  for(int i = skipnum + 1; i <= endnum; i++){
    cout << i << endl;
  }

  return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;

map <pair<int, int>, int> mp;

void solve(){   
    ll h, w;
    int n;
    cin >> w >> h >> n;
    for (int it = 0; it < n; it++){
        int x, y;
        cin >> x >> y;
        for (int i = x - 2; i <= x; i++){
            for (int j = y - 2; j <= y; j++){
                if (i < 1 || j < 1 || i + 2 > w || j + 2 > h) continue;
                mp[{i, j}]++;
            }
        }
    }
    vector <ll> ans(10, 0);
    
    for (auto x : mp){
        ans[x.sc]++;
    }
    ans[0] = (h - 2) * (w - 2);

    for (int i = 1; i < 10; i++)
        ans[0] -= ans[i];
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if(a+b+c>=22)
    cout << "bust" <<endl;
    else
    {
        cout << "win" << endl;
    }
    
}




Measured memory_bytes: 256
A, B, C = [int(i) for i in input().split()]

if A == 7 and B == 5 and C ==5:
  print("YES")
elif A == 5 and B == 7 and C ==5:
  print("YES")
elif A == 5 and B == 5 and C ==7:
  print("YES")
else:
  print("NO")
  
  
  

Measured memory_bytes: 2940
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a >= 13)
        printf("%d\n", b);
    if (a <= 12 && a >= 6)
        printf("%d\n", b / 2);
    if (a < 6)
        printf("0\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static int a[];
    static int b[];
    static boolean move[][];
    static boolean vis[];
    static int m;
    static int n;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        a = new int[m];
        b = new int[m];
        move = new boolean[n + 1][n + 1];
        vis = new boolean[n + 1];
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                move[i][j] = false;
            }
        }
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            move[a[i]][b[i]] = true;
            move[b[i]][a[i]] = true;
        }
        // 一つずつ線を消していく
        int ans = 0;
        boolean conected = true;
        for (int i = 0; i < m; i++) {
            move[a[i]][b[i]] = false;
            move[b[i]][a[i]] = false;
            // 初期化する
            for (int j = 0; j < n + 1; j++) {
                vis[j] = false;
            }
            conected = true;
            dfs(1);
            vis[0] = true;
            for (int j = 0; j < n + 1; j++) {
                if (!vis[j]) {
                    conected = false;
                }
            }
            if (!conected) {
                ans++;
            }
            move[a[i]][b[i]] = true;
            move[b[i]][a[i]] = true;

        }
        System.out.println(ans);

    }

    static void dfs(int x) {
        if (vis[x])
            return;
        vis[x] = true;
        for (int i = 1; i < n + 1; i++) {
            if (move[x][i]) {
                dfs(i);
            }
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    map<ll,ll>br;
    ll a,i;
    for( i= 1; i<=n; i++)
    {
        cin>>a;
        br[a]++;
        if(br[a]>1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;

}


Measured memory_bytes: 12800
string = input()

lt = True
ans = 0
l_cnt = 0
m_cnt = 0
if string[0] == ">":
    lt = False

for s in string:
    if s == "<":
        if not lt:
            a, b = max(l_cnt, m_cnt), min(l_cnt, m_cnt)
            ans += a * (a + 1) // 2 + b * (b - 1) // 2
            l_cnt = m_cnt = 0
        l_cnt += 1
        lt = True
    else:
        m_cnt += 1
        lt = False
a, b = max(l_cnt, m_cnt), min(l_cnt, m_cnt)
ans += a * (a + 1) // 2 + b * (b - 1) // 2
print(ans)

Measured memory_bytes: 4212
n,m=map(int,input().split())
SC=[]
for i in range(m):
  s,c=map(int,input().split())
  SC.append((s,c))
for i in range(1000):
  chk=0
  i=str(i)
  l=len(i)
  for s,c in SC:
    if s<=l and i[s-1]==str(c):
      chk+=1
  if chk==m and l==n:
    print(int(i))
    break
else:
  print(-1)




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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    ll n;
    ll a[200008];
    map <ll, ll> count;

    cin>>n;
    FOR(i,1,n)
    {
        cin>>a[i];
        count[a[i]]++;
    }

    FOR(i,1,n+1)
    {
        if (count.find(i) == count.end())
            cout<<0<<endl;
        else
        {
            cout<<count[i]<<endl;
        }
    }
}


Measured memory_bytes: 17696
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define revstr(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll a,b;
	cin>>a>>b;
	if(a<10 && b<10)
	{
		cout<<a*b<<"\n";
	}
	else
	{
		cout<<"-1\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h.at(i);
  }
  
  int ans=0;
  int count=0;
  for(int i=0; i<n-1; i++){
    if(h.at(i) >= h.at(i+1)){
      count++;
    }
    else{
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans <<endl;
  
}


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

#define repi(i, s, n) for (long long i {s}, i##_len{n}; i < i##_len; ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) std::begin(x), std::end(x)

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
namespace xmaho
{
inline namespace integer
{
template<typename C>
constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type;
template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept;
}
}
using namespace xmaho;

int main()
{
  const auto n {get_value<uint64_t>()};
  const auto k {get_value<uint64_t>()};
  if (n <= k) {
    cout << 0 << '\n';
    return 0;
  }
  auto h {get_container<vector<uint64_t>>(cin, n)};
  sort(h.begin(), h.end());
  h.erase(h.end() - k, h.end());

  cout << accumulate(h.begin(), h.end(), 0ull) << '\n';
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}

template<typename C>
constexpr auto xmaho::integer::ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type
{ return c.size(); }

template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t xmaho::integer::ssize(const T (&)[N]) noexcept
{ return N; }


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    while((st=sc.readLine())!=null){
		String[] sp = st.split(" ");
		if(Double.valueOf(sp[2]) < Double.valueOf(sp[4]) || Double.valueOf(sp[3]) < Double.valueOf(sp[5]) || Double.valueOf(sp[6]) < Double.valueOf(sp[0]) || Double.valueOf(sp[7]) < Double.valueOf(sp[1])) 
		    System.out.println("NO");
		else
		    System.out.println("YES");
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};


int main(){
    int n;
    cin >> n;
    vector<pair<P, int> > p(n);
    rep(i, n) {
        cin >> p[i].first.first >> p[i].first.second;
        p[i].second = i;
    }
    vector<pair<P, int> > q(n);
    rep(i, n) {
        q[i].first.first = p[i].first.second;
        q[i].first.second = p[i].first.first;
        q[i].second = i;
    }
    sort(whole(p));
    sort(whole(q));
    
    vector<pair<int, P> > edge;
    rep(i, n-1) {
        int d1 = p[i+1].first.first - p[i].first.first;
        int d2 = q[i+1].first.first - q[i].first.first;
        edge.emplace_back(d1, P(p[i].second, p[i+1].second));
        edge.emplace_back(d2, P(q[i].second, q[i+1].second));
    }
    sort(whole(edge));
    UnionFind u(n);
    ll ans = 0;
    for (auto e: edge) {
        int l = e.second.first;
        int r = e.second.second;
        int d = e.first;
        if (u.same(l, r)) continue;
        u.unite(l, r);
        ans += (ll)d;
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8764
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int ans = 0;
int n;
bool check_753(int num){
  string tmp  = to_string(num);
  int a = 0, b = 0, c = 0;
  rep(i,tmp.size()){
    if(tmp[i] == '7')a++;
    else if(tmp[i] == '5')b++;
    else if(tmp[i] == '3')c++;
    else return false;
  }
  if(a > 0 && b > 0 && c > 0)return true;
  else return false;
}
bool check_753_can(int num){
  string tmp  = to_string(num);
  int a = 0, b = 0, c = 0;
  rep(i,tmp.size()){
    if(tmp[i] == '7')a++;
    else if(tmp[i] == '5')b++;
    else if(tmp[i] == '3')c++;
    else return false;
  }
  return true;
}
void dfs(int num){
  if(num > n)return;
  if(!check_753_can(num))return;
  dfs(num * 10 + 3);
  dfs(num * 10 + 5);
  dfs(num * 10 + 7);
  if(check_753(num))ans++;
  return;
}
int solve(){
  cin >> n;
  dfs(3);
  dfs(5);
  dfs(7);
  cout<<ans<<endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string S;
	VI a(200, 0);
	cin >> S;

	FOR(i, 0, S.length()) {
		a[S[i]]++;
	}

	string ans = "yes";
	FOR(i, 0, a.size()) {
		if (a[i] >= 2)
			ans = "no";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from bisect import bisect_left

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


L = 30
ans = 0
for l in range(L):
    P = []
    g = 1<<l
    g2 = 1<<(1+l)
    B1 = []
    B2 = []
    for b in B:
        if b&g:
            B1.append(b)
        else:
            B2.append(b)
    B = B2 + B1

    A1 = []
    A2 = []
    for a in A:
        if a&g:
            A1.append(a)
        else:
            A2.append(a)
    A = A1 + A2

    count = 0
    ind1 = 0
    ind2 = 0
    ind3 = 0
    for a in A:
        while ind1 < N and B[ind1]%g2 + a%g2 < g:
            ind1 += 1
        while ind2 < N and B[ind2]%g2 + a%g2 < 2*g:
            ind2 += 1
        while ind3 < N and B[ind3]%g2 + a%g2 < 3*g:
            ind3 += 1
        count += ind2 - ind1 + N - ind3
    if count%2 == 1:
        ans += g
print(ans)

Measured memory_bytes: 146012
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int a[N];
int b[N];
int main(void)
{
    int n;
    ios_base :: sync_with_stdio(0);
    cin>>n;
    for (int i = 1;i <= n;++i)
    	cin>>a[i];
    for (int i = 1;i <= n;++i)
    	cin>>b[i];
    int ans = 0;
    for (int t = 0;t <= 28;++t) {
    	vi s1[2],s2[2];
    	for (int i = 1;i <= n;++i) {
    		s1[(a[i] >> t) & 1].pb(((1 << t) - 1) & a[i]);
    		s2[(b[i] >> t) & 1].pb(((1 << t) - 1) & b[i]);	
    	}
    	for (int k = 0;k < 2;++k) {
    		sort(all(s1[k]));
    		sort(all(s2[k]));
    	}
    	int was = 0;
    	for (int k = 0;k < 2;++k) {
    		for (auto it : s1[k]) {
    			int index1 = lower_bound(all(s2[k^1]),(1 << t) - it) - s2[k ^ 1].begin();
    			was ^= index1;
    			int index2 = lower_bound(all(s2[k]),(1 << t) - it) - s2[k].begin();
    			was ^= (s2[k].size() - index2);
    		}
    	}
    	was &= 1;
    	ans += was * (1 << t);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7940
n,*b=map(int,open(0).read().split())
a=[]
while n:
  j=-1
  for i in range(n):
    if b[i]==i+1:
      j=i
  if j+1:
    b=b[:j]+b[j+1:]
    a+=[j+1]
  else:
    a=[-1]
    break
  n-=1
print(*a[::-1])

Measured memory_bytes: 38768
N,K=map(int,input().split())
S=list(input())
l = [0,0] if (S[0] == '0') else [0]
l += [i for i in range(1,N) if S[i-1] != S[i]]
l += [N] if (S[-1] == '1') else [N,N]

ll=len(l)
p=2*K+1
if ll<p:
    print(N)
else:
    print(max(l[p+i]-l[i] for i in range(0,ll-p+1,2)))

Measured memory_bytes: 8572
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    num = 0
    for i in range(9, N + 1):
        if i % 2 == 0:
            continue
        d = 0
        for j in range(1, N + 1):
            if i % j == 0:
                d += 1 
        if d == 8:
            num += 1
    print(num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21508
A,B,C,D = map(int, input().split())

if (C<A and D<=A) or (B<=C and C<D):
    time = 0
else:
    if A<=C and D<=B:
        time = D-C
    elif C<=A and B<=D:
        time = B-A
    elif C<=A and D<=B:
        time = D-A
    elif A<=C and B<=D:
        time = B-C
print(time)

Measured memory_bytes: 9176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int X = Integer.parseInt(arr[0]);
        int A = Integer.parseInt(arr[1]);
        out.println(X < A ? 0 : 10);
        out.close();
    }

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

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

  int K;
  ll A,B;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2!=0){
        A--;
      }
      B+=A/2;
      A/=2;
    }else{
      if(B%2!=0){
        B--;
      }
      A+=B/2;
      B/=2;
    }
  }
  cout<<A<<" "<<B<<endl;
}

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

int main()
{
    int n, Fa[100001], Fb[100001], Fc[100001], a[100001], b[100001], c[100001];
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];
    Fa[0]=0;
    Fb[0]=0;
    Fc[0]=0;
    for (int i=1; i<=n; i++)
    {
        Fa[i]=max(Fb[i-1],Fc[i-1])+a[i];
        Fb[i]=max(Fa[i-1],Fc[i-1])+b[i];
        Fc[i]=max(Fb[i-1],Fa[i-1])+c[i];
    }
    cout << max(Fa[n],max(Fb[n],Fc[n]));
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  string res  = "No";
  if (S[0] == S[1]) {
    if(S[2] == S[3]) {
      res="Yes";
    }
  } else if (S[0] == S[2]) {
    if(S[1] == S[3]){
      res ="Yes";
    }
  } else if (S[0] == S[3]) {
    if (S[1] == S[2]) {
      res = "Yes";
    }
  }

  if (S[0] == S[1] && S[0] == S[2] && S[0] == S[3]){
    res = "No";
  }

  cout << res << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int q;cin>>q;
    while(q--){
        int n,d;
        cin>>n>>d;

        int ans=(n-1)*127;
        if(n&1)ans+=d;
        else ans+=127-d;
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n,m,k; cin >> n >> m >> k;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i*m+j*n - i*j*2 == k) {cout << "Yes" << endl; return 0;}
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string s; cin >> s;
    ll K; cin >> K;
    ll N = s.size();
    vector<string> X;
    rep(i, N){
        rep2(j, 1, 6){
            if (i + j > N){continue;}
            X.push_back(s.substr(i, j));
            // cout << s.substr(i, j) << endl;
        }
    }
    sort(X.begin(), X.end());
    X.erase(std::unique(X.begin(), X.end()), X.end());
    cout << X.at(K - 1) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge (int A[], int n, int left, int mid, int right)
  {
     int n1 = mid - left;
     int n2 = right - mid;
     
     for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
     for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
     
     L[n1] = R[n2] = SENTINEL;
     
     int i = 0, j = 0;

     for (int k = left; k < right; k++){
       cnt++;
       if ( L[i] <= R[j] ){
         A[k] = L[i++];
       } else {
         A[k] = R[j++];
       }
     }
  }

void mergeSort(int A[], int n, int left, int right){
  if ( left + 1 < right ){
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main(){
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;

  for (i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);

 for (i = 0; i < n; i++){
   if (i) cout << " ";
   cout << A[i];
 }
 cout << endl;

 cout << cnt << endl;

 return 0;
} 

Measured memory_bytes: 5064
#include <iostream>
using namespace std;
#define ll long long int
int main() {
	ll n,w,i,j;
	cin>>n>>w;
	ll a[n],b[n];
	ll dp[n+1][w+1];
	for(i=0;i<n;i++)
	{
	    cin>>a[i]>>b[i];
	}
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=w;j++)
	    {
	        if(i==0||j==0)
	        dp[i][j]=0;
	        else if(a[i-1]>j)
	        dp[i][j]=dp[i-1][j];
	        else 
	        dp[i][j]=max(b[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j]);
	    }
	}
	cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

signed main()
{
    io;
    int n,a,b;cin>>n>>a>>b;
    int ans=0;
    ans += n/(a+b) * a;
   // cout<<ans<<endl;
    ans += min((n-n/(a+b)*(a+b)),a);
    cout<<ans<<endl;


    getchar();getchar();
}


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

namespace io {
    template <typename T> inline void read(T & _x) {
        int f = 0, ch; _x = 0;
        while(!isdigit(ch = getchar())) f |= ch == '-';
        while(isdigit(ch)) _x = _x * 10 + ch - '0', ch = getchar();
        if(f) _x = -_x;
    }
    template <typename T, typename ... Args> inline void read(T &_f, Args& ... args) {
        read(_f), read(args ...);
    }
    inline void _deal(char ch) { putchar(ch); }
    template <typename T> inline void _deal(T _x) {
        if (_x < 0) putchar('-'), _x = -_x;
        if (_x > 9) _deal(_x / 10);
        putchar(_x % 10 + '0');
    }
    inline void write() {}
    template <typename T, typename ... Args> inline void write(T _f, Args ... args) {
        _deal(_f), write(args...);
    }
}

int32_t main() {
	char ch;
	std::cin >> ch;
	if('a' <= ch && ch <= 'z')
		printf("a");
	else
		printf("A");
    return 0;
}



Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();

        System.out.print(String.format("%.6f", a*a*Math.PI)+" "+String.format("%.6f", 2*a*Math.PI));
        System.out.println();
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int N = NK[0];
            int K = NK[1];
            List<int> ilist = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            ilist.Sort();
            int ans = 0;
            for(int i = 0; i < K; i++)
            {
                ans += ilist[i];
            }
            Console.WriteLine(ans);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    ll a, b,c,k;
    cin>>a>>b>>c>>k;

    if(a>=k){
        cout<<k<<endl;
    }else if(a+b>=k){
        cout<<a<<endl;
    }else{
        cout<<a-(k-(a+b))<<endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;
	
	for (int i = X - K + 1; i < X + K; i++) {
		cout << i << " ";
	}
	

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin>>n>>k;
	vector<int>h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	sort(h.begin(),h.end());
	int ans=1145141919;
	for(int i=0;i<=n-k;i++){
		int tmp=h[i+k-1]-h[i];
		if(tmp<ans)ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n2,n,a[100010],ans,dat[400010];

void upd(int k,int lb,int ub)
{
	if(lb!=ub)
	{
		upd(k*2+1,lb,(lb+ub)/2);
		upd(k*2+2,(lb+ub)/2+1,ub);
		if(dat[k*2+1]==dat[k*2+2]&&dat[k*2+1]==-1) dat[k]=-1;else
		if(dat[k*2+2]==-1) dat[k]=dat[k*2+1];else
		dat[k]=__gcd(dat[k*2+1],dat[k*2+2]);
	}
	if(lb>=n2) dat[k]=-1;
}

int main()
{
	cin>>n2;
	n=1;
	while(n<n2) n*=2;
	rep(i,n2) scanf("%d",&a[i]),dat[i+n-1]=a[i];
	upd(0,0,n-1);
	rep(i,n)
	{
		int pos=i+n-1,now=-1,whi,t;
		while(true)
		{
			whi=(pos%2==0 ? 1:2);
			pos=(pos-1)/2;
			if(dat[pos*2+whi]==now&&dat[pos*2+whi]==-1) now=-1;else
			if(dat[pos*2+whi]==-1);else
			if(now==-1) now=dat[pos*2+whi];else
			now=__gcd(dat[pos*2+whi],now);
			if(pos==0) break;
		}
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 1664
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {
    int n,k;cin >>n>>k;
    vector<int> a(n);
    rep(i,n){cin >>a[i];a[i]--;}

    UnionFind uni(n);
    int now=0;
    vector<int> rot;
    int bac;
    while(1){
        if(!uni.same(now,a[now])){
            rot.pb(now);
            uni.unite(now,a[now]);
            int T=a[now];
            now=T;
        }else{
            rot.pb(now);
            rep(i,rot.size()){
                if(a[now]==rot[i]){
                    bac=i;break;
                }
            }
            break;
        }
    }

    if(rot.size()>k)cout <<rot[k]+1<<endl;
    else{
        int nk=k-(bac);
        cout <<rot[(nk%(rot.size()-bac))+bac]+1<<endl;
    }
    /*cout <<bac<<" "<<rot.size()<<endl;
    rep(i,rot.size())cout <<rot[i]<<endl;*/
}


















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

int main()
{
    char s[1000], x;
    int i, j, l;
    cin>>s;
    l = strlen(s);
    for(i = 0; i < l; i++){
        x = s[i];
         for(j = 0; j < l; j++){
            if(j != i){
                if(x == s[j])
                {
                    cout<<"no";
                    return 0;
                }
            }
         }
    }
    cout<<"yes";
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    
    X = abs(X);
    ll n = X / D;
    if(n >= K) PR(X-K*D);
    else {
        K -= n;
        ll right = X - n * D, left = abs(X - (n + 1) * D);
        if(K % 2 == 0) PR(right);
        else PR(left);
    }    

    return 0;
}

/*



*/

Measured memory_bytes: 3628
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

struct edge{
  int to, cost;
};

vector<edge> g[100010];
int x[100010], y[100010], dp[100010];
bool used[100010];

void dfs(int num) {
  used[num] = true;
  REP(i, g[num].size()) {
    if(used[g[num][i].to]) continue;
    dp[g[num][i].to] = dp[num] + g[num][i].cost;
    dfs(g[num][i].to);
  }
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a].PB({b, c});
    g[b].PB({a, c});
  }
  int q, k;
  cin >> q >> k;
  k--;
  REP(i, q) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }

  dp[k] = 0;
  used[k] = true;
  dfs(k);

  // REP(i, n) cout << dp[i] << " "; cout << endl;

  REP(i, q) {
    cout << dp[x[i]] + dp[y[i]] << endl;
  }

  return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    int i = 0;
    while (m) {
        int cnt = min(m, v[i].second);
        ans += 1ll * v[i].first * cnt;
        m -= cnt;
        ++i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin >>s;
    //Sunny, Cloudy, or Rainy
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else
        cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    ll cn=0;
    rep(i,0,s.size()-1){
        if(s.at(i)==s.at(i+1))cn++;
    }
    ll ans=min(n-1,cn+2*k);
    cout<<ans<<endl;
}







Measured memory_bytes: 512
n,m=map(int,input().split())
s=input()
t=input()
flag=0
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)
l=lcm(n,m)
for i in range(n):
  if (i*m)%n==0:
    j=i*m//n
    if s[i]!=t[j]:
      flag=1
      break
if flag==0:
  print(l)
else:
  print(-1)

Measured memory_bytes: 3316
def is_ok(mid: int, target: int, ls: []):
    return target <= ls[mid]


def bi_search(target: int, ls: []):
    ng = -1
    ok = len(ls)

    cnt = 0
    while ok - ng > 1:
        mid = ng + int((ok - ng) / 2)
        cnt += 1
        if is_ok(mid, target, ls):
            ok = mid
        else:
            ng = mid
    return ok


def main():
    n = int(input())
    l_dic = {}
    r_dic = {}
    i = 0
    for a in map(int, input().split()):
        ld = l_dic.setdefault(i + a, [])
        ld.append(i)
        rd = r_dic.setdefault(i - a, [])
        rd.append(i)
        i += 1

    count = 0
    for rk, rv_list in r_dic.items():
        if rk not in l_dic:
            continue
        lv_list = l_dic[rk]
        for rv in rv_list:
            ind = bi_search(rv, lv_list)
            if ind == len(lv_list):
                count += ind
            else:
                count += ind + 1
            # for lv in lv_list:
            #     if lv < rv:
            #         count += 1
            #     else:
            #         break

    print(count)


main()


Measured memory_bytes: 98960
#include<stdio.h>

int main(){
  int i,j,minj,c,l;
  int number=0,count=0;
  int n[100];
  scanf("%d",&l);
  
  for(i=0 ; i<l ; i++){
    scanf("%d",&n[i]);
  }
  for(i=0 ; i<l ; i++){
    minj = i;
    for(j=i ; j<l ; j++){
      if(n[j]<n[minj]){
	minj = j;
      }
    }
    if(minj != i){
    count++;
    c=n[i];
    n[i]=n[minj];
    n[minj] = c;
    }
  }
  for(i=0 ; i<l ; i++){
    if(i<l-1) printf("%d ",n[i]);
    else printf("%d\n",n[i]);
  }
  printf("%d\n",count);
}



Measured memory_bytes: 2144
#!/usr/bin/env pypy3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, x, y = map(int, sys.stdin.readline().split())
	x -= 1
	y -= 1
	ans = [0]*(n-1)
	for i in range(n):
		for j in range(i+1, n):
			if i == j:
				continue
			if (i <= x and j <= x) or (y <= i and y <= j):
				ans[abs(i-j)-1] += 1
			elif (i <= x and y <= j):
				ans[x-i + j-y + 1 - 1] += 1
			elif (x < i < y and x < j < y):
				ans[min(abs(i-j), i-x + 1 + y-j)-1] += 1
			elif (i <= x and x < j < y):
				ans[min(abs(i-j), x-i + 1 + y-j)-1] += 1
			elif (x < i < y and y <= j):
				ans[min(abs(i-j), j-y + 1 + i-x)-1] += 1
	for i in range(len(ans)):
		print(ans[i])







main()

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

int N, A, B, C;
int l[10];

int dfs(int d, int a, int b, int c) {
    if (d==N) {
        if (min({a, b, c})>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return 1000000;
    }
    int res = 1000000;
    res = min(res, dfs(d+1, a, b, c));
    res = min(res, dfs(d+1, a+l[d], b, c)+10);
    res = min(res, dfs(d+1, a, b+l[d], c)+10);
    res = min(res, dfs(d+1, a, b, c+l[d])+10);
    return res;
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> cnt(n, 0), ans;
    rrep(i, n) {
        ll cur = i, sum = 0;
        while(cur < n) {
            sum += cnt[cur];
            cur += i + 1;
        }
        if (sum % 2 != a[i]) {
            ans.push_back(i + 1);
            cnt[i]++;
        }
    }
    printf("%lld\n", sz(ans));
    rep(i, sz(ans)) printf("%lld%s", ans[i], (i == (sz(ans) - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 5108