akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()

	a := make([]int, n)
	for i := 1; i < n; i++ {
		a[i] = sc.ReadInt()
	}

	counts := make([]int, n)
	for i := 1; i < n; i++ {
		counts[a[i]-1]++
	}

	for i := 0; i < n; i++ {
		fmt.Println(counts[i])
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 6756
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<string,int>mp;
int n,m,ans;
string s[1000];
int main()
{
	ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		mp[s[i]]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		cin>>s[0];
		mp[s[0]]--;
	}
	for(int i=1;i<=n;i++)
		ans=max(mp[s[i]],ans);
	printf("%d",ans);
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: i64, b: i64
    }

    println!("{}", if b % a == 0 {a+b} else {b-a});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int cnt = 0;
  REP(i,s.size()){
    if(s[i]=='p') cnt++;
  }
  cout << s.size()/2 - cnt << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector<array<int,4> > Q;
int n,m,q;
int an = 0;
vector <int> v;

void dfs(int u){
	if(v.size()==n){
		int ma = 0;
		an = max(an, accumulate(all(Q), ma, [&](int k, array<int,4> z){
			return v[z[1]] - v[z[0]] == z[2]? k + z[3]: k;
		}));
		return;
	}
	for(int i = u; i<=m ;i++){
		v.pb(i);
		dfs(i);
		v.pop_back();
	}
}

int main(){
  fio();
  cin>>n>>m>>q;
  Q.resize(q);
  forn(i,q) forn(j,4) { cin>>Q[i][j]; Q[i][j]-=j<=1;}
  dfs(1);
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> kouho(102); //0~101までの配列
    rep(i, n)
    {
        int p;
        cin >> p;
        kouho[p] = 1;
    }

    int l, r;
    for (int i = x; i <= 101; i++)
    {
        if (kouho[i] == 0)
        {
            r = i;
            break;
        }
    }
    for (int i = x; i >= 0; i--)
    {
        if (kouho[i] == 0)
        {
            l = i;
            break;
        }
        }

    if (r - x >= x - l)
        cout << l << endl;
    else
        cout << r << endl;
}

Measured memory_bytes: 3628
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

ans = list(ascii_lowercase)

for x in S:
	if x in ans:
		ans.remove(x)

if ans == []:
	print("None")
else:
	print(ans[0])

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

int calc(stack<string> &formula) {
    string ope = formula.top(); formula.pop();
    int num1, num2;
    
    string next = formula.top();
    
    if (next == "+" || next == "-" || next == "*") num2 = calc(formula);
    else {
        num2 = stoi(formula.top());
        formula.pop();
    }
    
    next = formula.top();
    if (next == "+" || next == "-" || next == "*") num1 = calc(formula);
    else {
        num1 = stoi(formula.top());
        formula.pop();
    }
    
    int result;
    
    if (ope == "+") result = num1 + num2;
    else if (ope == "-") result = num1 - num2;
    else if (ope == "*") result = num1 * num2;
    
    return result;
}

