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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[105][105]; // 区間[i,j)の連鎖行列積の最小回数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll v(n+1);
  rep(i,n){
    cin>>v[i]>>v[i+1];
  }
  
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  
  for(ll l=2; l<=n; l++){
    for(ll i=0; i<n-l+1; i++){
      ll j=i+l;
      // [j,j+i)を更新する
      dp[i][j]=LINF;
      for(ll k=i+1; k<j; k++){
        chmin(dp[i][j],dp[i][k]+dp[k][j]+v[i]*v[k]*v[j]);
      }
    }
  }
  
  cout<<dp[0][n]<<endl;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

ll dp[101][100001];

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<ll> v(N);
    for (int i=0; i<N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i=1; i<=N; ++i) {
        for (int j=0; j<=W; ++j) {
            dp[i][j] = dp[i-1][j];
            if (j-1 >= 0) dp[i][j] = max(dp[i][j], dp[i][j-1]);
            if (j-w[i-1] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 78336
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char S[220000];
char T[220000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	int x,y;scanf("%d%d",&x,&y);
	x--;y--;
	scanf("%s%s",S,T);
	int U=0;
	int D=0;
	int L=0;
	int R=0;
	for(int i=0;i<c;i++){
		if(S[i]=='L')L++;
		if(S[i]=='R')R++;
		if(S[i]=='U')U++;
		if(S[i]=='D')D++;
		if(x-U<0||x+D>=a||y-L<0||y+R>=b){
			printf("NO\n");return 0;
		}
		if(T[i]=='L'&&y+(R-1)>=0)R--;
		if(T[i]=='R'&&y-(L-1)<b)L--;
		if(T[i]=='U'&&x+(D-1)>=0)D--;
		if(T[i]=='D'&&x-(U-1)<a)U--;
		
	}
	printf("YES\n");
}

Measured memory_bytes: 512
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N,K;
LL x[50],y[50];
 
LL ans = INF;

LL max_num(LL a,LL b,LL c,LL d){
	return max(a,max(b,max(c,d)));
}
LL min_num(LL a,LL b,LL c,LL d){
	return min(a,min(b,min(c,d)));
}
 
void solve(){
	for(int a=0;a<N;a++){
		for(int b=0;b<N;b++){
			for(int c=0;c<N;c++){
				for(int d=0;d<N;d++){
					LL right = max_num(x[a],x[b],x[c],x[d]);
					LL upper = max_num(y[a],y[b],y[c],y[d]);
					LL left = min_num(x[a],x[b],x[c],x[d]);
					LL bottom = min_num(y[a],y[b],y[c],y[d]);
					int counter = 0;
					for(int i=0;i<N;i++){
						if(bottom<=y[i] && y[i]<=upper && left<=x[i] && x[i]<=right) counter++;
					}
					if(counter<K) continue;
					ans = min(ans,(right-left)*(upper-bottom));
				}
			}
		}
	}
}
 
int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
    	cin >> x[i] >> y[i];
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] queryOrder = new int[Q];
		for(int i=0;i<Q;i++) queryOrder[i] = i;
		Array.Sort(queryOrder, (i, j) => R[i].CompareTo(R[j]));
		
		int[] last = new int[N + 1];
		for(int i=0;i<=N;i++) last[i] = -1;
		
		int[] ans = new int[Q];
		var BT = new FenwickTree(N + 10);
		int idx = 0;
		foreach(var q in queryOrder){
			
			int r = R[q];
			int l = L[q];
			while(idx <= r){
				int c = C[idx];
				if(last[c] == -1){
					last[c] = idx;
					BT.Add(idx + 1, 1);
				} else {
					var prev = last[c];
					BT.Add(prev + 1, -1);
					last[c] = idx;
					BT.Add(idx + 1, 1);
				}
				idx++;
			}
			
			int cnt = (int) (BT.Cumulate(r + 1) - BT.Cumulate(l));
			ans[q] = cnt;
		}
		
		Console.WriteLine(String.Join("\n",ans));
		
	}
	int N,Q;
	int[] C;
	int[] L,R;
	public Sol(){
		var d = ria();
		N = d[0]; Q = d[1];
		C = ria();
		L = new int[Q];
		R = new int[Q];
		for(int i=0;i<Q;i++){
			d = ria();
			L[i] = d[0] - 1;
			R[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class FenwickTree {
	// field
	long[] Data;
	public int N;		// base space size 
	int n;				// total size (pow of 2)
	
	// constructor
	public FenwickTree(int n_){
		N = n_;
		n = 1 << 2;
		while(n < N * 2) n <<= 1;
		Data = new long[n + 1];
	}

	// add at [0, i)
	public void Add(int i, long x){
		while(i <= n){
			Data[i] += x;
			i += (i & -i);
		}
	}
	
	// i => sum(a_k) for k in [0, i)
	public long Cumulate(int i){
		long s = 0;
		while(i > 0){
			s += Data[i];
			i -= (i & -i);
		}
		return s;
	}
}


Measured memory_bytes: 102000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] NK = cin.ArrayInt(2,0);
        int[] l=cin.ArrayInt(NK[0],0);
        Array.Sort(l);
        Array.Reverse(l);
        int ans=0;
        for(int i=0;i<NK[1];i++)
        {
          ans+=l[i];
        }
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
a,b,c,d = input()
for i in range(2**3):
    ku = ["+", "+", "+"]
    for j in range(len(ku)):
        if(i>>j)&1:
           ku[j]= "-"
    if eval(a+ku[0]+b+ku[1]+c+ku[2]+d) == 7:
     print(a+ku[0]+b+ku[1]+c+ku[2]+d+"=7")
     break

Measured memory_bytes: 61792
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int m, min, max; m = in(), min = in() - 1, max = in();) {
		vector<int> v(m), w;
		for (int &p: v)
			p = in();
		for (int i = min; i < max; i++)
			w.push_back(v[i] - v[i + 1]);
		long s = 0, i = 0;
		for (int &x: w)
			if (x >= s) {
				i = &x - &w[0];
				s = x;
			}
		outl(i + min + 1);
	}
}


Measured memory_bytes: 2616
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

signed main()
{
    int N;
    int w[105];

    int sumL = 0, sumR = 0;

    cin >> N;
    rep(i, 0, N) {
        cin >> w[i];
        sumR += w[i];
    }

    sumR -= w[0];
    sumL = w[0];
    int ans = abs(sumL - sumR);


    rep(i, 1, N) {
        sumL += w[i];
        sumR -= w[i];
        chmin(ans, abs(sumL - sumR));
    }

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

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 256
S = input().strip()
T = input().strip()
N = len(S)
K = len(T)
A = list(S)
for i in range(N-K,-1,-1):
    a = S[i:i+K]
    flag = 0
    for j in range(K):
        if a[j]!="?" and a[j]!=T[j]:
            flag = 1
            break
    if flag==1:continue
    A[i:i+K] = T[:]
    for j in range(N):
        if A[j]=="?":
            A[j]="a"
    break
if "?" in A:
    print("UNRESTORABLE")
else:
    print("".join(A))

Measured memory_bytes: 38384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String s = scan.next();
    
    if(s.equals("Sunny")){
      System.out.println("Cloudy");
    }else if(s.equals("Cloudy")){
      System.out.println("Rainy");
    }else{
	  System.out.println("Sunny");
    };
  }
}

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

