akhauriyash/Code-Regression huggingface dataset:
//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(ll (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

const int N = 100005;
int n,a[N];
ll rep[N];


int main()
{
    scanf("%d",&n);
    lp(i, 1, n){
        scanf("%d",&a[i]) ;
        ++rep[a[i]], ++rep[a[i]+1];
        if(a[i]) ++rep[a[i]-1];
    }
    
    
    ll ans = 0;
    lp(i, 1, N-2)
        ans = max(ans, rep[i]);
    
    printf("%lld\n",ans);
    return 0;
}
/*
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);



Measured memory_bytes: 1408
N = gets.to_i
W = gets.split.map(&:to_i)
wn = W.inject(:+)
wl = 0
ans = wn
1.step(N-1) do |t|
  wl += W[t-1]
  ans = [ans, (wl - (wn - wl)).abs].min
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=1e9+7;

int a;
int main(){
	cin>>a;
	if(a/100==a%10)p("Yes");
	else p("No");
	return 0;
}


Measured memory_bytes: 256
A,B = list(map(int,input().split()))

QA=(A-1)//50
QB=(B-1)//50
RA=(A-1)%50
RB=(B-1)%50

def PRINTw(x): #x個の白１黒３ブロック
    for j in range(x):
        print(".#",end="")
    for j in range(50-x):
        print("##",end="")
    print()
    for j in range(100):
        print("#",end="")
    print()
def PRINTb(x): #x個の白３黒１ブロック
    for j in range(100):
        print(".",end="")
    print()
    for j in range(x):
        print(".#",end="")
    for j in range(50-x):
        print("..",end="")
    print()

print("40 100")

for i in range(QA):
    PRINTw(50)
PRINTw(RA)
for i in range(10-(QA+1)):
    PRINTw(0)

for i in range(QB):
    PRINTb(50)
PRINTb(RB)
for i in range(10-(QB+1)):
    PRINTb(0)


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

int main(){
  int n,all = 0,sum = 0,mini = 101;
  cin >> n;
  int w[n];
  for(int i=0;i<n;i++)cin >> w[i];
  for(int i=0;i<n;i++)all += w[i];
  for(int cut=0;cut<n;cut++){
    for(int i=0;i<=cut;i++){
      sum+=w[i];
    }
    //left = all - sum;
    //right = sum;
    //mini = min(mini,abs(left - right));
    mini = min(mini,abs(all-sum-sum));
    sum = 0;
  }
  cout << mini << endl;
  return 0;
}

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

namespace C___Distinct_or_Not
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var a = Console.ReadLine ().Split (' ');
            var hash = new HashSet<string> ();
            foreach (var p in a)
            {
                hash.Add (p);
            }
            if (a.Length == hash.Count)
                Console.WriteLine ("YES");

            else
                Console.WriteLine ("NO");
        }
    }
}

Measured memory_bytes: 47132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string s; cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int idx = -1;
    int cCount = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (!islower(s[i])) {
            if (s[i] == 'C') {
                cCount++;
                idx = i;
                if (cCount > 1) {
                    cout << "WA" << endl;
                    return 0;
                }
            }
            else {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    if (idx > 1 && idx < s.size() - 1) {
        cout << "AC" << endl;
    }
    else {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a + b >= 10){
    cout << "error" << endl;
  }else{
    cout << a + b << endl;
  }

}

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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main()
{
    //fast;
    int t=1;
    while(t--)
    {
       int x;
       cin>>x;
       if(x>=400 && x<=599)
            cout<<8;
       else if(x>=600 && x<=799)
            cout<<7;
       else if(x>=800 && x<=999)
            cout<<6;
       else if(x>=1000 && x<=1199)
            cout<<5;
       else if(x>=1200 && x<=1399)
            cout<<4;
       else if(x>=1400 && x<=1599)
            cout<<3;
       else if(x>=1600 && x<=1799)
            cout<<2;
       else if(x>=1800 && x<=1999)
            cout<<1;
    }
    return 0;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	W, _ := strconv.Atoi(read())
	wv := make([][]int, N)
	for i := 0; i < N; i++ {
		wv[i] = make([]int, 2)
		wv[i][0], _ = strconv.Atoi(read())
		wv[i][1], _ = strconv.Atoi(read())
	}
	// 品物, 重量
	var dp = [105][1e5 + 5]int{}

	for i := 1; i < N+1; i++ {
		w, v := wv[i-1][0], wv[i-1][1]
		for j := 0; j <= W; j++ {
			if 0 <= j-w {
				dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j])
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}
	fmt.Println(dp[N][W])
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 85376
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
asum=0
bsum=0
pointer=0
while pointer<m and bsum+b[pointer]<=k:
	bsum+=b[pointer]
	pointer+=1
ans=pointer
for i in range(n):
	asum+=a[i]
	while asum+bsum>k and pointer>=0:
		pointer-=1
		bsum-=b[pointer]
	if asum+bsum>k:
		break
	ans=max(ans,(i+1)+pointer)
print(ans)

Measured memory_bytes: 117724
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: usize = read();
    let vec: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut a: [i64; 100010] = [<i64>::max_value(); 100010];
    a[0] = 0;

    for i in 0..n-1 {
        a[i+1] = cmp::min(a[i+1], a[i] + (vec[i] - vec[i+1]).abs());
        if i < n-2 {
            a[i+2] = cmp::min(a[i+2], a[i] + (vec[i] - vec[i+2]).abs());
        }
    }

    println!("{}", a[n-1]);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 5116
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int F(int64_t A, int64_t B){
  return log10(max(A, B))+1;
}

int main(){
  int64_t N;
  cin >> N;
  int ans = 11;
  rep2(i, 1, pow(N, 0.5)+1){
    if(N % i == 0){
      chmin(ans, F(i, N/i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  string s;
  cin >> s;
  cout << s << (s.back() == 's' ? "es" : "s") << endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static AtCoderCS.Util;

namespace AtCoderCS
{
	public interface IReader
	{
		string ReadLine();
		int ReadInt();
	}
	public class ConsoleReader : IReader
	{
		public string ReadLine() {
			return Console.ReadLine();
		}
		public int ReadInt() {
			return int.Parse(ReadLine());
		}
	}

	public interface IWriter
	{
		void WriteLine(string line);
		void WriteLine(int value);
		void WriteLine(ulong value);
	}
	public class ConsoleWriter : IWriter
	{
		public void WriteLine(string line){
			Console.WriteLine(line);
		}
		public void WriteLine(ulong value) { Console.WriteLine(value); }
		public void WriteLine(int value) { Console.WriteLine(value); }
	}

	public static class Util
	{
		public static void Dump<T>(this IEnumerable<T> array) {
			var sb = new StringBuilder();
			foreach (var item in array) {
				sb.Append(item);
				sb.Append(" ");
			}
			Console.WriteLine(sb.ToString());
		}
	}

	public class Solver
	{
		readonly IReader _reader;
		readonly IWriter _writer;

		public Solver(IReader reader = null, IWriter writer = null) {
			if (reader == null) {
				_reader = new ConsoleReader();
			} else {
				_reader = reader;
			}

			if (writer == null) {
				_writer = new ConsoleWriter();
			} else {
				_writer = writer;
			}
		}

		public void Run() {
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());
			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			////出力
			//Console.WriteLine((a + b + c) + " " + s);

			var N = _reader.ReadInt();
			//Console.WriteLine(N);

			// DMCを数値化
			var S = _reader.ReadLine();
			byte[] s_ary = new byte[S.Length];
			for (int i = 0; i < S.Length; i++) {
				var c = S[i];
				switch (c) {
					case 'D': s_ary[i] = 1; break;
					case 'M': s_ary[i] = 2; break;
					case 'C': s_ary[i] = 3; break;
				}
			}
			//s_ary.Dump();
			_reader.ReadInt();

			IEnumerable<int> k_ary = _reader.ReadLine().Split(' ').Select<string, int>((s) => {
				return int.Parse(s);
			});
			//k_ary.Dump();

			foreach (var k in k_ary) {
				int sect_len = k - 1;
				ulong d_num = 0;
				ulong m_num = 0;
				ulong dm_num = 0;
				ulong ans = 0;

				// 右端のindexをインクリメントしていく
				for (int r = 0; r < N; r++) {
					// 追加される文字の処理
					var c = s_ary[r];
					if (c == 3) // C
						ans += dm_num;
					else if (c == 1) // D
						++d_num;
					else if (c == 2) {// M
						dm_num += d_num;
						++m_num;
					}

					// 左端から区間外に飛び出す文字の処理
					if (0 <= r - sect_len) {
						var lc = s_ary[r - sect_len];
						if (lc == 1) {// D
							dm_num -= m_num;
							--d_num;
						} else if (lc == 2) {// 
							--m_num;
						}
					}
				}
				_writer.WriteLine(ans);
			}
}
	}

	class MainClass
	{
		public static void Main(string[] args) {
			new Solver().Run();
		}
	}
}


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

map <int, int> mp = {{4, 1}, {6, 1}, {9, 1}, {11, 1}};
map <int, int> mp2 = {{1, 1}, {3, 1}, {5, 1}, {7, 1}, {8, 1}, {10, 1}, {12, 1}};
int main()
{
    int x, y;
    cin >> x >> y;
    if(mp[x] && mp[y] || mp2[x] && mp2[y] || x == 2 && y == 2){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n, k = (int(x) for x in input().split())
    if n <= k:
        print(0)
        return
    hl = [int(x) for x in input().split()]
    hl = sorted(hl, reverse=1)[k:]
    print(sum(hl))


if __name__ == "__main__":
    main()

Measured memory_bytes: 90572
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    txys = ((map(int, line.split())) for line in sys.stdin.readlines())

    pt, px, py = 0, 0, 0
    for t, x, y in txys:
        timeleft =  t - pt - abs(x - px) - abs(y - py)
        if timeleft < 0 or timeleft % 2 == 1:
            print('No')
            break
        pt, px, py = t, x, y
    else:
        print('Yes')


if __name__ == '__main__':
    main()


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

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

  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, 0, n) cin >> p[i];
  int ans = 0;
  rep(i, 2, n) {
    if ((p[i - 1] > p[i - 2] && p[i - 1] < p[i]) ||
        (p[i - 1] < p[i - 2] && p[i - 1] > p[i]))
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long X;
  long money = 100;
  int year = 1;
  cin >> X;
  //cout << X << endl;
  
  while (true) {
    money *= 1.01;
    if (money >= X) {
      cout << year << endl;
      break;
    }
    year++;
  }  
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
	int n,i,j,candy,ans=0;
	int a1[100],a2[100];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a1[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&a2[i]);
	}
	
	for(i=0;i<n;i++){
		candy=0;
		for(j=0;j<=i;j++){
			candy+=a1[j];
		}
		for(j=i;j<n;j++){
			candy+=a2[j];
		}
		if(candy>ans){
			ans=candy;
		}
	}
	
	printf("%d",ans);
	
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    unordered_map<int,int>mp;
    long long ttl=0ll;
    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        mp[dif]++;
        if(dif==0)
            ttl++;
    }

    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        mp[dif]--;
        ttl+=(long long)mp[i+v[i]-v[0]];
    }
    cout << ttl << endl;
    return 0;
}
/***
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5

6
2 3 3 1 3 1
*/