int main() {
    stack<string> formula;
    while (true) {
        string s; cin >> s;
        if (s.empty()) break;
        formula.push(s);
    }
    
    cout << calc(formula) << endl;
        
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;

int main(){
   int x;
   cin >> x;
   int y = x/200;
   if(y<3) cout << 8 <<endl;
   else if(y>=3&&y<4) cout << 7 <<endl;
   else if(y>=4&&y<5) cout << 6 <<endl;
   else if(y>=5&&y<6) cout << 5 <<endl;
   else if(y>=6&&y<7) cout << 4 <<endl;
   else if(y>=7&&y<8) cout << 3 <<endl;
   else if(y>=8&&y<9) cout << 2 <<endl;
   else if(y>=9&&y<10) cout << 1 <<endl;
}

Measured memory_bytes: 3616
// TandT.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, a, d;
	cin >> n >> a >> d;
	cout << min(n * a, d) << endl;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    vector<int> nums(100001,0);
    ll ans = 0;
    rep(i,0,N) {
        int A;
        cin >> A;
        nums[A]++;
        ans += A;
    }
    int Q;
    cin >> Q;
    rep(i,0,Q) {
        int B, C;
        cin >> B >> C;
        ans += (C-B) * nums[B];
        nums[C] += nums[B];
        nums[B] = 0;
        cout << ans << endl;
    }

//    rep(i,0,100001) ans += i * nums[i];

//    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
pair<pii,int> items[1252];

ll dp[25252];

int main(){
  scanf("%d",&n);
  REP(i,n){
    int w,s,v;
    scanf("%d%d%d",&w,&s,&v);
    items[i] = make_pair(pii(s,w),v);
  }
  sort(items,items+n,[](pair<pii,int> a, pair<pii,int> b){
    return a.first.first + a.first.second < b.first.first + b.first.second;
  });
  fill(dp,dp+25252,-1ll<<60);
  dp[0] = 0;
  REP(i,n){
    int w,s,v;
    s = items[i].first.first;
    w = items[i].first.second;
    v = items[i].second;
    FORR(j,0,s+1){
      CHMAX(dp[j+w], dp[j]+v);
    }
  }
  printf("%lld\n",*max_element(dp,dp+25252));
  return 0;
}


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

int main () {
  	long long N, ans = 0;
  	cin >> N;
  	map<vector<long long>, long long> mp;
  	for (long long i = 0; i < N; i++) {
      	string s;
      	cin >> s;
      	vector<long long> tmp;
      	for (long long j = 0; j < 10; j++) {
          	tmp.push_back(s[j]-'a');
        }
      	sort(tmp.begin(),tmp.end());
      	mp[tmp]++;
    }
  	for (auto i : mp) {
      	ans += i.second * (i.second-1) / 2;
    }
  	cout << ans << endl;
  	return 0;
}
      	

Measured memory_bytes: 20768
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


Measured memory_bytes: 3640
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A, B, h[100001];
	scanf("%d %lld %lld", &N, &A, &B);
	for (i = 0; i < N; i++) scanf("%lld", &(h[i]));
	merge_sort(h, N);
	
	long long l = 1, r = (h[N-1] - 1) / B + 1, m, count;
	while (l < r) {
		m = (l + r) / 2;
		count = 0;
		for (i = N - 1; i >= 0; i--) {
			if ((h[i] - B * m) <= 0) break;
			else count += (h[i] - B * m - 1) / (A - B) + 1;
		}
		if (count <= m) r = m;
		else l = m + 1;
	}
	
	printf("%d\n", l);
	fflush(stdout);
	return 0;
}

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

long long ans[110][100100];

int main(){
  int n, w;
  cin >> n >> w;
  long long o[n], v[n];
  long long sum_v=0;
  for(int i=0;i<n;i++){
    cin >> o[i] >> v[i];
    sum_v+=v[i];
  }
  for(int i=0;i<n;i++)for(int j=0;j<=sum_v;j++) ans[i][j] = 100000000100;
  ans[0][0] = 0;
  for (int i=0;i<n;i++) {
        for (int j=0;j<=sum_v;j++) {
            if (j-v[i]>=0) {
              if(ans[i][j]>ans[i][j-v[i]]+o[i]){
                  ans[i+1][j]=ans[i][j-v[i]]+o[i];
              }else{
                ans[i+1][j] = ans[i][j];
              }
            }else{
              if(ans[i+1][j]>ans[i][j]){
                  ans[i+1][j]=ans[i][j];
                }
            }
        }
	}
    /*for (int i=0;i<n;i++) {
        for (int j=0;j<=sum_v;j++) {
          cout << ans[i][j];
        }
      cout << endl;
    }*/
  //cout << ans[n][18] << endl;
  long long f_ans=0;
  for(int j=0;j<=sum_v;j++){
    if(ans[n][j]<=w){
      f_ans=j;
    }
  }
  cout << f_ans << endl;
}

Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int>x(n); for (auto&& xx : x)cin >> xx;

	vector<int>ans;
	for (int i = 0; i + k - 1 < n; i++) {
		int xl = x[i], xr = x[i + k - 1];
		int time1 = abs(xl) + abs(xr - xl), time2 = abs(xr) + abs(xr - xl);
		ans.push_back(min(time1, time2));
	}
	sort(ans.begin(), ans.end());
	cout << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 1024
x=int(input())
lst=input().split()
i=0
k=0
while i<(x/2) :
    w=int(lst[i])
    lst[i]=int(lst[(x-1)-i])
    lst[(x-1)-i]=w
    i=i+1
