akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N, A[500], val[250005];
pair<int, int> P[500];
vector< pair<int, int> > v;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	for (int i = 0; i < N; i++) P[i] = make_pair(A[i] - 1, i);
	sort(P, P + N);
	int s = 0;
	for (int i = 0; i < N; i++) {
		int l = P[i].first;
		s += P[i].second;
		if (l < s) {
			printf("No\n");
			return 0;
		}
		s++;
	}
	s = 0;
	for (int i = N - 1; i >= 0; i--) {
		int r = N * N - P[i].first - 1;
		s += (N - P[i].second - 1);
		if (r < s) {
			printf("No\n");
			return 0;
		}
		s++;
	}
	memset(val, -1, sizeof(val));
	for (int i = 0; i < N; i++) val[A[i] - 1] = i + 1;
	for (int i = 0; i < N; i++) v.push_back(make_pair(P[i].second + 1, P[i].second));
	for (int i = 0; i < N; i++) v.push_back(make_pair(P[i].second + 1, N - P[i].second - 1));
	printf("Yes\n");
	int cnt = 0;
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].second; j++) {
			while (val[cnt] != -1) cnt++;
			val[cnt] = v[i].first;
		}
	}
	for (int i = 0; i < N * N; i++) {
		if (i) printf(" ");
		printf("%d", val[i]);
	}
	printf("\n");
}


Measured memory_bytes: 2304
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n     = readInt()
  val lines = Iterator.fill(n)(readLine())
  val cards = lines.map { _.split(" ") }.map { case Array(a, b) => (a, b) }

  val (taro, hanako) = cards.foldLeft((0, 0)) { (score, line) =>
    val (a, b) = line
    val (x, y) = score

    if (a == b)
      (x + 1, y + 1)
    else if (a > b)
      (x + 3, y)
    else
      (x, y + 3)
  }

  println(s"$taro $hanako")
}



Measured memory_bytes: 44872
//d0*(sum-d0)+d1*(sum-d1).../2=(sum*sum-d0*d0+d1*d1+...)/2
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,d,sum=0,powsum=0;
	cin>>n;
	for(i=0;i<n;++i){
    	cin>>d;
    	sum+=d;
    	powsum+=d*d;
    }
	cout<<(sum*sum-powsum)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll fac(ll n){if(n<=1)return 1; else return n*fac(n-1);}
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2)cout << "No" << endl;
    else
    {
        if(s.substr(0,n/2)==s.substr(n/2,n/2))cout << "Yes" << endl;
        else cout <<"No"<< endl;    }
}


Measured memory_bytes: 3624
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>
 
using namespace std;
 
const int mod = 1e9 + 7;


int n, a[500];