Measured memory_bytes: 19276
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
long long pre[maxn],suf[maxn],id[maxn],ans;
int n,a[maxn],op[maxn];
char s[2];
int main()
{
    scanf("%d",&n);
    scanf("%d",&a[1]),op[1]=1,pre[1]=a[1];
    for(int i=2;i<=n;i++)
    {
        scanf("%s%d",s,&a[i]);
        op[i]=(s[0]=='+'?1:-1);
        pre[i]=pre[i-1]+a[i]*op[i];
    }
    for(int i=n;i>=1;i--) suf[i]=suf[i+1]+a[i];
    id[n+1]=n+1;
    for(int i=n;i>=1;i--)
        if(op[i+1]==-1) id[i]=i+1;
        else id[i]=id[i+1];
    for(int i=2;i<=n;i++)
        if(op[i]==-1) ans=max(ans,pre[i-1]-suf[i]+2*suf[id[i]]);
    printf("%lld",max(ans,pre[n]));
}


Measured memory_bytes: 3328
import numpy as np
import itertools
 
n, d = map(int, input().split())
a = [[int(i) for i in input().split()] for n in range(n)]
count = 0
 
for i in list(itertools.combinations(a, 2)):
  length = 0
  i = np.array(list(i))
  for j in np.array(i[0]-i[1]):
    length += j**2
  if np.sqrt(length).is_integer():
    count+=1
