akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        private static final int INF = (int) 1e7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String S = in.next();
            int N = S.length();

            int[] dp = new int[1 << 26];
            Arrays.fill(dp, INF);
            int mask = 0;
            dp[0] = 0;

            for (int i = 0; i < N; i++) {
                mask ^= 1 << (S.charAt(i) - 'a');

                dp[mask] = Math.min(dp[mask], i + 1);

                for (int j = 0; j < 26; j++) {
                    dp[mask] = Math.min(dp[mask], 1 + dp[mask ^ 1 << j]);
                }
            }

            out.println(Math.max(1, dp[mask]));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 292692
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
    }

    let sm = a.iter().fold(0, |sum, x| sum + x);
    let mut anss = vec![0; n];
    anss[0] = sm;
    for i in 1..n {
        if i % 2 == 1 {
            anss[0] -= 2 * a[i];
        }
    }
    println!("{}", anss[0]);
    for i in 1..n {
        anss[i] = 2 * a[i - 1] - anss[i - 1];
        println!("{}", anss[i]);
    }
}


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

#define vi vector<int>

int main() {

    int N;
    cin >> N;

    int tmp;
    vi A;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }

    bool flag = true;
    int count = 0;
    while (flag) {
        flag = false;
        for (int j = N - 1; j > 0; j--) {
            if (A[j] < A[j - 1]) {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                count++;
                flag = true;
            }
        }
    }

    for (int k = 0; k < N; k++) {
        cout << A[k];
        if (k != N - 1) {
            cout << " ";
        }
        else {
            cout << endl;
        }
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3148
#include<iostream>
using namespace::std;
int main(){
int k;
cin>>k;
string str1;
cin>>str1;
if(k%2==0){
int i=k/2;
string str2=str1.substr(i);

//string str2(str1,str1+i);
string str3=str2+str2;
 if(str1==str3)
   cout<<"Yes";
  else 
    cout<<"No";
}
else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  ll n ;cin >>n ;
  vector<ll> A(n) ; rep(i,n) cin>>A[i] ;
  sort(A.begin(),A.end()) ;
  ll ans=0 ;
  rep(i,n-2){
     rep2(j,i+1,n-2){
      ll k= lower_bound(A.begin(),A.end(),A[i]+A[j])-A.begin() ;
      k-- ;
      if(A[n-1]<A[i]+A[j])  ans+=n-1-j ;
      else ans+= k-j ;
     }
  }
     cout<<ans<<endl ;
     return 0;
  }

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
max_conf=max(X)
point=[0]*(max_conf+1)
point[0]=10000000000

for i in range(1,max_conf+1):
  for j in X:
    point[i]=point[i]+(j-i)**2
print(min(point))
  

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<int, int> count;
  rep(i, N) {
    int A;
    cin >> A;
    count[A]++;
  }

  if (2 <= (count.rbegin()->first - count.begin()->first) || 2 < count.size()) {
    cout << "No" << endl;
    return 0;
  }

  if (count.size() == 2) {
    int B = count.rbegin()->first;
    int x = count.begin()->second;
    int y = N - x;
    if (x < B && 2 * (B - x) <= y) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {  // 1
    int B = count.begin()->first;
    if ((2 * B <= N) || (B + 1) == N) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8268
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var h [10000000]int
	for i := 0; i < n; i++ {
		var num int
		fmt.Scan(&num)
		h[i] = num
	}

	count := 0
	for i := 0; i < n; i++ {
		if h[i] >= k {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        long x = in.nextLong();
        long mod11 = x % 11L;
        long div11 = x / 11L;
        final long ans;
        if (mod11 == 0) {
            ans = div11 * 2L;
        } else {
            if (mod11 <= 6) {
                ans = (div11) * 2L + 1;
            } else {
                ans = div11 * 2L + 2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 9044
#include <cstdio>
#include <algorithm>

int n,a[300005],s[300005],s0,s1;

bool Check(int x)
{
    int v=0;
    for(int i=1;i<n;i+=2)
        if(s[i]-v>=x)
            v=std::min(v,s[i+1]);
    return s[n]-v>=x;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    if(!(n&1))
    {
        for(int i=1;i<=n;++i)(i&1?s0:s1)+=a[i];
        printf("%d %d\n",std::max(s0,s1),std::min(s0,s1));
        return 0;
    }
    for(int i=1;i<=n;++i)s[i]=s[i-1]+(i&1?a[i]:-a[i]);
    int l=1,r=1000*n,Mid;
    while(l<r)
        if(Check(Mid=(l+r)>>1))l=Mid+1;
        else r=Mid;
    int Ans=l-1,Sum=0;
    for(int i=2;i<=n;i+=2)Ans+=a[i];
    for(int i=1;i<=n;++i)Sum+=a[i];
    printf("%d %d\n",Ans,Sum-Ans);
    return 0;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc134/tasks/abc134_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // 最大の数と、最大の数が何回出現するか
    int N, maxv = 0, cnt = 0, before = 0;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
        if (A[i] > maxv) {
            before = maxv;
            maxv = A[i];
            cnt = 1;
        } else if (A[i] == maxv) {
            cnt++;
        } else {
            before = max(before, A[i]);
        }
    }
    REP(i, N) {
        if (A[i] == maxv && cnt == 1) {
            cout << before << "\n";
        } else {
            cout << maxv << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int k;
  cin>>k;
  for(int i=0;i<k;i++){
    if(s[i]=='1'&&k==i+1){
      cout<<1<<endl;
      return 0;
    }else if(s[i]!='1'){
      cout<<s[i]<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const nums = input.split(/\s/).map(str => { return parseInt(str) });
    console.log(Math.min(nums[1], nums[2]) + ' ' + Math.max(nums[1] + nums[2] - nums[0], 0));
};
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,0,n) cin >> a[i];
    ll sxor[n+1] = {},ssum[n+1] = {};

    rep(i,0,n){
        sxor[i+1] = sxor[i] ^ a[i];
        ssum[i+1] = ssum[i] + a[i];
    }

    ll cnt = 0;
    rep(i,0,n){
        ll ok = i,ng = n;
        while(abs(ok-ng) > 1){
            ll mid = (ok+ng)/2;

            if((sxor[mid+1] ^ sxor[i]) == (ssum[mid+1] - ssum[i])){
                ok = mid;
            }
            else{
                ng = mid;
            }
        }
        cnt += ok - i + 1;
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, X) for (auto itr = X.begin(); itr != X.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int MOD = 1000000007;
const int INF = 1000000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> snuke(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            ++snuke[a - 1];
        }
    }

    int ans = 0;
    rep(i, n) {
        if (snuke[i] == 0) ++ans;
}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    H, W = MAP()
    S = [input() for i in range(H)]
    # 上下左右
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    D = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                L[i][j] = 0
            elif j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
    for i in range(H):
        for j in range(W-1, -1, -1):
            if S[i][j] == "#":
                R[i][j] = 0
            elif j == W-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
    
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                U[i][j] = 0
            elif i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

    for i in range(H-1, -1, -1):
        for j in range(W):
            if S[i][j] == "#":
                D[i][j] = 0
            elif i == H-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1
    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
    print(ans)

if __name__ == "__main__":
    main()




Measured memory_bytes: 187868
#include<iostream>
#include<stack>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<sstream>

using namespace std;

int main(){
    stack<int> st;

    
    string line;
    getline(cin,line);
    line += " ";
    stringstream ss;
    ss<<line;
    
    while (1) {
        char s[100];
        ss>>s;
        if (ss.eof()) {
            break;
        }
        //cout<<s[0]<<endl;
        if (s[0]=='+') {
            //cout<<st.top()<<endl;
            int a = st.top();
            st.pop();
            //cout<<st.top()<<endl;
            int b = st.top();
            st.pop();
            st.push(a+b);
        }
        else if(s[0]=='-'){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(b-a);
        }
        else if(s[0]=='*'){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a*b);
        }
        else{
            int x = atoi(s);
            st.push(x);
        }
    }
    cout<<st.top()<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define f first
#define s second
#define ss string
#define mp make_pair
#define pb push_back
#define p pair<int, int>
#define pp pair<int, p>
#define v vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<p>
#define vpp vector<pair<int, p>>
#define vv vector<v>
#define vvl vector<vl>
#define vvp vector<vp>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repa(i, a, n) for(int i = a; i <= (n); ++i)
#define repd(i, n) for(int i = n; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ss ans = "";
        while(n > 0){
            if(n%26 == 0){
                ans += 'z';
                n = (n-26)/26;
            }
            else{
                ans += 'a'+ n%26-1;
                n /= 26;
            }
        }
        reverse(all(ans));
        cout << ans;
    return 0;
}   

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15); } };

vector<string> s;
int h, w;
int dist(int stx, int sty){
    vector<vector<int>> step(h, vector<int>(w, -1));
    queue<pair<int, int>> q;
    q.emplace(stx, sty);
    step[sty][stx] = 0;
    while(!q.empty()){
        pair<int, int> xy = q.front(); q.pop();
        int x = xy.first, y = xy.second;
        rep(i, 4){
            int X = x+dx[i], Y = y+dy[i];
            if(X < 0 or X >= w or Y < 0 or Y >= h) continue;
            if(step[Y][X] >= 0) continue;
            if(s[Y][X] == '#') continue;
            step[Y][X] = step[y][x] + 1;
            q.emplace(X, Y);
        }
    }
    int ret = 0;
    rep(i, h){
        rep(j, w){
            chmax(ret, step[i][j]);
        }
    }
    return ret;

}

int main(){

    scanf("%d%d", &h, &w);
    s.resize(h);
    int ans = 0;
    vector<pair<int, int>> start;
    rep(i, h){
        cin >> s[i];
        rep(j, w){
            if(s[i][j] == '.')
                start.emplace_back(j, i);
        }
    }
    for(pair<int, int> st : start){
        chmax(ans, dist(st.first, st.second));
    }
    ppp(ans);


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)

{
 int a,b,d,r;
 double f;
 
 scanf("%d %d",&a,&b);

 d=a/b;
 r=a%b;
 f=(double)a/(double)b;

 printf("%d %d %lf\n",d,r,f);

 return 0;
}

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

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> st;
    vector<int> order(n+1, -1);
    int t, l, v = 1;
    while(1) {
        if(order[v]!=-1) {
            l = order[v];
            t = st.size() - l;
            break;
        }
        order[v] = st.size();
        st.push_back(v);
        v = a[v-1];
    }
    if(k<l) cout << st[k] << endl;
    else {
        k-=l;
        k%=t;
        cout << st[k+l] << endl;
    }
    return 0;
}

Measured memory_bytes: 5792
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll k,a,b;
    cin>>k>>a>>b;
    ll i;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK\n";
            return;
        }
    }
    cout<<"NG\n";
  
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

	String S = sc.next();
	String x[] = S.split("");

	int count = 0;
	if (x.length < 2)
	    System.out.println(0);
	else {
	    for (int i = 1; i < x.length; i++) {
		if (x[i - 1].equals(x[i])) {
		    if (x[i].equals("0"))
			x[i] = "1";
		    else if (x[i].equals("1"))
			x[i] = "0";
		    count++;
		}
	    }
	    System.out.println(count);
	}
    }
}

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

