akhauriyash/Code-Regression huggingface dataset:
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

func Solve(){
  var X, Y, A, B, C int
  NextInt(&X, &Y, &A, &B, &C)
  var P, Q, R []int
  NextIntVec(&P)
  sort.Sort(sort.Reverse(sort.IntSlice(P)))
  NextIntVec(&Q)
  sort.Sort(sort.Reverse(sort.IntSlice(Q)))
  NextIntVec(&R)
  sort.Sort(sort.Reverse(sort.IntSlice(R)))
  p, q, r := X - 1, Y - 1, 0
  for (0 <= p || 0 <= q) && (r < C) {
    if 0 <= p && 0 <= q {
      if P[p] < Q[q] {
        if R[r] <= P[p] { break }
        P[p] = R[r]
        p--
        r++
      } else {
        if R[r] <= Q[q] { break }
        Q[q] = R[r]
        q--
        r++
      }
    } else if 0 <= p {
      if R[r] <= P[p] { break }
      P[p] = R[r]
      p--
      r++
    } else {
      if R[r] <= Q[q] { break }
      Q[q] = R[r]
      q--
      r++
    }
  }
  Write(SumInt(P[:X]...) + SumInt(Q[:Y]...))
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,t; cin>>n>>x>>t;
    if(n%x!=0) cout<<t+(n/x)*t<<endl;
    else cout<<n/x*t<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int K,A,B;
    scanf("%d",&K);
    scanf("%d",&A);
    scanf("%d",&B);
    bool jud=false;
    for(int i=A;i<=B;++i){
        if(i%K==0){
            jud=true;
            break;
        }
    }
    if(jud){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    
    
}


Measured memory_bytes: 3688
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll a[200010];
ll b[200010];
int main()
{
	ll n;
	scanf("%lld", &n);
	for (ll i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (ll i = 0; i < n; i++)
		scanf("%lld", &b[i]);
	ll dap = 0;
	for (ll i = 1; i <= 30; i++)
	{
		ll ch = ((ll)1 << (i-1));
		vector<ll> vt;
		for (ll y = 0; y < n; y++)
			vt.push_back(a[y] % ((ll)1 << i));
		vt.push_back((1 << 30));
		sort(vt.begin(), vt.end());
		ll gap = 0;
		for (ll y = 0; y < n; y++)
		{
			ll ch1 = b[y] % ((ll)1 << i);
			ll t = lower_bound(vt.begin(), vt.end(), ch - ch1) - vt.begin();
			ll o = upper_bound(vt.begin(), vt.end(), ((ll)1<<i)-ch1-1) - vt.begin();
			o--;
			if (o >= t) {
				gap = gap + (o - t) + 1;
			}
			t = lower_bound(vt.begin(), vt.end(), ch - ch1 +((ll)1<<i)) - vt.begin();
			o = upper_bound(vt.begin(), vt.end(), ((ll)1 << i) * 2 - ch1 - 1) - vt.begin();
			o--;
			if(o>=t)
				gap += (o - t+1);
		}
		if (gap % 2)
			dap += ((ll)1 << (i - 1));
	}
	printf("%lld", dap);
}

Measured memory_bytes: 7028
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <unordered_set>
using namespace std;

const int INF = 100001;

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

	vector< vector<int> > mp(INF, vector<int>());
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		mp[a].push_back(b);
	}

	long long ans = 0;
	priority_queue<int> que;
	for(int i=1;i<=m;i++){
		for(int j=0;j<mp[i].size();j++){
			que.push(mp[i][j]);
		}
		if(!que.empty()){
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5632
"""
例２
3 2 5 1 4 6
5と6については昇順になっているので、4,3,2,1の順で配列の先頭に移動させればよい

↑のように考えると、既に並んでいる部分以外を適切な順で動かせばよいので、既に昇順のもので一番長いものをNから引くとよい？

"""

N = int(input())
P = [int(input()) for _ in range(N)]



idxs = [None] * N
for i,p in enumerate(P):
    idxs[p-1] = i

ans = N - 1

cnt = 1

for i in range(1,N):
    if idxs[i] > idxs[i-1]:
        cnt +=1
    else:
        ans = min(ans, N - cnt)
        cnt = 1

ans = min(ans, N - cnt)

print(ans)

Measured memory_bytes: 18888
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k;
  cin >> n>> k;
  vector<int>a(n);
  vector<int>b(n);
  int ri = 0;
  int rcount = 0;
  int count=0;
  int rc=0;
  rep(i,n) cin >> a.at(i);
  rep(i,n) b.at( a.at(i) - 1 )++;
  rep(i,n) if(b.at(i)!=0)count++;
  if(k>=count)cout<<"0"<<endl;
  else{
    sort(b.begin(), b.end());
    for(;;){
      if(b.at(ri)!=0){
      rcount+=b.at(ri);
      rc ++;
      }
      if(k>=count - rc)break;
      ri ++;
    }
      cout << rcount <<endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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 long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<int> n(3);
	rep(i, 3) cin >> n[i];
	sort(n.begin(), n.end());
	int sum = n[2] - n[1] + n[2] - n[0];
	cout << (sum % 2 == 0 ? sum / 2 : (sum + 3) / 2) << endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int s = sc.nextInt();
        int y = s / 100;
        int m = s % 100;
        if ((m > 12 && y > 12) || (m == 0 && y > 12) || (y == 0 && m > 12) || (m == 0 && y == 0)) {
            System.out.println("NA");
            return;
        } else if ((m > 0 && m <= 12) && (y > 0 && y <= 12)) {
            System.out.println("AMBIGUOUS");
            return;
        } else if ((y > 0 && y <= 12) && (m > 12 || m == 0)) {
            System.out.println("MMYY");
            return;
        } else {
            System.out.println("YYMM");
            return;
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22740
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(N) { pairIntLong() }
    val WVc = Array(4) { mutableListOf<Long>() }
    val baseW = WV[0].first.toLong()
    WV.forEach { wv -> WVc[wv.first - WV[0].first].add(wv.second) }
    WVc.forEach {
        it.sortDescending()
        it.add(0, 0)
    }
    val WVs = WVc.map { it.toLongArray() }.toTypedArray()
    var ans = 0L
    for (n0 in (0 until WVs[0].size).reversed()) {
        val w0 = (baseW + 0) * n0
        for (n1 in (0 until WVs[1].size).reversed()) {
            val w1 = (baseW + 1) * n1
            for (n2 in (0 until WVs[2].size).reversed()) {
                val w2 = (baseW + 2) * n2
                for (n3 in (0 until WVs[3].size).reversed()) {
                    val w3 = (baseW + 3) * n3
                    if (w0 + w1 + w2 + w3 > W) continue
                    val v0 = WVs[0].sliceArray(0 .. n0).sum()
                    val v1 = WVs[1].sliceArray(0 .. n1).sum()
                    val v2 = WVs[2].sliceArray(0 .. n2).sum()
                    val v3 = WVs[3].sliceArray(0 .. n3).sum()
                    ans = Math.max(ans, v0 + v1 + v2 + v3)
                }
            }
        }
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

int main() {
  string s;
  cin >> s;
  string t;
  t = s[0];
  int t_size = s.length() - 2;
  t += to_string(t_size);
  t += s[s.length()-1];
  cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, B, C; cin >> A >> B >> C;
	bool is = false;
	int x = A;
	rep(i, 1, 100) {
		if (x % B == C)is = true;
		x += A;
	}
	cout << (is ? "YES" : "NO") << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>



using namespace std;


int main() {
	int s = 0;
	string a;
	cin >> a;
	for (int i = 0; i <= 3 ; i++) {
		if (a[i] == '+') {
			s++;
		}
		else {
			s--;
		}
	}
	cout << s;
}

Measured memory_bytes: 256
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ;

char arr[1069][1069] ;
int n , m , mark[MAXN] ;
vector <int> g[MAXN] ;
queue <int> q ;

void add(int i , int j , int it , int jt) {
	g[(i - 1) * m + j].pb((it - 1) * m + jt) ;
	g[(it - 1) * m + jt].pb((i - 1) * m + j) ;
}
void bfs() {
	while ( q.size() ) {
		int v = q.front() ; q.pop() ;
		for ( auto u : g[v] )
			if ( mark[u] == MOD )
				q.push(u) , mark[u] = min(mark[u] , mark[v] + 1) ;
	}
}

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n >> m ;
	for ( int i = 1 ; i <= n * m ; i ++ )
		mark[i] = MOD ;
	for ( int i = 1 ; i <= n ; i ++ )
		for ( int j = 1 ; j <= m ; j ++ ) {
			cin >> arr[i][j] ;
			if ( arr[i][j] == '#' )
				q.push((i - 1) * m + j) , mark[(i - 1) * m + j] = 0 ;
		}
	for ( int i = 1 ; i <= n ; i ++ ) {
		for ( int j = 1 ; j <= m ; j ++ ) {
			if ( arr[i - 1][j] == '.' or arr[i - 1][j] == '#' )
				add(i , j , i - 1 , j) ;
			if ( arr[i][j - 1] == '.' or arr[i][j - 1] == '#' )
				add(i , j , i , j - 1) ;
			if ( arr[i + 1][j] == '.' or arr[i + 1][j] == '#' )
				add(i , j , i + 1 , j) ;
			if ( arr[i][j + 1] == '.' or arr[i][j + 1] == '#' )
				add(i , j , i , j + 1) ;
		}
	}
	bfs() ;
	int ans = 0 ;
	for ( int i = 1 ; i <= n * m ; i ++ )
		ans = max(ans , mark[i]) ;
	cout << ans << "\n" ;
}


Measured memory_bytes: 118928
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int K,S;
  cin>>K>>S;
  int count=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      int z=S-i-j;
      if(z>=0&&z<=K){
        count++;
      }
    }
  }
  printf("%d",count);

}

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

int main() {
    // your code goes here
    char c[5];
    cin >> c;
    if(c[0]!=c[1]||c[1]!=c[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 155 A - Poor
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/23
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int a, b, c;

void solve() {
    if (a == b && b == c) {
        printf("No\n");
        return;
    }
    if (!(a ^ b) || !(b ^ c) || !(c ^ a)) {
        printf("Yes\n");
        return;
    }
    printf("No\n");
    return;

}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    solve();

}

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

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main(void)
{
    
    int a,b,c,t;
    
    cin >> a >> b >> c;
    
    t = a;
    a = b;
    b = t;
    t = a;
    a = c;
    c = t;
    
    
    
    printf("%d %d %d", a, b, c);
    
}

Measured memory_bytes: 3692
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int>P;
#define X first
#define Y second
int dx[6]={1,0,-1,0,1,-1};
int dy[6]={0,1,0,-1,1,-1};

int main(){
	
	int t,n;
	while(cin>>t>>n,t){
		int mp[200][200];
		/*
		-2:到達不可
		-1:未到達
		0>=:到達コスト
		*/
		memset(mp,-1,sizeof(mp));
		int ans=0;
		int sx,sy;
		queue<P>Q;
		
		
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			mp[x+100][y+100]=-2;
		}
		cin>>sx>>sy;
		sx+=100;
		sy+=100;
		mp[sx][sy]=0;
		ans++;
		Q.push(P(sx,sy));
		while(!Q.empty()){
			P p=Q.front();
			Q.pop();
			if(mp[p.X][p.Y]>t)break;
			//cout<<p.X-100<<" "<<p.Y-100<<endl;
			for(int i=0;i<6&&mp[p.X][p.Y]<t;i++){
				if(mp[p.X+dx[i]][p.Y+dy[i]]==-1){
					mp[p.X+dx[i]][p.Y+dy[i]]=mp[p.X][p.Y]+1;
					Q.push(P(p.X+dx[i],p.Y+dy[i]));
					ans++;
				}
			}
			
			
		}
		
		cout<<ans<<endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1380
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1e18
#define PI 3.14159265359

int n, mxw;
ll memo[100010];
vii items;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, 0, sizeof(memo));
    cin >> n >> mxw;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = mxw - a; j >= 0; j--) {
            memo[j + a] = max(memo[j + a], memo[j] + b);
        }
    }
    cout << memo[mxw] << endl;

    return 0;
}

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

int main(){
	char word[10];
	char T[1000];
	char end[]="END_OF_TEXT";
	int count=0;
	int i=0;
	
	scanf("%s",word);
	
	while(1){
		scanf("%s",T);
		if(strcmp(T,end)==0){
			break;
		}
		while(T[i]!='\0'){
			if(isupper(T[i])){
				T[i]=tolower(T[i]);
			}
			i++;
		}
		i=0;
		
		if(strcmp(T,word)==0){
			count++;
		}
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int H, W;
vector< vector<ll> > mapA;
vector< vector<ll> > mapB;
int diffMax = 13000;
ll dp[80][80][13010];


int main(){

    cin >> H >> W;

    mapA.resize(H);
    mapB.resize(H);

    for(int i = 0; i < H; i++){
        mapA[i].resize(W);
        for(int j = 0; j < W; j++){
            ll num;
            cin >> num;
            mapA[i][j] = num;
        }
    }

    for(int i = 0; i < H; i++){
        mapB[i].resize(W);
        for(int j = 0; j < W; j++){
            ll num;
            cin >> num;
            mapB[i][j] = num;
        }
    }

    int dh[2] = {1, 0};
    int dw[2] = {0, 1};
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            for(int k = 0; k < diffMax; k++){
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][  abs( mapA[0][0] - mapB[0][0] ) + diffMax / 2 ] = 1;
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            for(int n = 0; n < diffMax; n++){
                for(int k = 0; k < 2; k++){

                int nh = i + dh[k];
                int nw = j + dw[k];
                if(nh < 0 || nh >= H) continue;
                if(nw < 0 || nw >= W) continue;
                    if(dp[i][j][n] ){
                        int diff = mapA[nh][nw] - mapB[nh][nw];
                        if(diff + n >= 0 && diff + n < diffMax) dp[nh][nw][ diff + n] = 1;
                        diff = -diff;
                        if(diff + n >= 0 && diff + n < diffMax) dp[nh][nw][ diff + n] = 1;

                    }
                }
            }
        }
    }  

    int ans = diffMax;
    for(int k = 0; k < diffMax; k++){
        if(dp[H-1][W-1][k]) ans = min(ans, abs( k - diffMax / 2 ) );
    }
    cout << ans << endl;

}

Measured memory_bytes: 651008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#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); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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 (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

const double PI = acosl(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++) {
        vector<double> ang;
        for (int j = 0; j < n; j++) {
        if (i != j) {
            ang.push_back(atan2(y[j] - y[i], x[j] - x[i]));
        }
        }
        sort(ang.begin(), ang.end());
        double mx = 0.0;
        for (int j = 0; j < n - 2; j++) {
            mx = max(mx, ang[j + 1] - ang[j]);
        }
        mx = max(mx, ang[0] + 2 * PI - ang[n - 2]);
        double res = (mx > PI ? (mx - PI) / 2 / PI : 0.0);
        cout << fixed << setprecision(17) << res << '\n';
    }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int L = 0, R = 0;
  int l = 0, r = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == ')') {
      if (l) {
        l--;
        continue;
      } else {
        L++;
      }
    } else {
      l++;
    }
  }
  reverse(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '(') {
      if (r) {
        r--;
        continue;
      } else {
        R++;
      }
    } else {
      r++;
    }
  }
  reverse(S.begin(), S.end());
  while (L--) cout << "(";
  cout << S;
  while (R--) cout << ")";
  cout << "\n";
}