print(count)

Measured memory_bytes: 12452
def we_can(s):
    ptr = 0
    while True:
        if len(s) == abs(ptr):
            return True
        else:
            if ptr == 0:
                if s[ptr-5:] == 'dream' or s[ptr-5:] == 'erase':
                    ptr -= 5
                    continue
                elif s[ptr-6:] == 'eraser':
                    ptr -= 6
                    continue
                elif s[ptr-7:] == 'dreamer':
                    ptr -= 7
                    continue
            if s[ptr-5:ptr] == 'dream' or s[ptr-5:ptr] == 'erase':
                ptr -= 5
                continue
            elif s[ptr-6:ptr] == 'eraser':
                ptr -= 6
                continue
            elif s[ptr-7:ptr] == 'dreamer':
                ptr -= 7
                continue
            return False


s = input()
if we_can(s):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 39664
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    h = {}
    for a in A:
        if a in h:
            h[a] += 1
        else:
            h[a] = 1
    for m in range(M):
        B, C = map(int, input().split())
        if C in h:
            h[C] += B
        else:
            h[C] = B
    nums = list(h.keys())
    nums.sort(reverse=True)
    c = 0
    s = 0
    for i in nums:
        if c + h[i] >= N:
            s += i * (N - c)
            break
        else:
            c += h[i]
            s += i * h[i]
    print(s)

