akhauriyash/Code-Regression huggingface dataset:
/*
* @Author: Samson
* @Date:   2018-06-14 14:39:51
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-14 15:04:58
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10;

int n,color[105],d[105];
vector<pair<int,int> > a[105];

void dijkstra()
{
	priority_queue<pair<int,int> > que;
	memset(color,0,sizeof color);
	memset(d,INF,sizeof d);
	d[0] = 0;
	que.push(make_pair(0,0));
	while(que.size())
	{
		pair<int,int> p = que.top();
		que.pop();
		int u = p.second;
		color[u] = 1;

		if(d[u] < p.first*(-1))	continue;

		for(int i = 0; i < a[u].size(); ++i)
		{
			int v = a[u][i].first;
			if(color[v])	continue;
			if(d[v] > d[u]+a[u][i].second)
			{
				d[v] = d[u]+a[u][i].second;
				que.push(make_pair(d[v]*(-1),v));
			}
		}
	}
	for(int i = 0; i < n; ++i)
		cout<<i<<' '<< (d[i]==INF?-1:d[i])<<'\n';
}
int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	int u,k,v,w;
	for(int i = 0; i < n; ++i)
	{
		cin>>u>>k;
		for(int j = 0; j < k; ++j)
		{
			cin>>v>>w;
			a[u].push_back(make_pair(v,w));
		}
	}
	dijkstra();
	return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();

		long a = 0;
		for(int i = 1;i <= N;i++){
			if(i % K == 0){
				a++;
			}
			
		}
		if(K % 2 ==0){
			long b = 0;
			for(int i = 1;i <= N ;i++){
				if(i % K ==K /2){
					b++;
				}
			}
			System.out.println((long)(Math.pow(a, 3) + Math.pow(b, 3)));
			
		}else{
			System.out.println((long)(Math.pow(a, 3)));

		}


	}






}


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

int main(){
  string S;
  cin >> S;
  int ans=700;
  for(int i=0;i<3;i++){
    if(S.at(i)=='o'){
      ans+=100;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                      \
  ifstream in("loadtolb/abc138_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

vector<ll> c;
vector<bool> seen;
vector<vector<int>> g;

void dfs(int i) {
  seen[i] = true;
  for (auto j : g[i]) {
    if (seen[j] == true) continue;
    c[j] += c[i];
    dfs(j);
  }
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, Q;
  cin >> N >> Q;

  c = vector<ll>(N, 0);
  seen = vector<bool>(N, false);
  g = vector<vector<int>>(N, vector<int>(0));
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i, Q) {
    int q, x;
    cin >> q >> x;
    q--;
    c[q] += x;
  }

  dfs(0);
  rep(i, N) { cout << c[i] << " "; }
}

Measured memory_bytes: 24320
#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 main(){
  ll x,y;
  cin>>x>>y;
  ll ans=1e14;
  if(y>x)CHMIN(ans,y-x);
  if(x*y<=0){
    CHMIN(ans,abs(abs(y)-abs(x))+1);
  }else{
    CHMIN(ans,abs(abs(y)-abs(x))+2);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
G = []
for i in range(n):
    T = [0]*n
    G.append(T)
for i in range(n):
    L = list(map(int,input().split()))
    for j in range(2,len(L)):
        G[i][L[j]-1] += 1
d = [float('inf')]*n
q = collections.deque()
q.append(0)
d[0] = 0
while len(q) > 0:
    start = q.popleft()
    for i in range(n):
        if G[start][i] == 1:
            if d[i] == float('inf'):
                q.append(i)
                d[i] = d[start]+1
for i in range(n):
    if d[i] != float('inf'):
        print(i+1,d[i])
    else:
        print(i+1,-1)


Measured memory_bytes: 6108
//
// Created by 佐竹俊哉 on 2019/11/12.
//

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N; cin >> N;
    V<int> x(N); rep(i, N) cin >> x[i];
    int ans = 0;
    rep(i, N) {
        rep(j, i) {
            ans += x[i] * x[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Written by newbiechd
#include <cstdio>

const int maxN = 100003, mod = 1e9 + 7;
int x[maxN], inv[maxN];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &x[i]);
  inv[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = -1ll * (mod / i) * inv[mod % i] % mod;
  int ans = 0, temp = 0;
  for (int i = 1; i < n; ++i) {
    temp = (temp + inv[i]) % mod;
    ans = (1ll * temp * (x[i + 1] - x[i]) + ans) % mod;
  }
  for (int i = 1; i < n; ++i)
    ans = 1ll * ans * i % mod;
  printf("%d\n", (ans + mod) % mod);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdlib>
#include<climits>
#include<algorithm>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  int h[n+1],dp[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  for(int i=2;i<=n;i++)dp[i]=INT_MAX;
  dp[0]=dp[1]=0;
  for(int i=1;i<=n;i++)for(int j=1;j<=k;j++)if(i+j<=n+1)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int id;
	double weight, height, BMI;
	int flg = 0;	//該当データがあるかどうか
	int i = 0, cnt = 0;

	while(scanf("%d,%lf,%lf", &id, &weight, &height) != EOF) {
		BMI = weight / (height * height);
		if (BMI >= 25.0) {
			printf("%d\n", id);
			cnt++;
			flg = 1;	//該当あり
		}
	}

	if (flg == 0)
		printf("該当なし\n");
	/* else {
		for (i = 0; i < cnt; ++i) {
			printf("%d\n", arr[i]);
		}
	}
	*/

	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