Measured memory_bytes: 3616
def prepare(n, MOD):
    factorials = [1] * (n + 1)
    for i in range(2, n + 1):
        factorials[i] = factorials[i - 1] * i % MOD
    finvs = [1] * (n + 1)
    finvs[n] = pow(factorials[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        finvs[i - 1] = finvs[i] * i % MOD
    return factorials, finvs


def solve(n, a):
    MOD = 10 ** 9 + 7
    facts, finvs = prepare(n, MOD)
    invs = [facts[i - 1] * finvs[i] % MOD for i in range(n + 1)]  # invs[0]: undefined
    r = n - a

    ans = 0
    # a個がいずれも自己ループを持たないパターン
    for l in range(a):
        tmp1 = facts[a] * finvs[l] % MOD * finvs[a - l] % MOD
        tmp2 = facts[n - l - 1] * (a - l) % MOD
        ans = (ans + (-1) ** (l & 1) * tmp1 * tmp2) % MOD

    # a個中k+1個目ではじめて自己ループを持つが、それまでのk個で全点灯できるパターン
    for k in range(1, a):
        for l in range(k):
            tmp1 = facts[k] * finvs[l] % MOD * finvs[k - l] % MOD
            tmp2 = facts[n - l - 1] * (k - l) % MOD * invs[r + k - l] % MOD
            ans = (ans + (-1) ** (l & 1) * tmp1 * tmp2) % MOD

    return ans


n, a = map(int, input().split())
print(solve(n, a))


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    map<ll, ll> mp;
    mp[0]=1;
    ll sum=0;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        sum+=a;
        mp[sum]++;
    }

    ll ans=0;
    for(auto x : mp){
        if(x.second>1) ans+=(x.second*(x.second-1)/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
template <unsigned int Modulus>
class IntMod {
	typedef unsigned long long ULL;
private:
	unsigned int value_m;

	void Copy(const IntMod& other) { value_m = other.value_m; }
	bool Modulus_is_valid() { return Modulus != 0; }
public:
	IntMod() { value_m = 0; }
	IntMod(unsigned int value) { value_m = value % Modulus; }
	IntMod(const IntMod& other) { Copy(other); }
	IntMod& operator=(const IntMod& other) { Copy(other); return *this; }
	IntMod& operator==(const IntMod& right) const { return value_m == right.value_m; }
	IntMod& operator!=(const IntMod& right) const { return value_m != right.value_m; }
	IntMod& operator++() {
		++value_m; 
		value_m %= Modulus;
		return *this;
	}
	IntMod& operator--() {
		if (value_m == 0) { value_m = Modulus - 1; }
		else { --value_m; }
		return *this;
	}
	IntMod operator-() const {
		if (value_m == 0) return IntMod(0);
		return IntMod(Modulus - value_m);
	}
	IntMod& operator+=(const IntMod& right) {
		ULL sum = (ULL)value_m + right.value_m;
		if (sum >= (ULL)Modulus) { value_m = (unsigned int)(sum - (ULL)Modulus); }
		else { value_m = (unsigned int)sum; }
		return *this;
	}
	IntMod& operator-=(const IntMod& right) {
		(*this) += (-right);
		return *this;
	}
	IntMod operator+(const IntMod& right) {
		IntMod ret(*this);
		ret += right;
		return ret;
	}
	IntMod operator-(const IntMod& right) {
		IntMod ret(*this);
		ret -= right;
		return ret;
	}
	IntMod& operator*=(const IntMod& right) {
		ULL tmp = (ULL)value_m * right.value_m;
		value_m = tmp % (ULL)Modulus;
		return *this;
	}	
	IntMod& operator/=(const IntMod& right) {
		(*this) *= (right.Inverse());
		return *this;
	}
	IntMod operator*(const IntMod& right) {
		IntMod ret(*this);
		ret *= right;
		return ret;
	}
	IntMod operator/(const IntMod& right) {
		IntMod ret(*this);
		ret /= right;
		return ret;
	}
	/* 素数判定は自分でしろ */
	IntMod Inverse() const {
		return (*this).Pow(Modulus - 2);
	}
	IntMod Pow(unsigned int exp) const {
		unsigned int arr[32];		// 32じゃなくてもいい
		ULL sum = 1;
		arr[0] = value_m;
		for (int i = 1; i < 32; ++i) {
			arr[i] = ((ULL)arr[i - 1] * arr[i - 1]) % (ULL)Modulus;
		}
		for (int i = 0; i < 32; ++i) {
			if (exp & (0x1 << i)) {
				sum *= arr[i]; sum %= (ULL)Modulus;
			}
		}
		return (unsigned int)sum;
	}
	unsigned int Get_value() {
		return value_m;
	}
};

typedef IntMod<1000000007> MInt;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)

string str;
int N, K;

MInt DP[5001][5003];

int main() {
	cin >> N;
	cin >> str;
	K = str.size();

	REP(i, 0, N + 1) {
		REP(j, 0, (N + K) / 2 + 2) {
			if (i == 0) {
				DP[i][j] = (j == 0) ? 1 : 0;
			} else {
				DP[i][j] = (j == 0) ? DP[i - 1][j] + DP[i - 1][j + 1] : DP[i - 1][j - 1] * 2 + DP[i - 1][j + 1];
			}
		}
	}
	cout << (DP[N][K] / MInt(2).Pow(K)).Get_value() << endl;
	return 0;
}

Measured memory_bytes: 98048
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 100000;
int a[MAX_N];

int main() {
  int n, k;
  while (cin >> n >> k) {
    if (n == 0 && k == 0) break;
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i < k) { sum += a[i]; ans = sum; }
      else { sum = sum + a[i] - a[i-k]; ans = max(ans, sum); }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
N = int(input())
d = {}
for i in range(1,N+1):
    d[i] = 0
A = list(map(int,input().split()))
for i in range(N):
    a = A[i]
    d[a] += 1
s = 0
for i in range(1,N+1):
    x = d[i]
    s += (x*(x-1))//2
for i in range(N):
    y = A[i]
    z = s + 1 - d[y]
    print(z)

Measured memory_bytes: 44384
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals("H")){
			System.out.println(b);
		}else if(a .equals("D")){
			if(b.equals("H")){
				System.out.println("D");
			}else if(b.equals("D")){
				System.out.println("H");
			}
		}
	}
}

