akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m,x,y,z;
  cin >> n >> m >> x >> y >> z;
  ll a[x+1],b[y+1],c[z];
  rep(i,x) R a[i];
  rep(i,y) R b[i];
  rep(i,z) R c[i];
  sort(a,a+x);
  sort(b,b+y);
  sort(c,c+z,greater<ll>());
  a[x]=b[y]=MAX;
  ll l=x,r=y,sum=0;
  rep(i,n) {
    l--;
    sum+=a[l];
  }
  rep(i,m) {
    r--;
    sum+=b[r];
  }
  ll ans=sum;
  rep(i,min(z,n+m)) {
    sum+=c[i];
    if(a[l]<b[r]) {
      sum-=a[l];
      l++;
    } else {
      sum-=b[r];
      r++;
    }
    ans=max(ans,sum);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int par[100010],unionfind_rank[100010];

void init(int n){
  FOR(i,n){
    par[i]=i;
    unionfind_rank[i]=0;
  }
}

int root(int x){
  return par[x] == x ? x : par[x] = root(par[x]);
}

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

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

int main(){
  ll n,m;
  cin >> n >> m;
  ll x[100010],y[100010],z[100010];
  FOR(i,m){
    cin >> x[i] >> y[i] >> z[i];
    }
    init(n+1);
    FOR(i,m){
      unite(x[i],y[i]);
    }

    set<int> ans;

    for(int i=1;i<n+1;i++){
      ans.insert(root(i));
    }

    cout << ans.size() << endl;


}


Measured memory_bytes: 8064
n, k, q = map(int, input().strip().split())
ans = []
for i in range(q):
    ans.append(int(input()))

# ポイントが減らなかった回数
saved = [0] * n
for a in ans:
    saved[a - 1] += 1

for s in saved:
    if k - q + s > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8632
#include<stdio.h>

int main(){
  
  int i, j, n, x, y, z[100], cnt;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      cnt = 0;
      scanf("%d%d",&x,&y);
      for(j = 0; j < y; j++)scanf("%d",&z[j]);
      for(j = 0; j < n; j++)
	{
	  if(z[cnt] == j + 1)
	    {
	      printf("1");
	      z[cnt] = -1;
	      cnt++;
	    }
	  else printf("0");

	  if(j != n - 1)printf(" ");
	  else printf("\n");
	}
    }
  return 0;
}



Measured memory_bytes: 2132
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int a[1 << 17],n,ans;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for(int i = 1;i <= n;i++) if(i == a[a[i]]) ans++;
    rc(ans / 2);
}


Measured memory_bytes: 640
#include <stdio.h>

int abs(int x) {
    if(x < 0) {
        return -x;
    }

    return x;
}

void mostrar_resultado(int A, int B) {
    int dif = abs(A - B);

    if(dif <= 1) {
        printf("Yay!");
    }

    else {
        printf(":(");
    }

    printf("\n");
}

int main() {
    int A, B;

    scanf("%d %d", &A, &B);

    mostrar_resultado(A, B);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n, 0);
    rep(i, n - 1) cin >> a[i];
    rep(i, n - 1){
        b[a[i] - 1] += 1;
    }
    rep(i, n) cout << b[i] << endl;
}



Measured memory_bytes: 4364
package main

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

const Mod = 2019

func main() {
	S := ReadString()
	T := make([]int, len(S)+1)
	base := 1
	for i := len(S) - 1; i >= 0; i-- {
		T[i] = T[i+1] + base*int(S[i]-'0')
		T[i] %= Mod
		base = base * 10 % Mod
	}
	m := make(map[int]int)
	for _, v := range T {
		m[v]++
	}
	ans := 0
	for _, c := range m {
		ans += Combination(c, 2)
	}
	fmt.Println(ans)
}

