akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	s := readString()

	rindices := make([]int, 0, len(s))
	lindices := make([]int, 0, len(s))
	for i := range s {
		if s[i] == 'R' {
			rindices = append(rindices, i)
		} else {
			lindices = append(lindices, i)
		}
	}

	ans := make([]int, len(s))
	for i := range s {
		if s[i] == 'R' {
			lidx := lindices[sort.SearchInts(lindices, i)]
			if (lidx-i)%2 == 0 {
				ans[lidx]++
			} else {
				ans[lidx-1]++
			}
		} else {
			ridx := rindices[sort.SearchInts(rindices, i)-1]
			if (i-ridx)%2 == 0 {
				ans[ridx]++
			} else {
				ans[ridx+1]++
			}
		}
	}

	for i := range ans {
		fmt.Printf("%v ", ans[i])
	}
}


Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
#include<queue>
using namespace std;
static const int MAX=100000;
vector<int>G[MAX];
list<int>out;
bool V[MAX];
int n;
int indeg[MAX];
void bfs(int s){
  queue<int>q;
  q.push(s);
  V[s]=true;
  while(!q.empty()){
    int u=q.front();
    q.pop();
    out.push_back(u);
    for(int i=0;i<G[u].size();++i){
      int v=G[u][i];
      indeg[v]--;
      if(indeg[v]==0 && !V[v]){
	V[v]=true;
	q.push(v);
      }
    }
  }
}
void tsort(){
  for(int i=0;i<n;++i){ 
    indeg[i]=0; 
  }
  for(int u=0;u<n;++u){
    for(int i=0;i<G[u].size();++i){
      int v=G[u][i];
      indeg[v]++;
    }
  }
  for(int u=0;u<n;++u) if(indeg[u]==0 && !V[u]) bfs(u);
  for(list<int>::iterator it =out.begin(); it!=out.end(); ++it){
    cout<<*it<<endl;
  }
}
int main(){
  int s,t,M;
  cin>>n>>M;
  for(int i=0;i<n;++i){ V[i]=false; }
  for(int i=0;i<M;++i){
    cin>>s>>t;
    G[s].push_back(t);
  }
  tsort();
  return 0;
}



Measured memory_bytes: 6156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,ans;
  string op;
  cin >> A >> op >> B;
  if(op.at(0) == '+'){
    ans = A + B;
  }else if (op.at(0) == '-'){
    ans = A - B;
  }
  cout << ans << endl;

}

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

int main()
{
    int N;
    cin >> N;
    N %= 10;
    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
    {
        cout << "hon" << endl;
    }
    else if (N == 3)
    {
        cout << "bon" << endl;
    }
    else
    {
        cout << "pon" << endl;
    }
}


Measured memory_bytes: 3636
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def comb_mod(n, r):
    res = 1
    r = min(n - r, r)

    for i in range(r):
        res *= (n - i)
        res %= MOD
        res *= pow((r - i), MOD - 2, MOD)

    return res


def main():
    S = int(readline())

    ans = 0

    for i in range(1, 700):
        x = S - 3 * i
        if x < 0:
            break
        cnt = comb_mod(x + i - 1, x)
        ans += cnt
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67700
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , m ,k;
	cin >> n >> m >> k;
	char a[n][m];
	for(int i = 0; i < n;i++){
		for(int j = 0; j < m;j++) cin >> a[i][j];
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++){
		for(int j = 0; j < (1 << m); j++){
			char c[n][m];
			for(int l = 0; l < n; l++){
				for(int r = 0; r < m; r++){
					c[l][r] = a[l][r];
				}}
			for(int l = 0; l < n; l++){
				if(i & (1 << l)){
					for(int r = 0; r < m; r++) c[l][r] = '0';
				}
			}
			for(int r = 0; r < m; r++){
				if(j & (1 << r)) 
					for(int l = 0; l < n; l++) c[l][r] = '0';
			}
			int cnt = 0;
			for(int l = 0; l < n; l++){
				for(int r = 0; r < m; r++) if(c[l][r] == '#') cnt++;
			}
			ans += (cnt == k);
		}
	}
	cout << ans;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

string S;
int N, K;

int main(){
  cin >> N >> K >> S;

  char k = S.at(K-1);

  if(k == 'A'){
    S.at(K-1) = 'a';
  }else if(k == 'B'){
    S.at(K-1) = 'b';
  }else if(k == 'C'){
    S.at(K-1) = 'c';
  }

  cout << S << endl;
}


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