main()


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

int n, k;
vector<bool> dislike(10, false);

// 嫌いな数字が含まれている
bool contain(int n)
{
    string s = to_string(n);
    REP(i, s.length())
    {
        if(dislike[s[i] - '0'] == true) return true;
    }    
    return false;
}

void solve()
{
    cin >> n >> k;
    REP(i, k)
    {
        int tmp;
        cin >> tmp;
        dislike[tmp] = true;
    }

    int ans = 0;
    while(true)
    {
        if(!contain(n))
        {
            ans = n;
            break;
        }
        n++;
    }

    cout << ans << endl;
}

int main()
{
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define ll long long int
#define pii pair <ll , ll >
#define pb push_back
ll x8[] = {1, 1, 1, 0, 0, -1, -1, -1};
ll y8[] = {1, 0, -1, 1, -1, -1, 0, -1};
ll x4[] = {1, -1, 0, 0};
ll y4[] = {0, 0, 1, -1};
ll mod = 1e9 + 7;
ll inf = 1e18;
string k;
int d;
int len;
ll dp[10001][2][101];
ll solve(int pos, int isSmall, int curr)
{
    if(pos == len)
    {
        if(curr % d == 0)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else if(dp[pos][isSmall][curr % d] != -1)
    {
        return dp[pos][isSmall][curr % d] % mod;
    }
    else
    {
        int limit = 9;
        if(!isSmall)
        {
            limit = k[pos] - '0';
        }
        ll ans = 0;
        for(int i = 0; i <= limit; i++)
        {
            if(i < k[pos] - '0')
            {
                ans += solve(pos + 1, 1, (curr + i) % d) % mod;
                ans %= mod;
            }
            else
            {
                ans += solve(pos + 1, isSmall, (curr + i) % d) % mod;
                ans %= mod;
            }
        }
        dp[pos][isSmall][curr] = ans % mod;
        return dp[pos][isSmall][curr];
    }
}
void getac()
{
    string t;
    cin >> t;
    k = t;

    cin >> d;
    len = k.length();
    for(int i = 0; i <= len; i++)
    {
        for(int j = 0; j <= d; j++)
        {
            dp[i][0][j] = -1;
            dp[i][1][j] = -1;
        }
    }
    ll ans = solve(0, 0, 0) % mod;
    ans = (ans - 1 + mod) % mod;
    cout << ans;
}
int  main()
{
    fastio;
    ll t;
    // #ifndef ONLINE_JUDGE
    // freopen("_input.txt", "r", stdin);
    // freopen("_output.txt", "w", stdout);
    // freopen("_error.txt", "w", stderr);
    // #endif

    t = 1;


    while(t--)
    {
        getac();
    }

    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 16896
#include<cstdio>
#define MAX 100
struct Point{double x, y;};
Point T[MAX];

double cross(double x1, double y1, double x2, double y2){
    return x1*y2 - x2*y1;
}

double ccw(Point p1, Point p2, Point p3){
    return cross(p2.x-p1.x, p2.y-p1.y, p3.x-p2.x, p3.y-p2.y);
}

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    for(int i =0; i<n; i++) scanf("%lf %lf", &T[i].x, &T[i].y);

    double result;
    bool flag = true;
    for(int i=0; i<n; i++){
        if(i==0){
            result = ccw(T[n-1], T[i], T[i+1]);
        }
        else if(i == n-1){
            result = ccw(T[i-1], T[i], T[0]);
        }else{
            result = ccw(T[i-1], T[i], T[i+1]);
        }
        if(result <0){
            flag = false;
            break;
        }
    }

    if(flag) printf("1\n");
    else printf("0\n");
    return 0;
}   



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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
vector<ll> enum_divisors(ll N) {
	vector<ll>res;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			res.push_back(i);
			if (N / i != i)res.push_back(N / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
int n;
ll x[3];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	rep(i, n)cin >> x[i];
	ll g = 0;
	rep(i, n) {
		g = gcd(g, x[i]);
	}
	vector<ll> ans = enum_divisors(g);
	for (ll p : ans) {
		cout << p << endl;
	}
	return 0;
}


Measured memory_bytes: 3168
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int[]seq= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		pw.println(seq[sc.nextInt()-1]);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}
 


 

Measured memory_bytes: 22100
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int count = 0;
        for(int i = 0; i < n; i++) {
            int h = sc.nextInt();
            if(max <= h) {
                count++;
                max = h;
            }
        }
        System.out.println(count);
    }
}




Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<int> a(n);

    int now = 1;
    REP(i, n) {
        cin >> a[i];

        if (a[i] == now) {
            now += 1;
        }
    }
    
    if (now == 1) {
        cout << -1 << endl;
    } else {
        cout << n - (now - 1) << endl; 
    }

    return 0;
}


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