int main(void){
    int k,n;
    cin >> k >> n;
    int sum = 2*k-1;
    for(int i=0;i<sum;i++){
        if(i!=sum-1) cout << n-k+1+i << " ";
        else cout << n-k+1+i << endl;

    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	string s;
	cin >> s;
	vector<char> c;
	vector<int> r;
	int k=1;
	for(int i=1;i<s.size();i++)
	{
		if(s[i-1]==s[i])k++;
		else
		{
			if(s[i-1]=='J')c.pb('J');
			if(s[i-1]=='O')c.pb('O');
			if(s[i-1]=='I')c.pb('I');
			r.pb(k);
			k=1;
		}
	}
	if(s[s.size()-1]=='J')c.pb('J');
	if(s[s.size()-1]=='O')c.pb('O');
	if(s[s.size()-1]=='I')c.pb('I');
	r.pb(k);
	int ans=0;
	for(int i=1;i<r.size()-1;i++)
	{
		int res=0;
		if(c[i]=='O'&&c[i-1]=='J'&&c[i+1]=='I')
		{
			if(r[i-1]>=r[i]&&r[i]<=r[i+1])res=r[i];
		}
		ans=max(ans,res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9152
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n int
  fmt.Scan(&n)
  as := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&as[i])
  }
  sort.Ints(as)
  isPossible := true
  if n%2 == 0 {
    for i, a := range as {
      if a != (i/2)*2+1 {
        isPossible = false
        break
      }
    }
  } else {
    for i, a := range as {
      if i == 0 && a != 0 {
		isPossible = false
        break
      }
      if a != ((i+1)/2)*2 {
        isPossible = false
        break
      }
    }
  }
  var result int
  if isPossible {
    result = 1
    for i := 0; i < n/2; i++ {
      result *= 2
      result %= 1000000007
    }
  } else {
    result = 0
  }

  fmt.Println(result)  
}

Measured memory_bytes: 5504
N = int(input())
A = list(map(int, input().split()))
c = 0
k = 0
for i in range(N):
    if A[i] < 0:
        c += 1
        A[i] *= -1
    elif A[i] == 0:
        k = 1

if c % 2 == 0:
    print(sum(A))
elif k == 1:
    print(sum(A))
else:
    print(sum(A)-2*min(A))

Measured memory_bytes: 85144
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long A, long long B){
    REP(i,1,1000000){
        if(i*8/100==A && i*10/100==B){
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[99, 50];
        var j = 0;
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] line2 = line.Trim().Split(',');
            for (int i = 0; i < line2.Length; i++)
                a[j, i] = int.Parse(line2[i]);
            j++;
        }
        var w = (j + 1) / 2;
        var dp = new int[j, w];
        goDp(a, dp);
        Console.WriteLine(dp[j - 1, 0]);
    }
    public static void goDp(int[,] a, int[,] dp)
    {
        var h = dp.GetLength(0);
        var w = dp.GetLength(1);
        dp[0, 0] = a[0, 0];
        for (int i = 1; i < w; i++)
        {
            dp[i, 0] = dp[i - 1, 0] + a[i, 0];
            dp[i, i] = dp[i - 1, i - 1] + a[i, i];
        }
        for (int i = 2; i < w; i++)
            for (int j = 1; j <= i - 1; j++)
                dp[i, j] = a[i, j] + Math.Max(dp[i - 1, j - 1], dp[i - 1, j]);
        for (int i = w ; i < h; i++)
            for (int j = 0; j <= h - 1 - i; j++)
                dp[i, j] = a[i, j] + Math.Max(dp[i - 1, j], dp[i - 1, j + 1]);
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), B(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    B[i] = a[i] - i - 1;
  }  
  sort(B.begin(), B.end());
  int b = B[n/2];
  ll ans = 0;
  for (int i = 0; i < n; i++) ans += abs(a[i] - (b+(i+1)));
  cout << ans << endl;
}