func Combination(n int, k int) int { return Permutation(n, k) / Factorial(k) }
func Factorial(n int) int          { return Permutation(n, n-1) }
func Permutation(n int, r int) int {
	v := 1
	for i := 0; i < r; i++ {
		v *= n - i
	}
	return v
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF =1e12+7;
#define ii pair<ll,ll>;
#define f(i,a,b) for(ll i = a;i < b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
void printDivisors(ll n)
{
    ll ans=INF;
    for (ll i=1; i<=sqrt(n); i++){
        if (n%i == 0){
            ll k=n/i;
            ans = min(ans,(k+i)-2);
        }
    }
    cout<<ans;
}
int main(){
    ll n;
    c(n);
    printDivisors(n);
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    int n,k;
    cin>>n>>k;
    map<int,int> m;
    rep(i,n){
        int a;
        cin>>a;
        m[a]++;
    }
    vi v;
    irep(i,m){
        v.pb(i->second);
    }
    Sort(v);
    ll ans=0;
    for(int i=0;i<max(0,(int)v.size()-k);i++){
        ans+=v[i];
    }
    fin(ans);
}

Measured memory_bytes: 10748
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    using namespace std;
    #define INF 10000000;

    int main(){
      int n;
      long sum = 0;
      
      cin >> n;
      vector<long>a(n*3);
      for(int i=0;i<n*3;i++){
        cin >> a[i];
      }

      sort(a.begin(),a.end(),greater<long>());
      for(int i=0;i<n*2;i++){
        if(i%2 != 0)sum += a[i];
      }
      cout << sum <<endl;
    }

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string n = Console.ReadLine();
      bool flag = true;
      for (int i=0;i<n.Length;i++)
      {
        if (n[i]!=n[n.Length-1-i])
        {
          flag=false;
        }
      }
      if (flag)
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }
    }
}


Measured memory_bytes: 25884
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=5e2+4;

int me(int a,int b)
{
	int res=1;

	while(b)
	{
		if(b&1)
		res=(1LL*res*a)%mod;

		b>>=1; 

		a=(1LL*a*a)%mod;
	}

	return res;
}

int main()
{
	int n,k;

	scn(n); scn(k);

	int dp[k+1];

	for(int i=k;i>=1;i--)
	{
		int choices=k/i;

		dp[i]=me(choices,n);

		for(int j=2*i;j<=k;j+=i)
		dp[i]=(dp[i]-dp[j]+mod)%mod;

		//cout<<i<<" "<<dp[i]<<endl;
	}

	int ans=0;

	rep(i,1,k+1)
	ans=(ans+(1LL*i*dp[i])%mod)%mod;

	pri(ans);


    return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >> S;
  string answer = "Yes";
  for (int i = 0; i < (int)S.size(); ++i) {
    // 奇数文字の判定
    if (i % 2 == 0) {
      if (S[i] == 'L') answer = "No";
    }
    // 偶数文字の判定
    else {
      if (S[i] == 'R') answer = "No";
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
        
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++)
        {
        	String[] sinput = br.readLine().split(" ");
        	String[] color = br.readLine().split(" ");
        	int[][] card = new int[3][9];
        	
        	for (int j = 0; j < 9; j++)
        	{
        		int suji = Integer.parseInt(sinput[j]) - 1;
        		
        		if (color[j].equals("R"))
        			card[0][suji] += 1;
        		else if (color[j].equals("G"))
        			card[1][suji] += 1;
        		else if (color[j].equals("B"))
        			card[2][suji] += 1;
        	}
        	
        	
        	
        	int set = 0;
        	for (int j = 0; j < 3; j++)
        	{
        		for (int k = 0; k < 9; k++)
        		{
        			if (k < 7)
        			{
        				if (card[j][k] > 0 && card[j][k + 1] > 0 && card[j][k + 2] > 0)
                		{
                			set++;
                			card[j][k]--;
                			card[j][k + 1]--;
                			card[j][k + 2]--;
                			k--;
                			//System.out.println("a");
                			continue;
                		}
        			}
        			//System.out.println(card[j][k]);
        			if (card[j][k] >= 3)
        			{
        				set++;
            			card[j][k] -= 3;
            			k--;
            			//System.out.println("b");
        			}
        		}
        		
        	}if (set >= 3)
        		System.out.println(1);
        	else
        		System.out.println(0);
        }
	}
}

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