int main() {
	for(int i = 1; i <= 300; i++)
	for(int j = i; j <= 300; j += i) a[j]++;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i+=2) {
		if(a[i] == 8) ans++;
	}
	cout << ans;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	char tmp, mes[ 101 ];
	int i, N, a[ 100 ], b[ 100 ];

	for ( ; scanf( "%d %s", &N, mes ), N; printf( "%s\n", mes ) ) {
		for ( i = 0; i < N; i++ )
			scanf( "%d %d", a + i, b + i );

		while ( N-- ) {
			int idx[ 2 ] = { a[ N ] - 1, b[ N ] - 1 }; 

			for ( i = 2; i--; mes[ idx[ i ] ] = ( mes[ idx[ i ] ] - 'a' + idx[ 1 ] - idx[ 0 ] ) % 26 + 'a' ) ;

			tmp = mes[ idx[ 0 ] ];
			mes[ idx[ 0 ] ] = mes[ idx[ 1 ] ];
			mes[ idx[ 1 ] ] = tmp;
		}
	}

	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    UnionFind uf;
    uf.init(N+M);
    for(int i=0;i<N;i++){
        int K;
        cin >> K;
        for(int j=0;j<K;j++){
            int L;
            cin >> L;
            uf.unite(i,N+L-1);
        }
    }
    for(int i=0;i<N-1;i++){
        if(!uf.same(i,i+1)){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

int D[6];

class Dice{
  public:
    
    Dice(int a, int b, int c, int d, int e, int f){
        D[0] = a;
        D[1] = b;
        D[2] = c;
        D[3] = d;
        D[4] = e;
        D[5] = f;
    }
    int p,q;
    void move(char ord){
        if (ord == 'S'){
            p = D[4];
            D[4] = D[5];
            q = D[0];
            D[0] = p;
            p = D[1];
            D[1] = q;
            D[5] = p;
        }
        if (ord == 'E'){
            p = D[5];
            D[5] = D[2];
            q = D[3];
            D[3] = p;
            p = D[0];
            D[0] = q;
            D[2] = p;
        }
        if (ord == 'W'){
            p = D[5];
            D[5] = D[3];
            q = D[2];
            D[2] = p;
            p = D[0];
            D[0] = q;
            D[3] = p;
        }
        if (ord == 'N'){
            p = D[5];
            D[5] = D[4];
            q = D[1];
            D[1] = p;
            p = D[0];
            D[0] = q;
            D[4] = p;
        }
    }
};

int main(){
    
    string order;
    int list[6];
    
    for ( int i = 0; i < 6; i++ ){
        scanf("%d",&list[i]);
    }
    cin >> order;
    
    Dice saikoro(list[0],list[1],list[2],list[3],list[4],list[5]);
    for ( int i = 0; order[i] != '\0'; i++){
        saikoro.move(order[i]);
    }
    printf("%d\n",D[0]);
    
    return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
#define CoutV(vec)     \
    for (auto v : vec) \
        Cout(v);
#define CoutVV(vecvec)      \
    for (auto vec : vecvec) \
        CoutV(vec);

using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;
//int t[10010];

int main()
{

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int cnt = 0;
        int now = i;

        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
                cnt++;
        }
        if (cnt == 8)
            ans++;
    }
    Cout(ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N, ans = 1;
	int d[100] = { 0 };
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> d[i];
	}
	sort(d, d + N);
	for (int i = 0;i < N - 1;i++) {
		if (d[i + 1] - d[i] > 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	private static final int NOT_ADD = -1;

	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
 
		try {
			if ((buf = br.readLine())!=null) {
				double max,min;
				max = min = Double.parseDouble(buf);
				while ((buf = br.readLine())!=null) {
					double d = Double.parseDouble(buf);
					if (max<d) max = d;
					if (min>d) min = d; 
				}
				System.out.println((double)Math.round((max-min)*100)/100);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16916
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		
		int[] a=new int[n];
		boolean jubge=false;
		double sum=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				if(a[i]<a[j]){
					int nn=a[j];
					a[j]=a[i];
					a[i]=nn;
				}
			}
		}
		
		sum=(double)(sum)/(4*m);
		int count=0;
		for(int i=0;i<n;i++){
			if(a[i]>=sum){
				count++;
			}
		}
		
		if(count>=m)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define N 200008
using namespace std;
int n,rr[N];
long long ans,a[N];
bool flag;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) 
	{
		scanf("%lld",&a[i]);
		if(a[i]-a[i-1]>1) flag=1;
	}
	if(a[1]!=0) {
		flag=1;
	}
	if(flag)  
	{
		cout<<"-1";
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		int k=0;
		while(a[i+k]==a[i+k+1]-1&&i+k+1<=n)
		{
			rr[i+k+1]=k+1;
			++k;
		}
		i+=k;
	}
	for(int i=n;i>=1;--i)
	{
		ans+=a[i];
		i-=rr[i];
	}
	//for(int i=1;i<=n;++i) cout<<rr[i]<<" ";  
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	// ????????????10??????
	public static int LOAN = 100000;

	public static void main(String[] args) {

		// ???????????????
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		double result = LOAN;

		// ?????±??????????¨????
		for (int i = 0; input > i; i++) {

			// ??????????????????
			result = result * 1.05;

			// 1000??§?????????????????\??????????????????
			result = Math.ceil(result / 1000);
			// ?????????????????????
			result = result * 1000;
		}
		System.out.println((int) result);
	}
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using Lint = long long;
#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define PB push_back
#define MP make_pair
using P=pair<int, int>;
using V=vector<int>;
using M=map<int, int>;
using S=set<int>;

#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
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;}
/* vector<T>のイテレータはvector<T>::iterator型
vector<int>::iterator it = vc.begin();  // begin()はvectorの最初の要素を指すイテレータを返す。
vector<int>::iterator endIt = vc.end(); // end()はvectorの終端位置を指すイテレータを返す。
while (it != endIt)
{
  cout << *it << '\n'; // イテレータの指す要素は、ポインタのように*演算子でアクセスします。
  it++;                // インクリメントすることで次の要素を指します。
}
}*/
int main()
{
  
  int x,n,aa=1;
  cin>>x>>n;
  V a(n);
  REP(i,n)cin>>a[i];
  int b=100;
  int tmp=1;
  int f=-1;
  while(b){
    REP(i,n){
  		if(x==a[i])
  		{x-=tmp;
  		aa++;
  		tmp=aa*(f);
         f=f*(-1);
  		}
	 }
    b--;
  }

  COUT(x);
 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10){
    cout << r << endl;
  }else{
    cout << 100*(10-n)+r << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000


int main()
{   
    fastio
    
    int n;
    cin>>n;
    vector<double> arr(n);

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

    double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
        for(int j =0;j<=n;j++)
            dp[i][j] =0;
    dp[0][0] = 1;

    for(int i = 1;i<=n;i++)
    {
        for(int j =0;j<=n;j++)
        {
            dp[i][j] = dp[i-1][j]*(1-arr[i-1]);
            if(j>0)dp[i][j] += (dp[i-1][j-1]*(arr[i-1])); 
        }
    }

    double ans =0;

    int half = n/2;

    for(int i = half+1;i<=n;i++)
        ans += dp[n][i];

    cout<<setprecision(12);
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll inf = 1e9;
const int maxn = 2e5 + 10;

ll n, a[maxn];
ll d[maxn][5], ans = 0;

ll f(int x, int y) {
    if(x > n)   return 0;
    ll& r = d[x][y];
    if(r == -1) {
        r = LLONG_MIN;
        for(int j = 0; j < y; ++j) {
            r = max(r, a[x + j] + f(x + j + 2, y - j));
        }
    }
    return r;
}

int main(void) {
    fastio;
    memset(d, -1, sizeof(d));
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    if(n % 2 == 0)  cout << f(1, 2);
    else            cout << f(1, 3);
    return 0;
}

Measured memory_bytes: 19228
use std::cmp::min;
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)*}
    };
}

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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! {
    n: usize,
    a: [i64; n]
    }
    let mut ans = 0;
    let mut m = std::i64::MAX;
    let mut c = 0;
    for i in 0..n {
        ans += a[i].abs();
        m = min(a[i].abs(), m);
        if a[i] < 0 {
            c += 1;
        }
    }
    if c % 2 == 1 { ans -= 2 * m }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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 Graph = vector<vector<int>>;