while k<x :
    if k<(x-1) : print(lst[k],end=" ")
    else : print(lst[k])
    k=k+1


Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


int main() {

	int n, l;
	cin >> n >> l;

	int a[201];
	int sum = 0;

	for (int i = 1; i <= n; i++) {
		a[i] = l + i - 1;
		sum += a[i];
	}
	int mini = 100000;
	int num;
	for (int i = 1; i <= n; i++) {
		if (abs(a[i]) < mini) {
			mini=abs(a[i]);
			num=i;

		}
	}


	int ans = sum - a[num];

	cout <<ans<<endl;

	return 0;
}





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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> B(N);
  REP(i, N) cin >> B[i];
  vector<ll> C(N);
  REP(i, N) cin >> C[i];
  ll ans = 0;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  for(ll i = 0; i < N; i++) {
    auto a = lower_bound(A.begin(), A.end(), B[i]);
    ll d_a = distance(A.begin(), a);
    auto c = upper_bound(C.begin(), C.end(), B[i]);
    ll d_c = N - distance(C.begin(), c);
    ans += d_a * d_c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2688
n=int(input())
a=list(map(int,input().split()))
from collections import deque
from math import gcd
a_left=deque()

a_left.append(a[0])


a_right=deque()

a_right.append(a[-1])

for i in range(n-1):
    a_left.append(gcd(a_left[-1],a[i+1]))
    a_right.appendleft(gcd(a_right[0],a[n-i-2]))


a_right=list(a_right)
a_left=list(a_left)

count=max(a_left[-2],a_right[1])

for j in range(n-2):
    count=max(gcd(a_left[j],a_right[j+2]),count)
print(count)

Measured memory_bytes: 22436
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n;

	int a[15];
	int x[15][15], y[15][15];
	REP(i, n) {
		int ai;
		cin >> ai;
		a[i] = ai;
		REP(j, ai) {
			int xi,yi;
			cin >> xi>>yi;
			xi--; yi;
			x[i][j] = xi; y[i][j] = yi;
		}
	}
	int f = 1;
	REP(i, n)f = f * 2;
	int ans = 0;
	REP(i, f) {
		bool flag = true;
		REP(j, n) {
			if ((i >> j) % 2 == 0)continue;
			//dump(i); dump(j);
			//dump(a[j]);
			REP(k, a[j]) {
				//dump((i >> x[j][k]) % 2); dump(y[j][k]);
				if ((i >> x[j][k]) % 2 != y[j][k]) {
					flag = false;
					break;
				}
			}
			if (!flag)break;
		}
		if (flag) {
			int tmp = 0;
			int now = i;
			while (now) {
				if (now % 2 == 1)tmp++;
				now /= 2;
			}
			chmax(ans, tmp);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int findsumofdigits(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
 
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int total=0;
  for(int i=1;i<=N;i++){
    int sum=findsumofdigits(i);
    if(sum>=A && sum<=B){
      total+=i;
    }
  }
  cout << total << endl;
  return 0;
}



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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineStringSplit().Select(x => x.First().ToString().ToUpper()).ToArray();
            
            Console.WriteLine(n[0]+n[1]+n[2]);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

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

int main() {
    int N,a,b,c,d;
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    cin >> N;
    string C;
    for (int i = 0; i < N; i++) {
        cin >> C;
        if (C == "AC") {
            a++;
        }
        if (C == "WA") {
            b++;
        }
        if (C == "TLE") {
            c++;
        }
        if (C == "RE") {
            d++;
        }
    }
    cout << "AC" << " " << 'x' << " " << a << endl;
    cout << "WA" << " " << 'x' << " " << b << endl;
    cout << "TLE" << " " << 'x' << " " << c << endl;
    cout << "RE" << " " << 'x' << " " << d << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>v[i];
    ans+=v[i];
  }
  if(ans%10!=0){
    cout<<ans<<endl;
    return 0;
  }
  else{
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
      if(v[i]%10!=0){
        ans-=v[i];
        cout<<ans<<endl;
        return 0;
      }
    }
  }
  cout<<0<<endl;
}


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

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


n, m = map(int, input().split())
coins = list(map(int, input().split()))

# dp[i] := ちょうどi円支払うときのコインの最小枚数

dp = [INF] * (n + 1)
dp[0] = 0

for i in range(n + 1):
    for c in coins:
        if i - c < 0:
            continue
        dp[i] = min(dp[i], dp[i-c] + 1)

print(dp[n])



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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
vector<int> adj[100005];
bool vis[100005];
int c[100005];
int dfs(int s)
{
    vis[s]=1;
    int ch=0;
    f(i,0,adj[s].size())
    {
        int o=0;
        if(vis[adj[s][i]]==0)
        {
            o=dfs(adj[s][i])+1;
        }
        ch=ch^o;
    }
    return ch;
}
int main()
{
	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
        int n,x,y;
        cin>>n;
        f(i,0,n-1)
        {
            cin>>x>>y;
            adj[x].pb(y);
            adj[y].pb(x);
        }
        x=dfs(1);
        if(x)
            cout<<"Alice";
        else
            cout<<"Bob";
	}
}


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

