akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {1, 0};
const int dy[] = {0, 1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P  = pair<int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  deque<P> deq;
  vector<vector<int>> grid(h, vector<int>(w, INF));
  grid[0][0] = (s[0][0] == '#');
  deq.push_front({0, 0});
  while (!deq.empty()) {
    int x, y;
    tie(x, y) = deq.front();
    deq.pop_front();
    rep(i, 2) {
      if (x+dx[i] < 0 || y+dy[i] < 0 || x+dx[i] >= h || y+dy[i] >= w)
        continue;
      if (s[x+dx[i]][y+dy[i]] == '.' || s[x+dx[i]][y+dy[i]] == s[x][y]) {
        if (chmin(grid[x+dx[i]][y+dy[i]], grid[x][y]))
          deq.push_front({x+dx[i], y+dy[i]});
      } else {
        if (chmin(grid[x+dx[i]][y+dy[i]], grid[x][y]+1))
          deq.push_back({x+dx[i], y+dy[i]});
      }
    }
  }
  cout << grid[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 401000
#define LL long long

LL n;
int s[AC], d[AC], f[AC];

inline int read()
{
	int x = 0;char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

inline LL lowbit(int x){
	return x & (-x);
}

inline void add(int x){
	//printf("add : %d\n", x);
	for(R i = x; i <= 300000; i += lowbit(i)) d[i] += 1;
}

inline LL find(int x)
{
	LL rnt = 0;
	//printf("find : %d\n", x);
	for(R i = x; i; i -= lowbit(i)) rnt += d[i];
	return rnt;
}

void pre()
{
	n = read();
	for(R i = 1; i <= n; i ++) s[i] = read();
}

LL cal(int x)
{
	memset(f, 0, sizeof(f));
	memset(d, 0, sizeof(d));
	LL rnt = 0, k = 201000;//偏移量，防止负数
	for(R i = 1; i <= n; i ++) 
		f[i] = f[i - 1] + (s[i] <= x);
	for(R i = 1; i <= n; i ++)//枚举右端点
	{
		add(i - 2 * f[i - 1] + k);
		rnt += find(355000) - find(i - 2 * f[i] + 1 + k);
	}
	return rnt;
}

void half()
{
	int l = 0, r = 1000000000, mid;
	LL lim = (n * (n + 1) / 2) / 2 + 1;//这里乘的时候爆int了
	while(l < r)
	{
		mid = (l + r) >> 1;
		LL tmp = cal(mid);
		if(tmp >= lim) r = mid;
		else l = mid + 1;
	}	
	printf("%d\n", l);
}

int main()
{
	//freopen("in.in", "r", stdin);
	pre();
	half();
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [usize1; n],
  }
  let mut next = 0;
  for &x in &a {
    if x == next {
      next += 1;
    }
  }

  puts!("{}\n", if next == 0 { -1 } else { (n - next) as i32 });
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <string.h>

#define MAX_N 10000

int is_prim(int val) {
  int i;
  if(val == 2) return 1;
  if(val < 2 || val%2 == 0) return 0;
  for(i = 3; i*i <= val; i+=2) {
    if(val%i == 0) return 0;
  }
  return 1;
}

int main() {
  int prim[MAX_N + 10];
  int n, val, ans = 0;
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &val);
    if(is_prim(val)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ll i,j,n;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    ll ans = 0;
    ll mod = 1e9+7;
    vector<ll> suf(n,0);
    suf[n-1] = a[n-1]%mod;
    for(i=n-2;i>=0;i--) suf[i] = (suf[i+1] + a[i])%mod;
    for(i=0;i<n-1;i++)
    {
        ll cur = (a[i]*suf[i+1])%mod;
        ans = (ans + cur)%mod;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 6424
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
   
      int N = sc.nextInt();
      int K = sc.nextInt();

      Integer[] l = new Integer[N];

      for (int i = 0;i<N;i++){
        l[i] = sc.nextInt(); 
      }
      
      Arrays.sort(l,Collections.reverseOrder());
      
      int len=0;
      for (int i = 0;i<K;i++){
          len += l[i];  
      }
      System.out.println(len);
	}
}

Measured memory_bytes: 21972
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		List<Integer> S = new ArrayList<Integer>(n);
		for (int i = 0; i < n; i++) {
			S.add(scan.nextInt());
		}
		int q = scan.nextInt();
		List<Integer> T = new ArrayList<Integer>(q);
		for (int i = 0; i < q; i++) {
			T.add(scan.nextInt());
		}
		
		int ans = 0;
		for (int i = 0; i < q; i++) {
			if (S.contains(T.get(i))) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
		scan.close();
		
	}

}

Measured memory_bytes: 32344
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int m, k;
	cin >> m >> k;
	if (m == 1)
	{
		if (k == 0) puts("0 0 1 1");
		else puts("-1");
		return 0;
	}
	if (k >= (1 << m))
	{
		puts("-1");
		return 0;
	}
	vector<int> ans;
	ans.push_back(k);
	for (int i = 0; i < (1 << m); i++)
	{
		if (i == k) continue;
		ans.push_back(i);
	}
	ans.push_back(k);
	for (int i = (1 << m) - 1; i >= 0; i--)
	{
		if (i == k) continue;
		ans.push_back(i);
	}
	for (int i = 0; i < ans.size(); i++)
		printf("%d%c", ans[i], " \n"[i + 1 == ans.size()]);
	return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < ll > A(N),B(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];

    ll sumA = 0;
    ll sumB = 0;
    REP(i,N) {
        sumA += A[i];
        sumB += B[i];
    }

    if (sumA < sumB) {
        cout << -1 << endl;
        return 0;
    }

    ll sum_lack = 0;
    ll ans = 0;
    REP(i,N) {
        if (A[i] < B[i]) {
            sum_lack += B[i] - A[i];
            ans++;
        }
    }

    vector < ll > over;
    REP(i,N) {
        if (A[i] > B[i]) {
            over.push_back(A[i] - B[i]);
        }
    }

    sort(over.begin(), over.end());
    reverse(over.begin(), over.end());

    if (sum_lack == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll sum_flow = 0;
    REP(i,over.size()) {
        sum_flow += over[i];
        if (sum_flow >= sum_lack) {
            cout << ans + i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 2428
#include<stdio.h>
int main(){
    int a,b,i;
    scanf("%d %d",&a,&b);
    if(a<b){
        for(i =0;i<b;i++){
            printf("%d",a);
    }
    }
    else{
                    for(i =0;i<a;i++){
        printf("%d",b);
    }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X, A, B;
  cin >> X >> A >> B;

  X -= A;
  X %= B;

  cout << X << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
const int INF = 1001001001;
vector<int> to[100005];

int main(void){
    int n,m;
    cin >> n >> m;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n,INF);
    vector<int> pre(n,-1);
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v=q.front();q.pop();
        for(int u : to[v]){
            if(dist[u] != INF) continue;
            dist[u]=dist[v]+1;
            pre[u]=v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    REP(i,n){
        if(i==0)continue;
        int ans=pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10532
def main():
    n = int(input())
    array = [int(i) for i in input().split(' ')]
    my_print(array)
    for i in range(1, n):
        target = array[i]

        j = i - 1
        while target < array[j] and j >= 0:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = target
        my_print(array)


def my_print(array):
    print(' '.join(map(str, array)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5604
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	private int totalEdge;
	private LinkedList<LinkedList<Integer>> adjList;
	private int[] degree;

	public Graph() {
		totalVertex = 0;
		totalEdge = 0;
	}

	public void loadAdjList() {
		Scanner sc = new Scanner(System.in);
		totalVertex = sc.nextInt();
		totalEdge = sc.nextInt();
		degree = new int[totalVertex];
		adjList = new LinkedList<LinkedList<Integer>>();
		
		for(int i = 0; i < totalVertex ; i++) {
			LinkedList<Integer> vert = new LinkedList<Integer>();
			adjList.add(vert);
			degree[i] = 0;
		}
		
		int row;
		int col;
		for (int i = 0; i < totalEdge; i++) {
			row = sc.nextInt();
			col = sc.nextInt();
			adjList.get(row).add(col);
			degree[col] += 1;
		}
		sc.close();
	}
	
	public void eligible() {
		Queue<Integer> eligibleQ = new LinkedList<Integer>();
		for(int i = 0; i < totalVertex; i++) {
			if(degree[i] == 0) {
				eligibleQ.add(i);
			}
		}
		while(!eligibleQ.isEmpty()) {
			int num = eligibleQ.poll();
			System.out.println(num);
			for(Integer n : adjList.get(num)) {
				degree[n] -= 1;
				if(degree[n] == 0) {
					eligibleQ.add(n);
				}
			}
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.eligible();
	}
}


Measured memory_bytes: 73668
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n, a[100], dp[100][100];

int main()
{
	int cs;
	cin >> cs;
	while(cs--){
		cin >> n;
		rep(i, n) cin >> a[i];
		memset(dp, 0, sizeof(dp));
		rep(i, n) dp[i][(i+1) % n] = abs(a[i] - a[(i+1) % n]);
		for(int s = 2; s < n; s++){
			rep(i, n){
				int j = (i+s) % n;
				dp[i][j] = dp[i][(j+n-1) % n] + abs(a[i] - a[j]);
				for(int k = i+1; k < i+s; k++)
					dp[i][j] = max(dp[i][j], dp[i][k%n] + dp[k%n][j]);
			}
		}
		int ans = 0;
		rep(i, n) ans = max(ans, dp[i][(i+n-1) % n]);
		cout << ans << endl;
	}
	
	return 0;
}

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

int main(){
	int K, S;
	cin >> K >> S;
	int num = 0;
	for(int i = 0; i <= K; i++)
	{
		for(int j = 0; j <= K; j++)
		{
			if(S - i - j <= K && S - i - j >= 0){
				num += 1;
			}
		}
		
	}
	cout << num << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
   string s;
   cin>>s;
   std::vector<ll> pref(s.size(), 0); 
   //reverse(call(s));
   map<ll,ll> mp;
   ll n=s.size();
   pref[0]=s[n-1]-'0';
   mp[0]++;
   mp[pref[0]]++;
   ll ans=0;
   ll fc=10;
   for(ll i=1;i<s.size();i++)
   {
      pref[i] = (pref[i-1] + (s[n-1-i]-'0')*(fc%2019))%2019;
      //cout<<pref[i]<<" "<<fc<<endl;
      fc = (fc*10)%2019;
    if(mp.count(pref[i])) ans+=mp[pref[i]];
      mp[pref[i]]++;
   }
   //cout<<"\n";
   cout<<ans;

}

int main(){
    solve();
}

Measured memory_bytes: 5244
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main(){
	cin>>N;
	ll dp[1001]={};
	for(int i=2;i<N+1;i++){
		int k=i;
		for(int j=2;j<=k;j++){
			while(k%j==0){
				dp[j]++;
				k=k/j;
			}
		}
	}

	ll ans=1;
	for(int i=2;i<N+1;i++){
		ans=ans*(dp[i]+1);
		ans=ans%1000000007;
	}


	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

int main() {
  ll x,y;
  cin >> x >> y;
  cout << (x%y?x*(1+lcm(x,y)/x):-1)<< endl;
}

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

int main() {
    ll n, m;
    cin >> n >> m;

    ll ans = 1;
    if (abs(n - m) <= 1) {
        rep(i, n) ans = ans * (i + 1) % MOD;
        rep(i, m) ans = ans * (i + 1) % MOD;

        if (n == m)
            ans = ans * 2 % MOD;
    } else
        ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

constexpr int INFI = 1145141919;

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

    long long A, B, C;
    std::cin >> A >> B >> C;

    //各々が貰うのは別の人の半分
    if((A==B && B==C)&&(A%2==0 && B%2==0 && C%2==0)){
        std::cout << -1;
    }else{
        long long count=0;
        while(A%2==0 && B%2==0 && C%2==0){
            count++;
            long long a, b, c;
            a = B/2 + C/2;
            b = A/2 + C/2;
            c = A/2 + B/2;
            A = a; B = b; C = c;
        }
        std::cout << count;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
        using ll = long long;
        using namespace std;
        int main(){
        	ll x;
        	scanf("%lld", &x);
        	ll ans = x/11*2;
        	x %= 11;
        	ans += (x+5)/6;
        	printf("%lld\n", ans);
        	return 0;
        }


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

int main(){

    int N,K,ans=0; cin >> N >> K;
    int data[N];
    map<int,int> mp{};
    for(int i=0;i<N;i++) cin >> data[i];
    
    for(int i=0;i<N;i++){
        if(mp[data[i]] == 0) mp[data[i]] = 1;
        else mp[data[i]]++;
    }
    
    vector<int> vec{};
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        vec.push_back(itr->second);
    }
    sort(vec.begin(),vec.end());
    int size = mp.size();
    int i=0;
    while(1){
        if(size <= K) break;
        ans +=vec[i];
        size--;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14420
import collections

n = int(input())
v = [int(_) for _ in input().split()]

vo = [v[i] for i in range(n) if i % 2 == 0]
ve = [v[i] for i in range(n) if i % 2 == 1]

count_vo = collections.Counter(vo).most_common()
count_ve = collections.Counter(ve).most_common()

res = 200001

if count_vo[0][0] != count_ve[0][0]:
    print(n-count_vo[0][1]-count_ve[0][1])
elif len(count_vo) == 1 and len(count_ve) == 1:
    print(n//2)
elif len(count_vo) == 1:
    print(n//2-count_ve[1][1])
elif len(count_ve) == 1:
    print(n//2-count_vo[1][1])
else:
    if count_vo[1][1] >= count_ve[1][1]:
        print(n-count_vo[1][1]-count_ve[0][1])
    else:
        print(n - count_vo[0][1] - count_ve[1][1])

Measured memory_bytes: 21084
# coding: utf-8
def divisor(N):
    # 約数列挙
    divs = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divs.append(i)
            divs.append(N//i)
    return divs
def F(a, b):
    return max(len(str(a)), len(str(b)))
N = int(input())
divs = divisor(N)
ans = 10**9
for i in range(len(divs)//2):
    a, b = divs[2*i], divs[2*i+1]
    ans = min(ans, F(a,b))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    int p = -1;
    int s = 0;
    for(int i=1;i<=1000;i++){
        s +=i;
        if(s==n){
            p = i;
            break;
        }
    }
    if(p==-1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        cout << p+1 << endl;
        cout << p << " ";
        for(int j=1;j<=p;j++){
            cout << j;
            if(j!=p){
                cout << " ";
            }
        }
        cout << endl;
        for(int i=1;i<=p;i++){
            cout << p << " ";
            int zz = 0;
            for(int j=0;j<p;j++){
                if(j==0){
                    cout << i;
                    zz = i;
                }else{
                    if(j<=i){
                        if(j==i){
                            zz += p-j+1;
                        }else{
                            zz += p-j;
                        } 
                        cout << zz;
                    }else{
                        zz++;
                        cout << zz;
                    }
                }
                if(j!=p-1)cout << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

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

typedef struct
{
  int id, score;
} Student;

class GreaterScore
{
public:
  bool operator() (const Student& lhs, const Student& rhs) const
  {
    if (lhs.score == rhs.score)
      return lhs.id < rhs.id;
    return lhs.score > rhs.score;
  }
};

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<Student> s(n);
    for (int i = 0; i < n; ++i) {
      cin >> s[i].id;

      vector<int> p;
      for (int j = 0; j < 10; ++j) {
	int p1;
	cin >> p1;
	p.push_back(p1);
	if (p1 == 10 && j != 9)
	  continue;

	int p2;
	cin >> p2;
	p.push_back(p2);

	if (p1+p2 >= 10 && j == 9) {
	  int p3;
	  cin >> p3;
	  p.push_back(p3);
	}
      }

      int idx = 0;
      bool first = true;
      vector<int> frame(10, 0);
      for (unsigned int j = 0; j < p.size(); ++j) {
	if (idx == 9) {
	  frame[idx] += p[j];
	  continue;
	} else if (first) {
	  frame[idx] += p[j];
	  if (frame[idx] == 10)
	    frame[idx++] += p[j+1] + p[j+2];
	  else
	    first = false;
	} else {
	  frame[idx] += p[j];
	  if (frame[idx] == 10)
	    frame[idx] += p[j+1];
	  ++idx;
	  first = true;
	}
      }
      s[i].score = accumulate(frame.begin(), frame.end(), 0);
    }

    sort(s.begin(), s.end(), GreaterScore());
    for (int i = 0; i < n; ++i)
      cout << s[i].id << " " << s[i].score << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,m = map(int,input().split())
a = [int(input()) for nesya in range(m)]
hoge = [1]*(n+1)
for i in range(m):
  hoge[a[i]] = 0
for j in range(1,n+1):
  if hoge[j] == 0:
    continue
  else:
    if j == 1:
      hoge[j] = hoge[j-1]
    else:
      hoge[j] = hoge[j-1] + hoge[j-2]
  hoge[j] = hoge[j] % (10**9+7)
print(hoge[j]%(10**9+7))

Measured memory_bytes: 7848
//Contains functions for implementing a disjoint set union
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define inf 1000000000000000000ll
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pi pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) (a>b)?a:b
//#define min(a,b) (a>b)?b:a
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
//#define push push_back
//#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define fir first
#define sec second
#define mod(a) ((a)>0)?(a):(-(a))
 
 
typedef long long ll;
 
ll next(ll a, ll n)
{
    return (a==n-1)?0:a+1;
}
ll parent[1000005],size[1000005],  tail[300005];
set<ll> cur_par;
ll n,m,q;
ll pos(ll x,ll y)
{
    return (m*(x-1))+y;
}
void init_parent(ll n)
{
    memset(parent,-1,sizeof(parent[0])*n);
}
void make_set(ll v)
{
    parent[v]=v;
    ::size[v]=1;
    tail[v]=v;
}
ll find_set(ll v)
{
    if(parent[v]==v)
    return v;
    return parent[v]=find_set(parent[v]);
}
void union_sets(ll a,ll b, ll A[])
{
    a=find_set(a);
    b=find_set(b);
    if(a==b)
    return;
    if(::size[a]<::size[b])
    {
        swap(a,b);
    }
    parent[b]=a;
    ::size[a]+=::size[b];
    A[a] = min(A[a], A[b]);
}
ll prev(ll a,ll n)
{
    if(a==0)
    return n-1;
    return a-1;
}
ll nex(ll a,ll n)
{
    if(a==n-1)
    return 0;
    else
    return a+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vll r,g;
    set<ll> b;
    REP(i,0,s.size())
    {
        switch(s[i])
        {
            case 'R':
                r.push_back(i+1);
                break;
            case 'G':
                g.push_back(i+1);
                break;
            case 'B':
                b.insert(i+1);
                break;
        }
    }
    ll tot=0;
    for(auto A: r)
    {
        for(auto B: g)
        {
            tot+=b.size();
            if( (A+B)%2==0 && b.count((A+B)/2)==1)
            {
                tot--;
            }
            if(b.count(2*B - A)==1)
            {
                tot--;
            }
            if(b.count(2*A-B)==1)
            {
                tot--;
            }
        }
    }
    cout<<tot<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int k;
    cin>>k>>s;

    if(s.size()>k){
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }
    else{
        cout<<s;
    }
}

Measured memory_bytes: 3596
/*
    Author      : Dinesh Verra
    College     : ABV-IIITM
    Date        : 14/08/2020
*/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
// #define ll int
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf 1000000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

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


	string s;
	cin>>s;
	ll ans=0;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R') ans=3;
	else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R')) ans=2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R') ans=1;
	prn(ans);
}

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

typedef long long ll;
struct edge {int to, cost; };
 
int main(){
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<2; j++){
      if((c[i][j]-c[(i+1)%3][j])!=(c[i][j+1]-c[(i+1)%3][j+1])){
        cout << "No" << endl;
        return 0;
      }
      if((c[j][i]-c[j][(i+1)%3])!=(c[j+1][i]-c[j+1][(i+1)%3])){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  int n = stoi(s);
  int digsum = 0;
  for(int i=0;i<s.size();i++){
    digsum += (s[i]-'0');
  }
  if(n%digsum==0) cout<< "Yes" <<endl;
  else cout<< "No"  <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
int L = 1000000007;
using namespace std;
ll t[200050] = {};
int main()
{
	ll n, T;
	cin >> n >> T;
	
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
	}

	ll ans = T;

	for (int i = 1; i < n; i++)
	{
		ans += min(T, t[i] - t[i - 1]);
	}

	cout << ans << endl;
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


Measured memory_bytes: 1792
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append((b, c))
    G[b].append((a, c))

Q, k = tuple(map(int, input().split()))
INF = 10**9*n + 1
dists = [INF] * n
dists[k-1] = 0

from collections import deque
q = deque([k-1])

while q:
    node = q.popleft()
    for to, c in G[node]:
        if dists[to] > dists[node] + c:
            dists[to] = dists[node] + c
            q.append(to)

for _ in range(Q):
    s, g = tuple(map(int, input().split()))
    print(dists[s-1] + dists[g-1])

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

int I, O, S, L, R;

int main() {
	scanf("%d%d%d%d%d%d%d", &I, &O, &S, &L, &R, &S, &S);
	long long ans = 0;
	ans += I/2*4;
	ans += O*2;
	ans += L/2*4;
	ans += R/2*4;
	int sum = (I%2)+(R%2)+(L%2);
	if (sum==3) ans += 6;
	else if (sum==2&&min(L, min(R, I)) != 0) ans+=2;
	printf("%lld\n", ans/2);
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll k, s;
    cin >> k >> s;

    ll ans = 0;
    rep(x, k+1) {
        rep(y, k+1) {
            ll z = s - (x + y);
            if(0 <= z && z <= k) {
                ans++;
            }
        }
    }

    out(ans);
    re0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> deta(H+2,vector<char>(W+2));
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
        if(j==W+1){
          deta.at(i).at(j) = '#';
          cout << deta.at(i).at(j) << endl;
        }
        else if(i==0 || i==H+1 || j==0){
          deta.at(i).at(j) = '#';
          cout << deta.at(i).at(j);
        }
        else{
          cin >> deta.at(i).at(j);
          cout << deta.at(i).at(j);
          }
        }
     }
   }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>

using std::cin;using std::cout;using std::cerr;using std::endl;

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)

long long n,x,y,ans,d;

int main(){

	std::ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n>>d;

	rep(i,1,n){
		cin>>x>>y;
		if(x * x + y * y <= d * d){
			ans++;
		}
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

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

  long sum_of_elems = 0;
  for (auto &n : arr)
    sum_of_elems += n;

  cout << *min_element(arr, arr + n) << " ";
  cout << *max_element(arr, arr + n) << " ";
  cout << sum_of_elems << endl;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; i++) {
        int D; cin >> D; A[D]++;
    }
    int M; cin >> M;
    for (int i = 0; i < M; i++) {
        int T; cin >> T;
        if (A[T]-- == 0) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


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

	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout << 0 << endl;
		return 0;
	}
  
  	if(b > c){
		  t = b;
		  b = c;
		  c = t;
	}
	if(a > b){	
		t = a;
		a = b;
		b = t;
	}
	if(b > c){
		  t = b;
		  b = c;
		  c = t;
	}

	cout << a * b * ((c + 1) / 2) - a * b * (c / 2) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



string a;
int data[30];

ll f(ll n) {
  return n * (n - 1) / 2;
}

int main () {
  cin >> a;
  int n = a.size();

  Rep(i, n) {
    int tmp = a[i] - 'a';
    data[tmp]++;
  }

  ll ans = f(n);

  Rep(i, 26) {
    ans -= f(data[i]);
  }

  ans++;
  cout << ans << "\n";

}

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

int main() {
  int N;
  cin >> N;
  for (int i = N; i < 2*N; i++) {
    int s = sqrt(i);
    bool b = true;
    for (int j = 2; j <= s; j++) {
      if (i % j == 0) {
        b = false;
        break;
      }
    }
    if (b) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);
    var sortTable = [a, b, c].sort(function(a, b) {
        return a - b;
    });
    console.log(sortTable.join(' '));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

left_side = 0
right_side = 0
ans = 1e12
# 両サイドの累積和が必要
left_wa = [0, A[0]]
right_wa = [A[-1]]

for i in range(1, N):
    left_wa.append(left_wa[-1] + A[i])
for i in range(2, N+1):
    right_wa.append(right_wa[-1] + A[-i])
# right_wa.append(0)
# print(left_wa)
# print(right_wa)
#
# exit()
for i in range(1, N):
    left_side = left_wa[i]
    right_side = right_wa[-(i+1)]
    # print(left_side, right_side)
    ans = min(ans, abs(left_side-right_side))
print(ans)


Measured memory_bytes: 30956
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1e5 + 5;
ll n;

int solve(){
	cin>>n;
	int k = n%10;
	if(k == 3) {
		cout<<"bon";
		return 0;
	}		
	else if(k == 0 || k== 1 || k == 6 || k == 8){
		cout<<"pon";
		return 0;
	}
	else {
		cout<<"hon";
		return 0;
	}
}
 
int main(){
	fast;
	ll testcase;
	testcase = 1;
	// cin>>testcase;
	while(testcase--) {
		solve();
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
int main(){
    LL w,h,x,y;cin >> w >> h >> x >> y;
    if(w==2*x&&h==2*y){
        cout << (double)w*h/2 << " " << 1 << endl;
    }
    else{
        cout << (double)w*h/2 << " " << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    S = input()

    insert_L = 0
    cnt_L = 0

    for s in S:
        if s == '(':
            cnt_L += 1
        else:
            if cnt_L:
                cnt_L -= 1
            else:
                insert_L += 1

    insert_R = cnt_L

    res = '(' * insert_L + S + ')' * insert_R
    print(res)


if __name__ == '__main__':
    resolve()


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

int n, a[16][16];
int64_t score[1 << 16];
int64_t go(int mask) {
    if (score[mask] != -1)
        return score[mask];
    int bit_count = __builtin_popcount(mask);
    if (bit_count <= 1)
        return 0;
    // all as one group
    score[mask] = 0;
    int64_t all_score = 0;
    for (int i = 0; i < n; i++) {
        if (!(mask & (1 << i))) continue;
        for (int j = i + 1; j < n; j++) {
            if (!(mask & (1 << j))) continue;
            else all_score += a[i][j];
        }
    }
    score[mask] = max(score[mask], all_score);
    // split into some groups
    vector<int> ind;
    for (int j = 0; j < n; j++)
        if (mask & (1 << j)) 
            ind.push_back(j);
    for (int submask = 0; submask < (1 << bit_count); submask++) {
        if (__builtin_popcount(submask) > bit_count / 2) continue;
        int real_mask = 0;
        for (int j = 0; j < bit_count; j++)
            if (submask & (1 << j)) 
                real_mask |= (1 << ind[j]);
        int conj_mask = mask ^ real_mask;
        score[mask] = max(score[mask], go(real_mask) + go(conj_mask));
    }
    return score[mask];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n;
    memset(score, -1, sizeof(score));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    cout << go((1 << n) - 1) << '\n';
    return 0;
}

Measured memory_bytes: 4152
N = int(input())
An = list(map(int,input().split()))
num = 0
for A in An:
  if A < 0: num+=1
An = list(map(lambda x: abs(x), An))
if num%2==0:
  print(sum(An))
else:
  print(sum(An) - 2*min(An))

Measured memory_bytes: 14252
/*input
3000
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=8e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
ll mult(ll a,ll b){
    a%=MOD;
    b%=MOD;
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <unistd.h>
#include <sstream>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    string s;cin>>s;
    int n=s.length();
    if(s[n-1]!='s')
        s+='s';
    else
        s+="es";
    cout<<s;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;

main(){
    int n, m;
    cin >> n >> m;
    int cur = m / n + 1;
    while (cur--){
        if (cur == 1){
            cout << 1;
            return 0;
        }
        if ((m - cur * n) % cur == 0){
            cout << cur;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

const long long MOD = 1000000007;
#define NFRAC 200000

LL fac[NFRAC+1];
LL ifac[NFRAC+1];

LL mpow(LL x, LL n){
    LL ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

LL comb(LL a, LL b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    LL tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

LL perm(LL a, LL b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    return ifac[a-b] * fac[a] % MOD;
}

void init(){
    fac[0] = 1;
    ifac[0] = 1;
    for(LL i = 0; i<NFRAC+1; i++){
        fac[i+1] = fac[i]*(i+1) % MOD;
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
    }
}


void solve(long long n, std::vector<long long> arr){
    init();
    map<LL, LL> pos;
    LL cnt=0,a=0,b=0;
    rep(i, n+1){
        if(pos.find(arr[i]) != pos.end()){
            a=pos[arr[i]];
            cnt=0;
        }else{
            pos[arr[i]] = i;
            cnt++;
        }
    }
    b=cnt;

    for(LL k=1; k<=n+1; k++){

        cout<< (comb(n+1,k)-comb(a+b, k-1)+MOD)%MOD << endl;
    }
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n+1);
    for(int i = 0 ; i < n+1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


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

using namespace std;

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

  long long a[5] = {0, 0, 0, 0, 0};
  while (N--) {
    string s;
    cin >> s;
    switch (s.at(0)) {
      case 'M': a[0]++; break;
      case 'A': a[1]++; break;
      case 'R': a[2]++; break;
      case 'C': a[3]++; break;
      case 'H': a[4]++; break;
    }
  }

  long long res = 0;
  for (int i = 0; i < 5; i++)
    for (int j = i + 1; j < 5; j++)
      for (int k = j + 1; k < 5; k++)
        res += a[i] * a[j] * a[k];

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


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

public class MainClass
{

	public static void Main(string[] args)
	{
		string[] s = Console.ReadLine().Split(' ');
		int a = int.Parse(s[0]);
		int b = int.Parse(s[1]);
		int c = int.Parse(s[2]);
		
		Console.WriteLine(Math.Min(a+b,Math.Min(a+c,b+c)));
	}

	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================


template <class T, class Op>
class SegmentTree {
private:
    const Op op;
    const T ID;
    std::vector<T> vec;
    size_t sz;

public:
    explicit SegmentTree(size_t _n, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        sz = 1;
        while (sz < _n) sz <<= 1;
        vec.resize(sz * 2, ID);
    }
    explicit SegmentTree(const std::vector<T>& _vec, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        size_t n = _vec.size();
        sz = 1;
        while (sz < n) sz <<= 1;
        vec.resize(sz * 2, ID);
        set_array(_vec);
    }
    void set_value(size_t _idx, T _val) noexcept {
        vec[_idx + sz] = _val;
    }
    template <class RandomIt>
    void set_array(RandomIt _begin, RandomIt _end) noexcept {
        std::copy(_begin, _end, vec.begin() + sz);
    }
    void set_array(const std::vector<T>& _newvec) noexcept {
        set_array(_newvec.begin(), _newvec.end());
    }
    void build() noexcept {
        for (size_t i = sz - 1; i > 0; i--) {
            vec[i] = op(vec[i * 2], vec[i * 2 + 1]);
        }
    }
    void update(size_t _idx, T _val) noexcept {
        _idx += sz;
        vec[_idx] = _val;
        for (_idx >>= 1; _idx > 0; _idx >>= 1) {
            vec[_idx] = op(vec[_idx * 2], vec[_idx * 2 + 1]);
        }
    }
    // 区間[_i, _r)に対するクエリを実行する
    T query(size_t _l, size_t _r) const noexcept {
        T l_val = ID, r_val = ID;
        _l += sz, _r += sz - 1;
        for (; _l <= _r; _l >>= 1, _r >>= 1) {
            if (_l & 1) l_val = op(l_val, vec[_l++]);
            if (!(_r & 1)) r_val = op(r_val, vec[_r--]);
        }
        return op(l_val, r_val);
    }
    const T& operator[](size_t _idx) const noexcept {
        return vec[_idx + sz];
    }
};

using Bs = bitset<26>;

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    auto op = [](const Bs& a, const Bs& b) {
        return a | b;
    };
    SegmentTree<Bs, decltype(op)> seg(N, op, Bs());
    for (int i = 0; i < N; i++) {
        seg.set_value(i, Bs().set(S[i] - 'a'));
    }
    seg.build();
    int Q;
    cin >> Q;
    while (Q--) {
        int query;
        cin >> query;
        if (query == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            seg.update(idx - 1, Bs().set(c - 'a'));
        }
        else {
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << seg.query(l, r + 1).count() << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 9116
#include <iostream>

int main(int argc, char *argv[])
{
  int n, l;
  int res;

  std::cin >> n >> l;
  if (l >= 0) {
    res = l * (n-1) + (n-1)*n/2;
  } else {
    if (abs(l) < n) {
      res = (2*l+n-1) * n/2;
    } else {
      res = (2*l+n-1) * n/2 - (l+n-1);
    }
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256