akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};

void print(Point p) {printf("%.8f %.8f\n", p.x, p.y);}

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	print(s);
	koch(n - 1, s, u);
	print(u);
	koch(n - 1, u, t);
	print(t);
	koch(n - 1, t, b);
}

int main() {

	Point a, b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	print(a);
	koch(n, a, b);
	print(b);
	return 0;
}



Measured memory_bytes: 2740
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * N
R = [0] * N

for i in range(N - 1):
    L[i + 1] = gcd(L[i], A[i])
    R[N - 2 - i] = gcd(R[N - 1 - i], A[N - 1 - i])

res = []
for j in range(N):
    res.append(gcd(L[j], R[j]))

res = max(res)
print(res)

Measured memory_bytes: 90088
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] Vi = new int[N];
        for (int i = 0; i < Vi.length; i++) {
            Vi[i] = stdIn.nextInt();
        }
        int[] Ci = new int[N];
        for (int i = 0; i < Ci.length; i++) {
            Ci[i] = stdIn.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < N; i++) {
            if (Vi[i] - Ci[i] > 0) {
                sum += Vi[i] - Ci[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
N=int(input())
p=list(map(int,input().split()))

P=sorted(p)
diff=[]
index=[]

#print(P)

if P==p:
    print("YES")
else:
    for i in range(N):
        if p[i]!=P[i]:
            diff.append(p[i])
            index.append(i)
    if len(diff)>2:
        print("NO")
    else:
        p[index[0]]=diff[1]
        p[index[1]]=diff[0]
        if P==p:
            print("YES")
        else:
            print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  deque<P> que;
  vector<vector<int>> dp(H, vector<int>(W, -1));
  REP(i, H) REP(j, W) if(A[i][j] == 'S') {
    que.push_back(make_pair(i, j));
    dp[i][j] = 0;
  }
  vector<int> dx = {-1, 1, 0, 0};
  vector<int> dy = {0, 0, -1, 1};
  while(!que.empty()) {
    P p = que.front();
    if(dp[p.first][p.second] == K) break;
    que.pop_front();
    if(p.first == 0 || p.first == H-1 || p.second == 0 || p.second == W-1) {
      cout << 1 << endl;
      return 0;
    }
    REP(k, 4) {
      if(A[p.first+dx[k]][p.second+dy[k]] != '#' && dp[p.first+dx[k]][p.second+dy[k]] == -1) {
        dp[p.first+dx[k]][p.second+dy[k]] = dp[p.first][p.second] + 1;
        que.push_back(make_pair(p.first+dx[k], p.second+dy[k]));
      } 
    }
  }
  REP(i, H) REP(j, W) if(dp[i][j] >= 0 && A[i][j] != '#') {
    que.push_back(make_pair(i, j));
    dp[i][j] = K;
  }
  while(true) {
    P p = que.front();
    que.pop_front();
    if(p.first == 0 || p.first == H-1 || p.second == 0 || p.second == W-1) {
      cout << (dp[p.first][p.second] - 1) / K + 1 << endl;
      return 0;
    }
    REP(k, 4) {
      if(dp[p.first+dx[k]][p.second+dy[k]] == -1) {
        dp[p.first+dx[k]][p.second+dy[k]] = dp[p.first][p.second] + 1;
        que.push_back(make_pair(p.first+dx[k], p.second+dy[k]));
      }
    }
  }

}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 1234567;

ll cnt[N];

int main() {
  int n;
  ll m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  ll sum = 0;
  for (int i = 1; i < N; i++) {
    sum += cnt[i];
    if (m <= sum) { cout << i << endl; break; }
  }
  return 0;
}


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

int main(void){
	int n,max,min;
        long sum = 0;
	cin >> n;
	double *a = new double[n];
	for(int j = 0;j < n; j++){
		cin >> a[j];
	}
	
	min = a[0];
	max = a[0];

	for(int i = 0;i < n;i++){
		if(min > a[i]){
			min = a[i];
		}
		if(max < a[i]){
			max = a[i];
		}
		sum += a[i];
	}
	delete[] a;
	cout << min << " " << max << " " << sum << endl;
	return 0;
} 

Measured memory_bytes: 1312
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define int long long int

using namespace std;

int32_t main(void) {
    fast;
    int a; cin>>a;
    string s; cin>>s;
    if(a>=3200) 
        cout<<s;
    else
        cout<<"red";
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	
	void cal()
	{
		Scanner sc=new Scanner(System.in);
		int H,A;
		H=sc.nextInt();
		A=sc.nextInt();
		int i=0;
		while(H>0)
		{
			H=H-A;
			
			i++;
			
		}
		System.out.println(i);
		
		
	}
	
	
	
	
	




public static void main (String args[])
{
	Main obj= new Main();
	obj.cal();

}
}





Measured memory_bytes: 21844
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.07 16:00:25
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

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

int main() {
    int n, d;
    cin >> n >> d;
    int d1 = d * 2 + 1;

    cout << (n - 1) / d1 + 1 << '\n';

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
def chk(n):
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True
ans=[]
for i in range(2,10000*1000+1):
  if chk(i) and i%5==1:
    ans.append(i)
  if len(ans)>=n:
    break
print(' '.join(map(str,ans)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

vector<int> e[100000];
int num[100000];

void dfs(int v){
    int ma=-1;
    for(int u:e[v]){
        if(num[u]==-1)dfs(u);
        ma=max(ma,num[u]);
    }
    num[v]=ma+1;
}

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;
        e[x].push_back(y);
    }
    for(int i=0;i<n;i++){
        num[i]=-1;
    }
    for(int i=0;i<n;i++){
        if(num[i]==-1){
            dfs(i);
        }
    }
    int ans=-1;
    for(int i=0;i<n;i++){
        ans=max(ans,num[i]);
    }
    cout<<ans<<endl;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string S;
  cin >> N >> S;
  vector<map<char, int>> c_map;
  c_map.push_back({make_pair(S.at(0), 1)});

  REPI(i, 1, N) {
    map<char, int> m = c_map.at(i - 1);
    if (m.find(S.at(i)) == m.end()) {
      m.insert(make_pair(S.at(i), 1));
    } else {
      ++m.at(S.at(i));
    }

    c_map.push_back(m);
  }

  // for (auto s : c_map) {
  //   for (auto c : s) {
  //     cout << c.first << ":" << c.second << endl;
  //   }
  //   cout << endl;
  // }

  int ans = 0;
  REP(i, N) {
    int count = 0;
    auto m1 = c_map.at(i);
    auto m2 = c_map.at(N - 1);
    for (auto const &it : m1) {
      m2.at(it.first) -= it.second;
      if (m2.at(it.first) > 0) {
        ++count;
      }
    }

    ans = max(ans, count);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
 
void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = readln.chomp;
    
    auto ans = arr.uniq.array.length;
    
    ans.writeln;
}

Measured memory_bytes: 2556
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long llt;

const int MAXN = 5000;
const llt Mod = 1000000007;

int N, len;
char str[MAXN+1];
llt dp[MAXN+1][MAXN+1];

void init()
{
    memset( dp, 0, sizeof dp );
    scanf( "%d\n", &N );
    scanf( "%s", str );
    len = strlen( str );
}

llt fast_pow( llt low, int high )
{
    llt ans = 1;
    while ( high )
    {
        if ( high & 1 ) ans = ans * low % Mod;
        high >>= 1;
        low = low * low % Mod;
    }
    return ans;
}

llt Mod_inverse( llt x ) { return fast_pow( x, Mod - 2 ); }

void solve()
{
    dp[0][0] = 1;
    for ( int i = 1; i <= N; ++i )
    {
        dp[i][0] = ( dp[i - 1][1] + dp[i - 1][0] ) % Mod;
        dp[i][i] = dp[i - 1][i - 1] * 2 % Mod;
        for ( int j = 1; j < i; ++j )
            dp[i][j] = ( dp[i - 1][j - 1] * 2 + dp[i - 1][j + 1] ) % Mod;
    }
    //for ( int i = 1; i <= N; ++i ) for ( int j = 0; j <= len; ++j )
    //    printf( "dp[%d][%d] = %lld\n", i, j, dp[i][j] );
    llt ans = dp[N][len] * Mod_inverse( fast_pow( 2, len ) ) % Mod;
    printf( "%lld\n", ans );
}

int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 195712
/*
 Algorithms and Data Structures 1
 Name: Ryuya Asada
 ID: s1260064
*/


#include <stdio.h>
#include <stdlib.h>


void peek(int, int[]);
void InsertionSort(int, int[]);


int main(int argc, char* argv[]) {
    int length = 0;
    int A[100];

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

    InsertionSort(length, A);
    peek(length, A);

    return 0;
}


void peek(int length, int A[]) {
    for(int i=0; i < length; ++i) {
        if(i != 0)
            printf(" ");
        
        printf("%d", A[i]);
    }
    printf("\n");
}


void InsertionSort(int length, int A[]) {
    for(int i=1; i < length; ++i) {
        int key = A[i];
        int j = i - 1;
        peek(length, A);
        while(j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            --j;
        }
        A[j+1] = key;
    }
}



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

const int N = 100;
int rsum[N+1][N];
int in[N][N];

void precalc(int n){
  for(int j=0;j<n;j++){
    rsum[0][j] = 0;
    for(int i=0;i<n;i++){
      rsum[i+1][j] = rsum[i][j] + in[i][j];
    }
  }
}

int maximumSum1D(int n,int *a){
  int ret = a[0],cur = a[0];
  for(int i=1;i<n;i++){
    if (cur < 0){
      cur = a[i];
    }else {
      cur = cur + a[i];
    }
    ret = max(ret,cur);
  }
  return ret;
}

int solve(int n){
  int ret = 0;
  int a[n];
  for(int i=0;i<n;i++){
    for(int k=i;k<n;k++){
      for(int j=0;j<n;j++){
	a[j] = rsum[k+1][j] - rsum[i][j];
      }
      ret = max(ret,maximumSum1D(n,a));
    }
  }
  return ret;
}

main(){
  int n;
  while(cin>>n && n){
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    cout << maximumSum1D(n,a) << endl;
  }
}

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

int main() {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int mxx=x;
    int mny=y;
    int a;
    for (int i=0;i<n;i++) {
        cin>>a;
        mxx=max(mxx,a);
    }
    for (int i=0;i<m;i++) {
        cin>>a;
        mny=min(mny,a);
    }
    if (mxx<mny)
        puts("No War");
    else
        puts("War");
    return 0;
}

Measured memory_bytes: 256
from collections import deque
S = deque(input())
Q = int(input())
#W, H, N = map(int, input().split())
lst = []
for i in range(Q):
    lst.append(list(input().split()))
#print(lst)

flag = 'left' #文字列が左向き
for i in range(Q):
    if flag == 'left':
        if lst[i][0] == '1':
            flag = 'right'
        else:
            if lst[i][1] == '1':
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])
    else: #flag == right
        if lst[i][0] == '1':
            flag = 'left'
        else:
            if lst[i][1] == '1':
                S.append(lst[i][2])
            else:
                S.appendleft(lst[i][2])
if flag == 'left':
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))
    