using namespace std;
const int maxn = 1e5+10;

int n;
int sol[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        sol[x - 1] = i;
    }
    for (int i = 0; i < n; i++)
        printf("%d ", sol[i]);
    return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int ans = 0; int n, a;
vector<int>v; vector<vector<vector<int> > >dp;
int solve(int i = 0, int sum = 0, int cnt = 0) {
	if (dp[i][sum][cnt] != -1)return dp[i][sum][cnt];
	if (i == n) {
		if (cnt&&sum == a*cnt)return dp[i][sum][cnt] = 1;
		else return 0;
	}
	return dp[i][sum][cnt] = solve(i + 1, sum + v[i], cnt + 1) + solve(i + 1, sum, cnt);
}
signed main() {
	cin >> n >> a; v = vector<int>(n); rep(i, 0, n)cin >> v[i];
	dp = vector<vector<vector<int> > >(51, vector <vector<int> >(2510, vector<int>(51, -1)));
	cout << solve() << endl;
	return 0;
}

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

int main(void){
        int i,j,x,y,s,before,after,max;
        int before1,before2,after1,after2;

        while(1){
                max = 0;
                cin >> x >> y >> s;
                if(x == 0 && y == 0 && s == 0){ 
                        break;
                }   

                for(i = 1; i < s; i++){
                        for(j = 1; j < s; j++){
                                before1 = i * (100 + x);
                                before2 = j * (100 + x);
                                before1 = before1 / 100;
                                before2 = before2 / 100;
                                before = before1 + before2;

                                if(before == s){
                                        after1 = i * (100 + y);
                                        after2 = j * (100 + y);
                                        after1 = after1 / 100;
                                        after2 = after2 / 100;
                                        after = after1 + after2;
                                        if(after > max){
                                                max = after;
                                        }   
                                }   
                        }   
                }   
                cout << max << endl;
        }   
        return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int N; 
  cin>> N;
  vector<int> A(N,0);
  
  int sum = 0;
  int max = 0;
  for(int i=0; i<N; i++) {
    cin >> A[i];
    sum += A[i];
    if(max<A[i]) {
      max = A[i];
    }
  }
  
  if(max>=sum-max) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import queue
def main():
    k = int(input())
    q = queue.Queue()
    for i in range(1,10):
        q.put(i)
    cnt = 0
    for i in range(1,k + 1):
        cnt += 1
        val_i = q.get()
        if cnt == k:
            print(val_i)
        keta_1 = val_i % 10
        if keta_1 != 0:
            q.put(val_i * 10 + keta_1 - 1)
        q.put(val_i * 10 + keta_1)
        if keta_1 != 9:
            q.put(val_i * 10 + keta_1 + 1)


if __name__=='__main__':
    main()


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		int N;
	cin >> N;
	vec(A);
	fx(N) {
		vecp(A);
	}

	sorts(A);
	reverses(A);
	ll ans = A[0];
	int cnt = 2;
	for(int y = 1; cnt <= N-1; y++) {
		if (cnt+2<=N) {
			ans += A[y]*2;
			cnt += 2;
		}
		else {
			ans += A[y];
			cnt++;
		}
		
	}

	ce(ans)

    return 0;
}



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

