akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp0 = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0 { u = u, p = p });
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				es[f.u].Remove(f.p);
				st.Push(new A0 { u = f.u, p = -1 });
				foreach (var v in es[f.u]) st.Push(new A0 { u = v, p = f.u });
			}
			else
			{
				dp0[f.u] = 1L;
				foreach (var v in es[f.u]) dp0[f.u] = dp0[f.u] * (dp0[v] + 1) % Mod;
			}
		}
		return dp0;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp1 = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			var x = new long[W + 1];
			var y = new long[W + 1];
			x[0] = y[W] = 1;
			for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
			x = y = null;
			foreach (var v in es[u]) st.Push(v);
		}
		return dp1;
	}
}
struct A0 { public int u, p; }


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

using namespace std;
#define N 515155
int arr[N];

int main(){
  int n;
  cin>>n;
  int ans=0;
  scanf("%d",&arr[1]);
  if(n==1){
    cout<<arr[1];
    return 0;
  }
  int temp=arr[1];
  for(int i=2;i<=n;i++){
    scanf("%d",&arr[i]);
    if(i==n){
      ans+=max(temp,arr[i]);
      break;
    }
    if(arr[i]<temp){
      ans+=temp-arr[i];
      temp=arr[i];
    }else{
      temp=arr[i];
    }
  }
  cout<<ans; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int h,w,z;
        cin>>h>>w>>z;
        int ans=0;
        string s[h];
        for(int i=0;i<h;i++)
            cin>>s[i];
        int a[7];
        a[0]=1;
        for(int i=1;i<=6;i++)
            a[i]=2*a[i-1];
        for(int i=0;i<a[h];i++){
            int c=0;
            int g=i;
            int d[6];
            while(c<6){
                d[c]=g%2;
                g/=2;
                c++;
            }
            for(int j=0;j<a[w];j++){
                int h1=0;
                int p=j;
                int q[6];
                while(h1<6){
                    q[h1]=p%2;
                    p/=2;
                    h1++;
                }
                int ctr=h*w;
                for(int k=0;k<h;k++){
                    for(int l=0;l<w;l++){
                        if(d[k]==1||q[l]==1||s[k][l]=='.')
                            ctr--;
                    }
                }
                if(ctr==z)
                    ans++;
            }
        }    
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
x1, y1, x2, y2 = $stdin.read.split.map(&:to_i)
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  int i,j;
  vector<vector<char>> a(H, vector<char>(W));

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> row(H,false);
  vector<bool> col(W,false);

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(a.at(i).at(j) == '#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  for(i=0;i<H;i++){
    if(row.at(i)){
        for(j=0;j<W;j++){
          if(col.at(j)){
              cout << a.at(i).at(j);
          }
        }
        cout << endl;
    }
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll h,w ;
 cin >> h>> w ;
 ll ans=0 ;
 if(h*w%3==0)
 ans=0 ;
 else{ll k=w/3 ;ll l=h/3 ;
 ll hmi=h/2 ;ll wmi= w/2 ;
 if(h%2==1) hmi= k+(h+1)/2 ;if(w%2==1) wmi =l+(w+1)/2 ;
 ans=min(h,min(w,min(hmi,wmi))) ;
 }
 cout <<ans<<endl ;
     return 0;
}

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,H,W,t;


int main(){
  int ans=0;
  cin >> H >> W;
  vector<vector<int>> vv = vector<vector<int>>(H, vector<int>(W, 0));
  string S;
  REP(i,H){
    cin>>S;
    int t=3000;
    REP(j,W){
      if (S[j]=='.'){//白
        t++;
      }else{//黒のとこだけ0にする
        t=0;
      }
      vv[i][j]=t;
    }
  }
  //右から左にカウント
  
  REP(i,H){
    t=3000;
    REPR(j,W){
      if (vv[i][j]==0){
        t=0;
      }else{
        t++;
      }
      vv[i][j]=min(vv[i][j],t);
    }
  }
  
  
  //上から下に
  REP1(i,H){
    REP(j,W){
      vv[i][j]=min(vv[i][j],vv[i-1][j]+1);
    }
  }
  
  //下から上に
  REPR(i,H-1){
    REP(j,W){
      vv[i][j]=min(vv[i][j],vv[i+1][j]+1);
    }
  }

  
  REP(i,H){
    REP(j,W){
      ans=max(vv[i][j],ans);
    }
  }


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

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

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

    cout << (N < 1000 ? "ABC" : "ABD") << endl;
}

Measured memory_bytes: 256
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    

    void dfs(string s,int maxi)
    {
        if(s.size()==n)
            cout<<s<<endl;
        else
        {
            for(char i='a';i<=maxi;i++)
            dfs(s+i,((i)==maxi)?(maxi+1):maxi);
        }

    }
    void solve()
    {
        cin>>n;
        dfs("",'a');
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }


Measured memory_bytes: 1536
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, m; cin >> n >> m; 
  vi v(n); input(v);
  vi dp(n, INF);
  dp[0] = 0;
  forall(i,1,n){
    forall(j, max(0,i-m), i){
      dp[i] = min(dp[i], dp[j]+abs(v[i]-v[j]));
    }
  }
  cout << dp.back() << endl;
  return 0;
}


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


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