Measured memory_bytes: 4832
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll a[1000002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n, s=0;
	cin>>n;
	for (int i = 0; i <= n; ++i)
	{
		cin>>a[i];
		s += a[i];
	}
	ll ans = 0;
	ll tot=0;
	for (int i = 0; i <= n; ++i)
	{
		ans*=2;
		if (i==0)
		{
			ans++;
		}
		if (ans < a[i])
		{
			cout<<-1<<endl;
			return 0;	
		}
		if (ans>s)
		{
			ans = s;
		}
		ans -= a[i];
		tot += ans + a[i];
		// cout<< ans + a[i]<<endl;
		s -= a[i];
	}
	if (tot==0)
	{
		tot = -1;
	}
	cout<<tot<<endl;
	return 0;	
}


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

class Progaram
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine().Split(' ').ToArray();
        var H = int.Parse(str[0]);
        var N = int.Parse(str[1]);
        var str2 = Console.ReadLine().Split(' ').ToArray();
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {            
            A[i] = int.Parse(str2[i]);
        }

        int Sum = 0;
        
        for(int i = 0;i < N;i++)
        {
            Sum += A[i];
            
            if(Sum >= H)
            {
                Console.WriteLine("Yes");
                return;
            }

        }
        Console.WriteLine("No");

    }
}