int main() {
    int A, B, C;
    cin >> A >> B >>C;

    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }
    if (B > C) {
        int t = B;
        B = C;
        C = t;
    }
    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }

    int counter = 0;
    while (B < C) {
        ++A;
        ++B;
        ++counter;
    }
    while (A < C) {
        A += 2;
        ++counter;
    }
    if (A > C) {
        ++B;
        ++C;
        ++counter;
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> A(N + 2);
    rep(i,0,N) cin >> A[i + 1];

    ll sumA = 0LL;
    rep(i,0,N+1){
        sumA += abs(A[i+1] - A[i]);
    }

    for(int i = 1; i <= N; i++){
        if((A[i+1] - A[i]) * (A[i] - A[i-1]) == 0){
            cout << sumA << endl;
        }else if((A[i+1] - A[i]) * (A[i] - A[i-1]) < 0){
            ll a = abs(A[i] - A[i+1]);
            ll b = abs(A[i] - A[i-1]);
            ll mi = min(a,b);
            cout << sumA - mi * 2 << endl;

        }else{
            cout << sumA << endl;
        }
    }



    return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  int a , b , c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}


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


int MOD=1000000007;
char S[100005];
char T[100005];
int ans=0;
vector<int> Scnt[30];
int Tcnt[30];


signed main(){
    scanf("%s",S);
    scanf("%s",T);
    int ssize=strlen(S);
    rep(i,ssize){
        Scnt[S[i]-'a'].pb(i);
    }
    int ans=0;
    rep(i,strlen(T)){
        if(Scnt[T[i]-'a'].size()<1){printf("-1\n");return 0;}
        Tcnt[T[i]-'a']++;
    }
    ans=-1;
    rep(i,strlen(T)){
        int t=T[i]-'a';
        int cursol=lower_bound(Scnt[t].begin(), Scnt[t].end(), ans%ssize+1)-Scnt[t].begin();
        if(cursol==Scnt[t].size())ans+=ssize-(ans%ssize)+Scnt[t][0];
        else ans+=Scnt[t][cursol]-(ans%ssize);
    }
    printf("%lld\n",ans+1);
}


Measured memory_bytes: 1568
#include  <iostream>
#include  <string>
#include  <cstdlib>


int main(void)
{
	int N, K;
	std::cin >> N >> K;

	long long A[N];
	for(int i = 0; i < N; i++)
		std::cin >> A[i];

	for(int i = K+1; i <= N; i++)
	{
		if(A[i-1] > A[i-K-1])
			std::cout << "Yes" << std::endl;
		else
			std::cout << "No" << std::endl;
	}

	return EXIT_SUCCESS;
}


Measured memory_bytes: 5156
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
  if(a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]):
    ans += 2
  elif(not(a[i]==b[i]==c[i])):
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>

using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int counter = 0;
	for (int a = 0; a < n - 1; a++) {
		for (int b = a + 1; b < n; b++) {
			int dem = 0;
			for (int i = 0; i < d; i++) {

				dem += (x[a][i] - x[b][i])*(x[a][i] - x[b][i]);
			}
			//cout << a << b << ":" << dem << endl;
			if (sqrt(dem) == int(sqrt(dem)))counter++;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 384
import java.util.*;
   
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        int i;
   
        if(x<=y){
            i = y%x;
            while(i!=0){
                y = x;
                x = i;
                i = y%x;
            }
            System.out.println(x);
        }else{
            i = x%y;
            while(i!=0){
                x = y;
                y = i;
                i = x%y;
            }
            System.out.println(y);
        }
    }
}

Measured memory_bytes: 26128
#include <iostream>
#include <algorithm>
using namespace std;
int n, q, c, x, y, size_, dat[262144];
void update(int pos, int x) {
	pos += size_; dat[pos] = x;
	while(pos > 1) {
		pos /= 2;
		dat[pos] = min(dat[2 * pos], dat[2 * pos + 1]);
	}
}
int query(int a, int b, int k, int l, int r) {
	if(r <= a || b <= l) return 2147483647;
	if(a <= l && r <= b) return dat[k];
	int lc = query(a, b, 2 * k, l, (l + r) / 2);
	int rc = query(a, b, 2 * k + 1, (l + r) / 2, r);
	return min(lc, rc);
}
int main() {
	scanf("%d%d", &n, &q);
	for(size_ = 1; size_ < n;) size_ *= 2;
	for(int i = 0; i < size_ * 2; i++) dat[i] = 2147483647;
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if(c == 0) update(x, y);
		else printf("%d\n", query(x, y + 1, 1, 0, size_));
	}
}