Measured memory_bytes: 20564
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second
#define pb push_back
#define sz(x) ((int)(x).size())

inline int in(){ int x, y; y = scanf("%d", &x); return x; }

const int N = -1;

int n, a, b;

vector<int> ans, tmp; 

void handle(int i, int j) {
    ans.swap(tmp); 

    ans.clear(); 
    bool st = 0; 

    for(auto x: tmp) {
        if( x == tmp.back() ) {
            ans.pb( x ^ (1<<j) ); 
            ans.pb( x ); 
            ans.pb( x ^ (1<<i) ); 
            ans.pb( x ^ ( (1<<j) | (1<<i) ) ); 
        } else if( st == 0 ) { 
            ans.pb(x); 
            ans.pb( x ^ (1<<i) ); 
            ans.pb( x ^ ( (1<<j) | (1<<i) ) ); 
            ans.pb( x ^ (1<<j) ); 
        } else {
            ans.pb( x ^ (1<<j) ); 
            ans.pb( x ^ ( (1<<j) | (1<<i) ) ); 
            ans.pb( x ^ (1<<i) ); 
            ans.pb(x); 
        }
        
        st ^= 1;
    }
}

void handle(int i) { 
    ans.swap(tmp); 

    ans.clear(); 
    bool st = 0; 

    for(auto x: tmp) { 
        if( st == 0 ) {
            ans.pb(x);
            ans.pb( x ^ (1<<i) );
        } else {
            ans.pb( x ^ (1<<i) );
            ans.pb(x);
        }
        st ^= 1; 
    }
}

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

    b ^= a; 

    if( __builtin_popcount(b) % 2 == 0 ) { 
        cout << "NO" << endl;
        return 0; 
    }

    cout << "YES" << endl;

    ans.pb( a ); 

    bool flag = false;
    int last = -1; 
    for(int j = 0; j < n; j++) 
        if( (b>>j) & 1 ) { 
            if( !flag ) { 
                if( last == -1 ) 
                    ans.pb( a ^ (1<<j) ); 
                else 
                    handle(last, j);
            } else  
                last = j; 
            flag ^= 1; 
        }

    for(int j = 0;j < n; j++) 
        if( ( (b>>j) & 1 ) == 0 ) 
            handle(j); 

    last = -1; 
    for(auto x: ans) { 
        cout << x << ' ';
        if( last != -1 ) 
            assert( __builtin_popcount(last ^ x) == 1 ); 
        last = x; 

    }
    
    cout << endl;


    return 0;
}