using namespace std;

int minmax_diff(int v1, int v2, int v3) {
  return max(v1, max(v2, v3)) - min(v1, min(v2, v3));
}

int divide(int len1, int len2, bool first_smaller) {
  auto len1_1 = len1 / 3;
  if (!first_smaller) ++len1_1;
  auto len1_2 = len1 - len1_1;
  auto len2_1 = len2 / 2;
  auto len2_2 = len2 - len2_1;
  return minmax_diff(len1_1 * len2, len2_1 * len1_2, len2_2 * len1_2);
}

int solve(int shorter, int longer) {
  if (shorter % 3 == 0 || longer % 3 == 0)
    return 0;
  auto result = shorter;
  result = min(result, divide(shorter, longer, true));
  result = min(result, divide(longer, shorter, true));
  result = min(result, divide(shorter, longer, false));
  result = min(result, divide(longer, shorter, false));
  return result;
}

int main() {
  int H, W;
  cin >> H >> W;
  auto p = minmax(H, W);
  cout << solve(p.first, p.second) << endl;
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        int buf;
        while ((buf = System.in.read()) != '\n') {
            ;;
        }

        StringBuilder builder = new StringBuilder();
        int max = 0;
        int min = 1000;
        int num;
        while (true) {
            buf = System.in.read();
            if (buf != ' ' && buf != '\n') {
                builder.appendCodePoint(buf);
            } else {
                num = Integer.parseInt(builder.toString());
                if (num < min) min = num;
                if (max < num) max = num;
                if (buf == '\n') break;
                builder.setLength(0);
            }
        }

        System.out.print(max - min);
    }
}


Measured memory_bytes: 32348
/* author   : mpily :-()
title : Competing.cpp
time :Sun Sep 29 14:59:59 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	vector<int>arr(N);
	for(int i = 0; i < N; i++){
		cin>>arr[i];
	}
	int count = 0;
	for(auto & a: arr){
		if(a >= K)count+=1;
	}
	cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=105;
char c1[MAXN],c2[MAXN],c3[MAXN];
int n;
int main()
{
	n=read();
	scanf("%s",c1+1);
	scanf("%s",c2+1);
	scanf("%s",c3+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(c1[i]!=c2[i]&&c1[i]!=c3[i]&&c2[i]!=c3[i])ans+=2;
		else if(c1[i]==c2[i]&&c2[i]==c3[i])continue;
		else ans++;
	}
	pr2(ans);
	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int main(void) {
	int h,n;
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) {
		int k;
		scanf("%d", &k);
		h -= k;
	}
	
	if (h<=0) {
		printf("Yes");
	}
	else printf("No");
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n; cin >> n;
  string s; cin >> s;
  int c=0; for(int i=0; i<n; i++){if(s[i]=='R') c++;}
  int w=0; for(int i=0; i<c; i++){if(s[i]!='R') w++;}
  cout << w << endl;
}


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


int main()
{
    string s;
    cin >> s;
    int res;

    if(s == "SUN")
        res = 7;
    if(s == "MON")
        res = 6;
    if(s == "TUE")
        res = 5;
    if(s == "WED")
        res = 4;
    if(s == "THU")
        res = 3;
    if(s == "FRI")
        res = 2;
    if(s == "SAT")
        res = 1;

    cout << res << "\n";
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int A, B,c; cin >> A >> B;
	c = max(A + B, A - B); c = max(c, A*B);
	cout << c << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 205
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[20005],b[20005],p[20005];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(p[i]);
    for(int i = 1 ; i <= N ; ++i) {b[i] = (N - i + 1) * N; a[i] = i * N;}
    for(int i = 1 ; i <= N ; ++i) {
	b[p[i]] += i - 1;
    }
    for(int i = 1 ; i <= N ; ++i) {
	out(a[i]);space;
    }
    enter;
    for(int i = 1 ; i <= N ; ++i) {
	out(b[i]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 896
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll k;
    cin >> k;

    ll ans = 0;
    for(ll i = 1; i <= k; i++){
        for(ll j = 1; j <= k; j++){
            for(ll l = 1; l <= k; l++){
                ll tmp = gcd(i, j);
                tmp = gcd(tmp, l);
                ans += tmp;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::BinaryHeap;

fn main() {
    let n: usize = read();
    let mut bh: BinaryHeap<i64> = BinaryHeap::new();
    for _ in 0..n {
        let ai = read();
        bh.push(ai);
    }

    let mut alice = 0;
    let mut bob = 0;
    let mut cnt = 0;

    while !bh.is_empty() {
        let card = bh.pop().unwrap();
        if cnt % 2 == 0 {
            alice += card;
        } else {
            bob += card;
        }
        cnt += 1;
    }
    println!("{}", alice - bob)
}


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

using namespace std;

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node *listSearch(int key){
    Node *cur = nil->next;
    while (cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;    
}

void init(){
    nil = new Node;
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(cur != nil){
        if(isf++ > 0) cout << " ";
        cout << cur->key;
        cur = cur->next;
    }
    cout << endl;
}

void deleteNode(Node *t){
    if(t == nil)return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    delete(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = new Node;
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(int i=0; i<n; i++){
        scanf("%s%d", com, &key);
        if(com[0] == 'i'){
            insert(key);
        }else if(com[0] == 'd'){
            if(strlen(com)>6){
                if(com[6] == 'F'){
                    deleteFirst();
                }else if (com[6] == 'L')
                {
                    deleteLast();
                }
            }else
            {
                deleteKey(key);
            }
        }

    }
    printList();

    return 0;
}


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

int main()
{
  int N;
  cin >> N;

  vector<int> A(N);

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

  sort(A.begin(), A.end());

  bool flg = true;

  for (int i = 0; i < N - 1; i++)
  {
    if (A.at(i) == A.at(i + 1))
    {
      flg = false;
      break;
    }
  }

  if (flg)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#include <cmath>
#define db double
#define LL long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;

const int N=1e5+5;
int n,i,j,pn,s,ans,nop[N];
LL a[N],prm[N],s1[N],s2[N];
map<LL,int> cnt;
template <typename T>
void read(T &ret) {
	char ch; ret=0;
	for (ch=getchar();ch<'0' || ch>'9';ch=getchar()) ;
	for (;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
}
LL Sqrt(LL x)
{
	LL l=1,r=x,mid;
	while (l<r)
	{
		if (r-l>1) 	mid=(l+r)>>1;
		else mid=r;
		if (mid*mid>x) r=mid-1;
		else l=mid;
	}
	return l;
}
int main()
{
/*	#ifdef ONLINE_JUDGE
	#else
		freopen("anticube.in","r",stdin);
		freopen("anticube.out","w",stdout);
	#endif
*/
	read(n);