Measured memory_bytes: 4244
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=parseMap(split(readline()))
    if min(a,b)<=c<=max(a,b)
        println("Yes")
    else
        println("No")
    end
end
main()

Measured memory_bytes: 173040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  int N;
  cin >> N;
  map<string, int> mp;
  repr(i, N, 0) {
    string s;
    cin >> s;
    mp[s] += 1;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3672
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
  for j in range(N-M+1):
    
    for k in range(M):
      if A[i+k][j:j+M] != B[k]:
        break
    else:
      print('Yes')
      exit()

print('No')


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s1, s2, checkStr;
		boolean ans = false;
		int s1Length, s2Length;
		s1 = in.readLine();
		s2 = in.readLine();
		s1Length = s1.length();
		s2Length = s2.length();
		for (int i = 0; i < s1Length; i++) {
			if (s1.charAt(i) == s2.charAt(0)) {
				if ((i + 1) + s2Length > s1Length) {
					checkStr = s1.substring(i, s1Length)
							+ s1.substring(0, s2Length - (s1Length - i));
				} else {
					checkStr = s1.substring(i, i + s2Length);
				}
				if (checkStr.matches(s2)) {
					ans = true;
				}
			}
		}
		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17080
// Written by newbiechd
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int BUF = 1000003;
inline char getChar() {
  static char buf[BUF], *bufS, *bufT;
  if (bufS == bufT) {
    bufT = (bufS = buf) + fread(buf, 1, BUF, stdin);
    if (bufS == bufT)
      return EOF;
  }
  return *bufS++;
}
inline int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getChar())) {}
  do f = f * 10 + (ch ^ 48);
  while (isdigit(ch = getChar()));
  return f;
}

const int maxN = 100003;
int a[maxN];

int main() {
  int n = read(), m = read(), V = read(), P = read(), i;
  for (i = 1; i <= n; ++i)
    a[i] = read();
  sort(a + 1, a + n + 1);
  
  n -= P - 1, V -= P - 1;
  long long now;
  int l = 1, r = n, mid;
  while (l < r) {
    mid = (l + r) >> 1;
    now = 0;
    for (i = 1; i <= n; ++i)
      if (a[mid] + m >= a[i])
        now += min(a[mid] + m - a[i], m);
      else
        break;
    if (i <= n)
      l = mid + 1;
    else
      now >= 1ll * V * m ? r = mid : l = mid + 1;
  }
  printf("%d\n", n + (P - 1) - l + 1);
  return 0;
}


Measured memory_bytes: 1536
// 173 a
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int ans = n%1000;
        if (ans == 0){
            System.out.println(ans);
        } else {
            System.out.println(1000-ans);
        }
    }
}

Measured memory_bytes: 35684
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
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; }

int main() {
    int N, K; cin >> N >> K;
    vector<int>p(N);
   rep(i, N) {
        cin >> p[i];
    }
   sort(p.begin(), p.end());
   int ans = 0;
   rep(i, K) {
       ans += p[i];
   }


   
       cout << ans << endl;

}



















Measured memory_bytes: 3628
import sys
def input(): return sys.stdin.readline().strip()

def main():
    M, K =map(int, input().split())
    k = bin(K)[2:]

    """
    構成問題無理です。。。。。。
    K < 2^Mを最初にちゃんと定式化しておけば、Mに関して場合分けしたくなるのか？
    （Kで場合分けして詰んだ人）

    そしてどっちみちM=2で実験しても定式化できんかった。。。。。。
    「K以外の0以上2M未満の整数を昇順に並べた数列をbとします。またbの逆順をcとします。
    このとき bKcK と並べてできる数列をaとすればよいです。」
    →言われれば納得するけどなあ

    0 ¥oplus 1 ¥oplus ... ¥oplus (2^M-1) = 0　(M >= 2)なのは覚えても良さそう。
    """

    if K >= 2**M:
        print(-1)
        return
    if M == 1 and K == 0:
        print("0 0 1 1")
        return
    if M == 1 and K == 1:
        print(-1)
        return

    b = [i for i in range(K)] + [i for i in range(K + 1, 2 ** M)]
    c = list(reversed(b))
    ans = b + [K] + c + [K]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 96568
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll = long long;
using ull = unsigned long long;