Measured memory_bytes: 19808
from collections import deque
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
s = [list(input()) for _ in range(h)]
visited = [[False]*w for _ in range(h)]
ch -= 1
cw -= 1
dh -= 1
dw -= 1

coordinates = [(1,0),(0,1),(-1,0),(0,-1)]

que = deque([(0,ch,cw)])
while que:
    d,i,j = que.popleft()
    if (i,j) == (dh,dw):
        print(d)
        exit()
    if visited[i][j]:
        continue
    visited[i][j] = True
    for cdi,cdj in coordinates:
        ni,nj = i + cdi, j + cdj
        if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == '.':
            que.appendleft((d,ni,nj))
    for di in range(-2,3):
        for dj in range(-2,3):
            if di == dj == 0:
                continue
            ni,nj = i+di,j+dj
            if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == '.' and not visited[ni][nj]:
                que.append((d+1,ni,nj))
print(-1)

Measured memory_bytes: 235776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

int s;

int memo[2020];
int md = 1e9+7;
int dp(int at) {
    if(at > s) return 0;
    if(at == s) return 1;
    if(memo[at] != -1) return memo[at];
    int sm = 0;
    rep(i,3,s+1) {
        sm += dp(at+i);
        sm %= md;
    }
    return memo[at] = sm;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> s;
    cout << dp(0) << endl;
}