int main() {
  double a,b,A,B;
  cin >> a >> b >> A >> B;
  cout << a*b/2 << endl;
  if(A==a/2 && B==b/2){
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<ll> frac(100011);

ll modinv(ll a) {
  ll M = MOD, b = M, u = 1, v = 0;
  while (b)
    u -= a / b * v, swap(u, v), a %= b, swap(a, b);
  return (u % M + M) % M;
}

ll nCk(ll n, ll k) {
  if (n - k < 0) return 0;
  ll ret = frac[n];
  ret *= modinv(frac[k]);
  ret %= MOD;
  ret *= modinv(frac[n-k]);
  ret %= MOD;
  return ret;
}

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep (i, N) cin >> A[i];
  sort(A.begin(), A.end());

  frac[0] = 1;
  for (ll i = 1; i <= 100010; i++) {
    ll tmp = frac[i-1];
    tmp *= i;
    tmp %= MOD;
    frac[i] = tmp;
  }

  ll ans = 0;

  rep (i, N) {
    ans += nCk(i, K-1) * A[i];
    ans %= MOD;
  }

  rep (i, N) {
    ans += MOD;
    ans -= nCk(N-i-1, K-1) * A[i];
    ans %= MOD;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1010;
int n,m;
int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	n%=500;
	if(n<=m)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
} 

Measured memory_bytes: 128
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class SegmentTree:
        def __init__(self, A, initialize=True, segfunc=max, ident=-2000000000):
            self.N = len(A)
            self.LV = (self.N - 1).bit_length()
            self.N0 = 1 << self.LV
            self.segfunc = segfunc
            self.ident = ident
            if initialize:
                self.data = [self.ident] * self.N0 + A + [self.ident] * (self.N0 - self.N)
                for i in range(self.N0 - 1, 0, -1):
                    self.data[i] = segfunc(self.data[i * 2], self.data[i * 2 + 1])
            else:
                self.data = [self.ident] * (self.N0 * 2)

        def update(self, i, x):
            i += self.N0 - 1
            self.data[i] = x
            for _ in range(self.LV):
                i >>= 1
                self.data[i] = self.segfunc(self.data[i * 2], self.data[i * 2 + 1])

        # open interval [l, r)
        def query(self, l, r):
            l += self.N0 - 1
            r += self.N0 - 1
            ret_l = self.ident
            ret_r = self.ident
            while l < r:
                if l & 1:
                    ret_l = self.segfunc(ret_l, self.data[l])
                    l += 1
                if r & 1:
                    ret_r = self.segfunc(self.data[r - 1], ret_r)
                    r -= 1
                l >>= 1
                r >>= 1
            return self.segfunc(ret_l, ret_r)

        # return smallest i(l <= i < r) s.t. check(A[i]) == True
        def binsearch(self, l, r, check):
            if not check(self.query(l, r)):
                return r
            l += self.N0 - 1
            val = self.ident
            while True:
                if check(self.segfunc(val, self.data[l])):
                    break
                if l & 1:
                    val = self.segfunc(val, self.data[l])
                    l += 1
                l >>= 1
            while l < self.N0:
                newval = self.segfunc(val, self.data[l * 2])
                if not check(newval):
                    val = newval
                    l = (l << 1) + 1
                else:
                    l <<= 1
            return l - self.N0 + 1

    N, K = map(int, input().split())
    ST = SegmentTree([0] * 300010)
    for _ in range(N):
        a = int(input())
        ST.update(a + 1, ST.query(max(1, a - K + 1), min(300010, a + K + 2)) + 1)
    print(ST.data[1])


if __name__ == '__main__':
    main()


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

using graph = vector<vector<int>>;

// require: input graph is bipartite
class bipartite_matching {
public:
    bipartite_matching(graph const& g)
        : g_(g), match_(g.size(), -1), used_(g.size(), false)
    {}

    int solve() {
        const int n = g_.size();
        int res = 0;
        bool update = true;
        while(update) {
            update = false;
            for(int v = 0; v < n; ++v) {
                if(match_[v] == -1 && dfs(v)) {
                    update = true;
                    ++res;
                }
            }
            if(update) fill(used_.begin(), used_.end(), false);
        }
        return res;
    }

    int match(int v) const { return match_[v]; }

private:
    bool dfs(int v) {
        if(used_[v]) return false;
        used_[v] = true;
        for(auto u : g_[v]) {
            if(match_[u] < 0 || dfs(match_[u])) {
                match_[u] = v;
                match_[v] = u;
                return true;
            }
        }
        return false;
    }

private:
    graph g_;
    vector<int> match_;
    vector<bool> used_;
};

int main() {
    int X, Y, E; cin >> X >> Y >> E;
    graph g(X + Y);
    for(int i = 0; i < E; ++i) {
        int x, y; cin >> x >> y;
        g[x].push_back(y + X);
        g[y + X].push_back(x);
    }
    bipartite_matching bm(g);
    cout << bm.solve() << endl;
}



Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	vector<int> y(N);
	vector<char> c(N);
	int res = 0;
	vector<vector<int> > A(K + 2 , vector<int>(2 * K + 2, 0));
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> c[i];
		int a = 0;
		a = ((x[i] / K) + (y[i] / K)) % 2;
		x[i] %= K;
		y[i] %= K;
		if ((c[i] == 'W' && a == 0) || (c[i] == 'B' && a == 1)) {
			A[1][1] += 1;
			A[1][y[i] + 1] -= 1;
			A[x[i] + 1][1] -= 1;
			A[x[i] + 1][y[i] + 1] += 2;
			A[1][y[i] + K + 1] += 1;
			A[x[i] + 1][y[i] + K + 1] -= 2;
		}
		else {
			A[1][y[i] + 1] += 1;
			A[x[i] + 1][1] += 1;
			A[x[i] + 1][y[i] + 1] -= 2;
			A[1][y[i] + K + 1] -= 1;
			A[x[i] + 1][y[i] + K + 1] += 2;
		}
	}
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= 2 * K; j++) {
			A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
			res = max(res, A[i][j]);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t X, sum = 0;
    cin >> X;
    for (int64_t i = 1; true; i++){
        sum += i;
        if (sum >= X) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BAnOddProblem {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        int a[n];
        int count=0;
        for (int i=1;i<=n;i++){
            int a;
            cin>>a;
            if (i%2==1&&a%2==1)
                count++;
        }
        cout<<count;
	}
};


int main() {
	BAnOddProblem solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


int n;
double arr[3000];
double	dp[3000];
/*double f(int i,int h){
	if(i==n){
		if(h<(n-h)) return 0;
		return 1.0;
	}
	if(dp[i][h].first!=-1) return dp[i][h].second;
	double ans = 0.0;
	ans += (arr[i]*f(i+1,h+1)+(1.0-arr[i])*f(i+1,h));
	return dp[i][h].second=ans;
}*/

int main(int argc, char const *argv[])
{
	//int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	
	//memset(dp,-1.0,sizeof(dp));
	dp[0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j>=0; j--)
		{
			dp[j] = (j==0?0:arr[i]*dp[j-1])+dp[j]*(1-arr[i]);
		}
	}
	double ans =0.0;
	for (int i = 0; i <= n; ++i)
	{
		if(i>n-i){
			ans += dp[i];
		}
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
typedef long long ll;
using namespace std;
typedef vector<ll> vll; typedef set<ll> sll; typedef map<ll,ll> mll;
int bitct(long long r) {int c=0; for(; r; r&=r-1) c++; return c;}
long long gcd(long long x, long long y) {return x ? gcd(y%x,x) : y;}
long long choose(long long n, long long q) { if(n==0 || q==0) return 1;
  if (q==1) return n; else return ( choose(n, q-1) * (n-q+1 ) /q); }
template<typename T> ostream& operator << (ostream &o,vector<T> v) {o<<"[";
  int i=0,s=v.size();for(;i+1<s;i++)o<<v[i]<<", ";if(s)o<<v[i];o<<"]";return o;}
template<typename K, typename V> ostream& operator << (ostream &o,
  unordered_map<K, V> m) {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second <<
  ", "; o<<"}";return o;}
template<typename K, typename V> ostream& operator << (ostream &o, map<K, V> m)
  {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second << ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, unordered_set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename T> ostream& printv(vector<T> v) {int i=0,s=v.size();
  for(;i+1<s;i++)cout<<v[i]<<" ";if(s)cout<<v[i];return cout;}

int main() {
  ios_base::sync_with_stdio(false);
  string S;
  cin >> S;

  for(int i=0;i<S.size()-1;i++) {
    if(S[i]=='A' && S[i+1]=='C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

int main(){
    
    int n;
    double d;
    
    cin >> n >> d;
    
    int c = 0;
    for(int i = 0; i < n; i++){
        
        double x, y;
        cin >> x >> y;
        
        double distance = (double)sqrt((x*x) + (y*y));
        
        if((double)distance <= (double)d){
            c++;
        }
        
    }
    
    cout << c << endl;
    
    return 0;
    
}

Measured memory_bytes: 3832
import sys
import itertools
sys.setrecursionlimit(10**8)
#input = sys.stdin.readline
from math import factorial
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
  
def solve():
  x,y = (int(i) for i in input().split())
  mod = 10**9+7
  ct = 0
  for k in range(10**6+1):
    if x < k:
      break
    else:
      #y構成可能？
      remx = x-k
      remy = y-2*k
      if remy*2 == remx:
        times = k+remy
        res = 1
        for i in range(1,times+1):
          res = res*i%mod
        for i in range(1,remy+1):
          res = res*mod_inv(i,mod)%mod
        for i in range(1,k+1):
          res = res*mod_inv(i,mod)%mod
        ct += res
      ct %= mod
      
  print(ct)
  
solve()


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

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int[] d = na(n);
		Arrays.sort(d);
		int arc = d[n/2];
		int abc = d[n/2 - 1];
		if(arc == abc) {
			System.out.println(0);
		}else{
			System.out.println(arc - abc);
		}
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 34764
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    double x[100],y[100];
    int m = 1;
    for(int i=0; i<n; i++) scanf("%lf,%lf",&x[i],&y[i]);
    for(int i=0; i<n; i++){
      for(int j=i+1; j<n; j++){
	double dx,dy,dis,sq,s,t;
	int a;
	dx = x[i]-x[j];
	dy = y[i]-y[j];
	dis = dx*dx+dy*dy;
	if(dis<=4.0000001){
	  sq = sqrt(dis-dis*dis/4);
	  s = ((dis/2)*dx+dy*sq)/dis+x[j];t = ((dis/2)*dy-dx*sq)/dis+y[j];a = 0;
	  for(int k=0; k<n; k++) if((x[k]-s)*(x[k]-s)+(y[k]-t)*(y[k]-t)<=1.0000001) a++;
	  if(a>m) m = a;
	  s = ((dis/2)*dx-dy*sq)/dis+x[j];t = ((dis/2)*dy+dx*sq)/dis+y[j];a = 0;
	  for(int k=0; k<n; k++) if((x[k]-s)*(x[k]-s)+(y[k]-t)*(y[k]-t)<=1.0000001) a++;
	  if(a>m) m = a;
	}
      }
    }
    cout <<m<<endl;
  }
  return 0;
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[101][4][4];

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {


        string s;
        cin >> s;
        int n = s.size();
        vector<pair<int, char>> par(n + 1);
        vector<int> used(n + 1);
        set<int> pos[26];
        {
            int x = 0;
            for (auto c:s) {
                pos[c - 'a'].insert(x);
                ++x;
            }
        }
        queue<int> q;
        vector<int> dp(n + 1);
        q.emplace(-1);
        while (!q.empty()) {
            auto v = q.front();
            q.pop();
            for (char c = 'a'; c <= 'z'; ++c) {
                auto it = pos[c - 'a'].upper_bound(v);
                int nv = n;
                if (it != pos[c - 'a'].end()) {
                    nv = *it;
                }
                if (!used[nv]) {
                    par[nv] = {v, c};
                    used[nv] = 1;
                    q.emplace(nv);
                }
            }
        }
        string ans;
        int x = n;
        while (x != -1) {
            auto it = par[x];
            ans.push_back(it.second);
            x = it.first;
        }
        reverse(ans.begin(), ans.end());
        cout << ans;
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 14996
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    private static int h[] = new int[(int) (1e5 + 1)];
    private static int dp[] = new int[(int) (1e5 + 1)];
    private static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0;i < n;i++)
            h[i] = sc.nextInt();
        Arrays.fill(dp,0,n,-1);
        System.out.println(dp(0));
    }

    private static int dp(int idx) {
        if(idx == n - 1)
            return 0;
        if(dp[idx] != -1)
            return dp[idx];
        if(idx + 1 < n)
            dp[idx] = Math.abs(h[idx] - h[idx + 1]) + dp(idx + 1);
        if(idx + 2 < n){
            dp[idx] = Math.min(dp[idx],Math.abs(h[idx] - h[idx + 2]) + dp(idx + 2));
        }
        return dp[idx];
    }
}

Measured memory_bytes: 73436
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
// #include <bits/stdc++.h>
#define req(i,h) for(int i = 0; i < h; i++)

using namespace std;


int main(void) {
    int b = 0;
    vector<int> a(3);
    req(i,3) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    req(i,2) {
        b += (a.at(i+1) - a.at(i));
    }
    cout << b;
    return 0;
}


Measured memory_bytes: 256
import org.w3c.dom.ls.LSOutput;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

public class Main {
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int mod=1000000007;
    public static int n;
    public static class Matrix{
        long [][]a;
        public Matrix(){
            a=new long[n][n];
        }
    }
    public static Matrix mult(Matrix a,Matrix b){
        Matrix c=new Matrix();
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                for(int k=0;k<n;++k){
                    c.a[i][k]=(c.a[i][k]+a.a[i][j]*b.a[j][k])%mod;
                }
            }
        }
        return c;
    }

    public static Matrix poww(Matrix a,long b){
        Matrix r=new Matrix();
        for(int i=0;i<n;++i) r.a[i][i]=1;
        while(b>0){
            if(b%2==1){
                r=mult(r,a);
            }
            a=mult(a,a);
            b/=2;
        }
        return r;
    }

    public static FastReader r=new FastReader();
    public static void main(String[] args){
        n=r.nextInt();
        long k=r.nextLong();
        Matrix mat=new Matrix();
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                mat.a[i][j]=r.nextInt();
            }
        }
        mat=poww(mat,k);
        long ans=0;
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                ans=(ans+mat.a[i][j])%mod;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36228
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char ch=getchar();int x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return ff*x;
}
void write(int z)
{
	if(z<0){putchar('-');z=-z;}
	if(z>=10){write(z/10);}
	putchar(z%10+'0');
}
const int inf=100000;
int H,W,S,T,cnt,ans;
int idh[105],idl[105];
int dep[500005];
char s[1005];
int tot=1,head[500005],nx[540015],to[540015],w[540015];
void jia(int aa,int bb,int cc)
{
	tot++;
	nx[tot]=head[aa];
	to[tot]=bb;
	w[tot]=cc;
	head[aa]=tot;
	return;
}
int bfs()
{
	memset(dep,0,sizeof(dep));
	queue<int>q;
	q.push(S);
	dep[S]=1;
	while(!q.empty())
	{
		int kk=q.front();
		q.pop();
		for(int i=head[kk];i;i=nx[i])
		if(w[i]>0)
		{
			int yy=to[i];
			if(dep[yy]) continue;
			dep[yy]=dep[kk]+1;
			q.push(yy);
		}
	}
	return dep[T];
}
int dfs(int rt,int zhi)
{
	if(rt==T) return zhi;
	for(int i=head[rt];i;i=nx[i])
	if(w[i]>0)
	{
		int yy=to[i];
		if(dep[yy]!=dep[rt]+1) continue;
		int tt=dfs(yy,min(zhi,w[i]));
		if(tt)
		{
			w[i]-=tt;
			w[i^1]+=tt;
			return tt;
		}
	}
	return 0;
}
void wang()
{
	while(bfs())
	{
		int tmp;
		while((tmp=dfs(S,inf))) ans+=tmp;
	}
	return;
}
int main()
{
	H=read(),W=read();
	for(int i=1;i<=H;++i) idh[i]=++cnt;
	for(int i=1;i<=W;++i) idl[i]=++cnt;
	S=++cnt;T=++cnt;
	for(int i=1;i<=H;++i)
	{
		scanf("%s",s+1);
		for(int j=1;j<=W;++j) 
		{
			if(s[j]=='S') 
			{
				jia(S,idh[i],inf);jia(idh[i],S,0);
				jia(S,idl[j],inf);jia(idl[j],S,0);
			}
			else if(s[j]=='T')
			{
				jia(idh[i],T,inf);jia(T,idh[i],0);
				jia(idl[j],T,inf);jia(T,idl[j],0);
			}
			else if(s[j]=='o')
			{
				jia(idh[i],cnt+1,inf);jia(cnt+1,idh[i],0);
				jia(idl[j],cnt+1,inf);jia(cnt+1,idl[j],0);
				jia(cnt+1,cnt+2,1);jia(cnt+2,cnt+1,0);
				jia(cnt+2,idh[i],inf);jia(idh[i],cnt+2,0);
				jia(cnt+2,idl[j],inf);jia(idl[j],cnt+2,0);
				cnt+=2;
			}
		}
	}
	wang();
	if(ans<inf) write(ans);
	else write(-1);
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2)
    cout<<3;
  if(a==2 && b==1)
    cout<<3;
  if(a==3 && b==2)
    cout<<1;
  if(a==3 && b==1)
    cout<<2;
  if(a==1 && b==3)
    cout<<2;
  if(a==2 && b==3)
    cout<<1;
}

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