/*!
@fn z_algorithm
@brief 長さNの文字列Sについて, S[0:N-1]とS[i:N-1] (0 < i < N)の最長共通接頭辞の長さを求める
*/
vector<int> z_algorithm(const string& s)
{
    const int n = s.size();
    vector<int> z(n);
    z[0] = n;

    int i = 1;
    int j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) {
            ++j;
        }
        z[i] = j;
        if (j == 0) {
            ++i;
            continue;
        }

        int k = 1;
        while (i+k < n && k+z[k] < j) {
            z[i+k] = z[k];
            ++k;
        }
        i += k;
        j -= k;
    }

    return z;
}

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

    string S;
    cin >> S;

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        auto z = z_algorithm(S.substr(i));

        for (int j = 1; j < z.size(); ++j) {
            if (z[j] <= j) {
                ans = max(ans, z[j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	string a, b;
	cin >> n >> a >> b;
	string ans = "";
	for(int i = 0; i < n; i++)
	{
		ans += a[i];
		ans += b[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
S = input()

Count = 0
for i in range(len(S)):
    count = 0
    for j in range(len(S)-i-1):
        # print('i,j:',i,j)
        # print('S[i]:',S[i],'S[i+j+1]:',S[i+j+1])
        if (S[i] == S[i+j+1]):
            count += 1
            # print('aaaaaaaa')
            # print('count:',count)
        if (count == 1):
            Count += 1
            # print('bbbbbbb')
            # print('Count:',Count)
            break

if (Count == 2):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
/*
 * main.c
 *
 *  Created on: 2019/06/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    char S[5];
    int i = 0, same0 = 0, ans = 0;
    scanf("%s", S);
    for(i = 1; i < 4; i++) {
    	if(S[0] == S[i]) {
    		same0++;
    	}
    }
    if(same0 == 1) {
    	if((S[0] == S[1]) && (S[2] == S[3])) {
    		ans++;
    	}
    	if((S[0] == S[2]) && (S[1] == S[3])) {
    		ans++;
    	}
    	if((S[0] == S[3]) && (S[1] == S[2])) {
    		ans++;
    	}
    }

    if(ans == 0) {
    	printf("No\n");
    } else {
    	printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
// g++ -std=gnu++1y -O2 xxx.cpp

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

int main() {
    int N,K; cin>>N>>K;
    vector<int> xn(N);
    rep(i,N) cin>>xn[i];

    int ans=0;
    rep(i,N) {
        ans += min(xn[i],abs(K-xn[i])) * 2;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    int ans = 0;
    for(int i = 0; i < m; i++) {
        int x; cin >> x;
        ans += x;
    }

    if(ans > n) cout << -1;
    else cout << (n - ans);

    return 0;
}

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

int n,m;

int f[N],d[N];


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    string s;
    cin>>s;
    int kl=0,r=0;
    for(int i=0;i<n;i++){
        if(s[i]==')'){
            if(r==0) kl++;
            else r--;
        }
        else r++;
    }

    while(kl--){
        cout<<'(';
    }
    cout<<s;
    while(r--) {
        cout<<')';
    }
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	char a[10],b[10],c[10];
	int i=0,j=0;
	scanf("%s %s %s",&a,&b,&c);
	while(a[i]!='\0'){
        i++;
    }
    while(b[j]!='\0'){
        j++;
    }
	if(a[i-1]==b[0] && b[j-1]==c[0]){
        printf("YES\n");
	}
    else{
        printf("NO\n");
	}
    return 0;
}

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

int main() {
ll n;
cin>>n;
ll a[n]={};
ll b[n]={};
cin>>a[0];
b[0]=a[0];
for(ll i=1; i<n; i++){
cin>>a[i];
b[i]=b[i-1]+a[i];}
ll S=b[n-1];
ll x=0;
ll y=0;
ll counter=1000000000000;
for(ll i=0; i<n-1; i++){
x=b[i];
y=S-b[i];
counter=min(abs(x-y), counter);}
cout<<counter<<endl;}


Measured memory_bytes: 3328