class BMakingTriangle {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vector<ll> l(n);
        rep(i,n){
            in >> l[i];
        }
        ll cnt=0L;
        sort(l.begin(),l.end());
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    if(l[k]<l[i]+l[j]&&l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
                        cnt++;
                    }
                }
            }
        }
        out <<cnt << endl;
	}
};


int main() {
	BMakingTriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    if(r < 1200) {
        cout << "ABC" << endl;
    } else if(r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}


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

int main(){
  int result = 7;
  int A,B;
  
  cin >> A >> B;
  
  if(A == 1){
    result &= 0x6;
  }else if(A == 2){
    result &= 0x5;
  }else if(A == 3){
    result &= 0x3;
  }
  if(B == 1){
    result &= 0x6;
  }else if(B == 2){
    result &= 0x5;
  }else if(B == 3){
    result &= 0x3;
  }
  if(result == 4){
    cout << 3 << endl;  
  }else{
    cout << result << endl;  
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    
    long x,y,i,X,Y,r;
    
    
    long ans=1;
    
    cin>>x>>y;
    X=x%y;
    Y=y%x;
    
    
    if (x==y)
    {
        ans=x;   
    }
    
    else
    {
     if(x>y)
     {
         while (y>0)
         {
             
            
             r=x;
             x=y;
             y=r%y;
             
             
         }
     }
     else
     {
         while (x>0)
         {
             
            
             r=y;
             y=x;
             x=r%x;
             
             
         }
         x=y;
     }
     
     
    }
    
    cout<<x<<endl; 
        
    
    
}



Measured memory_bytes: 3096
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    surplus_scores = []
    sum_lack_score = 0
    ans = 0
    for a, b in zip(A, B):
        if a > b:
            surplus_scores.append(a - b)
        elif a < b:
            sum_lack_score += b - a
            ans += 1

    if sum_lack_score > 0:
        surplus_scores.sort(reverse=True)
        pass_exam = False
        for i, score in enumerate(surplus_scores):
            sum_lack_score -= score
            if sum_lack_score <= 0:
                ans += (i + 1)
                pass_exam = True
                break
        if not pass_exam:
            ans = -1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18652
n, s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
MOD = 998244353
dp = Array.new(n+1){ [0] * (s + 1)}
dp[0][0] = 1

1.upto(n) do |i|
  _a = a[i-1]
  0.upto(s) do |j|
    dp[i][j] = (dp[i][j] + 2 * dp[i-1][j]) % MOD
    if j - _a >= 0
      dp[i][j] = (dp[i][j] + dp[i-1][j-_a]) % MOD
    end
  end
end

puts dp[n][s]

Measured memory_bytes: 84832
import sys
import itertools

dataset_num = int(input())

class Overflow(Exception):
    pass

for _ in range(dataset_num):
    try:
        k1 = input()
        k2 = input()
        k1_val = [0] * 100
        k2_val = [0] * 100

        if len(k1) > 80 or len(k2) > 80:
            raise Overflow()
        
        for i, x in enumerate(reversed(k1)):
            k1_val[i] = int(x)

        for i, x in enumerate(reversed(k2)):
            k2_val[i] = int(x)
        
        res = [0] * 100 
        for i in range(0, 100):
            res[i] += k1_val[i] + k2_val[i]
            if res[i] >= 10:
                res[i+1] += 1
                res[i] -= 10
        sumstr = "".join([str(x) for x in itertools.dropwhile(lambda x: x == 0, reversed(res))])
        if len(sumstr) > 80:
            raise Overflow()
        if len(sumstr) == 0:
            sumstr = "0"

        print(sumstr)
    except Overflow:
        print("overflow")

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

int main() {
	int n, k; cin >> n >> k;
	vector<int>a(200005, 0);
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp]++;
	}
	sort(a.begin(), a.end(), greater<int>());

	int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 0)break;
		if (i >= k && i != a[i]) ans += a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