signed main(){
  int a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
  if(a-d==b-e&&b-e==c-f&&d-g==e-h&&d-g==f-i)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

int n, harga, diskon, total;

int main () {
	cin >> n;
	harga = n * 800;
	if (n>15){
		diskon = n/15 * 200;
	}
	total = harga - diskon;
	cout << total << endl;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
s = input()

count = [0]*p

key = 0
if p%2 and p%5:
  count = [0]*p
  key = 0
  
  mod = 1
  for i in range(n):
    key += (mod*int(s[n-1-i]))%p
    key %= p
    count[key] += 1
    mod *= 10
    mod %= p
  ans = count[0]
  for i in range(p):
    if count[i] >= 2:
      ans += (count[i])*(count[i]-1)//2
else:
  ans = 0
  for i in range(n):
    key = int(s[n-1-i])
    if key%p == 0:
      ans += n-i
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N,M; cin>>N>>M;
    vector<P>p(N);
    rep(i,N){
        ll x,y; cin>>x>>y;
        p[i]=mp(x,y);
    }
    sort(all(p));
    priority_queue<ll> que;
    ll ans=0;
    ll sub=0;//添え字
    rep1(i,M){
        while(sub<N && p[sub].a<=i){
            que.push(p[sub].b);
            sub++;
        }
        if(!que.empty()){
            ans+=que.top(); que.pop();
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2936
#include <algorithm>
#include <iostream>
#include <vector>

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

    if (a == b && b == c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    string s;
    cin >> s;
    while(!s.empty()){
        s.pop_back();
        bool ok = true;
        int p = s.size() / 2;
        for(int i = 0; i < p; i++){
            if(s[i] != s[i + p]){
                ok = false;
                break;
            }
        }
        if(ok && s.size() % 2 == 0){
            cout << s.size();
            return;
        }
    }
    cout << 0;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum = 0;
    vector<int> ans;
    int id = -1;
    for(int i = 1; i <= n; ++i){
        sum += i;
        ans.push_back(i);
        if(sum >= n) break;
    }
    if(sum > n) id = sum - n;
    for(auto e : ans){
        if(e != id) cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>

using namespace std;
using ll = long long;

set<string> s;

vector<string> alpha = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"};
void dfs(int n, int k, int m, string st){
  if(n == k){
    s.insert(st);
    return;
  }
  for(int i = 0; i < m+1; i++){
    dfs(n, k+1, max(i+1, m), st+alpha[i]);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  dfs(n, 0, 0, "");
  for(auto st: s) cout << st << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 14208
use std::cmp;
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, VecDeque};

const W: usize = 4001;
const N: usize = W * 2;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a = sc.chars();
    let b = sc.chars();
    let c = sc.chars();

    let ab = construct(&a, &b);
    let ac = construct(&a, &c);
    let bc = construct(&b, &c);

    let mut ans = b.len() + c.len() + a.len();
    for b_start in 0..N {
        for c_start in 0..N {
            if !ab[b_start] || !ac[c_start] {
                continue;
            }

            let head = min(min(b_start, c_start), W);
            let tail = max(max(b_start + b.len(), c_start + c.len()), W + a.len());

            // b= b_start..(b_start+b.len())
            if b_start >= W && c_start >= b_start - W {
                let c = c_start - (b_start - W);
                if bc[c] {
                    ans = min(ans, tail - head);
                }
            } else if b_start < W && c_start + W - b_start < N {
                let c = c_start + W - b_start;
                if bc[c] {
                    ans = min(ans, tail - head);
                }
            }
        }
    }

    println!("{}", ans);
}

fn construct(a: &Vec<char>, b: &Vec<char>) -> Vec<bool> {
    let mut row = vec!['?'; N];
    for i in 0..a.len() {
        row[i + W] = a[i];
    }

    let mut ok = vec![true; N];
    for start in 0..(N - b.len() + 1) {
        for i in 0..b.len() {
            if row[start + i] != '?' && row[start + i] != b[i] && b[i] != '?' {
                ok[start] = false;
                break;
            }
        }
    }
    ok
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
s=input()
k=int(input())

tmp=[s[0]]

for i in range(len(s)):
    for j in range(i,len(s)):
        cur_s=s[i:j+1]
        if cur_s not in tmp:
            if len(tmp)==k:
                if tmp[-1]<cur_s:
                    break
            idx=[ele<cur_s for ele in tmp].count(True)
            if len(tmp)==k:
                tmp=tmp[:idx]+[cur_s]+tmp[idx:-1]
            else:
                tmp=tmp[:idx]+[cur_s]+tmp[idx:]
print(tmp[-1])

Measured memory_bytes: 3188
use proconio::{input, marker::Usize1};

static mut QS: Vec<(usize, usize, u64, u64)> = Vec::new();
static mut SQ: Vec<u64> = Vec::new();

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    unsafe {
        QS = qs;
        let ans = dfs(n, m);
        println!("{}", ans)
    }
}

unsafe fn dfs(n: usize, m: u64) -> u64 {
    if SQ.len() == n {
        let mut res = 0;
        for &(a, b, c, d) in &QS {
            if SQ[b] - SQ[a] == c {
                res += d;
            }
        }
        return res;
    }
    let last = *SQ.last().unwrap_or(&1);
    let mut res = 0;
    for a in last..=m {
        SQ.push(a);
        res = res.max(dfs(n, m));
        SQ.pop();
    }
    res
}


Measured memory_bytes: 2152
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

neg_a = sorted([a for a in A if a < 0], reverse=True)
pos_a = sorted([a for a in A if a >= 0])
ans = 1

if len(pos_a) == 0 and K % 2 == 1:
    for a in neg_a[:K]:
        ans = ans * a % MOD
    print(ans)
    exit()

while K > 0:
    if K == 1 or len(neg_a) <= 1:
        if len(pos_a) == 0:
            ans *= neg_a.pop()
        elif len(pos_a) > 0:
            ans *= pos_a.pop()
        K -= 1
    elif len(pos_a) <= 1:
        ans *= neg_a.pop() * neg_a.pop()
        K -= 2
    elif pos_a[-1] * pos_a[-2] > neg_a[-1] * neg_a[-2]:
        ans *= pos_a.pop()
        K -= 1
    else:
        ans *= neg_a.pop() * neg_a.pop()
        K -= 2
    ans %= MOD

print(ans)


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int v[n];
	rep(i, n) cin >> v[i];
	
	bool allsame = true;
	rep(i, n - 1) {
		if (v[i] != v[i + 1]) allsame = false;
	}
	if (allsame) {
		cout << n / 2 << endl;
		return 0;
	}
	
	
	map<int, int> m1, m2;
	rep(i, n) {
		if (i % 2 == 0) {
			if (m1.find(v[i]) == m1.end()) {
				m1.insert(P(v[i], 1));
			} else {
				m1[v[i]]++;
			}
		} else {
			if (m2.find(v[i]) == m2.end()) {
				m2.insert(P(v[i], 1));
			} else {
				m2[v[i]]++;
			}
		}
	}
	
	
	int maxcnt1 = 0, maxcnt12 = 0;
	int maxvalue1;
	for (auto t:m1) {
		if (t.second >= maxcnt1) {
			maxcnt12 = maxcnt1;
			maxcnt1 = t.second;
			maxvalue1 = t.first;
		} else if (t.second >= maxcnt12) {
			maxcnt12 = t.second;
		}
	}
	
	int maxcnt2 = 0, maxcnt22 = 0;
	int maxvalue2;
	for (auto t:m2) {
		if (t.second >= maxcnt2) {
			maxcnt22 = maxcnt2;
			maxcnt2 = t.second;
			maxvalue2 = t.first;
		} else if (t.second >= maxcnt22) {
			maxcnt22 = t.second;
		}
	}
	
//	cout << maxcnt1 << " " << maxcnt12 << " " << maxcnt2 << " " << maxcnt22 << endl;
	
	if (maxvalue1 != maxvalue2) {
		cout << n - maxcnt1 - maxcnt2 << endl;
	} else {
		cout << min(n - maxcnt1 - maxcnt22, n - maxcnt2 - maxcnt12) << endl;
	}
	
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="RRR"){
        cout << 3 << endl;
        return 0;
    }
    else if(s=="SRR"){
        cout << 2 << endl;
        return 0;
    }
    else if(s=="RRS"){
        cout << 2 << endl;
        return 0;
    }
    for(int i=0; i<3; i++){
        if(s.at(i)=='R'){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3628
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
ll dp[114514]={0};
ll sum[114514]={0};

int N;
ll A,B;

int main(){
	cin>>N;
	string s[10005];
	rep(i,N)cin>>s[i];
	int ans=0;
	int x=0,y=0,z=0;
	rep(i,N){
		int sz=s[i].size();
		rep(j,sz-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
		}
		if(s[i][0]!='B'&&s[i][sz-1]=='A')x++;
		if(s[i][0]=='B'&&s[i][sz-1]!='A')y++;
		if(s[i][0]=='B'&&s[i][sz-1]=='A')z++;
	}
	if(z==0){
		ans+=min(x,y);
	}else{
		ans+=z-1;
		if(x>0){
			x--;
			ans++;
		}
		if(y>0){
			y--;
			ans++;
		}
		ans+=min(x,y);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%2&&b%2)cout<<"Odd"<<endl;
	else cout<<"Even"<<endl;
}


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

int main(){
  int N;
  cin >> N;
  int F = 0;
  
  for (int i = 1; i <= 9; i++ ) {
    for (int p = 1; p <= 9; p++ ) {
      if (N == i * p){
        F++;
      }
    }
  }
  if (F != 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())

sabun=0
for i in range(n):
    r=int(input())
    if i>=1:
        sabun=r-min_r
        if i==1:
            saidai=sabun
        if sabun>saidai:
            saidai=sabun
    if i==0:
        min_r=r
    elif r<min_r:
        min_r=r

print(saidai)



Measured memory_bytes: 5612
use proconio::input;
use proconio::marker::Usize1;
use std::collections::VecDeque;
use std::cmp::max;

struct Node {
    to: Vec<usize>,
    from: Vec<usize>,
    count: usize,
    dist: u32,
}

impl Node {
    fn new() -> Self {
        Node {
            to: Vec::new(),
            from: Vec::new(),
            count: 0,
            dist: 0,
        }
    }
}

fn main()
{
    input! {
    n:usize,
    m:usize,
    edge:[(Usize1,Usize1);m],
    }

    let mut v = (0..n).map(|_| Node::new()).collect::<Vec<Node>>();
    for &(a, b) in edge.iter() {
        v[a].to.push(b);
        v[b].from.push(a);
    }

    let mut q = VecDeque::new();
    for i in 0..n {
        if v[i].to.len() == 0 {
            q.push_back(i);
        }
    }

    while let Some(idx) = q.pop_front() {
        let dist = v[idx].dist + 1;
        for i in 0..v[idx].from.len() {
            let nxt = v[idx].from[i];
            v[nxt].dist = max(v[nxt].dist, dist);
            v[nxt].count += 1;

            if v[nxt].count == v[nxt].to.len() {
                q.push_back(nxt);
            }
        }
    }

    let mut ans = 0;
    for e in v.into_iter() {
        ans = max(ans, e.dist);
    }

    println!("{}", ans);
}

Measured memory_bytes: 17204
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto D=in();
	auto C=vecin(26);
	vvll S(D,vll(26));
	REP(i,D){
		REP(j,26) S[i][j]=in();
	}
	vll L(26,0);
	vll H;

	ll A=0;
	REP(i,D){
		ll d=i+1;
		ll maxB=-(1ll<<60),index=-1;
		REP(t,26){
			ll B=0;
			B += S[i][t];
			REP(j,26){
				if(t!=j){
					B -= C[j]*(d-L[j]);
				}
			}
			if(B>maxB){
				maxB = B;
				index=t;
			}
		}
		A+=maxB;
		H.push_back(index+1);
		L[index] = d;
		//out(A);
	}

	for(auto& x:H) out(x);
	return 0;
}


Measured memory_bytes: 3768
#!/bin/bash

read a b c;
min=1000000
if [ $(($a + $b)) -lt $(($min)) ]
then
    min=$(($a + $b))
fi
if [ $(($c + $b)) -lt $(($min)) ]
then
    min=$(($c + $b))
fi
if [ $(($c + $a)) -lt $(($min)) ]
then
    min=$(($c + $a))
fi
echo $min
exit 0

Measured memory_bytes: 376
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 998_244_353


@njit((i8, i8[:]), cache=True)
def main(N, LR):
    L, R = LR[::2], LR[1::2]
    K = len(L)
    F = np.zeros(N + 10, np.int64)
    F[0] = 1
    for n in range(1, N + 10):
        F[n] += F[n - 1]
        for k in range(K):
            l, r = L[k], R[k] + 1
            if n - l >= 0:
                F[n] += F[n - l]
            if n - r >= 0:
                F[n] -= F[n - r]
        F[n] %= MOD
    ans = F[N - 1] - F[N - 2]
    return ans % MOD


N, K = map(int, readline().split())
LR = np.array(read().split(), np.int64)

print(main(N, LR))


Measured memory_bytes: 107896
Num,K=map(int,input().split())
L=[[]for i in range(Num+1)]
for i in range(Num):
    t,d=map(int,input().split())
    L[t].append(d)
for i in range(1,Num+1):
    L[i].sort(reverse=True)

M=[]
m=[]
for i in range(1,Num+1):
    if len(L[i])>=1:
        M.append(L[i][0])
        if len(L[i])>=2:
            for j in range(1,len(L[i])):
                m.append(L[i][j])
M.sort(reverse=True)
m.sort(reverse=True)
MM=[0]
for i in range(len(M)):
    MM.append(MM[-1]+M[i])
mm=[0]
for i in range(len(m)):
    mm.append(mm[-1]+m[i])
#print(MM)
#print(mm)
ANS=0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,min(K,len(M))+1):
    ANS=max(i*i+MM[i]+mm[min(len(mm)-1,K-i)],ANS)
    #print(ANS,i)
print(ANS)

Measured memory_bytes: 77728
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a-1)*(b-1))
    return

#B
def B():
    def est(n):
        res = 0
        for i in range(1, int(n ** 0.5) + 1):
            if not n % i:
                res += 2
        res -= float.is_integer(n ** 0.5)
        return res == 8
    n = II()
    ans = 0
    for i in range(1, n + 1, 2):
        ans += est(i)
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39152
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n = int(input())
	s = input()[:-1]
	if(n%2==1):
		print('No')
		return
	print('Yes' if s[:n//2]==s[n//2:] else 'No')

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

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

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

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 5460
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
using namespace atcoder;


void solve(){
  int n,q;
  cin>>n>>q;
  fenwick_tree<ll>bit(n);
  rep(i,n){
    ll a;
    cin>>a;
    bit.add(i,a);
  }
  while(q--){
    int que;
    ll x,y;
    cin>>que>>x>>y;
    if(que==0)bit.add(x,y);
    else {
			cout<<bit.sum(x,y)<<"\n";
		}
  }
}


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


Measured memory_bytes: 8232
### main

loop do
  x, y, sx = gets.split.map(&:to_i)
  break if (x | y | sx) == 0

  max_sy = 0
  for a in (1..sx)
    af = a.to_f
    ax = (af * (100 + x) / 100).to_i
    ay = (af * (100 + y) / 100).to_i
    for b in (1..sx)
      bf = b.to_f
      bx = (bf * (100 + x) / 100).to_i
      by = (bf * (100 + y) / 100).to_i
      if ax + bx == sx
        sy = ay + by
        max_sy = sy if max_sy < sy
      end
    end
  end

  puts max_sy
end

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG
#include "cpp-pyprint/pyprint.h"
#endif

void Main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A ) {
        cin >> a;
    }

    vector<int> que;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int a = A[i];
        if (i == 0) {
            que.push_back(a);
            ans ++;
        }else{
            int idx = upper_bound(que.begin(), que.end(), a-1) - que.begin();
            if (idx == 0) {
                que.insert(que.begin(), a);
                ans ++;
            }else{
                que[idx-1] = a;
            }
        }
    }
    cout << ans << endl;
}

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


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

string a,b,c;

int main(){
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m;
	cin>>n>>m;

	ll l[m];
	ll r[m];

	for(int i =0;i<m;i++)
		cin>>l[i]>>r[i];

	int id[n+1];
	for(int i =1;i<=n;i++)
		id[i] = 0;

	for(int i =0;i<m;i++){
		id[l[i]]++;
		if(r[i]+1 <= n)
			id[r[i] + 1]--;
	}

	for(int i =2;i<=n;i++)
		id[i] = id[i] + id[i-1];

	int cnt =0;
	for(int i =1;i<=n;i++)
		if(id[i] == m)
			cnt++;

	cout<<cnt;
	return 0;

}

Measured memory_bytes: 2176
import java.util.*;
import java.lang.*;

public class Main {
    
    static int n;
    static int k;
    static int[] truck;
    static int[] w;
    
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        truck = new int[k];
        w     = new int[n];
        int max = 0;
        int min = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            max += w[i];
        }
        min = max / k;
        
        System.out.println(binarySearch(max, min));
        
    }
    
    static boolean check(int mid) {
        int num = 1;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (mid < w[i]) {
                num = k + 1;
                break;
            }
            sum += w[i];
            if (sum > mid) {
                num++;
                sum = w[i];
            }
        }
        if (num <= k) {
            return true;
        } else {
            return false;
        }
    }
    
    static int binarySearch(int max, int min) {
        int right = max;
        int left = min;
        int mid = (left + right) / 2;
        while (right > left + 1) {
            mid = (left + right) / 2;
            //System.out.println("left: " + left + ", right: " + right + ", mid: " + mid);

            if (check(mid)) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return (check(left) ? left : right);
    }
}


Measured memory_bytes: 71480
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	string o, e;
	cin >> o >> e;

	rep(i, o.length())
	{
		cout << o[i];
		if (i < e.length()) cout << e[i];
	}

	return 0;
}

Measured memory_bytes: 3560