//	printf("%d\n",n);
	rep(i,1,n) read(a[i]); //scanf("%d",&a[i]);
	rep(i,2,2155)
	{
		if (!nop[i]) prm[++pn]=i;
		rep(j,1,prm[pn])
		{
			if (prm[j]*i>2155) break;
			nop[prm[j]*i]=1;
			if (i%prm[j]==0) break;
		}
	}
	LL tmp,cur,inv,Sq;
	int tt;
	rep(i,1,n)
	{
		tmp=a[i]; cur=1; inv=1;
		rep(j,1,pn)
		{
			s=0;
			if (tmp<prm[j]) break;
			//cb=prm[j]*prm[j]*prm[j];
			tt=0;
			while (tmp%prm[j]==0) tmp/=prm[j],tt++;
			tt%=3;
			if (tt==2) cur*=prm[j]*prm[j],inv*=prm[j];
			else if (tt==1) cur*=prm[j],inv*=prm[j]*prm[j];
		}
		if (tmp>1) {
			Sq=sqrt(tmp);
			if (Sq*Sq==tmp) cur*=tmp,inv*=Sq;
			else if (tmp<=1e5) cur*=tmp,inv*=tmp*tmp;
		}
		if (tmp>1e5 && Sq*Sq!=tmp) {
			s1[i]=-1; ans++; continue;
		}
		s1[i]=cur; s2[i]=inv; cnt[cur]++;
	}
	int one=0;
	
	rep(i,1,n)
	{
		if (s1[i]==-1) continue;
		if (s1[i]==1) {
			one=1; continue;
		}
		ans+=max(cnt[s1[i]],cnt[s2[i]]); cnt[s1[i]]=cnt[s2[i]]=0;
	}
	
	printf("%d\n",ans+one);
	return 0;
} 