string s;
int k;

int main()
{
    cin >> s >> k;
    set<string> t;
    for(int i = 0; i < s.size(); i++)
    {
        for(int j = 1; j <= 5; j++)
        {
            if(i + j > (int)s.size()) break;
            t.insert(s.substr(i, j));
        }
    }
    auto itr = t.begin();
    rep(i, k - 1) itr++;
    cout << *itr << endl;

    return 0;
}

Measured memory_bytes: 1664
while True:
    n = int(raw_input())
    if n == 0:
        break
    else: # n > 0
        table = []
        for m in range(n):
            line = []
            
            line = map(int,raw_input().split())

            line_sum = sum(line)
            line.append(line_sum)
            table.append(line)
            
        
        
        vert_sum_line=[]
        for k in range(n):
            vert_sum = 0
            for j in range(n):
                vert_sum += table[j][k]
            vert_sum_line.append(vert_sum)
        
        total = sum(vert_sum_line)
        vert_sum_line.append(total)
    
        # .rjust(5)
        temp = []
        for line in table:
            temp.append( [str(x).rjust(5) for x in line])
        temp.append([str(x).rjust(5) for x in vert_sum_line])
        
        for i in xrange(n+1):
            print "".join(temp[i])

Measured memory_bytes: 4252
import sys
a, b = map(int, input().split())
resa_min = int(-(-a//0.08))
resa_max = int(-((-a-1)//0.08))
resb_min = int(-(-b//0.1))
resb_max = int(-((-b-1)//0.1))
al = range(resa_min, resa_max)
bl = range(resb_min, resb_max)
for i in al:
    for j in bl:
        if i == j:
            print(i)
            sys.exit()
print(-1)

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

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> a;
    int color = 0;
    for(int i = 0;i < n;i++){
        int b;
        cin >> b;
        color++;
        for(int i = 0;i < b;i++){
            a.push_back(color);
        }
    }
   
    for(int i = 0;;){
        for(int j = 0;j < w;j++){
            cout << a[i];
            if(j != w-1)cout << " ";
            i++;
        }
        cout << endl;
        if(i >= w*h)break;
        i+=w;
        for(int j = 0;j < w;j++){
            i--;
            cout << a[i];
            if(j != w-1)cout << " ";
        }
        cout << endl;
        i+=w;
        if(i >= w*h)break;
    }
    
    return 0;
}


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

using namespace std;

int main(){

  string osero;

  cin>>osero;

  if(osero[0] == 'x' && osero[osero.size()-1] == 'x')
	cout<<'x'<<endl;
  else
	cout<<'o'<<endl;

  return 0;

}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;
    int n;
    BinaryIndexedTree(int n_, T x) : n(n_), data(n_+1,x) {}
    T sum(int i) {
        T res = 0;
        for(++i; i>0; i -= (i&-i)) res += data[i];
        return res;
    }
    void add(int i, T x) {
        for(++i; i <= n; i += i&-i) data[i] += x;
    }
    int lower_bound(int k) {
        if(k <= 0) return 0;
        int x = 0, i = 1;
        while(i<n) i *= 2;
        for(; i>0; i/=2) {
            if(x+i <= n && data[x+i] < k) {
                k -= data[x+i];
                x += i;
            }
        }
        return x + 1;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    BinaryIndexedTree<int> bit(n, 0);
    REP(i,q) {
        int c,x,y; cin >> c >> x >> y; --x,--y;
        if(!c) bit.add(x,++y);
        else {
            int s = bit.sum(y) - bit.sum(x-1);
            cout << s << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 3340
N = int(input())
a = [int(x) for x in input().split()]
b = [int(y) for y in range(N)]
for i in range(N):
    b[i]=0
    while a[i]%2==0:
        b[i]=b[i]+1
        a[i]=a[i]//2
print(min(b))

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

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  for (ll i = k; i <= n+1; i++) {
    ll mn = (i-1)*i/2, mx = (n-(i-1)+n)*i/2;
    ans += mx-mn+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> V;
int main()
{
    ios::sync_with_stdio(false);
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        V.clear();
        V.push_back(a);V.push_back(b);V.push_back(c);
        sort(V.begin(),V.end(),greater<int>());
        cout<<V[0]*10+V[1]+V[2]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
    vector<int> good(n, 1);
    for (int i = 0; i < m; i++) {
        if (h[a[i]-1] < h[b[i]-1]) good[a[i]-1] = 0;
        else if (h[a[i]-1] > h[b[i]-1]) good[b[i]-1] = 0;
        else {
            good[a[i]-1] = 0;
            good[b[i]-1] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) if (good[i] == 1) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 5108
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  string s;
  ll k;
  cin>>s>>k;
  
  ll cnt=0;
  ll t;
  rep(i,s.size()){
    if(s[i]=='1') cnt++;
    else{
      t=s[i]-'0';
      break;
    }
  }
  if(k<=cnt) cout<<1<<endl;
  else cout<<t<<endl;
    
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c=0,d,i;
   char s[10];
   scanf("%s",s);
   for(i=0;i<6;i++)
   {
       if(s[2]==s[3]&&s[4]==s[5])
       {
           c++;
       }
   }
   if(c!=0)
   {
       printf("Yes\n");
   }
   else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    string s; cin >> s;
    string ans(s.size(), 'x');
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    lint A, B;
    cin >> A >> B;
    lint C = abs(A - B);
    if(C % 2 == 0) {
        cout << min(A, B) + (C / 2) << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;
typedef vector<vector<int>> vvi;

void DFS(vvi &graph, int cur, ll weight[], set<ll> &acc, int res[], int par = 0) {

	int val = weight[cur];
	bool last_erased = false, inserted = false;
	ll last_erased_val;

	if (acc.find(val) == acc.end()) {
		// Not present
		auto it = acc.upper_bound(val);
		if (it != acc.end()) {
			last_erased_val = *it;
			last_erased = true;
			acc.erase(it);
		}

		inserted = true;
		acc.insert(val);
	}

	res[cur] = acc.size();

	for (int x: graph[cur])
		if (x != par)
			DFS(graph, x, weight, acc, res, cur);

	if (inserted)
		acc.erase(acc.find(val));	

	if (last_erased) {
		acc.insert(last_erased_val);
	}
	
}

void SOLVE(vvi &graph, ll weight[], int n) {

	int res[n+1];

	set<ll> acc;

	DFS(graph, 1, weight, acc, res);

	for (int i = 1; i <= n; i++)
		cout << res[i] << endl;
}

int main() {

	IOS

	int n;
	cin >> n;

	vvi graph(n+1);
	ll weight[n+1];

	for (int i = 1; i <= n; i++)
		cin >> weight[i];

	int u, v;
	for (int i = 0; i < n-1; i++) {
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	SOLVE(graph, weight, n);

	return 0;
}

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

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

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

int main(){
    ll  n ;
    cin >> n ;
    vector<ll> A(100005,0) ;
    A[100] = 1 ;
    A[101] = 1 ;
    A[102] = 1 ;
    A[103] = 1 ;
    A[104] = 1 ;
    A[105] = 1 ;
    for(int i =  105 ; i <= 100005 ; i++ ){
      if( A[i-100] == 1 ) A[i] = 1 ;
      if( A[i-101] == 1 ) A[i] = 1 ;
      if( A[i-102] == 1 ) A[i] = 1 ;
      if( A[i-103] == 1 ) A[i] = 1 ;
      if( A[i-104] == 1 ) A[i] = 1 ;
      if( A[i-105] == 1 ) A[i] = 1 ;
    }
    cout << A[n] << endl ; 
}

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

int main()
{
	int n,r;
	while(cin>>n>>r){
		if(n==0) return 0;
		vector<int> V;
		for(int i=0;i<n;i++)
			V.push_back(n-i);

		for(int i=0;i<r;i++){
			int s,t;
			cin>>s>>t;
			s--;

			vector<int> w;
			for(int j=0;j<t;j++){
				w.push_back(V[s+j]);
			}

			vector<int> next;

			for(int k=0;k<w.size();k++){
				next.push_back(w[k]);
			}

			for(int k=0;k<s;k++){
				next.push_back(V[k]);
			}

			for(int k=s+t;k<n;k++)
				next.push_back(V[k]);

			V=next;
		}
		cout<<V[0]<<endl;


	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a,b;
cin>>a>>b;
a=a*100;
b=b*100;
bool flag=true;
for(int i=1;i<200000;i++){
    if(i*8>=a&&i*8<a+100){
             if(i*10>=b&&i*10<b+100){
        cout<<i<<endl;
        flag=false;
        break;
    }
    }
}
if(flag){
    cout<<"-1"<<endl;
}
}









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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const bool debug = 0;
//---------------------------------//

int solve(string S) {
	int dp[1000][26];
	fill(dp[0], dp[S.size() + 1], INF);
	dp[0][S[0]-'a'] = 0;
	
	REP(i, S.size() - 1) REP(j, 26) if (dp[i][j] != INF) {
		if (S[i + 1] - 'a' != j) chmin(dp[i + 1][S[i + 1] - 'a'], dp[i][j]);
		REP(k, 26) chmin(dp[i + 1][k], dp[i][j] + 1);
	}
	
	int res = INF;
	REP(i, 26) chmin(res, dp[S.size() - 1][i]);
	return res;
}

int main() {
	string S;
	int K;
	
	cin >> S >> K;
	
	ll ans;
	if (K == 1) ans = solve(S);
	else if (K == 2) ans = solve(S + S);
	else {
		ll ans4 = solve(S + S + S + S);
		ll ans3 = solve(S + S + S);
		ll ans2 = solve(S + S);
		ll ans1 = solve(S);
		
		
		if (K & 1) ans = (ans3 - ans1) * (K / 2) + ans1;
		else ans = (ans4 - ans2) * (K / 2 - 1) + ans2;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b >= c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import math
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
a=ll()
lol=[]
lol.append(a[0])
for i in range(1,n-1):
    lol.append(min(a[i-1],a[i]))
lol.append(a[n-2])
print(sum(lol))

Measured memory_bytes: 65368
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<VI> books(n, VI(m, 0));
    VI costs(n);

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

        for (int j = 0; j < m; j++) cin >> books[i][j];
    }

    int all = 1 << n;
    int lowest = -1;

    for (int mask = 0; mask < all; mask++) {
        vector<int> curr(m, 0);
        int cost = 0;

        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                for (int skill = 0; skill < m; skill++) {
                    curr[skill] += books[i][skill];
                }
                cost += costs[i];
            }
        }
        if (*min_element(curr.begin(), curr.end()) >= x) {
            lowest = lowest == -1 ? cost : min(cost, lowest);
        }
    }

    cout << lowest;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;cin >> t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3612
s = input()
flag = 1
i = 0

while i < len(s):
    if s[i:i+5] == 'dream':
        if s[i+5:i+10] != "erase" and s[i+5:i+7] == "er":
            i += 7
        elif s[i+5:i+11] == "eraser":
            i += 11
        elif s[i+5:i+10] == "erase":
            i += 10
        else:
            i += 5
    elif s[i:i+6] == "eraser":
        i += 6
    elif s[i:i+5] == "erase":
        i += 5
    else:
        flag = 0
        break

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

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    public static void Main()
    {
        int N = NextInt();
        //A終わり　B始まりをカウントしていい感じにする
        int A = 0, B = 0;
        int dottimo = 0;
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            string s = NextString();
            //とりあえず数える
            for (int j = 1; j < s.Length; j++)
                if (s[j - 1] == 'A' && s[j] == 'B') ans++;
            if (s[0] == 'B' && s[s.Length - 1] == 'A') dottimo++;
            else if (s[0] == 'B') B++;
            else if (s[s.Length - 1] == 'A') A++;

        }
        //dottimoは2個以上で-1個作れる
        if (dottimo >= 1)
        {
            if (B != 0) A++;
            if (A != 0) B++;
            ans += dottimo - 1;

        }
        ans += Math.Min(A, B);
        Console.WriteLine(ans);
    }

}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::string A, std::string B, std::string C){
    ll cnt  = 0;
    REP(i, N){
        set<char> tmp;
        tmp.insert(A[i]); tmp.insert(B[i]); tmp.insert(C[i]);
        if(tmp.size()==2){
            cnt ++;
        }
        else if(tmp.size() == 3){
            cnt +=2;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    std::string C;
    std::cin >> C;
    solve(N, A, B, C);
    return 0;
}


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

int		main(void)
{
	char S[11];
	char T[11];
	char U[11];
	int A;
	int B;

	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);
	if (strcmp(S, U) == 0)
		A  -= 1;
	else if (strcmp(T, U) == 0)
		B -= 1;
	printf("%d %d\n", A, B);
	return (0);
}


Measured memory_bytes: 128
def main():
  from collections import deque
  s=input()
  q=int(input())
  turn = 2
  d=deque(s)

  for _ in [0]*q:
      query = input()
      if query[0] == "1":
          t = int(query)
          turn = 3 - turn
      else:
          t,f,c = map(str,query.split())
          if (int(f) + turn)% 2  == 0:
              d.append(c)
          else:
              d.appendleft(c)
  if turn == 2:
      print("".join(d))
  else:
      print("".join(list(d)[::-1]))
main()


Measured memory_bytes: 10328
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
const int M=105;
const int MOD=1e9+7;

int n,m;
char a[N];
int dp[2][N][M];
void Add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

int main()
{
	
	scanf("%s%d",&a,&m);
	while(a[n]!='\0') n++;
	for(int i=0;i<n;i++)
		a[i]-='0';
	
	dp[1][0][0]=1;
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	for(int k=0;k<10;k++)
	{
		Add(dp[0][i+1][(j+k)%m],dp[0][i][j]);
		if(k>a[i]) continue;
		if(k==a[i]) Add(dp[1][i+1][(j+k)%m],dp[1][i][j]);
		else Add(dp[0][i+1][(j+k)%m],dp[1][i][j]);
	}
	printf("%d\n",(dp[0][n][0]+dp[1][n][0]-1+MOD)%MOD);
	
	return 0;
}

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

int main() {
  string a;
  cin >> a;
  int rmax = 0;
  int r = 0;
  for(int i = 0; i < a.size(); i++){
    if(a[i] == 'R'){
      r++;
      if(i == a.size()-1){
        if(r != 0 && r >= rmax) rmax = r;
      }
    }
    if(a[i] != 'R'){
      if(r != 0 && r >= rmax) rmax = r;
      r = 0;
    }
  }
  cout << rmax << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main(void)
{
	int n;
	while (scanf("%d", &n), n){
		
		for (int i = n; 5 <= i; i--){
			// cout << i << endl;
			if (isPrime(i) && isPrime(i-2)){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 884
import java.util.*;
public class Main {
    public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // get a integer
            int n = sc.nextInt();
            // get two integers separated with half-width break
            int k = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if(n > k)
                System.out.println( (k*x) + ( (n-k) * y ) );
            else
                System.out.println(n*x);
    }
}

Measured memory_bytes: 8788
#include<bits/stdc++.h>
using namespace std;
bool f[1000010];
vector<int> v;
int x;
int main(){
	for (int i=2;i<=200000;i++)
		if (f[i]==0){
			v.push_back(i);
			for (int j=i+i;j<=200000;j+=i) f[j]=1;
		}
	cin>>x;
	for (int i=0;i<v.size();i++)
		if (v[i]>=x){
			cout<<v[i]<<endl;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 640
def main():
    n, m, x, y = list(map(int, input().split()))
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    x_list.append(x)
    y_list.append(y)

    zx = max(x_list) + 1
    zy = min(y_list)

    if zx > zy :
        print('War')
    else:
        print('No War')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int K;
	string S;
	cin >> K >> S;

	if (S.size() <= K) {
		cout << S << endl;
	}
	else {
		string ans;
		for (int i = 0; i < K; i++) {
			ans += S[i];
		}
		ans += "...";
		cout << ans << endl;

	}

	return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> p(n); for (int i = 0; i < n; ++i) cin >> p[i];
  sort(begin(p), end(p));
  int res = accumulate(begin(p), end(p), 0);
  res -= p[n - 1] >> 1;
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A[100000];
int main()
{
long long a,b,i,c=1,d=0,n,m,t,j;
cin>>a>>b>>n;
for(i=a;i<=b;i++)
{
  if(i<=a+n-1||i>=b-n+1)
  cout<<i<<endl;
}

return 0;
}


Measured memory_bytes: 3608
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;

using namespace atcoder;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n,q; cin >> n >> q;
    fenwick_tree<ll> BIT(n);
    ll a;
    fr(i,n){
        cin >> a;
        BIT.add(i, a);
    }
    int x,y,z;
    fr(_, q){
        cin >> x >> y >> z;
        if(x)cout << BIT.sum(y, z) << endl;
        else BIT.add(y, z);
    }
    return 0;
}

Measured memory_bytes: 8256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n;
  int i,j;

  bool prime[55000]={};//?´???°??????
  for(i=2;i<55000;i++){
    if(prime[i])continue;
    else
      for(j=2;i*j<55000;j++)
	prime[i*j]=true;
  }

  while(scanf("%d",&n)!=EOF){
    for(i=n-1;i>1;i--)
      if(prime[i]==false){
	cout<<i<<" ";
	break;
      }
    for(i=n+1;i<55000;i++)
      if(prime[i]==false){
	cout<<i<<endl;
	break;
      }
  }
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d,g; cin >> d >> g;
    vector<int> p(d), c(d);
    REP(i,d) cin >> p[i] >> c[i];
    ll ans = INF;
    REP(bit,(1<<d)) {
        ll sum = 0;
        ll cnt = 0;
        REP(i,d) {
            if(bit & (1<<i)) {
                sum += (i+1)*p[i]*100 + c[i];
                cnt += p[i];
            }
        }
        if(sum<g) {
            [&] {
                REPR(i,d) {
                    if(bit & (1<<i)) continue;
                    int tmp = p[i];
                    REP(j,p[i]) {
                        if(sum>=g) return;
                        sum += (i+1)*100;
                        ++ cnt;
                    }
                }
            }();
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Code for B - Mix Juice
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);

  REP(i, N) {
    cin >> p[i];
  }

  sort(p.begin(), p.end());
  int total = 0;
  REP(i, K) {
    total += p[i];
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3624