s=str(input())
x=["a","b","c","d","e","f","g","h","i","j","k","l","n","m","o","p","q","r","s","t","u","v","w","x","y","z"]
c=0
for i in range(len(x)):
    S=s.count(x[i])
    if S%2!=0:
        print('No')
        c=1
        break
if c==0:
    print('Yes')


Measured memory_bytes: 3060
unittest
{
	assert( [ "-9" ].parse.expand.solve == "1011" );
	assert( [ "123456789" ].parse.expand.solve == "11000101011001101110100010101" );
	assert( [ "0" ].parse.expand.solve == "0" );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( int );
	
	return tuple( n );
}

auto solve( in int n )
{
	if( n == 0 ) return "0";
	
	auto b = "";
	int r = n;
	while( r != 0 )
	{
		b = ( r % -2 ).abs.to!string ~ b;
		r = cast( int ) ceil( cast( real ) r / -2 );
	}
	
	return b;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())


ans = 0
commands = [''] * N
for i, t in enumerate(T):
    if t == 'r':
        command = 'p'
        point = P

    elif t == 's':
        command = 'r'
        point = R

    elif t == 'p':
        command = 's'
        point = S

    if (i - K >= 0) and (commands[i -  K] == command):
        command = ''
        point = 0

    ans += point
    commands[i] = command

print(ans)

Measured memory_bytes: 50416
#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--)
 
int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	ll dp[n][n] = {};
	for(ll l=n-1; l>=0; l--){
		for(ll r=l; r<n; r++){
			if(l == r){
				dp[l][r] = a[l];
			}
			else{
				dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
			}
		}
	}
	cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
// clang-format off
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

struct MaxSegTree {
    int n;
    vector<ll> dat;
    // 初期化
    MaxSegTree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        dat = vector<ll>(2 * n - 1, -1);
    }
    // k番目(0-indexed)の値をaに変更
    void update(int k, ll a) {
        k += n - 1;
        dat[k] = a;
        //更新
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    // 内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return -1;

        if (a <= l && r <= b) return dat[k];

        ll vl = _query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = _query(a, b, 2 * k + 2, (l + r) / 2, r);
        return max(vl, vr);
    }
    // [a,b)
    ll query(int a, int b) { return _query(a, b, 0, 0, n); }
};

const int mod = 998244353;