Measured memory_bytes: 12928
import bisect

n,k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
for i in range(k+1):
  for j in range(k+1-i):
    if i > n-j:
      break
    now = sorted(v[:i]+v[n-j:])
    tmp = min(k-i-j,bisect.bisect_left(now, 0))
    ans = max(ans,sum(now[tmp:]))
print(ans)


Measured memory_bytes: 41072
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

n, m = li()
graph = [[] for _ in range(n)]

ins = [0]*n
par = [0]*n

# 親をたどるグラフを作る
for _ in range(n-1+m):
    a,b = li_()
    graph[a].append(b)
    ins[b] += 1

# 入次数が尽きたものからスタートに
start = ins.index(0)
que = deque([start])
while que:
    cur = que.popleft()
    for child in graph[cur]:
        ins[child] -= 1
        if ins[child] == 0:
            que.append(child)
            par[child] = cur+1
    
for pi in par:
    print(pi)

Measured memory_bytes: 23840
#include <iostream>
#include <bits/stdc++.h>
#define rawan ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define ll long long
using namespace std;
const int N = 1e5 + 5;
int main()
{ int n;
cin >> n;
int arr[n],dp[n];
for (int i=0; i<n; i++)
{
    cin >> arr[i];
}
dp[0]=0;
dp[1]=abs(arr[0]-arr[1]);
for(int i=2; i<n; i++)
{
    dp[i]=min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2]);
}
   cout << dp[n-1] << endl;
    return 0;
}

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

#define FOR(i, n, m) for(int i = (n);i < (m);i++)
#define REP(i, n) for(int i = 0;i < (n);i++)
#define PII pair<int, int>

using namespace std;

string worm;

int all(string a){
    char b = a[0];
    int cnt = 0;
    for(int i = 1;a[i] != '\0';i++){
        if(a[i] != b)
            cnt++;
    }
    return cnt;
}

int solve(){
    queue< pair<string, int> > que;
    map<string, int> m;
    que.push(pair<string, int>(worm, 0));

    if(all(worm) == 0){
        return 0;
    }

    while(que.size()){
        string worm1 = que.front().first;
        int num = que.front().second;
        que.pop();

        if(m[worm1]){
            continue;
        }
        if(all(worm1) == 0){
            return num;
        }

        m[worm1] = num;

        REP(i, worm1.size()-1){
            string tmp = worm1;
            if(tmp[i] != tmp[i+1]){
                if(tmp[i] != 'r' && tmp[i+1] != 'r') tmp[i] = tmp[i+1] = 'r';
                else if(tmp[i] != 'g' && tmp[i+1] != 'g') tmp[i] = tmp[i+1] = 'g';
                else tmp[i] = tmp[i+1] = 'b';

                que.push(pair<string, int> (tmp, num+1));
           }
        }
    }

    return -1;
}

int main(void){
    cin >> worm;
    while(worm[0] != '0'){
        int result = solve();
        if(result >= 0){
            cout << result << endl;
        }else{
            cout << "NA" << endl;
        }
        cin >> worm;
    }

    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll a,b,c,d;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num[100005];
ll n,k,x,y;
string s;
int main()
{
    //IOS
    while(cin>>n>>k)
    {
      vector<pii> v;
      for(int i=1;i<=n;i++)
      {
          for(int j=i+1;j<=n;j++)
          {
              v.pb({i,j});
          }
      }
      while(k--)
      {
          v.pop_back();
      }
      if(v.size()<n-1) {cout<<-1<<"\n";return 0;}
      cout<<v.size()<<"\n";
      for(auto i:v)
      {
          cout<<i.F<<" "<<i.S<<"\n";
      }
    }


}


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

bool onmp(int x,int y){return x>=0&&y>=0&&x<n&&y<n;}

int count(int x,int y,const vector<string> &A){
  int res=0;  
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int nx = x+i,ny = y+j;
      if((!i&&!j)||!onmp(nx,ny))continue;
      res += A[ny][nx]=='#'||A[ny][nx]=='@';
    }
  return res;
}

bool check(const vector<string> &A){
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)if(A[i][j]=='#')return 0;
  return 1;
}


vector<string> mkmp(const vector<string> &A){
  vector<string> res(n,string(n,'.'));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      int cnt = count(j,i,A);
      if(A[i][j]=='#')res[i][j]=(cnt==2||cnt==3)? '#':'.';
      if(A[i][j]=='.')res[i][j]=(cnt==3)? '#':'.';
      if(A[i][j]=='@')res[i][j]='@';
    }
  return res;
}