deque<char> deq;
int main()
{
    string s;
    cin>>s;
    for(auto tmp : s)
        deq.push_back(tmp);
    bool on=false;
    int q;
    cin>>q;
    while(q--)
	{
        int t;
        cin>>t;
        if(t==1)
			on^=true;
        else
		{
            int f;
            cin>>f;
            char c;
            cin>>c;
            if(on^(f==1))
				deq.push_front(c);
            else
				deq.push_back(c);
        }
    }
    string ans;
    for(auto tmp : deq)
		ans.push_back(tmp);
    if(on)
		reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
#define INF 1001001001001
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    ll n;
    cin >> n;
    ll ans = INF;
    ll sqrtn = (ll)floor(sqrt((ll)n));
    ll a = 1, b = n;
    for(ll i = sqrtn; i >= 1; i--) {
        if(fmod(n, i) == 0){
            a = i;
            b = n / i;
            break;
        }
    }
    cout << a + b - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

struct P{
    int x;
    int y;
    P(){}
    P(int p1,int p2){
        x=p1;
        y=p2;
    }
};


int W,H;
int N;
int dis[100010];
vector<int> posx;
vector<int> posy;
vector<P> pos;

int dist(int x,int y){
    int res=0;
    for(int i=0;i<N;++i){
        int disx=abs(x-pos[i].x);
        int disy=abs(y-pos[i].y);
        dis[i]=disx+disy;
    }
    sort(dis,dis+N);
    for(int i=0;i<N-1;++i)res+=dis[i]*2;
    res+=dis[N-1];
    return res;
}

signed main(){
    cin>>W>>H;
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        posx.PB(x);
        posy.PB(y);
        pos.PB(P(x,y));
    }
    if(N%2!=0){
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int x=posx[N/2];
        int y=posy[N/2];
        int ans=dist(x,y);
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else{
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int ans=INF;
        int x,y;
        int d1=dist(posx[N/2-1],posy[N/2-1]);
        int d2=dist(posx[N/2-1],posy[N/2]);
        int d3=dist(posx[N/2],posy[N/2-1]);
        int d4=dist(posx[N/2],posy[N/2]);
        if(ans>d1){
            ans=d1;
            x=posx[N/2-1];
            y=posy[N/2-1];
        }
        if(ans>d2){
            ans=d2;
            x=posx[N/2-1];
            y=posy[N/2];
        }
        if(ans>d3){
            ans=d3;
            x=posx[N/2];
            y=posy[N/2-1];
        }
        if(ans>d4){
            ans=d4;
            x=posx[N/2];
            y=posy[N/2];
        }
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
}

Measured memory_bytes: 7172
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>


//# define __TRR__


# define lint  long long int


using namespace std;


int n, m, a, b;
bool ok;


int main ()
{
# ifdef __TRR__
   freopen ("A.TXT", "r", stdin);
   freopen ("A.OUT", "w", stdout);
# endif

   cin >> n >> a >> b;

# ifdef __TRR__
   cout << "n = " << n << endl;
   cout << "a = " << a << endl;
   cout << "b = " << b << endl;
# endif

   ok = (abs (a - b) % 2) == 0;

   if ( ok )
      cout << "Alice";
   else
      cout << "Borys";

   return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int i, count=0;

    for(i=0; i<s.size(); i++)
    {
        if(i%2 != 0)
        {
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
                count++;
            else
                break;
        }
        else
        {
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
                count++;
            else
                break;
        }
    }


    if(count < s.size())
        cout<<"No";
    else
        cout<<"Yes";
}


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

int main(){
    int N,K;
    uint64_t ans=0;
    cin >> N >> K;
    for(uint64_t i=K; i<=N+1; i++){
      ans += (N-i+1)*i+1;
      ans %= M0D;
    }
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;


int main(int argc, const char * argv[]) {

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


	vector<int> a(3),b(3),cnt(6,0);
	bool flg;

	for(int i=0;i<3;i++){
		cin >> a[i] >> b[i];
	}

	flg=true;

	for(int i=0;i<3;i++){
		cnt[a[i]]++;
		cnt[b[i]]++;
	}

	for(int i=0;i<6;i++){
		if(cnt[i]>=3) flg=false;
	}

	if(flg){
		cout << "YES";
	}else{
		cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N,0);
    vector<int> count_H(N,1);
    rep(i, N) cin >> H[i];
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        if (H[a-1] <= H[b-1]) {
            count_H[a-1] = 0;
        }
        if (H[b-1] <= H[a-1]) {
            count_H[b-1] = 0;
        }
        
    }

    int count = 0;
    rep(i, N) count += count_H[i];
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4028
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
a = map(int, raw_input().split())

S = sum(a)

ans = 0
diff = INF

for i in range(N):
    if diff > abs(S - a[i] * N):
        diff = abs(S - a[i] * N)
        ans = i

print ans

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> cards(N, 0);
    for (int i = 0; i < M; i++)
    {
        int l, r;
        cin >> l >> r;
        cards[l - 1]++;
        cards[r]--;
    }
    for (int i = 0; i < N; i++)
    {
        if (0 < i)
        {
            cards[i] += cards[i - 1];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (cards[i] == M)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// C.

#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> II;

struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	std::vector<int> _edges;
	UnionFind(int size) : _parent(size, -1), _size(size, 1), _edges(size) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) {
			_parent[rb] = ra, _size[ra] += _size[rb], _edges[ra] += _edges[rb];
		} else {
			_parent[ra] = rb, _size[rb] += _size[ra], _edges[rb] += _edges[ra];
		}
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
	int &edges(int root) { return _edges[root]; }
};

int main(int argc, char *argv[])
{
	vector<II> e;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		e.push_back(II(a, b));
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		UnionFind uf(n + 1);
		for (int j = 0; j < m; ++j) {
			if (i != j) {
				uf.unite(e[j].first, e[j].second);
			}
		}
		ans += uf.size(1) != n;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int H, N, i, j, A;
    scanf("%d %d", &H, &N);
    int a[N];
    
    for(i=0; i<N; i++){
        scanf("%d", &A);
        a[i] = A;
        A = 0;
    }

    for(j=0; j<N; j++){
        H -= a[j];
    }
    
    if(H<=0){
        printf("Yes");
    }
    else{
        printf("No");
    }
        return 0;
}


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

int dy[6]={1,1,0,-1,-1,0};
int dx[6]={0,-1,-1,0,1,1};

int base[1000][1000];
int cnum[300];
char cc[300];

int main(){

  cnum['a']=0;
  cnum['b']=1;
  cnum['c']=2;
  cnum['d']=3;
  cnum['e']=4;
  cnum['f']=5;
  
  cc['a']='d';
  cc['b']='e';
  cc['c']='f';
  cc['d']='a';
  cc['e']='b';
  cc['f']='c';
  
  int n;

  cin>>n;
  
  while(n--){
    
    string s;
    string t;
    
    cin>>s;
    
    if(s=="-"){
      cout<<"true"<<endl;
      continue;
    }

    vector<int> X, Y;
    
    int y=500, x=500;

    memset(base,0,sizeof(base));

    base[y][x]=1;
    X.push_back(x);
    Y.push_back(y);
    
    for(int i=0;i<s.size();i++){
      
      y+=dy[cnum[s[i]]];
      x+=dx[cnum[s[i]]];

      base[y][x]=1;
      X.push_back(x);
      Y.push_back(y);
    }

    cin>>t;
    
    if(t=="-"){
      cout<<"false"<<endl;
      continue;
    }
    
    bool ans=false;
      
    for(int T=0;T<X.size();T++){
        
      for(int i=0;i<6;i++){

	
	int flag=0;

	y=Y[T], x=X[T];
      
	for(int j=0;j<t.size();j++){
      
	  y+=dy[(cnum[t[j]]+i)%6];
	  x+=dx[(cnum[t[j]]+i)%6];
	
	  if(!base[y][x]) flag=1;
	}
      
	if(!flag) ans=true;
      
      }

      reverse(t.begin(),t.end());
    
      for(int i=0;i<6;i++){
      
	int flag=0;
      
	y=Y[T], x=X[T];
	
	for(int j=0;j<t.size();j++){
	
	  y+=dy[(cnum[cc[t[j]]]+i)%6];
	  x+=dx[(cnum[cc[t[j]]]+i)%6];
	
	  if(!base[y][x]) flag=1;
	}

	if(!flag) ans=true;
      
      }
      
      reverse(t.begin(),t.end());

    }
    
    if(s.size()!=t.size()) ans=false;

    if(ans) cout<<"true"<<endl;
    else cout<<"false"<<endl;
    
    cin>>s;
  }
  
  return 0;
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
bool isPrime(ll a)
{
  ll count=0,i;
  rep(i,2,a/2+1)
    if(a%i==0) count++;
    if(count) return false;
    else return true;
}
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n;
 while(n)
 {
   if(isPrime(n)) {cout<<n;break;}
   n++;}
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int ans = 0;
  rep(i, 0, 10) {
    int a;
    cin >> a;
    ans += a;
  }
  cout << ans << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    int c[m], d[m];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int min_dist = INF;
        int min_num;

        rep(j, m) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < min_dist) {
                min_dist = dist;
                min_num = j;
            }
        }
        cout << min_num + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int digit(int n) {
    int ret = 0;
    while(n) {
        n /= 10;
        ret++;
    }
    return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  int n; cin >> n;

  long ans = 0;
  for(int i=1; i <= n; ++i) {
      if(digit(i)&1) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    ll suma=0,sumb=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0;i<n;i++) {
        cin>>b[i];
        sumb+=b[i];
    }
    if(suma<sumb) cout<<-1<<endl;
    else{
        ll sub=suma-sumb;
        int ans=0;
        vector<pair<int,pair<int,int>>> pa(n);
        for(int i=0;i<n;i++) pa[i]={a[i]-b[i],{a[i],b[i]}};
        sort(pa.begin(),pa.end());
        for(int i=0;i<n;i++){
            if(pa[i].first<0) ans++;
            else if(pa[i].first>0){
                if(sub>=pa[i].first) sub-=pa[i].first;
                else ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
    private int totalVertex;
    Queue<Integer> toVisit;
    private LinkedList<LinkedList<Integer>> adjList;
    int[] distance;
    //adjacency list of edges
    public Graph() { totalVertex = 0; }
    public void loadAdjList() {
        Scanner in = new Scanner(System.in);
        totalVertex = in.nextInt();
        toVisit = new LinkedList<Integer>();
        distance = new int[totalVertex];
        adjList = new LinkedList<LinkedList<Integer>>();
        for(int i = 0; i < totalVertex; i ++) {
            LinkedList<Integer> tmp = new LinkedList<Integer>();
            int idx1 = in.nextInt() - 1;
            int degree = in.nextInt();
            //System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
            for(int j = 0; j < degree; j ++) {
                int idx2 = in.nextInt() - 1;
                tmp.add(idx2);
            }
            adjList.add(tmp);
        }

        for(int i = 1; i < totalVertex; i++)
            distance[i] = Integer.MAX_VALUE;

        in.close();
    }

    public void BFS(int v){
        toVisit.add(v);
        while(!toVisit.isEmpty()){
            int next = toVisit.remove();
            for(int neighbor : adjList.get(next)){
                if(!toVisit.contains(neighbor)){
                    if(distance[neighbor] > distance[next] + 1){
                        toVisit.add(neighbor);
                        distance[neighbor] = distance[next] + 1;
                    }
                }
            }
        }
    }
    public void search(){
        BFS(0);
        for(int i = 0; i < totalVertex; i++){
            if(distance[i] == Integer.MAX_VALUE)
                distance[i] = -1;
            System.out.println(i + 1 + " " + distance[i]);
        }
    }
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main{
    public static void main(String argv[]) {
        Graph g = new Graph();
        g.loadAdjList();
        g.search();
    }
}


Measured memory_bytes: 28516
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
using namespace std;
int main(int argc, char const *argv[]) {
    long long n,m,tmp;
    long long MOD = 1000000007;
    std::cin >> n>>m;
    std::vector<bool> br(n+1);
    std::vector<long long> dp(n+1);
    for (size_t i = 0; i < m; i++) {
        std::cin >> tmp;
        br[tmp]=true;
    }
    dp[0]=1;
    for(int i=1;i<=n;i++){
        if(br[i]){
            dp[i]=0;
        }else{
            if(i==1)dp[1]+=dp[0];
            else dp[i]+= dp[i-1]%MOD+dp[i-2]%MOD;
        }
    }
    std::cout << dp[n]%MOD << '\n';

}


Measured memory_bytes: 1024
n, m = map(int, input().split())
XY = []
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    XY.append([x, y])

B = [["w", 1] for _ in range(n)]
B[0][0] = "r"

for i in range(m):
    x, y = XY[i]
    if B[y][1] == 0:
        B[y][0] = B[x][0]
    elif B[x][0] != B[y][0]:
        B[y][0] ="rw"
    B[x][1] -= 1
    B[y][1] += 1
    if B[x][1] == 0:
        B[x][0] = " "


ans = 0
for i in range(n):
    if B[i][1] >= 1 and B[i][0] == "r" or B[i][0] == "rw":
        ans += 1

print(ans)
    

Measured memory_bytes: 29772
//
//  main.cpp
//  Sample
//
//  Created by h3037183 on 2017/07/31.
//  Copyright ?? 2017??´ ?°????. All rights reserved.
//

#include <iostream>
using namespace std;
int main(){
    int i,l,j;
    for(i=1;i<10;i++){
        for(l=1;l<10;l++){
            j=i*l;
            cout<<i<<"x"<<l<<"="<<j<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3092
x = int(input())
y = x + 100
is_prime = [False] * 2 + [True for _ in range(2, y+1)]
prime = []
for i in range(2, y+1):
	for j in range(i*2, y+1, i):
		is_prime[j] = False
for i in range(y+1):
	if is_prime[i]:
		prime.append(i)
for i in range(len(prime)):
  if prime[i] >= x:
    print(prime[i])
    break
  else:
    continue

Measured memory_bytes: 4632