using pi = pair<int, int>;

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

    vector<pi> robot(n);
    rep(i, n) {
        int x, d;
        cin >> x >> d;
        robot[i] = {x, d};
    }
    sort(all(robot));

    MaxSegTree st(n);
    vector<int> nx(n);
    rep(i, n) nx[i] = i + 1;

    for (int i = n - 1; i >= 0; --i) {
        int x = robot[i].fi + robot[i].se;
        int idx = lower_bound(all(robot), pi(x, 0)) - robot.begin();

        int r = st.query(i, idx);
        nx[i] = max(r, nx[i]);
        st.update(i, nx[i]);
    }

    vector<int> dp(n + 1);
    dp[0] = 1;
    rep(i, n) {
        (dp[i + 1] += dp[i]) %= mod;
        (dp[nx[i]] += dp[i]) %= mod;
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int a,b;
    cin>>a>>b;
    int m = b-a;
    int ans = 0;
    REP(i,m)ans+=i;
    cout<<ans-b<<endl; return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem097b(n))
}

fun problem097b(n: Int): Long {
    val array = LongArray(n + 1) { 0 }
    array[0] = 2
    array[1] = 1
    for (i in 2..n) {
        array[i] = array[i - 2] + array[i - 1]
    }
    return array.last()
}

Measured memory_bytes: 35792
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		int N = Integer.parseInt(num);
		int[] W = new int[N];
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int S1 = 0;

		for(int i = 0; i < N; i++) {
			W[i] = Integer.parseInt(lines[i]);
			S1  = S1 + W[i];
		}

		S1 = S1 - W[N-1];
		int S2 = W[N-1];
		int min = 10000;

		for(int i = N-2; i > 0; i--) {
			int abs = Math.abs(S1 - S2);
			if(abs < min) {
				min = abs;
			}

			S1 = S1 - W[i];
			S2 = S2 + W[i];
		}


		System.out.println(min);
	}

}


Measured memory_bytes: 35800
#include <stdio.h>
#define REP(i, a, b) for(long long int i = a; i < b; i++)

int main(void) {
    int n;
    scanf("%d", &n);
    int a[n];
    REP(i, 0, n) {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i -= 2) {
        printf("%d ", a[i]);
    }
    for (int i = n % 2; i < n; i += 2) {
        printf("%d ", a[i]);
    }
    return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>

int main(void){
  int N,i,j,key,count=0;
  int length[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&length[i]);
  }
  
  for(i=0;i<=N-1;i++){
    for(j=N-1;j>i;j--){
      if(length[j]<length[j-1]){
	key=length[j];
	length[j]=length[j-1];
	length[j-1]=key;
	count++;
      }
    }
  }
  
  for(i=0;i<N;i++){
    printf("%d",length[i]);
    if(i<N-1) printf(" ");
  }
  
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)cout << "safe" << endl;
	else cout << "unsafe" << endl;
	return 0;
}

Measured memory_bytes: 3624
import sys
def input():
    return sys.stdin.readline()[:-1]

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        dist = 0
        for I, J in zip(X[i], X[j]):
            dist += (I-J)**2
        dist = dist**0.5
        
        if dist.is_integer():
            cnt += 1

print(cnt)

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

#define MOD 1000000007
typedef unsigned long long int ull;
using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int n;
  cin >> n;
  ull a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ull bit[60];
  int max = 0;
  for (int i = 0; i < 60; i++) bit[i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] & (1ULL<<j)) {
        bit[j]++;
        if (max < j) max = j;
      }
    }
  }
  max++;
  ull ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = 0; j < max; j++) {
      if (a[i] & (1ULL<<j)) {
        bit[j]--;
        ans += (n-1 - i - bit[j]) * ((1ULL<<j) % MOD);
      } else {
        ans += bit[j] * ((1ULL<<j) % MOD);
      }
      if (ans >= MOD) ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import numpy as np
N=int(input())
A=[int(input()) for i in range(N)]
Amax=max(A)

Ai=np.argmax(A)
if Ai==0:
  A2max=max(A[1:])
elif Ai==N-1:
  A2max=max(A[:-1])
else:
  A2max=max(max(A[:Ai]),max(A[Ai+1:]))
for i in range(N):
  if i==Ai:
    print(A2max)
  else:
    print(Amax)


Measured memory_bytes: 22836
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  ll N;
  ll cnt = 0;
  cin >> N;
  Rep(i, N) {
    ll a; cin >> a;
    if( a % 2 ) cnt++;
  }

  if( cnt % 2 ) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;


int main() {
	int n;
	cin >> n;
	int i = 1;
	while (true) {
		int c = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) c++;
		}
		if (c == n) break;
		i++;
	}
	cout << i << endl;
    return 0;
}