map<vector<string>,int> mem;
int ans,flg;
void dfs(int x,int y,int cnt,vector<string> A){
  if(check(A))ans=min(cnt,ans),flg=1;
  if(cnt>=ans) return;
  if(mem.count(A)&&mem[A]<=cnt)return;
  mem[A]=cnt;
  A[y][x] = '.';
  for(int dy=-1;dy<=1;dy++){
    for(int dx=-1;dx<=1;dx++){
      int nx = x+dx,ny = y+dy;
      if((!dx&&!dy)||!onmp(nx,ny)||A[ny][nx]=='#')continue;
      A[ny][nx] = '@';
      dfs(nx,ny,cnt+1,mkmp(A));
      A[ny][nx] = '.';
    }
  }
}

int main(){
  while(cin>>n,n){
    vector<string> mp(n);
    for(int i=0;i<n;i++)cin>>mp[i];
    int sx,sy;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)if(mp[i][j]=='@')sy=i,sx=j;
    ans = 10;flg=0;
    mem.clear();
    dfs(sx,sy,0,mp);
    cout<<(flg? ans:-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 6308
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
PY = [tuple(map(int,input().split())) for _ in range(M)]

# 県ごとに分類
A = [[] for _ in range(N+1)]
for i in range(M):
    p,y = PY[i]
    A[p].append((y,i))

for i in range(1,N+1):
    A[i].sort()

Ans = [0]*M
for i in range(1,N+1):
    for j in range(len(A[i])):
        y,k = A[i][j]
        Ans[k] = "{:06d}{:06d}".format(i,j+1)

for ans in Ans:
    print(ans)

Measured memory_bytes: 46280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,i,j;
    cin>>n;
    if(n>=1000)
        cout<<"ABD"<<endl;
    else
        cout<<"ABC"<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int r = Integer.parseInt(str[1]);
    System.out.println(n>=10?r:100*(10-n)+r);
  }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll a, b; cin >> a >> b;
    vector<string> s;
    REP(i, 50){
        string ss(100, '#');
        s.pb(ss);
    }
    REP(i, 50){
        string sss(100, '.');
        s.pb(sss);
    }

    ll cnta = 0, cntb = 0;
    ll flag = 1;
    for(ll i=0; i<50; i++){
        if(cnta == a-1) break;
        if(i%2 == 0){
            REP(j, 100){
                if(flag == 1){
                    if(j%2 == 0){
                        s[i][j] = '.';
                        cnta++;
                    }
                    if(cnta == a-1) break;
                }
                else{
                    if(j%2 != 0){
                        s[i][j] = '.';
                        cnta++;
                    }
                    if(cnta == a-1) break;
                }    
            }
            flag = 1 - flag;
        }
    }

    for(ll i=99; i>=50; i--){
        if(cntb == b-1) break;
        if(i%2 == 0){
            REP(j, 100){
                if(flag == 1){
                    if(j%2 == 0){
                        s[i][j] = '#';
                        cntb++;
                    }
                    if(cntb == b-1) break;
                }
                else{
                    if(j%2 != 0){
                        s[i][j] = '#';
                        cntb++;
                    }
                    if(cntb == b-1) break;
                }            
            }
            flag = 1 - flag;
        }
    }

    cout << s.size() << " " << s[0].size() << endl;
    REP(i, 100) cout << s[i] << endl;
}

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

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

int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();

	while( n-- )
	{
		std::string s;
		std::getline( std::cin, s );

		std::string t( s.size(), ' ' );

		for( int a = 1; a < 26; a += 2 )
		{
			if( a == 13 )
				continue;

			for( int b = 0; b != 26; ++b )
			{
				for( int i = 0; i != s.size(); ++i )
				{
					if( s[i] >= 'a' && s[i] <= 'z' )
					{
						int g = s[i] - 'a';

						t[i] = ( a * g + b ) % 26 + 'a';
					}
				}

				if( t.find( "this" ) != std::string::npos || t.find( "that" ) != std::string::npos )
					goto end;
			}
		}

end:;

		std::cout << t << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int count = 1;
        while(x != 0){
            System.out.println(String.format("Case %d: %d", count, x));
            x = sc.nextInt();
            count++;
        }
    }
}