Measured memory_bytes: 1996
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_multiset;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef pair<int,int> pii;



int main () {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//        freopen("test_input.txt", "r", stdin);
        double a, b; cin >> a >> b;
        for (int i = 1; i <= 1000000; i++) {
                if (int(i * 0.08) == a && int(i * 0.1) == b) {
                        cout << i;
                        exit(0);
                }
        }

        cout << -1;
        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 FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int getTimes(int x) {
  int cnt = 0;
  while (x > 0 && x % 2 == 0) {
    x /= 2;
    cnt++;
  }
  return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = Inf;
    rep(i, n) {
      int a;  cin >> a;
      ans = min(ans, getTimes(a));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X, K, D;
  cin>>X>>K>>D;
  X = abs(X);
  if(X/D>K) {
    cout<<X-D*K<<endl;
  }
  else {
    if(X/D%2==K%2) cout<<X%D<<endl;
    else cout<<D-X%D<<endl;
  }
}



Measured memory_bytes: 3648
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    const ll N = s.size();

    for (ll i = 0; i < N; i++) {
        if (i < N - 1 && s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (i < N - 2 && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define MAX 25
#define NIL -1

struct Node {int parent, left, right; };

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;
    if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1>h2 ? h1 : h2);
}

int getSibling(int u){
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int degree = 0;
    if (T[u].left != NIL) degree++;
    if (T[u].right != NIL) degree++;
    cout << "degree = " << degree << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    if(T[u].parent == NIL){
        cout << "root" << endl;
    } else if (T[u].left == NIL && T[u].right == NIL){
        cout << "leaf" << endl;
    } else {
        cout << "internal node" << endl;
    }
}

int main(){
    int v, l, r, root = 0;
    cin >> n;
    for(int i=0; i<n; i++) T[i].parent = NIL;
    for(int i=0; i<n; i++){
        cin >> v >> l >> r;
        T[v].right = r;
        T[v].left = l;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }
    for(int i=0; i<n; i++) if (T[i].parent == NIL) root = i;
    setDepth(root, 0);
    setHeight(root);
    for(int i=0; i<n; i++) print(i);
    return 0;
}

Measured memory_bytes: 1164
def check(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
                break
        else:
            return True
    else:
        return False


a = int(input())

for i in range(a, 100500):
    if check(i):
        print(i)
        break

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int x = 0;
  for (; x < n && s[x] != 'A'; ++x);
  int y = n - 1;
  for (; y >= 0 && s[y] != 'Z'; --y);
  printf("%d\n", y - x + 1);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int a;
vector<bool> is_pm( 300000, true );

int main() {
	is_pm[ 1 ] = false;
	for ( int i = 6; i * i <= 300000; i += 7 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j <= 300000; j += i ) {
				is_pm[ j ] = false;
			}
		}
	}
	for ( int i = 8; i * i <= 300000; i += 7 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j <= 300000; j += i ) {
				is_pm[ j ] = false;
			}
		}
	}
	VI pm;
	for ( int i = 8; i <= 300000; i += 7 ) {
		if ( is_pm[ i ] ) {
			pm.push_back( i );
		}
	}
	for ( int i = 6; i <= 300000; i += 7 ) {
		if ( is_pm[ i ] ) {
			pm.push_back( i );
		}
	}
	sort( pm.begin(), pm.end() );
	while ( ~scanf( "%d", &a ) && a != 1 ) {
		printf( "%d:", a );
		for ( int i = 0; i < pm.size(); i++ ) {
			if ( a % pm[ i ] == 0 ) {
				printf( " %d", pm[ i ] );
			}
			if ( a <= pm[ i ] ) {
				break;
			}
		}
		printf( "\n" );
	}
	return 0;
}