Measured memory_bytes: 35444
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    SORT(s);
    REP(i,s.length()-1){
        if(s[i]==s[i+1]){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>

int a, b, c, d;

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

	if (abs(a-c) <= d)
		printf ("Yes") ;

	else if (abs(a-b) <= d && abs(b-c) <= d)
		printf ("Yes") ;

	else if (abs(a-c) > d)
		printf ("No") ;

	else if (abs(a-b) > d || abs(b-c) > d)
		printf ("No") ;
}

Measured memory_bytes: 128
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	ans := powInt(10, 12)
	sqrtn := int(math.Sqrt(float64(N)))
	for x := 1; x <= sqrtn; x++ {
		if N%x != 0 {
			continue
		}
		ans = minInt(ans, x+(N/x)-2)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1800
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	string s;
  	cin >> s;
  	if (s[2] == s[3] && s[4] == s[5])
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<cassert>
using namespace std;

typedef function<int(int[3])> node_t;
int sub[3]={2,1,0};
int mul[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int add[3][3]={{0,1,2},{1,1,2},{2,2,2}};

string s;
int cur=0;

char readchar()
{
    assert(cur<s.size());
    char ret=s[cur];
    cur+=1;
    return ret;
}

node_t parse()
{
    char c=readchar();
    if(isdigit(c))
      return [=](int[3]) { return c-'0'; };
    if(isalpha(c))
      return [=](int a[3]) { return a[c-'P']; };
    node_t left=parse();
    if(c=='-')  
      return [=](int a[3]) { return sub[left(a)]; };
    assert(c=='(');
    char op=readchar();
    node_t right=parse();
    cur++;
    if(op=='*')
      return [=](int a[3]) { return mul[left(a)][right(a)]; };
    return [=](int a[3]) { return add[left(a)][right(a)]; };
}

int solve()
{
    cur=0;
    auto tree=parse();
    int count=0;
    for(int p:{0,1,2})
       for(int q:{0,1,2})
          for(int r:{0,1,2})
          {
              int a[]={p,q,r};
              if(tree(a)==2)
                count++;
          }
    return count;
}

int main()
{
    while(cin >> s && s !=".")
        cout << solve() << endl;
}


Measured memory_bytes: 3216
N = int(input())
A = list(map(int, input().split()))
ans = [-1]*N
ans[0] = sum(A[::2])-sum(A[1::2])

for i in range(1, N):
    ans[i] = 2*A[i-1] - ans[i-1]

print(' '.join(map(str, ans)))

Measured memory_bytes: 19096
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

//-------------------------------------------------//
//素数判定
//isPrime(x): x が素数なら true, 合成数なら falseを返す
//計算量は O[√x]
//[2以外の偶数は素数ではない]
//[合成数 x は P <= √x を満たす素因数 p を持つ] 素数の性質を利用
//-------------------------------------------------//
int isPrime( int x) {
  int i;
  if(x < 2) return 0;
  else if (x == 2)  return 1;   //2は素数
  if (x % 2 == 0) return 0;     //2以外の偶数は素数ではない
  for(i = 3; i*i <= x; i += 2){ //P <= √x を満たす素因数 p を持つなら素数ではない
    if (x % i == 0) return 0;
  }
  return 1;
}



int main() {
  int x;
  cin >> x;
  while(1){
    if(isPrime(x)) break;
    ++x;
  }

  cout << x << endl;

  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n, a, b;
	cin >> n >> a >> b;

	if (a * n > b)
	{
		cout << b << endl;
	}
	else
	{
		cout << a * n << endl;
	}

}

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

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

    short d = 0;
    for(short i = 1;i <= n; i++){
        short a, b;
        cin >> a >> b;
        if(a == b) d++;
        else{
            if(d < 3) d = 0;
        }
    }
    if(d >= 3) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3620
st = gets.chomp.split("")
st2 = gets.chomp.split("")
st3 = st2.pop
st4 = st.length
i = 0

st4.times do
    if st[i] != st2[i]
      puts "No"
      exit
    end
    i += 1
  end

  if st4 != st2.length
  puts "No"
  exit
end
puts "Yes"


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

bool isPrime[100005] = {};

int main()
{
  fill_n(isPrime, 100005, true);
  for (size_t i = 2; i < 100005; i++)
  {
    if (isPrime[i])
    {
      for (size_t j = 2 * i; j < 100005; j = j + i)
      {
        isPrime[j] = false;
      }
      
    }
    
  }
  int x; cin >> x;
  for (size_t i = x; i < 100005; i++)
  {
    //cout << "isPrime[" << i << "]: " << isPrime[i] << endl;
    if (isPrime[i])
    {
      cout << i << endl;
      return 0;
    }
    
  }
   
}

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

int main()
{
    long long n, w;
    
    cin >>n >> w;
    vector<int> weight(n), value(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
        sum+= value[i];
    }
    
    const long long INF = 1e18L +1;
    vector<long long> dp(sum+1, INF);
    dp[0] = 0; 
    for(int i = 0; i < n; i++){
        for(int j = sum - value[i]; j >=0; j--){
            dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
        }
    }
    long long answer = 0;
    for(int i = 0; i <= sum; i++){
        if(dp[i] <= w)
            answer = max(answer, (long long)i);
    }
    
    cout << answer;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int h,w,k;
  cin >> h >> w >>k;
  vector<vector<char>> c(h);
  rep(i,h) {
    rep(j,w) {
      char ch;
      cin >>ch;
      c[i].push_back(ch);
    }
  }
  int ans=0;
  rep(i,1<<h) {
    rep(j,1<<w) {
      int cnt = 0;
      rep(ii,h) {
        if(i&(1<<ii)){ 
        rep(jj,w) {
          if((j&(1<<jj))&&c[ii][jj]=='#') {
            cnt++;
          }
        }
      }
      }
      if(cnt==k) {
        ans++;
        //cout << i<<" "<<j << endl;
      }   
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 5 + 1e18;
const ll MAX = 5+ 3e5;
int n,a[MAX];
int dp[MAX];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    dp[0] = INF32;
    dp[1] = 0;
    for(int i=2;i<=n;i++)
    dp[i] = min(dp[i-1] + abs( a[i] - a[i-1] ),dp[i-2] + abs( a[i] - a[i-2] )  );
    cout << dp[n] << endl;
    return 0;
}


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

using namespace std;
const int N = 1000005;

long long a[3];
bool b;

void init(){
   for(int i = 0; i < 3; i++){
       cin >> a[i];
       if(a[i] % 2 == 0) b = 1;
   }
   if(b){
        puts("0");
        return;
   }
   sort(a,a+3);
   cout << a[0] * a[1] << endl;
}

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

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/21/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll MOD = 998244353;
constexpr ll MAX_GRANDY = 512;

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

  int N; cin>>N;
  vector<int> graph[3][N+1];
  for (int i = 0; i < 3; i++) {
    int M; cin>>M;
    for (int m = 0; m < M; m++) {
      int a,b; cin>>a>>b;
      if (a > b) swap(a,b);
      graph[i][a].push_back(b);
    }
  }

  vector<ll> pw(N+1);
  pw[0] = 1;
  constexpr ll p = ll(1e18)%MOD;
  for (int i = 1; i <= N; i++) {
    pw[i] = pw[i-1]*p%MOD;
  }

  array<array<ll, MAX_GRANDY>, 3> cnt={};
  for (int i = 0; i < 3; i++) {
    vector<int> gr(N+1, 0);
    for (int v = N; v >= 1; v--) {
      unordered_set<int> ps;
      for (auto t : graph[i][v])
        ps.insert(gr[t]);
      while (ps.count(gr[v]) > 0)
        ++gr[v];
      cnt[i][gr[v]] += pw[v];
      cnt[i][gr[v]] %= MOD;
    }
  }

  ll ans = 0;
  for (int i = 0; i < MAX_GRANDY; i++) for (int j = 0; j < MAX_GRANDY; j++) {
    ans += cnt[0][i] * cnt[1][j] % MOD * cnt[2][i^j] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13824
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A,B,C;
    map<string,int> S;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        string s;
        cin>>s;
        if(S.find(s)!=S.end())S[s]++;
        else S.insert({s,1});
    }
    cin>>M;
    REP(i,M){
        string s;
        cin>>s;
        if(S.find(s)!=S.end())S[s]--;
        else S.insert({s,-1});
    }
    for(auto x:S){
        if(x.second>0)ans=max(ans,(ll)x.second);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x, y, n, m;
		int x1[], y1[], ans[];
		int max = -200, min = 200;

		n = sc.nextInt();
		m = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		x1 = new int[n];
		y1 = new int[m];
		int count = -10000;

		for (int i = 0; i < n; ++i) {
			x1[i] = sc.nextInt();
			max = Math.max(max, x1[i]);
		}
		for (int i = 0; i < m; ++i) {
			y1[i] = sc.nextInt();
			min = Math.min(min, y1[i]);
		}

		if (y - x < 1) {
			System.out.println("War");
		} else {
			for (int i = 0; i < y - x; ++i) {
				if (max < i + x + 1 && min >= i + x + 1) {
					count = i + x + 1;
				}

			}
			if (count < -1000) {
				System.out.println("War");
			} else {
				System.out.println("No War");
			}

		}

		sc.close();

	}

}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N+1), B(N);
  for(int i=0; i<N+1; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  int64_t Ans=0;
  for(int i=0; i<N; i++){
    if(B.at(i)<=A.at(i)){
      Ans+=B.at(i);
    }
    else if(B.at(i)<=A.at(i)+A.at(i+1)){
      Ans+=B.at(i);
      A.at(i+1)=A.at(i+1)+A.at(i)-B.at(i);
    }
    else{
      Ans+=A.at(i+1)+A.at(i);
      A.at(i+1)=0;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 1792
"use strict"
const Main = (input) =>{
  let xs = input.trim().split(" ").map(v=>parseInt(v,10));
    let A = xs[0];
    let B = xs[1];
    let C = xs[2];
    let ans = "NO";
      for(let i = 0; i <= B; i++)
        if(A*i%B==C){
        ans = "YES";
        }
    console.log(ans);
  }
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
const output = (x: any) => console.log(x)
// debug(input)
const [S, T] = input
S === T.slice(0, -1) ? output('Yes') : output('No')



Measured memory_bytes: 29636
#include <stdio.h>

int main(void)
{
	int h,w,h2;
	int i,j,k;
	
	while(1){
		scanf("%d %d",&h,&w);
		
		if(h==0&&w==0) break;

		h2=h-2;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0||i==h-1)printf("#");
				else{
					if(j==0||j==w-1)printf("#");
					else{printf(".");}
				}
			}


			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var s = io.S;

        io.Write(s.Replace(',', ' '));
    }
}

Measured memory_bytes: 13268
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B = LI()

for i in range(1,1010):
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 38704
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	string s,t;
	cin >> s >> t;
	vector<int> a(26),b(26);
	for(int i=0; i<s.length(); i++){
		a[s[i]-'a']++;
		b[t[i]-'a']++;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int flag=1;
	for(int i=0; i<26; i++){
		if(a[i]!=b[i])flag=0;
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}	

Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;

int N, M, L, R, D;
vector<pair<int, int> > adj[100000];

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> L >> R >> D;
        L--; R--;
        adj[L].push_back(make_pair(R, D));
        adj[R].push_back(make_pair(L, -D));
    }

    bool visited[100000] = {};
    int dist[100000] = {};
    for(int i = 0; i < N; i++){
        if(!visited[i]){
            stack<int> st;
            st.push(i);
            dist[i] = 0;
            while(!st.empty()){
                int now = st.top(); st.pop();
                visited[now] = true;
                for(int j = 0; j < adj[now].size(); j++){
                    int next = adj[now][j].first;
                    int d = adj[now][j].second;
                    if(!visited[next]){
                        st.push(next);
                        dist[next] = dist[now]+d;
                    }else{
                        if(dist[next] != dist[now] + d){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 9728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a * b);
  }
}

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

int main(){
    long N;
    long tmp=0;
    cin >> N;
    vector<long> A(5);
    for(int i=0;i<5;++i) cin >> A[i];
    sort(A.begin(),A.end());
    tmp=(N+A[0]-1)/A[0];
    cout << tmp + 4 << endl;    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


dp = [-1]*100100
def rec(v, G):
    if dp[v]!=-1:
        return dp[v]
    
    cnt = 0
    for nv in G[v]:
        cnt = max(cnt, rec(nv, G) + 1)
    
    dp[v] = cnt
    return dp[v]


def main():
    N, M = map(int, input().split())
    
    G = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        G[x].append(y)
    
    ans = 0
    for v in range(N):
        ans = max(ans, rec(v, G))

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 139100
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
ll dp[100005];
ll lvl[100005];
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2){res=(res*x)%mod;}
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
ll invmod(ll x)
{ return power(x,mod-2);}
void solve()
{   ll W,X,D;
    cin>>X;
    ll ans=(1000*(X/500));
    X-=((X/500)*500);
    ans=ans+((X/5)*5);
    cout<<ans;
    


    
   

    
}

int main()
{
    ll t=1;
    //cin>>t;
    
    while(t--)
        solve();

}

Measured memory_bytes: 256
import Foundation

let num = readLine()!.components(separatedBy:" ").map{ Int($0)! }
let work = readLine()!.components(separatedBy:" ").map{ Int($0)! }.reduce(0) { $0 + $1 }
if( num[0] >= work){
  print(num[0] - work)
}else{
  print("-1")
}

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

int main() {
  int a,b,x,y;
  cin >> x >> y;
  a = 0;
  rep(i,x) {
    if (2*i+4*(x-i) == y) {
      a++;
    }
  }
  if (a==0) cout << "No" <<endl;
  else cout << "Yes" <<endl;
}


Measured memory_bytes: 3628
import java.math.BigDecimal;
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if (S.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
      	sc.close();
    }
		
		
}


Measured memory_bytes: 26960
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N, W = ri_()
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = ri_()
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(W + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(max(dp[N])) 

Measured memory_bytes: 125436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

vector<int> post,pre,mid;
int loc=0;

void reBuild(int l,int r){
    if(l>=r) return;
    int root=pre[loc++];
    int m=distance(mid.begin(),find(mid.begin(),mid.end(),root));
    reBuild(l,m);
    reBuild(m+1,r);
    post.push_back(root);
}

void solve(){
    loc=0;
    reBuild(0,pre.size());
    for(int i=0;i<post.size();i++){
        if(i) cout<<' ';
        cout<<post[i];
    }
    cout<<endl;

}

int main(){
    int n,k;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&k);
        pre.push_back(k);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&k);
        mid.push_back(k);
    }
    solve();
    return 0;
}



Measured memory_bytes: 3244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int MAX = 100000;
		int N = GetInt();
		int M = GetInt();
		int[] X = GetInts(N);

		int[] grpcnt = new int[M];
		int[] cnt = new int[MAX + 1];
		for(int i = 0; i < N; i++)
		{
			grpcnt[X[i] % M]++;
			cnt[X[i]]++;
		}

		int ans = grpcnt[0] / 2;
		if(M % 2 == 0)
			ans += grpcnt[M/2] / 2;

		for(int i = 1; i < (M + 1)/2; i++)
		{
			int a = i;
			int b = M - i;
			if(grpcnt[a] < grpcnt[b])
				swap(ref a, ref b);

			ans += grpcnt[b];

			int rest = grpcnt[a] - grpcnt[b];
			for(int j = a; j <= MAX; j += M)
			{
				int diff = Math.Min(rest, cnt[j]) / 2;
				ans += diff;
				rest -= diff * 2;
				if(rest < 2)
					break;
			}
		}

		Console.WriteLine(ans);
	}

	private void swap(ref int x, ref int y)
	{
		int tmp = x;
		x = y;
		y = tmp;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 23648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vi A(N);
rep(i,N) cin >> A[i];

vector<int> v;
map<int,int> cnt;

rep(i,N) {
    cnt[A[i]]++;
    if(cnt[A[i]] == 2) cnt[A[i]] = 0,v.push_back(A[i]);
}

sort(all(v), greater<int>());
ll ans = 0;
if(v.size() >= 2) ans = 1LL *v[0]*v[1];
cout << ans << endl;

return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  string S; cin>>S;
  if(S.size()==3) reverse(ALL(S));
  cout<<S<<endl;
}

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

int main() {
  int n,m,k,b;cin>>n>>m;
  int a[m]={};
  rep(i,n){
    cin>>k;
    rep(j,k){
      cin>>b;
      a[b-1]++;
    }
  }
  int sum=0;
  rep(i,m)if(a[i]==n)sum++;
  cout<<sum;
}

Measured memory_bytes: 256
from functools import reduce
N, X, M = list(map(int, input().split()))

dp = [-1] * (M+1)

res = X
A = X
stream = []
spot = 0
for i in range(N-1)[1:]:
  stream.append(A)
  if dp[A] == -1:
    dp[A] = A**2 % M
  else:
    spot = i
    break
  res += dp[A]
  A = dp[A]

if N == 1:
  print(X)
elif spot == 0:
  res += A**2 % M
  print(res)
else:
  leftN = N - spot
  startRoopIndex = stream.index(A)
  roopSize = spot - stream.index(A) - 1
  roopScore = reduce(lambda res, a: res + dp[a], stream[startRoopIndex:spot-1], 0)
  res += (leftN // roopSize) * roopScore
  res += reduce(lambda res, a: res + dp[a], stream[startRoopIndex:(leftN % roopSize)+startRoopIndex], 0)
  print(res)

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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
const int MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

void run() {
	int n, a, b;
	cin >> n >> a >> b;
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; i++)	{
		int p;
		cin >> p;
		if (p <= a) {
			x++;
		} else if (p <= b) {
			y++;
		} else {
			z++;
		}
	}
	cout << min({x, y, z}) << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include <vector>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	vector <int> arr;
	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		arr.push_back(tmp);
	}
	int tong = 0;
	for (int i = 0; i < k; ++i)
	{
		int dem=0;
		int MIN = arr[0];
		for (int i = 1; i < arr.size(); ++i)
		{
			if(arr[i]<MIN){
				MIN = arr[i];
				dem = i;
			}
		}
		tong += MIN;
		arr.erase(arr.begin()+ dem);
	}
	cout<<tong;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

signed main(){
	cin >> n;
	int ret = 0;
	REP(i, n){
		int a;
		cin >> a;
		while(a % 2 == 0){
			a /= 2;
			ret++;
		}
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256