Measured memory_bytes: 3716
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

A, B, M = tuple(load_list())

a = load_list()
b = load_list()

coupon = dict()
for _ in range(0, M):
    x, y, c = tuple(load_list())
    if (x-1, y-1) in coupon:
        coupon[(x-1,y-1)] = max(coupon[(x-1,y-1)], c)
    else:        
        coupon[(x-1,y-1)] = c 

minv = min(a) + min(b)

for key in coupon.keys():
    i, j = key
    minv = min(minv, a[i] + b[j] - coupon[(i, j)])

print(minv)




Measured memory_bytes: 35696
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
const int MAX_V = 202, infty=1<<28;
struct edge {
	int to, cap, rev;
};
std::vector<edge> G[MAX_V];
bool used[MAX_V];
void add_edge(int from, int to, int cap) {
	edge a = { to,cap,(int)G[to].size() }, b = { from,0,(int)G[from].size()};
	G[from].push_back(a);
	G[to].push_back(b);
}
//頂点sから頂点tへ深さ優先探索。残り容量はf
int dfs(int s, int t, int f) {
	if (s == t)return f;
	used[s] = true;
	for (int i = 0; i < (int)G[s].size(); i++) {
		edge &e = G[s][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, std::min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	while (true) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, infty);
		if (f == 0)return flow;
		flow += f;
	}
}
int main() {
	int n, a[100], b[100], c[100], d[100], i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d%d", &a[i], &b[i]);
	for (i = 0; i < n; i++)scanf("%d%d", &c[i], &d[i]);
	for (i = 0; i < n; i++) {
		add_edge(2 * n, i, 1);
		add_edge(n + i, 2 * n + 1, 1);
		for (j = 0; j < n; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				add_edge(i, n + j, 1);
			}
		}
	}
	printf("%d", max_flow(2 * n, 2 * n + 1));
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i,0,n) {
		int a;
		cin >> a;
		mp[a]++;
	}

	ll ans=0LL;
	for (auto x : mp) {
		if (x.first <= x.second) {
			ans += x.second - x.first;
		}
		else {
			ans += x.second;
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 4736
n = int(input())
H = list(map(int, input().split()))

INF = 10 ** 9
dp = [INF] * n
dp[0] = 0
for i in range(n - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))
    if i < n - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))