Measured memory_bytes: 1160
function Main(inputData) {
    init(inputData);
    
    var n = inI();
    var cnt = 0;
    for(var i = 1; i <= n;i+=2){
	var cnt8 = 0;
	for(var j = 1; j <= i; j++){
	    if(i%j == 0)cnt8++;
	}
	if(cnt8 == 8)cnt++;
    }
    outln(cnt);
}

////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//prototype
Array.prototype.rsort = function(){
  return this.sort(function(a,b){return (a<b ? 1:-1);});
}

Array.prototype.max = function(){
  return Math.max.apply(null, this);
}

Array.prototype.min = function(){
  return Math.min.apply(null, this);
}

//function
function values(array) {
    var values = [];
    if(array)for(var key in array)values.push(array[key]);
    return values;
};

function keys(array) {
    var keys = [];
    if(array)for(var key in array)keys.push(key);
    return keys;
};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

x = ni()
flag = False
for i in range(3, 8, 2):
    if x == i:
        flag = True

if flag:
    print("YES")
else:
    print("NO")

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

int main()
{
  int n;
  cin >> n;
  std::priority_queue<long> a;
  long ain;
  long min = 1000000000;
  long sum = 0;
  for(int i = 0 ; i<n;++i){
    cin >> ain;
    a.push(ain);
  }
  for(int i = 0 ; i<n-1;++i){
    sum += a.top();
    if(i%2==0) a.pop(); 
    //cout << sum << endl;
  }
  cout << sum << endl;
}


Measured memory_bytes: 5360
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    string s;
    scan(N, s);
    if (N % 2 == 1) {
        print("No");
        return 0;
    }

    rep(i, N / 2) {
        if (s[i] != s[i + N / 2]) {
            print("No");
            return 0;
        }
    }
    print("Yes");

    return 0;
}

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

const int MAXN = 212345;
int A[MAXN];
int next_non_zero[MAXN];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    A[N] = -1;
    for (int i = 0; i < N; ) {
        int ni = i+1;
        while (A[ni] == 0) {
            ++ni;
        }
        for (int j = i; j < ni; j++) {
            next_non_zero[j] = ni;
        }
        i = ni;
    }
    lint ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = i; j < N; ) {
            if (sum+A[j] == (sum^A[j])) {
                ans += next_non_zero[j] - j;
                sum += A[j];
                j = next_non_zero[j];
            } else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new CGL_3C().doIt();
	}

	class CGL_3C{
		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY()-p1.getY()*p2.getX();
		}
		double dot(Point2D p1,Point2D p2){
			return p1.getX()*p2.getX()+p1.getY()*p2.getY();
		}
		Point2D sub(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()-p2.getX(),p1.getY()-p2.getY());
		}
		int contains(Point2D[] plist,Point2D p) {
			boolean in = false;
			int n = plist.length;
			for(int i=0; i<n; i++){
				Point2D a = sub(plist[i], p);
				Point2D b = sub(plist[(i+1) % n], p);
				if(a.getY() > b.getY()){
					Point2D temp = (Point2D) a.clone();
					a = b;
					b = temp;
				}
				if(a.getY() <= 0 && 0 < b.getY()){
					if(cross(a,b) < 0) in = ! in;
				}
				if(cross(a,b) == 0 && dot(a, b) <= 0) return 0;
			}
			return in ? 1 : -1;
		}

		void doIt(){
			int n = in.nextInt();
			Point2D[] ps = new Point2D[n];
			for(int i=0;i<n;i++)ps[i] = new Point2D.Double(in.nextDouble(),in.nextDouble());
			int m = in.nextInt();
			for(int i=0;i<m;i++){
				Point2D p = new Point2D.Double(in.nextDouble(), in.nextDouble());
				int result = contains(ps, p);
				if(result>0)System.out.println("2");
				else if(result==0)System.out.println("1");
				else if(result<0)System.out.println("0");
			}
		}
	}

}