int main() {
    int a[3];
  	cin >> a[0] >> a[1] >> a[2];
  	sort(a, a+3);
  	int ans = a[2] * 10 + a[1] + a[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i<n; i++){
    cin >> p[i]; 
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans = ans + p[i];
    }
    cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int d, g;
    cin >> d >> g;
    int p[d], c[d];
    rep (i, 0, d) cin >> p[i] >> c[i];
    // 全完するものをbitで表す
    int ans = inf;
    rep (bit, 0, 1 << d) {
        int sum = 0, cnt = 0;
        rep (i, 0, d) {
            if (bit & 1 << i) {
                sum += (i + 1) * 100 * p[i] + c[i];
                cnt += p[i];
            }
        }
        if (sum >= g) {
            ans = min (ans, cnt);
        } else {
            per (i, 0, d) {
                if (1 << i & bit) continue;
                int res = (g - sum) / (100 * (i + 1));
                if (res * 100 * (i + 1) + sum < g) res++;
                if (res > p[i]) break;
                cnt += res;
                sum += res * 100 * (i + 1);
                break;
            }
            if (sum >= g) ans = min (ans, cnt);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll K;
    cin >> K;
    vector<ll> A(K);
    rep(i,K){
        cin >> A[i];
    }
    ll L = 1;
    ll R = 1e18;
    while(L+1 < R){
        ll X = (L+R)/2;
        ll cur = X;
        rep(i,K){
            cur = ll(cur / A[i])*A[i];
        }
        if(cur > 2){
            R = X;   
        }else{
            L = X;
        }
    }
    ll M = L;
    L = 1;
    R = 1e18;
    while(L+1 < R){
        ll X = (L+R)/2;
        ll cur = X;
        rep(i,K){
            cur = ll(cur / A[i])*A[i];
        }
        if(cur < 2){
            L = X;
        }else{
            R = X;
        }
    }
    ll m = R;
    if(m <= M){
        cout << m << " " << M << endl;
    }else{
        cout << -1 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)

int dp[105][4][2];

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  rep(i, n) rep(j, 4) rep(k, 2)
  {
    int nd = s[i] - '0';
    rep(d, 10)
    {
      int ni = i + 1, nj = j, nk = k;
      if (d != 0)
        nj++;
      if (nj > K)
        continue;
      if (k == 0)
      {
        if (d > nd)
          continue;
        if (d < nd)
          nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
    return 0;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)

int N, K, R, S, P;
string T;
lint ans;

void resolve()
{
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    map<char, int> point;
    point['r'] = P;
    point['s'] = R;
    point['p'] = S;

    ans = 0;
    vector<bool> win;
    RPT0(i, N)
    {
        if ((i < K) || (!win[i - K]) || (T[i] != T[i - K])) {
            ans += point[T[i]];
            win.push_back(true);
        } else {
            win.push_back(false);
        }
    }

    cout << ans << endl;
}

int main()
{
    resolve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll n;
int m;
pint p[100001];
int main(){
    cin>>n>>m;
    int ai,bi;
    rep(i,n){
        cin>>ai>>bi;
        p[i]={ai,bi};
    }
    sort(p,p+n);
    ll ans=0;
    int cur=0;
    rep(i,n){
        int tmp=min(p[i].second,m-cur);
        ans+=(ll)p[i].first*tmp;
        cur+=tmp;
        if(cur==m) break;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int a,b,ok,i;

int main()
{
    cin>>a;


    for(i=1;i<=9&&!ok;i++)
{
    if(a%i==0&&a/i<=9)
        ok=1;

}
if(ok)
    cout<<"Yes";
else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main(){

	string date;
	cin >> date;

	int year = ((int)date[0] - 48) * 1000 + ((int)date[1] - 48) * 100 + ((int)date[2] - 48) * 10 + ((int)date[3] - 48);
	int month = ((int)date[5] - 48) * 10 + ((int)date[6] - 48);

	if (year>=2020||(year == 2019 && month >= 5)) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
         
    int main() {
      int N;
      cin >> N;
      vector<vector<long long>> Ratio(N, vector<long long>(2));
      
      for(int i = 0; i < N; i++){
        for(int j = 0; j < 2; j++){
          cin >> Ratio.at(i).at(j);
        }
      }
      
      long long T = Ratio.at(0).at(0);
      long long A = Ratio.at(0).at(1);
   
      
      for(int k = 1; k < N; k++){
        for(long long i = max(max(T / Ratio.at(k).at(0), 1ll), A / Ratio.at(k).at(1) );
            i < max(max(T / Ratio.at(k).at(0), 1ll), A / Ratio.at(k).at(1)) + 2; i++){
            if(T <= Ratio.at(k).at(0) * i && A <= Ratio.at(k).at(1) * i){
            T = Ratio.at(k).at(0) * i;
            A = Ratio.at(k).at(1) * i;
            break;
          }
        }
      }
      
      cout << T + A << endl;
      
      
    }

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a[2];
    int b;
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    if(a[1] > a[2]){
        b = a[2];
        a[2] = a[1];
        a[1] = b;
    }
    if(a[0] > a[1]){
        b = a[1];
        a[1] = a[0];
        a[0] = b;
    }
    if(a[1] > a[2]){
        b = a[2];
        a[2] = a[1];
        a[1] = b;
    }
    printf("%d %d %d\n", a[0], a[1], a[2]);
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    int N;cin >> N;
    int M;cin >> M;
    vector<int> vec(N+1);
    for(int a = 0;a < M;a++){
        int b;cin >> b;
        vec.at(b) = 1;
    }
    vector<int> dp(N+1);
    dp[0] = 1;
    for(int a = 1;a <= N;a++){
        if(vec.at(a) == 1)continue;
        if(a == 1){
            dp[a] = dp[0];

        }else{
            dp[a] = dp[a-1]+dp[a-2];
            dp[a]%=MODk;
        }
    }
    cout<<dp[N]%MODk<<endl;
}


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

long long n, k, ans = 0;

int main() {
  cin >> n >> k;
  n *= 2;
  ans = min(n, k) / 2;
  n -= ans * 2;
  k -= ans * 2;
  if(k > 0) ans += k / 4;
  cout << ans << endl;
  return 0;
}

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

is_ok = True
# x[i] - X たちの最大公約数

from fractions import gcd
if N == 1:
    print(abs(x[0]-X))
elif N == 2:
    GCD = gcd(abs(x[0]-X), abs(x[1]-X))
    print(GCD)
else:
    GCD = gcd(abs(x[0]-X), abs(x[1]-X))
    for i in range(2, N):
        a = abs(x[i] - X)
        GCD = gcd(GCD, a)

    print(GCD)

Measured memory_bytes: 82068
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <string>
#include <array>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    char c0, c1, c2, c3;
        cin >> c0 >> c1 >> c2 >> c3;
        if (c1 == c2){
            if ((c0 == c1)||(c2 == c3)){
                cout << "Yes" << endl;
                return 0;
            }else{
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[114514];
signed main(){
	int i,j;
	cin>>a;
	for(i=0;i<a;i++)
		cin>>p[i];
	bool f=true;
	int ma=p[0],mi=p[0];
	for(i=0;i<a-1;i++){
		if(p[i]!=p[i+1])
			f=false;
		ma=max(ma,p[i]);
		mi=min(mi,p[i]);
	}
	if(f){
		if(ma==a-1||ma<=a/2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	else if(ma-mi>1){
		cout<<"No"<<endl;
	}
	else{
		int n=0,m=0;
		for(i=0;i<a;i++){
			if(p[i]==mi)
				n++;
			if(p[i]==ma)
				m++;
		}
		if(ma>n&&(ma-n)<=m/2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}


Measured memory_bytes: 1024
#include<stdio.h>
	int main(){
		int a[100][100],n,x,y,z,i,j;
		while(1){
		z=0;
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++)
			for(j=0;j<n;j++){
				scanf("%d",&a[i][j]);
		}
		for(i=0;i<n;i++){
			x=0;
			for(j=0;j<n;j++){
				printf("%5d",a[i][j]);
				x+=a[i][j];
			}
			printf("%5d\n",x);
		}
		for(i=0;i<n;i++){
			y=0;
			for(j=0;j<n;j++){
				y+=a[j][i];
			}
			z+=y;
			printf("%5d",y);
		}
		printf("%5d\n",z);
	}
	return 0;
}

Measured memory_bytes: 0
# import itertools
# import math

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
P = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()


min = 999999999
cnt = 0
for i in P:
    if min >= i:
        cnt += 1
        min = i

print(cnt)

Measured memory_bytes: 32288