print(dp[-1])


Measured memory_bytes: 13976
#include<stdio.h>

int gcd(int x, int y)
{
  if (y == 0)
    return x;

  return gcd(y, x % y);
}
int main(void)
{
  int x, y, tmp;

  scanf("%d %d", &x, &y);

  if (y > x) {
    tmp = x;
    x = y;
    y = tmp;
  }
  printf("%d\n", gcd(x, y));
  
  return 0;
}



Measured memory_bytes: 2096
import java.util.Scanner;

public class Main{
	static BinaryOperator add = new BinaryOperator(){
		@Override
		public int apply(int left, int right){ return left + right;}
		public String toString() { return "+";}
	};
	
	static BinaryOperator subtract = new BinaryOperator(){
		@Override
		public int apply(int left, int right){ return left - right;}
		public String toString() { return "-";}
	};
	
	static BinaryOperator multiply = new BinaryOperator(){
		@Override
		public int apply(int left, int right){ return left * right;}
		public String toString() { return "*";}
	};

	static int[][] permutation4 = new int[24][4];
	static BinaryOperator[] operation = new BinaryOperator[] {add, subtract, multiply};
	static BinaryOperator[][] permutation3 = new BinaryOperator[27][3];
	
	static {
		int n = 0;
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 4; j++) {
				if(i == j) continue;
				for(int k = 0; k < 4; k++) {
					if(i == k || j == k) continue;
					permutation4[n++] = new int[] {i, j, k, 6-i-j-k};
				}
			}
		}
		
		n = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 3; k++) {
					permutation3[n++] = new BinaryOperator[] {operation[i], operation[j], operation[k]};
				}
			}
		}
	}
	
	static FourExpression solve(int i1, int i2, int i3, int i4) {
		int[] in = new int[] {i1, i2, i3, i4};
		boolean[] bra = new boolean[] {false, true};
		for(int[] perm: permutation4) {
			for(BinaryOperator[] bp: permutation3) {
				for(boolean b: bra) {
					FourExpression result = new FourExpression(in[perm[0]], in[perm[1]], in[perm[2]], in[perm[3]], bp[0], bp[1], bp[2], b);
					if(result.calc() == 10) return result;
				}
			}
		}
		return null;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
			int arr[] = new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
			if(arr[0] == 0 && arr[1] == 0 && arr[2] == 0 && arr[3] == 0) break;
			
			FourExpression out = solve(arr[0], arr[1], arr[2], arr[3]);
			if(out != null)System.out.println(out);
			else System.out.println(0);
		}
		sc.close();
	}
	
}

interface BinaryOperator{
	int apply(int left, int right);
	String toString();
}

class FourExpression{
	
	int i1, i2, i3, i4;
	BinaryOperator o1, o2, o3;
	boolean bracket;
	
	public FourExpression(int i1, int i2, int i3, int i4, BinaryOperator o1, BinaryOperator o2, BinaryOperator o3, boolean bracket){
		this.i1 = i1;
		this.i2 = i2;
		this.i3 = i3;
		this.i4 = i4;
		this.o1 = o1;
		this.o2 = o2;
		this.o3 = o3;
		this.bracket = bracket;
	}
	
	int calc(){
		return bracket? o2.apply(o1.apply(i1, i2), o3.apply(i3, i4)): o3.apply(o2.apply(o1.apply(i1, i2), i3), i4);
	}
	
	public String toString() {
		return bracket? "(" + i1 + o1.toString() + i2 +")" + o2.toString() + "(" + i3 + o3.toString() + i4 + ")":
				"((" + i1 + o1.toString() + i2 + ")" + o2.toString() + i3 + ")" + o3.toString() + i4;
	}
}

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