Measured memory_bytes: 41052
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(0); cin.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define ll long long int 
#define ui unsigned int
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>  
#define mp make_pair
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(),(x).end() 
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v),greater<int>())
#define SET(a,b) for(ui i=0;i<size(a);++i){a[i]=b;} 
#define test() int t; cin>>t ; while(t--)
#define FOR(i,a,b) for(int i=a;i<b;++i)  
#define cerr if(0)cerr
#define watch(x) cerr<<#x<<" is "<<x<<endl;
#define print(x) cout<<x<<endl
#define readv(v) FOR(i,0,n){cin>>v[i];}
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl;
const ll MOD=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

using namespace std;

int main() {
  
  string s;
  cin>>s;
  int n=s.sz;
  int dp[n]={0};
  dp[0]=1;
  dp[1]=(s[0]==s[1])?1:2;
  
  if(s[0]!=s[1] && s[1]!=s[2])
	dp[2]=3;
  else
    dp[2]=2;
  
  for(int i=3;i<n;++i)
  {
	  if(s[i]!=s[i-1])
		dp[i]=dp[i-1]+1;
	  else
		dp[i]=dp[i-3]+2;
  }
  
  cout<<dp[n-1]<<endl;
  
  
	
    return 0;
}


Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
const long long maxn=100+5;
long long n,m,d,ans1,ans2=0,cnt1,cnt2;
long long a[maxn],C[maxn][maxn];
bool cmp(long long x,long long y)
{
	return x>y;
}
void init()
{
    C[0][0]=1;
    C[1][0]=1;
    C[1][1]=1;
    for(int i=1;i<=50;i++)
	{
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        C[i][j]=C[i-1][j]+C[i-1][j-1];
    }
}
int main()
{
	init();
	cin>>n>>m>>d;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(long long i=1;i<=m;i++)
	{
		ans1+=a[i];
	}
	for(long long i=1;i<=n;i++) 
	{
		if(a[i]==a[m]) 
		{
			cnt1++;
		}
	}    
	for(long long i=1;i<=m;i++)  
	{
		if(a[i]==a[m]) 
		{
			cnt2++;	
		}
	}
    if(a[1]==a[m]) 
	{
		for(long long i=m;i<=min(cnt1,d);i++) 
		{
			ans2+=C[cnt1][i];
		}	
	}
    if(a[1]!=a[m])  ans2=C[cnt1][cnt2];
    printf("%.6lf\n%lld",(double)ans1/m,ans2);
	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    cout<< max({a*c, a*d, b*c, b*d})<<endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    cout << a*b << "\n";

    return 0;
}

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

int main() {
  
  int N; cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    vec[A - 1] = i + 1;
  }
  
  for (int i = 0; i < N - 1; i++) cout << vec[i] << " ";
  
  cout << vec.back() << endl;
  
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int b[m], c[m];
    vector<pair<int, int>> v;
    rep(i, 0, m) {
        cin >> b[i] >> c[i];
        v.push_back(make_pair(c[i], b[i]));
    }

    sort(all(v));
    reverse(all(v));

    sort(all(a));

    int x = lower_bound(all(a), v[0].first) - a.begin();

    vector<int> v2;
    rep(i, 0, x) v2.push_back(a[i]);
    int cnt = 0;
    rep(i, 0, m) {
        rep(j, 0, v[i].second) {
            if (cnt == x) break;
            v2.push_back(v[i].first);
            cnt++;
        }
        if (cnt == x) break;
    }

    sort(all(v2));
    reverse(all(v2));

    ll ans = 0;
    rep(i, 0, x) ans += (ll)v2[i];
    rep(i, x, n) ans += (ll)a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3700