Measured memory_bytes: 1380
function main(input) {
   const lines = input.split('\n')
const names = lines[1].split(' ').map(item => +item)
const manzoku = lines[2].split(' ').map(item => +item)
const manzoku_a = lines[3].split(' ').map(item => +item)

let res = 0
for (let i = 0; i < names.length; i++) {
    if (i > 0) {
        if (names[i] - 1 === names[i - 1]) {
            res += manzoku_a[names[i-1] -1]
        }
    }

    res += manzoku[names[i] -1]
}
console.log(res)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int socket = sc.nextInt();
    int need = sc.nextInt();
    if(need == 1){
      System.out.println(0);
    }else if(socket == 1){
      System.out.println(need);
    }else if(need <= socket){
      System.out.println(1);
    }else if((need - socket) % (socket - 1) == 0){
      System.out.println(1 + (need - socket) / (socket - 1));
  }else{
    System.out.println(2 + (need - socket) / (socket - 1));
  }
}
}

Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } //最大公約数


int main() {
	
	//入力
	int N, Q;
	cin >> N >> Q;

	string S;

	cin >> S;

	vector<vector<int>> ques;

	for (int i = 0; i < Q; ++i) {
		vector<int> tmp;
		int q1, q2;
		cin >> q1 >> q2;
		tmp.push_back(q1);
		tmp.push_back(q2);
		ques.push_back(tmp);
	}

	//ある文字数目までにACが何個あるかを記録するvector作成
	int accnt = 0;
	vector<int> acvec;
	for (int i = 0; i < N; ++i) {
		if (i == 0) {
			//何もしない
		}
		else {
			if (S[i-1] == 'A' && S[i] == 'C') {
				accnt++;
			}
		}
		acvec.push_back(accnt);
	}

	for (int i = 0; i < Q; ++i) {
		int s = ques[i][0] - 1;
		int e = ques[i][1] - 1;

		cout << acvec[e] - acvec[s] << endl;
	}
}