int main(){
  int n,a=0;
  cin>>n;
  for(int i=1;i<=9;i++){
    if(n%i==0){
      if(n/i>9){
      }
      else{
        a=1;
        break;
      }
    }
    else{
    }
  }
  if(a==0)cout<<"No"<<endl;
  else if(a==1) cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
point = 0
hantei = 'x'

for i in range(n):
  if t[i] == 'r':
    t[i] = 'p'
  elif t[i] == 's':
    t[i] = 'r'
  elif t[i] == 'p':
    t[i] = 's'

  if k <= i:
    hantei = t[i-k]

  if t[i] != hantei:
    if t[i] == 'r':
      point += r
    elif t[i] == 's':
      point += s
    elif t[i] == 'p':
      point += p
  else:
    t[i] = 'x'

print(point)

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B==C){
    cout << "No" << endl;
  }
  else if(A!=B && B!=C && C!=A){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;	cin>>n;
	int buc[6]={0};
	while(n--){
		double t;	cin>>t;
		if     (t<165)	buc[0]++;
		else if(t<170)	buc[1]++;
		else if(t<175)	buc[2]++;
		else if(t<180)	buc[3]++;
		else if(t<185)	buc[4]++;
		else			buc[5]++;
	}
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
		for(int j=0;j<buc[i];j++)	cout<<'*';
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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 main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l;
  double ans = 0;
  double r;
  cin >> r;

  ans = 2 * PI * r;

  cout << std::fixed;
  cout << setprecision(6) << ans << endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e10;

vector<vector<int>> e;
vector<int> dp, o, a;

void dfs(int v, int p = -1) {
  auto it = lower_bound(dp.begin(), dp.end(), a[v]);
  int prev = *it;
  *it = a[v];
  for(auto x : e[v])
    if(x != p) dfs(x, v);
  o[v] = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INF)) - 1;
  *it = prev;
}

int main() {
  int n;
  scanf("%d", &n);
  e = vector<vector<int>>(n);
  dp = vector<int>(n + 1, INF);
  o = vector<int>(n);
  a = vector<int>(n);
  dp[0] = -INF;
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  for(int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    e[--u].push_back(--v);
    e[v].push_back(u);
  }
  dfs(0);
  for(int i = 0; i < n; i++) printf("%d\n", o[i]);
}

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

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


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

///@Tanvir

///template from: profile/hitman623
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define for0(i,a)   for(int i=0; i<a; i++)
#define bloop(i,n)  for(int i=n-1; i>=0; i--)


#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define N 100005

using namespace std;



void solve(){
    vi mp(N);
    int n;
    cin>>n;
    int a[n];
    int sum = 0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum += a[i];
        mp[a[i]]++;

    }
    int q;
    cin>>q;
    while (q--)
    {
        int b, c;
        cin>>b>>c;
        ///int cntb = mp[b];
        ///cout<<"cntb= "<<mp[b]<<"\n";

        /* code */
        //int diff = c - b;
        sum += (mp[b])*(c-b);
        cout<<sum<<"\n";


        mp[c]+= mp[b];
        mp[b] = 0;
    }




}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    f_in("in.txt");
//    f_out("out.txt");
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4752
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,k = m() 

l = []
a = (n-1)*(n-2)//2
if k > a:
    print(-1)
else:
    print(n-1 + a - k)
    co = a - k
    for i in range(2,n+1):
        l.append([1,i])
    for i in range(2,n+1):
        if co == 0:
            break
        for j in range(i+1,n+1):
            l.append([i,j])
            co -= 1
            if co == 0:
                break
        if co == 0:
            break
    for i in range(len(l)):
        print(jo(l[i]))








Measured memory_bytes: 68076
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  char C[H][W];
  rep(i,0,H-1)
    rep(j,0,W-1) cin >> C[i][j];

  rep(i,0,H-1) {
    rep(j,0,1) {
      rep(k,0,W-1) {
        cout << C[i][k];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256