n, k = map(int, input().split())
s = str(input())
L = []
cnt = 0
x = '1'
for i in range(n):
    if s[i] == x:
        cnt += 1
    else:
        L.append(cnt)
        x = '0' if x == '1' else '1'
        cnt = 1
else:
    L.append(cnt)
syaku = sum(L[:2*k+1])
ans = syaku
for i in range(len(L)-2*k):
    syaku -= L[i]
    if i % 2:
        syaku += L[i+2*k]
        if i+2*k+1 < len(L):
            syaku += L[i+2*k+1]
    ans = max(ans, syaku)
print(ans)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n; cin>>n;
    cout<<n*(n+1)/2<<endl;
}

Measured memory_bytes: 256
#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;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
string s, t;
int n, m;
int check(int x)
{
	int ans = 0;
	if(x+m-1>=n)return INT_MAX;
	FOR(i,x,x+m)
	{
		if(t[i-x]!=s[i])ans++;
	}
	return ans;
}
void fff()
{
	cin >> s >> t;
	n = s.length();
	m = t.length();
	int ans = m;
	FOR(i,0,n)
	{
		ans = min(ans, check(i));
	}
	cout << ans << ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,K; cin >> N >> K;
    int out=1;
    int s=1;
    for(int i=0;i<N;i++){
        if(s*2-s<K) out*=2;
        else out += K;
        s *= 2;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

void print_array(int a[], int length)
{
    for(int i=0; i<length; i++){
        if(i==length-1)
            printf("%d\n", a[i]);
        else
            printf("%d ", a[i]);
    }
}

void insertion_sort(int a[], int length)
{
    print_array(a, length);
    for(int i=1; i<length; i++){
        //int j = i+1;
        int temp = a[i];
        int k;
        for(k=i-1; k>=0; k--){
            if(temp<a[k]){
                a[k+1] = a[k];
            }
            else{
                //a[k+1] = temp;
                break;
            }
        }
        a[k+1] = temp;
        print_array(a, length);
    }
}

int main()
{
    int data_length, arr[110];
    scanf("%d", &data_length);
    for(int i=0; i<data_length; i++){
        scanf("%d", &arr[i]);
    }
    insertion_sort(arr, data_length);
}



Measured memory_bytes: 2072
import math
while True:
    try:
        n=int(input())
        num=list(range(n+1)) #[0,1,,,,n]が出力される
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]): #num[i]*2からn+1までnum[i]個飛ばしで
                num[j]=0
        print(n+1-num.count(0))
    except:
        break


Measured memory_bytes: 56772
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];

    rep(i, n-k) {
        if(a[i+k] > a[i]) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}

Measured memory_bytes: 3988
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	ll left = a / x + (a % x != 0);
	ll right = b / x + 1;
	cout << right - left << endl;
	return 0;
}

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

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

  for (int i=0; i<s.size(); i++) {
    if (s==t) {
      cout << "Yes";
      return 0;
    }
    s.insert(s.begin(), s[s.size()-1]);
    s.pop_back();
  }
  cout << "No";
}

Measured memory_bytes: 256
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b int
    Scanf("%d %d", &a, &b)

    cnt := 0
    for i := a; i <= b; i++ {
        tmp := i
        dig := make([]int, 0, 5)
        for j := 0; j < 5; j++ {
            dig = append(dig, tmp % 10)
            tmp /= 10
        }

        if dig[0] == dig[4] && dig[1] == dig[3] {
            cnt++
        }
    }
    Println(cnt)
}


Measured memory_bytes: 512