#define ten5 100000
using namespace std;



int main()
{
    int m,n,o=0,i,j,k;
    int sum=0,range=0;
    //long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>n;
    int *sequence=new int [ten5];
    for(i=0;i<ten5;i++) sequence[i]=0;
    for(i=0;i<n;i++)
    {
        cin>>m;
        if(m>n) sum++;
        else sequence[m-1]++;
    }
    for(i=0;i<ten5;i++)
        if(sequence[i]<i+1)
            sum+=sequence[i];
        else if(sequence[i]>i+1)
            sum+=sequence[i]-i-1;
    cout<<sum;
    delete [] sequence;
    return 0;
}





Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
 
  cout << (b+a-3)/(a-1) << endl;
  
}


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

int main() {
	int a,b;
	cin >> a >> b;
	int sum =0;
	for ( int i =0 ; i < 2 ; i ++ ){
	if(a>=b){
	sum += a;
	a --;
	}
	else {
	sum += b ;
	b -- ; 
	}
	}
	cout << sum <<endl;

}


Measured memory_bytes: 256
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while (0 < pow) do
    if (pow % 2 == 1) then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res;
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local function getComb(n, k)
  local ret = 1
  for i = 1, k do
    ret = bmul(ret, n + 1 - i)
    ret = bmul(ret, modinv(i))
  end
  return ret
end

local n, k = io.read("*n", "*n")
local red = n - k
local redres = {}
redres[1] = 1
for i = 1, k do
  redres[1 + i] = bmul(redres[i], bmul(red - i, modinv(i)))
end
local blue_cnt = 1
for i = 1, k do
  if 1 < i then
    blue_cnt = bmul(blue_cnt, bmul(k - i + 1, modinv(i - 1)))
  end
  local red_1 = redres[i]
  local red_2 = redres[i + 1]
  local red_3 = 0
  if i ~= 1 then
    red_3 = redres[i - 1]
  end
  local sum = bmul(blue_cnt, (red_1 * 2 + red_2 + red_3) % mod)
  print(sum)
end


Measured memory_bytes: 256
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(){
    int n;
    scanf("%d",&n);
    printf("ABC%d\n",n);

    return 0;
}


Measured memory_bytes: 128
"""
2 3
1 32
2 63
1 12

000001000002
000002000001
000001000001



2 3
2 55
2 77
2 99

000002000001
000002000002
000002000003
"""


first = list(map(int, input().split()))
ken_shi_dict = {}
c = 0
for i in range(first[1]):
    c += 1
    ken_year = input().split()
    ken = ken_year[0]
    year = ken_year[1]
    if ken in ken_shi_dict:
        ken_shi_dict[ken].append([year, c])
    else:
        ken_shi_dict[ken] = [[year, c]]

answer_dict = {}
sorted_ken = sorted(ken_shi_dict.keys())
for i in sorted_ken:
    count = 1
    ken_number = str(i).zfill(6)
    ken_shi_dict[i].sort(key=lambda x: int(x[0]))
    for j in ken_shi_dict[i]:
        year_number = str(count).zfill(6)
        count += 1
        print_str = ken_number + year_number
        answer_dict[j[1]] = print_str

for i in sorted(answer_dict.keys()):
    print(answer_dict[i])


Measured memory_bytes: 61728
/* ex 7_1
   yy8332 */
#include <stdio.h>

//構造体宣言
typedef struct point{
  int x_elem;
  int y_elem;
}point;

//(+x,+y)移動する関数
point shift_point(point p, int x, int y){
  point q;
  q.x_elem = p.x_elem + x;
  q.y_elem = p.y_elem + y;

  return q;
}

int main(void){
  point p1, p2, p3, p4;
  int x, y;

  //入力読み取り
  scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

  x = -p2.y_elem + p1.y_elem;
  y = -p1.x_elem + p2.x_elem;

  p3 = shift_point(p2, x, y);
  p4 = shift_point(p1, x, y);

  //出力
  printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);

  return 0;
}


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