Measured memory_bytes: 62496
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int m,d;
    cin >> m >> d;
    int d1 = d / 10,d2 = d % 10;
    int ans = 0;
    for(int i = 1;i <= m;i++)
    {
        for(int j = 2;j <= d1;j++)
        {
            for(int k = 2;k <= 9;k++)
            {
                if(10 * j + k > d)
                {
                    break;
                }
                if(i == j * k)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,s,a,b,c,ans=0;
	cin>>k>>s;
	for(int i=0;i<=s;i++)
		{a=i;
		for(int j=0;j<=s;j++)
			{b=j;
			c=s-a-b;
			if(a<=k and b<=k and c<=k and a>=0 and b>=0 and c>=0) ans++;
			}
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//yewala
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL inv(LL a) { return power(a, mod - 2) % mod; }


int main()
{

	int k, x;
	cin >> k >> x;
	if (k * 500 >= x)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<iomanip>
#include<unordered_map>
using namespace std;

int A[200000];

int main (void) {
  int N;
  cin >> N;
  unordered_map<int,int> umap;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (umap.find(A[i]) == umap.end()) umap[A[i]] = 1;
    else umap[A[i]]++;
  }
  
  // 1つずつ自分を除いた場合の数を出力していく
  unordered_map<int,long long> umap_ans;
  unordered_map<int, long long> umap_ans_nomiss;
  
  long long nomiss = 0;
  for (int i = 0; i < N; i++) {
    if (umap_ans_nomiss.find(A[i]) == umap_ans_nomiss.end()) {
      umap_ans_nomiss[A[i]] = (long long)umap[A[i]] * (long long)(umap[A[i]]-1)/2;
      umap_ans[A[i]] = (long long)(umap[A[i]]-1)*(long long)(umap[A[i]]-2)/2;
    }
  }
  for (unordered_map<int,long long>::iterator itr = umap_ans_nomiss.begin(); itr != umap_ans_nomiss.end(); ++itr) {
    nomiss += itr->second;
  }
  for (int i = 0; i < N; i++) {
    long long cnt = 0;
    cnt += nomiss;
    cnt -= umap_ans_nomiss[A[i]];
    cnt += umap_ans[A[i]];
    cout << cnt << endl;

  }

  
  return 0;
} 


Measured memory_bytes: 22216
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>
#include<bitset>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x,y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI MAX = 0,res = 0;
	LLI a;
	cin >> N;
	vector<LLI>vec(N);
	for (int i = 0; i < N;i++) {
		cin >> a;
		vec[i] = a;
	}

	for (int i = 0; i < N;i++) {
		if (MAX <= vec[i]) {
			res++;
			MAX = vec[i];
		}
	}
	cout << res << endl;
}

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

using namespace std;
int H, W;
string S;
int ans;

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

  for(int i = 0; i < H; i++) {
    cin >> S;
    for(int j = 0; j < S.length(); j++) if(S[j] == '#') ans++;
  }
  if(H+W-1 == ans) cout <<"Possible"<<endl;
  else cout << "Impossible" <<endl;
}

  


Measured memory_bytes: 256
#include<stdio.h>



int main() {
	
	int n, a, b;
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);

	if (a*n <= b) {
		printf("%d\n", a*n);
	}
	else {
		printf("%d\n", b);
	}

	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

/***************/
 #define amin main
/***************/


int amin()
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(k>a)
	{
		k = k-a;
		a =0;
	}
	else
	{
		
		a = a-k;
		k = 0;
	}
	if(k!=0)
	{
		if(k>b)
		{
			k = k-b;
			b=0;
		}
		else
		{
			//cout<<"l";
			
			b= b-k;
			k=0;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

vector<int> edge[108000];
vector<Int> dp[108000];
vector<Int> dp2[108000];
Int ans[108000];

Int n, M, x, y;

Int dfs(Int x, Int last = -1){
  dp[x].resize(edge[x].size(), -1);
  Int res = 1;
  for(int i = 0;i < edge[x].size();i++){
    int to = edge[x][i];
    if(to == last)continue;
    dp[x][i] = dfs(to, x) + 1;
    res = res * dp[x][i] % M;
  }
  return res;
}

Int dfs2(Int x, Int ind = -1, Int last = -1){
  if(last != -1){
    Int lstind = 0;
    while(dp[x][lstind] != -1)lstind++;
    dp[x][lstind] = dp2[last][ind] + 1;
  }
  vector<Int> lp, rp;
  lp.push_back(1);
  rp.push_back(1);
  for(int i = 0;i < dp[x].size();i++){
    lp.push_back(lp.back() * dp[x][i] % M);
    rp.push_back(rp.back() * dp[x][dp[x].size() - i - 1] % M);
  }
  ans[x] = lp.back();
  for(int i = 0;i < dp[x].size();i++){
    dp2[x].push_back(lp[i] * rp[dp[x].size() - i - 1] % M);
  }
  for(int i = 0;i < edge[x].size();i++){
    int to = edge[x][i];
    if(to == last)continue;
    dfs2(to, i, x);
  }
}

int main(){
  cin >> n >> M;
  for(int i = 0;i < n-1;i++){
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(1);
  dfs2(1);

  for(int i = 1;i <= n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    vll s(n+1,0);
    ll sum = 0;
    rep(i,n+1) {
        s[i] = (sum-i)%k;
        sum += a[i];
    }
    map<int,int> mp;
    ll ans = 0;
    rep(i,n+1) {
        if (i-k < 0) {
            ans += mp[s[i]];
            mp[s[i]]++;
        } else {
            mp[s[i-k]]--;
            ans += mp[s[i]];
            mp[s[i]]++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,k,l=0;
    string s,t,tmp;
    cin >> n;
    cin >> s;
    cin >> t;
    for (size_t i=s.size(); i>0; i--) {
        tmp=s.substr(s.size()-i, i);
        k=min(i, t.size());
        if (tmp.substr(0,k)==t.substr(0,k)) {
            l=k;
            break;
        }
    }
    cout << s.size()+t.size()-l;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		if(A > X) { 
			System.out.println("NO"); 
		}else if(A + B < X) { 
			System.out.println("NO"); 
		}else {
			System.out.println("YES");
		}
		sc.close();
	}

}


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

int main(){
    
    int n;
    cin >> n;
    vector<int>a(n);
    
    for(int i = 0; i < n; i++) cin >>a[i];
    
    sort(a.begin(), a.end());
    
    cout << a[n/2] - a[n/2 - 1] << "\n";
    
    
}


Measured memory_bytes: 3776
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int c(const void*a,const void*b){
	ll ha=*(ll*)a/200;
	ll wa=*(ll*)a%200;
	ll hb=*(ll*)b/200;
	ll wb=*(ll*)b%200;
	
	if(ha*ha+wa*wa<hb*hb+wb*wb)return -1;
	if(ha*ha+wa*wa>hb*hb+wb*wb)return 1;
	if(ha<hb)return -1;
	if(ha>hb)return 1;
	return 0;
}

ll a[40010];
ll cnt;
int main(){
	rep(i,1,150)rep(j,i+1,150)a[cnt++]=i*200+j;
	qsort(a,cnt,sizeof(ll),c);
//	rep(i,0,10)printf("%lld %lld\n",a[i]/200,a[i]%200);

	ll h,w;
	while(scanf("%lld%lld",&h,&w),h){
		ll d=h*200+w;
		ll l=0;//ng
		ll r=cnt;//ok
		while(r-l>1){
			ll m=(l+r)/2;
			if(c(&a[m],&d)==1)r=m;
			else l=m;
		}
		printf("%lld %lld\n",a[r]/200,a[r]%200);
	}
}


Measured memory_bytes: 2040
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF 100000

int main()
{
    long long a,b,c,k;
    
    cin >> a >> b >> c >> k;
    
    if (a >= k){
        cout << k << endl;
    }
    else if (a < k && k <= a+b){
        cout << a << endl;
    }
    else {
        cout << 2*a+b-k << endl;
    }
}


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

public class Main {
  private static int solve(int n, int[] as) {
    int[] counts = new int[100_001];
    for (int a : as) {
      counts[a]++;
    }
    
    int answer = 0;
    for (int i = 2; i <= 100_000; i++) {
      answer = Math.max(answer, counts[i - 2] + counts[i - 1] + counts[i]);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 35860
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
	
	int n, a[100], minn = 1000, maxn = 0;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		minn = min(minn, a[i]);
		maxn = max(maxn, a[i]);
	}

	cout << maxn - minn << "\n";



	return 0;
}

Measured memory_bytes: 256