Measured memory_bytes: 7856
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1000005;
const ll mod=924844033;
const ll g=5;
ll ksm(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return res;
}
ll fact[N+2],inv[N+2];
void Init(){
    fact[0]=inv[1]=1;
    for(ll i=1;i<=N;i++)
        fact[i]=fact[i-1]*i%mod;
    for(ll i=2;i<=N;i++)
        inv[i]=((mod-mod/i)*inv[mod%i])%mod;
    inv[0]=1;
    for(ll i=1;i<=N;i++)
        inv[i]=inv[i-1]*inv[i]%mod;
}
struct node{
    ll u,v,nxt;
}edge[N*2];
ll head[N],mcnt;
void add_edge(ll u,ll v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
ll sz[N];
ll cnt[N];
ll n;
void dfs(ll u,ll fa){
    sz[u]=1;
    for(ll i=head[u];i;i=edge[i].nxt){
        ll v=edge[i].v;
        if(v==fa)
            continue;
        dfs(v,u);
        sz[u]+=sz[v];
    }
    cnt[sz[u]]--;
    cnt[n-sz[u]]--;
}
void NTT(ll a[],ll n,ll mode){
	for(ll i=0,j=0;i<n;i++)
	{
		if(i<j) swap(a[i],a[j]);
		ll k=(n>>1);
		while(k&&(k&j)){ j^=k; k>>=1; }
		j^=k;
	}
	for(ll i=1;i<n;i<<=1)
	{
		ll w1=ksm(g,(mod-1)/(i<<1)),w=1;
		if(mode==-1) w1=ksm(w1,mod-2);
		for(ll j=0;j<i;j++,w=1ll*w*w1%mod)
			for(ll l=j,r=l+i;l<n;l+=(i<<1),r=l+i)
			{
				ll temp=1ll*w*a[r]%mod;
				a[r]=(a[l]-temp+mod)%mod;
				a[l]=(a[l]+temp)%mod;
			}
	}
	if(mode==-1)
	{
		ll inv=ksm(n,mod-2);
		for(ll i=0;i<n;i++) a[i]=1ll*a[i]*inv%mod;
	}
}
ll a[N];
ll b[N];
int main()
{
    //freopen("calculate.in","r",stdin);
    //freopen("calculate.out","w",stdout);
    Init();
    scanf("%lld",&n);
    for(ll i=1;i<n;i++){
        ll u,v;
        scanf("%lld%lld",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    ll len=1;
    cnt[n]=n;
    for(;len<=n*2;len<<=1) ;
    for(ll i=0;i<=n;i++){
        a[i]=cnt[i]*fact[i]%mod;
        b[i]=inv[n-i];
    }
    NTT(a,len,1);
    NTT(b,len,1);
    for(ll i=0;i<=len;i++)
        a[i]=a[i]*b[i]%mod;
    NTT(a,len,-1);
    for(ll i=1;i<=n;i++){
        ll ans=a[n+i]*inv[i]%mod;
        ans=(ans%mod+mod)%mod;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 62464