int main() {
	int a, b , c, d;
	cin >> a >> b >> c >> d;

	int ans;
	if (b <= c || d <= a) {
		cout << 0 << endl;
	} else {
		cout << min(b, d) - max(a, c) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
# a,b,c=map(int,input().split())
# s=input()
# s,t=map(str,input().split())

ans=[-1]*n
anss=""
for i in range(m):
  s,c=map(int,input().split())
  if ans[s-1] != -1 and ans[s-1] != c :
    print(-1)
    exit()
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  ans[s-1]=c

if m==0:
  if n==1:
    print(0)
  else:
    print(10**(n-1))
  exit()

if ans[0]==-1:
  ans[0]="1"



for x in ans:
  if x==-1:
    x=0
  anss+=str(x)
print(anss)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 100000+10;

int A[max_n];

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

    int x = 0;
    for(int i = 0;i < s.size()-1;i++) {
        if(s[i] == 'R' && s[i+1] == 'L') {
            A[i+1] += (x+1)/2 + 1;
            A[i] += x - (x+1)/2 + 1;
            x = 0;
        } else if(s[i] == 'R') {
            x++;
        }
    }

    x = 0;
    for(int i = s.size()-1;i > 0;i--) {
        if(s[i-1]  == 'R' && s[i] == 'L') {
            A[i-1] += (x+1)/2;
            A[i] += x - (x+1)/2;
            x = 0;
        } else if(s[i] == 'L') {
            x++;
        }
    }

    for(int i = 0;i < s.size();i++) {
        cout<<A[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b;
  for(int i=0;i<a.size()+b.size();i++){
    if(i%2==0)cout<<a[i/2];
    else cout<<b[i/2];
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int N_MAX = 100000;
typedef pair<int,int> P; // t,c
typedef pair<P,int> PP; // s,c,t
int main()
{
  int n,c,s,t,cc,i,j,res;
  P pt;
  vector<P> v;
  PP p[N_MAX];
  priority_queue<P,vector<P>,greater<P>> q;
  cin >> n >> c;
  for(i=0;i<n;i++)
    cin >> p[i].first.first >> p[i].second >> p[i].first.second;
  sort(p,p+n);
  q.push(P(p[0].second,p[0].first.second));
  for(i=1;i<n;i++){
    s=p[i].first.first;
    t=p[i].second;
    cc=p[i].first.second;
    if(!v.empty()){
      pt=v[0];
      if(pt.first<s || pt.first==s&&pt.second==cc){
        v.erase(v.begin());
        pt=P(t,cc);
        q.push(pt);
        continue;
      }else if(pt.first==s&&pt.second<cc){
        for(j=1;j<v.size();j++){
          pt=v[j];
          if(pt.first>s || pt.first==s&&pt.second>=cc)
            break;
        }
        if(pt.first==s&&pt.second==cc){
          v.erase(v.begin()+j);
          pt=P(t,cc);
          q.push(pt);
          continue;
        }else if(pt.first>s || pt.first==s&&pt.second>cc){
          pt=P(t,cc);
          q.push(pt);
          continue;
        }// else v.empty()の場合に合流
      }else{
        pt=P(t,cc);
        q.push(pt);
        continue;
      }
    }
    pt=q.top();
    if(pt.first<s || pt.first==s&&pt.second==cc){
      q.pop();
    }else if(pt.first==s&&pt.second<cc){
      while(pt.first==s&&pt.second<cc&&q.size()>1){
        q.pop();
        v.push_back(pt);
        pt=q.top();
      }
      if(pt.first==s&&pt.second==cc){
        q.pop();
      }
    }
    pt=P(t,cc);
    q.push(pt);
  }
  res=v.size()+q.size();
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int H, W;

int main() {
	cin >> H >> W;
	char *s = new char[(H + 2)*(W + 2)];

	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			if (i == 0 || i == H + 1 || j == 0 || j == W + 1) s[i*(W + 2) + j] = '.';
			else cin >> s[i*(W + 2) + j];
		}
	}

	bool flg = false;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (s[i*(W + 2) + j] == '.') continue;
			if (s[(i - 1)*(W + 2) + j] == '.' && s[(i + 1)*(W + 2) + j] == '.' && s[i*(W + 2) + j - 1] == '.' && s[i*(W + 2) + j + 1] == '.') flg = true;
			if (flg) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

l = 0
r = N-1

l_sum = 0
r_sum = 0
while l <= r:
    if l_sum <= r_sum:
        l_sum += A[l]
        l += 1
    else:
        r_sum += A[r]
        r -= 1
        
#print(l_sum, r_sum)
ans = abs(l_sum - r_sum)
print(ans)

Measured memory_bytes: 88912
#include<cstdio>
#include<algorithm>
#include<climits>
using namespace std;
static const int MAX_N = 100000;

int n, q;

int n_;
int dat[4 * MAX_N], laz[4 * MAX_N];

void init(){
	n_ = 1;
	while(n_ < n) n_ *= 2;
	for(int i = 0; i < 2 * n_ - 1; i++){
		dat[i] = INT_MAX;
		laz[i] = -1;
	}
}
void prop(int k){
	if(laz[k] == -1) return;
	if(2 * k + 1 < 2 * n_ - 1){
		laz[2 * k + 1] = laz[k];
		laz[2 * k + 2] = laz[k];
	}
	dat[k] = laz[k];
	laz[k] = -1;
}
void update(int a, int b, int x, int k, int l, int r){
	prop(k);
	if(r <= a || b <= l) return;
	if(a <= l && r <= b){
		laz[k] = x;
		return;
	}
	prop(k);
	update(a, b, x, 2 * k + 1, l, (l + r) / 2);
	update(a, b, x, 2 * k + 2, (l + r) / 2, r);
	int vl = (laz[2 * k + 1] == -1 ? dat[2 * k + 1] : laz[2 * k + 1]);
	int vr = (laz[2 * k + 2] == -1 ? dat[2 * k + 2] : laz[2 * k + 2]);
	dat[k] = min(vl, vr);
}
int find(int a, int b, int k, int l, int r){
	prop(k);
	if(r <= a || b <= l) return INT_MAX;
	if(a <= l && r <= b) return dat[k];
	int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr);
}

int main(){
	scanf("%d %d", &n, &q);
	init();
	update(0, n + 1, INT_MAX, 0, 0, n_);
	for(int i = 0; i < q; i++){
		int op;
		scanf("%d", &op);
		if(op == 0){
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);
			update(s, t + 1, x, 0, 0, n_);
		}else{
			int s,t;
			scanf("%d %d", &s, &t);
			printf("%d\n", find(s, t + 1, 0, 0, n_));
		}
	}
	return 0;
}



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

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

  int len;
  len = S.size();

  //cout << len;

  if (K>=len){
    cout << S;
  }
  else{
    S=S.erase(K);
    cout << S << "..." << endl;
  }

}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K - 1] += 'a' - 'A';

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
# ABC 122, c
n, q = [int(el) for el in input().split(' ')]
s = input()
T = [0] * (n + 1)
for i in range(n):
    T[i+1] = T[i] + (1 if s[i:i+2] == 'AC' else 0)


for i in range(q):
    l, r = [int(el) for el in input().split(' ')]
    print(T[r-1] - T[l-1])


Measured memory_bytes: 9284
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MAX_N = 8;
int N, A, B, C;
vector<int> l(MAX_N);

int dfs(int depth, int a, int b, int c) {
    if(depth == N) {
        if(a == 0 || b == 0 || c == 0) {
            return 999999999;
        }
        return abs(a-A) + abs(b-B) + abs(c-C) - 30; 
    }
    else {
        int notUse = dfs(depth+1, a, b, c);
        int useForA = dfs(depth+1, a+l[depth], b, c) + 10;
        int useForB = dfs(depth+1, a, b+l[depth], c) + 10;
        int useForC = dfs(depth+1, a, b, c+l[depth]) + 10;
        return min({notUse, useForA, useForB, useForC});
    }
}

int main() {
    cin >> N >> A >> B >> C;
    rep(i, N) {
        cin >> l[i];
    }

    cout << dfs(0, 0, 0, 0);

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e11;
using namespace std;
typedef long long ll;
ll dp[1001][1002]={0};
int main(){	
	ll n,m;
	cin>>n>>m;
	vector<ll>d(n+1);
	vector<ll>c(m);
	d[0]=0;
	rep(i,n)cin>>d[i+1];
	rep(i,m)cin>>c[i];
	//memset(dp,inf,sizeof(dp));
	rep(i,1001)rep(j,1002)dp[i][j]=inf;
	dp[0][1]=0;
	loop(i,1,m+1)loop(j,1,n+2){
		dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+d[j-1]*c[i-1]);
	}
	cout<<dp[m][n+1]<<endl;
}

Measured memory_bytes: 9044
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
y = N
for i in range(P,N):
  a = A[i]
  if x==a:
    ans+=1
  else:
    y=i
    break

z = sum(A[P-1:y])
for i in range(y,N):
  a = A[i]
  d = a+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    e = z+c
    f = d*(i-P+1)
    if f>=e:
      ans+=1
      
  z+=a
print(ans)

Measured memory_bytes: 23236
#include<stdio.h>
int main()
{
    int x,y,z,i=0;
    scanf("%d %d %d",&x,&y,&z);
    if((x==5&&y==5&&z==7)||(x==5&&y==7&&z==5)||(x==7&&y==5&&z==5))
       printf("YES\n");
    else
    printf("NO\n");

    return 0;

}


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

using namespace std;

const int maxn=1e6+5;

typedef long long ll;

const ll mod=1e9+7;

ll dig(ll x){
	ll ans=0;
	while(x){
		x>>=1;
		ans++;
	}
	return ans;
}

ll qPow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a;
		a=a*a;
		b>>=1;
	}
	return ans;
}

int main(){
	ll x;
	scanf("%lld",&x);
	ll num=dig(x);
	ll ans=qPow(2,num)-1;
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

namespace str{
    vector<ll> Manacher(const string &s){
        vector<ll> ret(s.size(),0);
        int j=0;
        for(int i=0;i<s.size();){
            while(i>=j && i+j<s.size() && s[i-j]==s[i+j]){j++;}
            ret[i]=j;
            int k=1;
            while(k<j && ret[i-k]+k<j){ret[i+k]=ret[i-k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    vector<ll> Z_Algorithm(const string &s){
        vector<ll> ret(s.size(),0);
        ret[0]=s.size();
        int j=0;
        for(int i=1;i<s.size();){
            while(i+j<s.size() && s[j]==s[i+j]){j++;}
            ret[i]=j;
            if(j==0){i++; continue;}
            int k=1;
            while(k+ret[k]<j){ret[i+k]=ret[k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    //1-indexed
    vector<ll> MP(const string &s){
        vector<ll> ret(s.size()+1,-1);
        ll j=-1;
        for(int i=0;i<s.size();i++){
            while(j>=0 && s[i]!=s[j]){j=ret[j];}
            j++;
            ret[i+1]=j;
        }
        return ret;
    }
};

using namespace str;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll N=s.size(),K=N;
  for(ll i=1;i<N;i++){
    if(N%i!=0){continue;}
    bool jd=true;
    for(int j=0;j<N;j++){
      jd&=s[j]==s[j%i];
    }
    if(jd){K=i; break;}
  }
  if(K==1){cout<<N<<endl<<1<<endl;}
  else if(K==N){cout<<1<<endl<<1<<endl;}
  else{
    cout<<2<<endl;
    auto A=Z_Algorithm(s);
    reverse(s.begin(),s.end());
    auto B=Z_Algorithm(s);
    vector<bool> uku1(N+1,true);
    vector<bool> uku2(N+1,true);
    //cout<<A<<endl;
    for(int i=1;i<N;i++){
      for(int j=i*2;j<=i+A[i];j+=i){
        uku1[j]=false;
      }
      for(int j=i*2;j<=i+B[i];j+=i){
        uku2[j]=false;
      }
    }
    ll ans=0;
    for(int i=0;i+1<N;i++){
      int i2=N-i-2;
      if(uku1[i+1] && uku2[i2+1]){ans++;}
    }
    cout<<ans<<endl;
  }


  return 0;
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
int main() {
  int n,k;
  cin>>n>>k;
  int h[n];
  int count=0;
  rep(i,n){
    cin>>h[i];
      if(k<=h[i]){
      count++;
    }
  
  }
  cout<<count;

}
 
    
 

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll a,b,c;
   cin>>a>>b>>c;
   ll s=a+b+c;
   if(s>=22)
   {
       cout<<"bust";
   }
   else
    cout<<"win";

}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n; cin>>n;
  int d[n];
  for(int i=0;i<n;i++) cin>>d[i];
  vector<int> v;
  int p[13]={};
  for(int i=0;i<n;i++) {
    p[d[i]]++;
  }
  
  int u[24]={true};
  for(int i=0;i<13;i++) {
    if (i==0 && p[i]>=1 || p[i] >= 3) {
      cout<<0<<endl;
      return 0;
    } else if (p[i] == 1) {
      v.push_back(i);
    } else if (p[i] == 2) {
      u[i]=true, u[24-i]=true;
    }
  }

  int an=0, m=v.size();
  for(int i=0;i<1<<m;i++) {
    int u2[24]; copy(u,u+24,u2);
    for(int j=0;j<m;j++) {
      if (i & (1<<j)) u2[v[j]]=true;
      else u2[24-v[j]]=true;
    }
    int sm=12, ls=0;
    for(int j=1;j<24;j++) {
      if (u2[j]) {
        sm=min(sm,j-ls);
        ls=j;
      }
      //cout<<u2[j];
    }
    // 逆側から
    for(int j=23;j>=0;j--) {
      if (u2[j]) {
        sm=min(sm,24-j);
        break;
      }
    }
    //cout<<" "<<sm<<endl;
    an=max(an,sm);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int n, m, a[200010];
int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n*2;i++) scanf("%d", a+i);
	sort(a+1, a+1+2*n);
	int ans = 0;
	for(int i=1;i<=n;i++) ans = max(ans, (a[i]+a[2*n+1-i])%m);
	
	int low = 0, high = n;
	while(low <= high) {
		int mid = (low + high) >> 1;
		int lmx = 0;
		for(int i=1;i<=mid;i++) {
			lmx = max(lmx, a[i]+a[mid*2+1-i]);
		}
		if(lmx >= m) {
			high = mid - 1;
			continue;
		}
		int rmn = 2e9;
		for(int i=2*n;i>2*n-(n-mid);i--) {
			int j = 2*n+2*mid+1-i;
			rmn = min(rmn, a[i]+a[j]);
		}
		if(rmn < m) {
			low = mid + 1;
			continue;
		}
		int lv = 0, rv = 0;
		for(int i=1;i<=mid;i++) {
			lv = max(lv, a[i]+a[mid*2+1-i]);
		}
		for(int i=2*n;i>2*n-(n-mid);i--) {
			int j = 2*n+2*mid+1-i;
			rv = max(rv, a[i]+a[j] - m);
		}
		if(lv >= rv) {
			ans = min(ans, lv);
			high = mid - 1;
		}
		else {
			ans = min(ans, rv);
			high = mid - 1;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s; cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
%>

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

class SegTree():
    """
    0-indexedの配列[a0, a1, a2, ..., a(N-1)]に対して以下のクエリをそれぞれO(logx)で行う：
        1. i番目の要素にxを代入
        2. 半開区間[i, j)内の最小値を返す
    self.id_elemとself.funcを変えることでRmQ以外にも例えばRMQに対応可能。
    参考：https://juppy.hatenablog.com/entry/2019/05/02/蟻本_python_セグメント木_競技プログラミング_Atcoder
    """
    def __init__(self, N):
        #####identity element######
        self.id_elem = 10**10
        self.func = min

        #num_max: the smallest power of two over N
        self.num_max = 2 ** ((N - 1).bit_length())
        self.x = [self.id_elem] * (2 * self.num_max - 1)

    def get_elem(self, i):
        """
        i番目の要素を返す
        """
        return self.x[self.num_max + i - 1]

    def update(self, i, x):
        """
        i番目の要素にxを代入
        """
        i += self.num_max - 1
        self.x[i] = x
        while (i > 0):
            i = (i - 1) // 2
            self.x[i] = self.func(self.x[i * 2 + 1], self.x[i * 2 + 2])

    def query(self, i=0, j=-1, k=0, l=0, r=-1):
        """
        半開区間[i, j)内の最小値を返す
        [l, r)はノードkに対応づく区間を与える
        query()で配列全体に対してクエリを実行する
        """
        if j == -1: j = self.num_max
        if r == -1: r = self.num_max

        # [i, j) and [l, r) are disjoint
        if (r <= i or j <= l): return self.id_elem
        # [l, r) is included in [i, j)
        if (i <= l and r <= j): return self.x[k]
        # [i, j] and [l, r) partially intersect
        vl = self.query(i, j, k * 2 + 1, l, (l + r) // 2)
        vr = self.query(i, j, k * 2 + 2, (l + r) // 2, r)
        return self.func(vl, vr)

def main():
    N, Q = map(int, input().split())
    black = (N - 2) * (N - 2)
    """
    クエリの管理にセグ木をどう使うかわからず止まってしまった。。。
    （区間minをとるのにどこからどこまでの区間を取るか効率的に取得する方法がわからなかった）

    結論としては自分自身の位置から「末尾まで」のminを取れば良い。
    というのも白マスの取れる個数はjの位置に対して単調増加だから。
    """
    tree_width = SegTree(N)
    tree_height = SegTree(N)
    tree_width.update(N - 2, N - 2)
    tree_height.update(N - 2, N - 2)
    reversed = 0
    for _ in range(Q):
        q, x= map(int, input().split())
        x -= 1
        if q == 1:
            new_reversed = tree_width.query(x, N)
            if tree_height.query(new_reversed, N) > x - 1:
                tree_height.update(new_reversed, x - 1)
        else:
            new_reversed = tree_height.query(x, N)
            if tree_width.query(new_reversed, N) > x - 1:
                tree_width.update(new_reversed, x - 1)
        reversed += new_reversed
    print((N - 2) * (N - 2) - reversed)


if __name__ == "__main__":
    main()


Measured memory_bytes: 96744
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

var lines = [];
reader.on('line',(line) => {
          lines.push(line);
});

reader.on('close', () => {
          var line = lines[0];
  var elems = line.split(' ');
  var A = elems[1];
  var B = elems[2];
  var D = B - A;
  if ( D % 2 == 1){
    console.log('Borys');
  } else {
    console.log('Alice');
  }
});

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

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

    long double bunbo=0;
    rep(i,n){
        bunbo+=1/(double)a[i];
    }
    cout<<fixed<<setprecision(10);
    cout<<1.0/bunbo<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF (INT32_MAX/2)
typedef pair<int, int> P;
 
int main()
{
	int N, M, S, T;
 
	cin >> N >> M;
	vector<vector<int>> G( N );
	for( int i = 0; i < M; i++ ) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		G[u].push_back( v );
	}
	cin >> S >> T;
	S--;
	T--;
 
	vector<vector<int>> G1( N * 3 );
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < G[i].size(); j++ ) {
			int u0 = i;
			int u1 = u0 + N;
			int u2 = u1 + N;
			int v0 = G[i][j];
			int v1 = v0 + N;
			int v2 = v1 + N;
			G1[u0].push_back( v1 );
			G1[u1].push_back( v2 );
			G1[u2].push_back( v0 );
		}
	}
	queue<P> que;
	vector<int> d( N * 3, INF );
	d[S] = 0;
	que.push( P( S, 0 ) );
	while( !que.empty() ) {
		P p = que.front();
		que.pop();
		int v = p.first;
		if( d[v] < p.second ) continue;
		for( int i = 0; i < G1[v].size(); i++ ) {
			int e = G1[v][i];
			if( d[e] > d[v] + 1 ) {
				d[e] = d[v] + 1;
				que.push( P( e, d[v] + 1 ) );
			}
		}
	}
	int ans = -1;
	if( d[T] != INF ) {
		ans = d[T] / 3;
	}
 
	cout << ans << endl;
}


Measured memory_bytes: 23296
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int pos;
vector<int> pre, in, post;

void Reconst (int left, int right) {
	if (left >= right) {
		return;
	}

	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));

	Reconst(left, m);
	Reconst(m + 1, right);

	post.push_back(root);
}

void Solve (int n) {
	pos = 0;
	Reconst(0, pre.size());

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

	cout << endl;
}


int main() {
	int n, k;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> k;
		pre.push_back(k);
	}

	for (int i = 0; i < n; i++) {
		cin >> k;
		in.push_back(k);
	}

	Solve(n);

	return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int N[31]={0},a=0;
	for(int i=1;i<31;i++)
	{
		scanf("%d",&a);
		N[a]=1;
	}
	for(int i=1;i<31;i++)
	{
		if(N[i]!=1){printf("%d\n",i);}
	}
	return 0;
}
//前回記録31:37.770クリア


Measured memory_bytes: 3212
N, K = map(int, input().split())
mod = 10 ** 9 + 7
def mod_cmb(n, r, mod=10 ** 9 + 7):
	assert n >= r >= 0

	def ex_euclid(x, y):
		a, b = 1, 0
		while y != 0:
			a, b = b, (a - x // y * b)
			x, y = y, x % y
		return a

	p = q = 1
	for i in range(n - r + 1, n + 1):
		p *= i
		p %= mod
	for i in range(2, r + 1):
		q *= i
		q %= mod
	p *= ex_euclid(q, mod)
	p %= mod
	return p
if N<K:
	print(0)
	exit()
print(mod_cmb(N-1,K-1))


Measured memory_bytes: 5600
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "vector"
using namespace std;
#define MAXN 116
#define P 1000000007
int n;
int A[MAXN];
int Pow( int x , int a ) {
    int cur = x % P , ans = 1;
    while( a ) {
        if( a & 1 ) ans = 1ll * ans * cur % P;
        cur = 1ll * cur * cur % P , a >>= 1;
    }
    return ans;
}
pair<int,int> solve( int l , int r , int c ) {
//    cout << l << ' ' << r << endl;
    if( l > r ) return make_pair( 1 , 0 );
    int h = 0x3f3f3f3f;
    for( int i = l ; i <= r ; ++ i ) h = min( h , A[i] );
    vector<int> pos;
    pos.push_back( l - 1 );
    for( int i = l ; i <= r ; ++ i ) if( A[i] == h ) pos.push_back( i );
    pos.push_back( r + 1 );
    int nm = pos.size() - 2;
    int re = 1 , tot = 1;
    for( int i = 0 ; i < pos.size() - 1 ; ++ i ) {
        pair<int,int> ret = solve( pos[i] + 1, pos[i + 1] - 1, h );
        re = 1ll * re * ret.first % P , tot = 1ll * tot * ( ret.first + ret.second ) % P;
//        cout << l << ' ' << r << ' ' << pos[i] + 1 << ' ' << pos[i + 1] << ' ' << re << ' ' << tot << endl;
    }
    return make_pair( 1ll * re * Pow( 2 , h - c ) % P , ( 1ll * re * ( Pow( 2 , h - c ) - 2 ) % P + 1ll * Pow( 2 , nm ) * tot % P ) % P );
}
int main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%d",&A[i]);
    cout << solve( 1 , n , 0 ).second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
template <typename T>
struct RMQ {
    const T INF = numeric_limits<T>::max();
    int n;
    vector<T> dat, lazy;
    RMQ(int n_) : n(), dat(n_ * 4, INF), lazy(n_ * 4, INF) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }
    /* lazy eval */
    void eval(int k) {
        if (lazy[k] == INF) return;  // 更新するものが無ければ終了
        if (k < n - 1) {             // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = lazy[k];
            lazy[k * 2 + 2] = lazy[k];
        }
        // 自身を更新
        dat[k] = lazy[k];
        lazy[k] = INF;
    }
    void update(int a, int b, T x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = x;
            eval(k);
        } else if (a < r && l < b) {                     // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, T x) { update(a, b, x, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return INF;
        } else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        } else {  // 一部区間が被る時
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    /* debug */
    inline T operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < 2 * n - 1; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    RMQ<int> A(n),B(n);
    A.update(0,n,n-2),B.update(0,n,n-2);
    int aa=n,bb=n;
    rep(i,q){
        int c,x;
        cin>>c>>x;
        x--;
        if(c==1){
            int a=A[x];
            A.update(x,x+1,0);
            if(aa>x) B.update(0,a+1,x-1),aa=x;
        }
        else{
            int b=B[x];
            B.update(x,x+1,0);
            if(bb>x) A.update(0,b+1,x-1),bb=x;
        }
    }
    vec C(n),D(n);
    rep(i,n) C[i]=A[i],D[i]=B[i];
    ll ans=0;
    int z=0;
    rep(i,n-2) ans+=C[i+1];
    rep(i,n-2){
        if(D[i+1]==0) z=1;
        if(z) ans+=D[i+1];
    }
    cout<<ans;
}

Measured memory_bytes: 18772
from collections import Counter
 
n = int(input())
v = list(map(int, input().split()))
ve = Counter(v[::2]).most_common() # 一番個数の多いものと、その個数のタプル
vo = Counter(v[1::2]).most_common()


if ve[0][0] == vo[0][0]:
    if len(ve) == len(vo) == 1:
        ans = n - max(ve[0][1], vo[0][1])
    else:
        ans = n - max(ve[0][1]+vo[1][1], vo[0][1]+ve[1][1])
else:
    ans = n - ve[0][1] - vo[0][1]
print(ans)

Measured memory_bytes: 20700
N = int(input())
S = input()

count_max = 0

for i in range(1,N):
    count = 0
    S_tmp = []
    for j in range(0,i):
        count_S = S_tmp.count(S[j])
        if count_S == 0:
            S_tmp.append(S[j])
            for k in range(i,N):
                if S[j] == S[k]:
                    count += 1
                    break
    if count_max < count:
        count_max = count

print(count_max)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            if (input[0] > input[1])
            {
                Console.WriteLine("safe");
                return;
            }
            Console.WriteLine("unsafe");
        }
    }
}


Measured memory_bytes: 28180
#include <stdio.h>

#define MAX 100

int main(void) {
    int N, M;
    int i, j;
    int A[MAX][MAX];
    int b[MAX];

    scanf("%d %d", &N, &M);
    for(i=0; i<N; ++i) {
      for(j=0; j<M; ++j) {
        scanf("%d", &A[i][j]);
      }
    }
    for(i=0; i<M; ++i) {
      scanf("%d", &b[i]);
    }

    for(i=0; i<N; ++i) {
      int C = 0;
      for(j=0; j<M; ++j) {
        C += A[i][j] * b[j];
      }
      printf("%d\n", C);
    }

    return 0;
}



Measured memory_bytes: 2052
# 入力
n = int(input().rstrip())
data = list(map(int,input().split()))

# ソート
for i in range(1, n):
    for s in range(n):
        if s != n-1:
            print(data[s], end=" ")
        else:
            print(data[s])
    min = i
    j = i-1
    while j >= 0:
        if data[min] < data[j]:
            tmp = data[j]
            data[j] = data[min]
            data[min] = tmp
            min = j
        j -= 1

for s in range(n):
    if s != n - 1:
        print(data[s], end=" ")
    else:
        print(data[s])


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

int main(void){
    int n, a[100010], cnt=1;
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a, a+n);
    for(int i=1;i<n;++i){
        if(a[i]!=a[i-1]) ++cnt;
    }
    if(cnt%2==0){
        cout << cnt-1 << endl;
    }else{
        cout << cnt << endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int n;cin >> n;
    double a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n;i++)a[i] = 1/a[i];
    double sum = 0;
    for(int i = 0;i < n;i++)sum += a[i];
    cout << 1/sum;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		String st = scan.nextLine();
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			char ch = st.charAt(i);
			if (ch == '1') {
				ans += 1;
			}
		}
		System.out.println(ans);
	}

}


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

int fun(int x){
    int res=0;
    while(x!=0){
        res+=x--;
    }
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    printf("%d\n",fun(n));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		int upper = (n + 1)* 100 / 108;
		int lower = n * 100 / 108;
		
		for(int i = lower; i <= upper; i++) {
			int zeikomi = i * 108 / 100;
			if(zeikomi == n) {
				System.out.println(i);
				return;
			}
		}
		
		System.out.println(":(");
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int s_length = s.length();
    int t_length = t.length();

    int ans = 10000;
    int count = 0;
    int head = 0;
    rep(i, s_length - t_length + 1) {
        head = i;
        count = 0;

        rep(j, t_length) {
            if(t[j] != s[head + j])
                count++;
        }

        ans = min(ans, count);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

const double pi = 3.14159265358979323846264338327950288419716;

int32_t main(){
    fast_io;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h += m/60.0;
    double x = (h/6.0)*(pi);
    double y = (m/30.0)*(pi);
    double theta = abs(x-y);
    theta = min(theta, 2*pi);
    // show(cos(theta));
    double ans = a*a + b*b -2.0*a*b*cos(theta);
    ans = sqrt(ans);
    printf("%.10f \n", ans);
    return 0;
}

Measured memory_bytes: 4236