akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
constexpr long long mod = 1e9 + 7;
template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}
signed main() {
    long long x,y; cin >> x >> y;
    long long ans = 0;
    for(int i = 0; i <= x; ++i){
        long long tx = x - i;
        long long ty = y - 2 * i;
        if(tx < 0 || ty < 0 || (ty * 2 + i != x))continue;
        ans += mod_nCr(i + ty,ty,mod);
        ans %= mod;
    }
    cout << ans % mod << endl;
}


Measured memory_bytes: 256
n,m,x = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
count_a = 0
count_b = 0
a = [*0..x]
b = [*x..m]
for i in 0..m - 1
if x < c[i]
    b << c[i]
    count_b += 1
elsif x > c[i]
    a << c[i]
    count_a += 1
end
end
if count_a > count_b
    puts count_b
else
    puts count_a
end

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
 
using namespace std;


int main()
{
	int N;
	cin >> N;
	string str, cpy;
	cin >> str;
	cpy = str;
	vector<int> a(N);

	while (1) {
		bool flag = true;
		for (int i = 0; i < str.size()-1; i++) {
			if (str[i] == '(' && str[i+1] == ')') {
				str.erase(str.begin()+i);
				str.erase(str.begin()+i);
				//cout << str << ":" << endl;
				if (str.size() == 0) break;
				flag = false;
				break;
			}
		}
		if (flag)
			break;
	}

	//cout << str << endl;

	int right = 0, left = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '(') {
			right++;
		} else if (str[i] == ')') {
			left++;
		}
	}
	//cout << right << ", " << left << endl;

	for (int i = 0; i < left; i++) {
		cout << '(';
	}
	cout << cpy;

	for (int i = 0; i < right; i++) {
		cout << ')';
	}
	cout << endl;

	getchar();getchar();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct asdf
{
	string s;
}a[101];
int n;
bool operator < (const asdf &a,const asdf &b)
{
	return a.s<b.s;
} 
int main()
{
	cin>>n>>a[1].s;
	for (int i=2;i<=n;++i)
	{
		cin>>a[i].s;
		if (a[i].s[0]!=a[i-1].s[a[i-1].s.size()-1])
		{
			printf("No");
			return 0;
		} 
	}
	sort(a+1,a+1+n);
	for (int i=2;i<=n;++i)
		if (a[i].s==a[i-1].s)
		{
			printf("No");
			return 0;
		}
	printf("Yes");
}

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


int main() {
    string S, T;
    cin >> S >> T;

    int N = S.size();
    int M = T.size();

    int ans = 1 << 30;
    for (int i = 0; i <= N - M; i++) {
        int diff = 0;
        rep(j, M) if (S[i + j] != T[j]) diff++;
        ans = min(ans, diff);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
from itertools import combinations, permutations
import math
import numpy as np
import sys
readline = sys.stdin.readline
N = int(readline())
coords = []
for _ in range(N):
  xi, yi = map(int, readline().split())
  coords.append((xi,yi))
  
D = np.zeros((N, N))
for i, j in combinations(range(N), 2):
  xi, yi = coords[i]
  xj, yj = coords[j]
  
  dist = math.sqrt(
    (xi - xj)**2 + (yi - yj)**2
  )
  D[i, j] = dist
  D[j, i] = dist

sum = 0
l = 0
for c in permutations(range(N)):
  dist = 0
  for i in range(len(c)-1):
    dist += D[c[i], c[(i+1)]]
  sum += dist
  l += 1

# print(l)
print(sum/l)

Measured memory_bytes: 12516
import itertools

N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
a=[i+1 for i in range(N)]
x=0
y=0
i=0
for b in itertools.permutations(a):
    if list(b)==P:
        x=i
    if list(b)==Q:
        y=i
    i+=1
print(abs(x-y))


Measured memory_bytes: 9164
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
	   string[] inputs = Console.ReadLine().Split(' ');
	   int N = int.Parse(inputs[0]);
	   int L = int.Parse(inputs[1]);
	   string[] strArray = new string[N];
	   string result = "";
	   
	   for(int i = 0; i < N; i++)
	   {
	      strArray[i] = Console.ReadLine();
	   }
	   string[] alphabet = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
	   
	   
	   string s = "";
	   int a = 0;
	   int b = 0;
	   for(int i = 0; i < N; i++)
	   {
	      for(int j = 0; j < N-1; j++)
	      {
	         int k = 0;
	         while(true)
	         {
	            a = Array.IndexOf(alphabet, strArray[j].Substring(k, 1));            //左の文字
	            b = Array.IndexOf(alphabet, strArray[j+1].Substring(k, 1));          //右の文字
	            if( a > b )
	            {
	               s = strArray[j];
	               strArray[j] = strArray[j+1];
	               strArray[j+1] = s;
	               break;
	            }
	            else if(a < b){break;}
	            if(k == L-1){break;}
	            k++;
	         }
	      }
	   }
	   
	   for(int i = 0; i < N; i++)
	   {
	      result = result + strArray[i];
	   }
	   
	   Console.WriteLine(result);
	}
}


Measured memory_bytes: 15308
n, m = map(int, input().split())

l = []

for i in range(m):
  l.append(list(map(int, input().split())))

ans = -1
if n == 1:
  start = 0
else:
  start = 10 ** (n - 1)
for i in range(start, 10 ** n):
  s = str(i)
  result = True
  for x in l:
    if not s[x[0] - 1] == str(x[1]):
      result = False
      break
  if result:
    ans = i
    break

print(ans)
  

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		String[] s = new String[h];
		for (int i = 0; i < s.length; i++) {
			s[i] = sc.next();
		}
		
		boolean[] row = new boolean[h];
		boolean[] column = new boolean[w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i].charAt(j) == '#') {
					row[i] = true;
					column[j] = true;
				}
			}
		}

		
		for (int i = 0; i < h; i++) {
			if (row[i]) {
				for (int j = 0; j < w; j++) {
					if (column[j]) {
						System.out.print(s[i].charAt(j));
					}
				}
				
				System.out.println();
			}
		}
		
	}
}

Measured memory_bytes: 24916
N, L = gets.split(" ").map(&:to_i)
# S = gets.chomp
# N = gets.to_i

arr = []
sum = 0
absmin = 99999
min = absmin
N.times do |i|
  v = L + i
  sum += v
  abs = v.abs
  if abs < absmin
    absmin = abs
    min = v
  end
end

# p [sum, min]
puts sum - min


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()

bool o = false;
ll n, k, a = 0, b = 0;
int main(){
	cin >> n >> k;
	REP(i, n) {
		ll in; cin >> in;
		if (in == 1)o = true;
		else (o ? a++ : b++);
	}
	cout << (a + b + k - 2) / (k - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int ats=0;
    for (int i=0;i<n;i++) {
		if (s[i]!=t[i]) {ats++;}
		}
	cout<<ats<<endl;
    return 0;
}


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


int main(void){
    int k,num=0;
    cin>>k;
    for (int i = 0; i < 10e6; i++)
    {
        num=(10*num+7)%k;
        if (num==0){
            cout<<1+i<<endl;
            return 0;}
        
    }
    cout<<-1<<endl;
    return 0;
}

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


 int main(){
     long long X,num500,num5;
     cin >> X;
     num500 = X/500;
     num5 = (X-500*num500)/5;
     cout << num500*1000 + num5*5 << endl;
     return 0;
 }
 


Measured memory_bytes: 256
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec   

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
void solve()
{
	ll k;
	cin>>k;
	ll num=7,cnt=1;
	unordered_map<int,int> prev;
	while(num%k)
	{
		prev[num%k]++;
		if(prev[num%k]>1)
		{
			cout<<-1<<endl;
			return;
		}
		num=((num%k)*10)+7;
		cnt++;
	}
	cout<<cnt<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 42628
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=2e5+2;


int main(){
    string S;
    cin>>S;
    cout<<S.substr(0,SZ(S)-8)<<endl;
    return 0;
}


Measured memory_bytes: 764
d = int(input())

D   = "Christmas"
D_1 = "Christmas Eve"
D_2 = "Christmas Eve Eve"
D_3 = "Christmas Eve Eve Eve"

if d == 25:
  print(D)
elif d == 24:
  print(D_1)
elif d == 23:
  print(D_2)
else:
  print(D_3)



Measured memory_bytes: 9156
n= int(input())
a = format(n,"b")
mod = 1000000007
dp = [[0 for j in range(3)] for i in range(len(a)+1)]
dp[0][0] = 1
for i in range(len(a)):
  for j in range(3):
      for x in range(2):
        for y in range(x,2):
          b=(n>>i)&1
          dp[i+1][(x+y+j-b+1)//2] = (dp[i+1][(x+y+j-b+1)//2]+dp[i][j])%mod
print(dp[len(a)][0])

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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    int c=0;
    cin >> s;
    rep(i,(int)s.size()/2) {
        if (s[i] != s[(int)s.size()-1-i]) c++;
    }

    cout << c << '\n';

    return 0;
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 256
#3,5,7の全探索はdfs全探索で求める
#どれか一つを使ってるかどうかはbitで値を持つ

N = int(input())

ans = 0

def dfs(A,use_num):
    global ans
    #Nより大きくなれば終了
    if len(A) > 1:
        if int("".join(map(str, A))) > N:
            return
    if use_num == 0b111:
        ans += 1

    for v in [3,5,7]:
        A.append(v)
        if v == 3:
            dfs(A,use_num | 0b001)
        elif v == 5:
            dfs(A,use_num | 0b010)
        elif v == 7:
            dfs(A,use_num | 0b100)
        A.pop()

dfs([],0b000)

print(ans)


Measured memory_bytes: 3064
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}

ll ans;




int main(void){
	
	ll n;
	
	while(cin>>n,n!=0){
		ans=0;
		for(ll i=n-1;i>=0;i--){
			ll count=n;
			for(int j=i;j>=0;j--){
				if(count-j<0)
					break;
				else if(count-j==0){
					ans++;
					break;
				}
				else
					count-=j;
			}
		}
		cout<<ans<<endl;
	}

	
}

Measured memory_bytes: 3064
def insertion(A,n):
  for i in range(0,n):
    tmp = A[i]
    j = i - 1
    while(A[j] > tmp and j >= 0):
      A[j+1] = A[j]
      j-=1
    A[j+1] = tmp
    printList(A)


def printList(A):
  print(" ".join(str(x) for x in A))

n = int(input())
A = [int(x) for x in input().split()]
insertion(A,n)

Measured memory_bytes: 7744
a,b = map(int,input().split(" "))
ar = []
for i in range(a):
    l = list(input())
    ar.append(l)
count = 0
for i in range(a):
    for j in range(b):
        if ar[i][j] == "#":
            count += 1
if count == a + b - 1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp2 = input[1].split(" ");
    tmp3 = input[2].split(" ");
    T = parseInt(tmp2[0]);
    A = parseInt(tmp2[1]);
    var ans;
    var ansAmari;
	//文字列から10進数に変換するときはparseIntを使います
    for(i = 0;i < parseInt(input[0]);i++){
        kion = T - parseInt(tmp3[i]) * 0.006;
        amari = A - kion;
        if(ansAmari > Math.abs(amari) || i === 0){
            ans = i+1;
            ansAmari = Math.abs(amari);
        }
    }
	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void) {
	int x; cin >> x;
	int num = x;
	int ad;
	while(!IsPrime(num)){
		num++;
	}
	out(num);
}




Measured memory_bytes: 256
n, k, q = map(int,input().split())
a =  []
for i in range(q):
  a.append(int(input()))
p = [k for i in range(n)]
for i in range(q):
  p[a[i]-1] += 1
for i in range(n):
  if p[i] -q <= 0:
    print('No')
  else:
    print('Yes')

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B;
    rep(i, N){
        cin >> A[i];
        int a = A[i] - (i+1);
        B.push_back(a);
    }
    sort(B.begin(), B.end());
    int x = (N-1)/2;
    int b = B[x];
    ll ans = 0;
    rep(i, N){
        ans += abs(B[i] - b);
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll ans = 1;
    cin >> N >> K;
    while(N) {
        if(ans * 2 < ans + K) ans *= 2;
        else ans += K;
        N--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e7

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;

vector<ll>par,len;

ll find(ll x)
{
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(ll x, ll y)
{
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(len[x] < len[y]) par[x] = y;
    else par[x] = y;
    if(len[x] == len[y]) len[x]++;
}

bool same(ll x,ll y)
{
    return find(x) == find(y);
}

int main()
{
    ll N; cin >> N;
    vector<pair<ll,ll>>vx,vy;
    for(ll i = 0; i < N; i++)
    {
        ll x,y; cin >> x >> y;
        vx.push_back(pair(x,i));
        vy.push_back(pair(y,i));
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    priority_queue<tll,vector<tll>,greater<tll>>que;
    for(int i = 0; i < N-1; i++)
    {
        que.push(tuple(vx[i+1].first-vx[i].first,vx[i].second,vx[i+1].second));
        que.push(tuple(vy[i+1].first-vy[i].first,vy[i].second,vy[i+1].second));
    }
    len.assign(N,0);
    par.resize(N);
    for(ll i = 0; i < N; i++) par[i] = i;
    ll ans = 0;
    while(!que.empty())
    {
        auto p = que.top(); que.pop();
        ll cost = get<0>(p);
        ll a = get<1>(p);
        ll b = get<2>(p);
        if(same(a,b)) continue;
        unite(a,b);
        ans += cost;
    }
    cout << ans << endl;
}

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

int main() {
  //変数たち
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int sum=0,item_number=0;
  
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  
  double a = double(1)/double(4)/double(M);
  
  for(int i=0;i<N;i++){
    if( (double(A.at(i))/double(sum)) >= a ){
		item_number++;
    }
  }
  if(item_number>=M){
	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
      
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char S[6];
  int i;
  for (i=0;S[i]!='\0';i++)
      scanf("%s",S);
  if (S[2]==S[3] && S[4]==S[5])
    printf("Yes");
  else 
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[]) {
    int N,origN;cin >> N; origN = N;
    vector<int> div;
    for(int d=2;d*d<=N;d++){
        if(N%d == 0){
            div.push_back(d);
            while(N % d == 0)N /= d;
        }
    }
    if(N != 1) div.push_back(N);
    int M = div.size(), ans=0;
    for(int bit=1;bit<(1<<M);bit++){
        int popcnt = __builtin_popcount(bit);
        int mul = 1;
        for(int i=0; i<M; i++){
            if(bit >> i&1)mul *= div[i];
        }
        if(popcnt % 2 == 1) ans += origN/mul;
        else                ans -= origN/mul;
    }
    ans = origN - ans;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        pq.push(x);
    }
    for(int i = 0; i < m; ++i) {
        int x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=200005;
//i_am_noob
int a[maxn]={0},cnt=0,target;
vector<vector<int>> vec;
char c[2]={'+','<'};

void func1(int x, int y, int z){vec.pb({0,x,y,z});a[z]=a[x]+a[y];cnt++;}
void func2(int x, int y, int z){vec.pb({1,x,y,z});a[z]=a[x]<a[y];cnt++;}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    //cin >> a[0] >> a[1];
    target=a[0]*a[1];
    func1(0,1,3);func2(4,3,3);
    rep2(i,1,30) func1(i+2,i+2,i+3);
    func1(0,3,9999);
    rep3(i,29,0){
        func1(10000,i+3,10000);
        func2(10000,9999,40+i);
        rep1(j,i) func1(40+i,40+i,40+i);
        func1(10001,40+i,10001);
        func1(10001,826,10000);
    }
    func1(1,3,9999);
    func2(0,0,10000);func2(0,0,10001);
    rep3(i,29,0){
        func1(10000,i+3,10000);
        func2(10000,9999,70+i);
        rep1(j,i) func1(70+i,70+i,70+i);
        func1(10001,70+i,10001);
        func1(10001,826,10000);
    }
    rep(30) rep1(j,30){
        func2(826,40+i,10000);
        func2(826,70+j,10001);
        func1(10000,10001,10000);
        func2(3,10000,10000);
        rep1(k,i+j) func1(10000,10000,10000);
        func1(2,10000,2);
    }
    //print2(target,a[2]);

    print1(sz(vec));
    for(auto vec1: vec){
        print0(c[vec1[0]]);
        rep2(i,1,4) print0(vec1[i]);
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 5492
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ull;
typedef long long ll;
//const int INF=0x3f3f3f3f;
const int INF=1e9;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e9+7;
const ll maxn=1e5+7;
const int MAXN=1005;
const int MAX=2e5+5;
const int MAX_N=MAX;
const ll MOD=1e9+7;
//const double eps=0.00000001;
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
int mina[MAX<<2][2];
int a[MAX],lo[MAX],n;
void init(int l,int r,int k)
{
    mina[k][0]=mina[k][1]=INF;
    if(l==r)
        return;
    init(l,(l+r)/2,2*k);
    init((l+r)/2+1,r,2*k+1);
}
void build(int l,int r,int k)//左闭右闭
{
    if(l==r)
    {
        scanf("%d",&a[l]);
        lo[a[l]]=l;
        mina[k][l%2]=a[l];return;
    }
    int mid=(l+r)/2;
    build(l,mid,2*k);
    build(mid+1,r,2*k+1);
    mina[k][0]=min(mina[2*k][0],mina[2*k+1][0]);
    mina[k][1]=min(mina[2*k][1],mina[2*k+1][1]);
}
int query(int ql,int qr,int l,int r,int k,int st)
{
    if(l>=ql&&r<=qr)
        return mina[k][st];
    int mid=(l+r)/2;
    if(mid<ql)
        return query(ql,qr,mid+1,r,2*k+1,st);
    else if(mid>=qr)
        return query(ql,qr,l,mid,2*k,st);
    else
        return min(query(ql,qr,l,mid,2*k,st),query(ql,qr,mid+1,r,2*k+1,st));
}
struct node
{
    int l,r,xiao,status;
    bool operator <(node b)const
    {
        return xiao>b.xiao;
    }
    node(int x=0,int y=0,int z=0,int s=0):l(x),r(y),xiao(z),status(s){}
};
priority_queue<node>que;
int an[MAX],cnt;
int main()
{
    cnt=0;
    scanf("%d",&n);
    init(0,n-1,1);
    build(0,n-1,1);
    node tem;
    tem.l=0;tem.r=n-1;tem.xiao=query(0,n-1,0,n-1,1,0);tem.status=0;
    que.push(tem);
    while(!que.empty())
    {
        tem=que.top();que.pop();
        int now=lo[tem.xiao];
        int nxt=query(now+1,tem.r,0,n-1,1,1^tem.status);
        int to=lo[nxt];
        an[cnt++]=tem.xiao;an[cnt++]=nxt;
        if(now>tem.l)
            que.push(node(tem.l,now-1,query(tem.l,now-1,0,n-1,1,tem.status),tem.status));
        if(to-now>1)
            que.push(node(now+1,to-1,query(now+1,to-1,0,n-1,1,tem.status^1),tem.status^1));
        if(tem.r>to)
            que.push(node(to+1,tem.r,query(to+1,tem.r,0,n-1,1,tem.status),tem.status));
    }
    for(int i=0;i<cnt;i++)
        printf("%d ",an[i]);
    return 0;
}


Measured memory_bytes: 10484
#include <cstdio>
#include <stdint.h>
#include <cstdlib>

void check(int64_t N,int64_t S,int64_t B){
  int64_t sum=0;
  for(;N;N/=B){
    sum+=N%B;
  }
  if(sum==S){
    printf("%ld\n",B);
    exit(0);
  }
}

int main(){
  int64_t N,S;
  scanf("%ld %ld",&N,&S);
  if(S>N){
    printf("-1\n");
    return 0;
  }
  if(S==N){
    printf("%ld\n",N+1);
    return 0;
  }
  int64_t i=1;
  for(;i*i<=(N-S);i++){
    if((N-S)%i==0) check(N,S,i+1);
  }
  for(;i>0;i--){
    if((N-S)%i==0) check(N,S,(N-S)/i+1);
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 128
from collections import deque

n = int(input())
data = deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        data.appendleft(command[1])
    elif command[0] == "delete":
        try:
            data.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        data.popleft()
    elif command[0] == "deleteLast":
        data.pop()
print(*data)



Measured memory_bytes: 69740
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <random>

using namespace std;

#define x first
#define y second
#define prev _prev
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(rand());
const int MOD = 1e9 + 7;
const ll BIG_MOD = 1e18 + 7;
const int MAXN = 1e5 + 7;

map <int, int> d;

signed main(){
	cout.precision(20);
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	int len;
	for (int i = 0; i < n; ++i){
		cin >> len;
		d[len]++;
	}

	vector <int> a;
	for (pair <int, int> elem: d){
		if (elem.second >= 4){
			a.push_back(elem.first);
			a.push_back(elem.first);
		}
		else if (elem.second >= 2){
			a.push_back(elem.first);
		}
	}

	if (a.size() < 2){
		cout << "0\n";
		return 0;
	}

	sort(a.begin(), a.end());
	int l = a.size();
	cout << (ll)a[l - 1] * (ll)a[l - 2] << '\n';

	return 0;
}

Measured memory_bytes: 4992
# 距離の最大公約数を求める

from fractions import gcd
N, X = map(int, input().split())
Xs = [int(i) for i in input().split()]

Xs.append(X)
position = sorted(Xs)

dist = []
for i in range(1, len(position)):
    dist.append(position[i] - position[i - 1])


i = dist[0]
# gcdは２数の最大公約数しか求めることができない。gcd(手前の２数の最大公約数,距離の値)とすれば全ての距離の最大公倍数が求められる。
for j in dist[1:]:
    i = gcd(i, j)

print(i)

# atcoderはpy3.4なので、上記ライブラリで動く。上記のライブラリは、py3.7では別のライブラリに統合されているので注意


Measured memory_bytes: 16272
#include<stdio.h>
#define N 100

int main(){

  int M[N][N];
  int n, u, k, v;
  int i, j;

  scanf("%d", &n);
  
  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ){
      M[i][j] = 0;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  for ( i = 0; i < n; i++ ){
    for ( j = 0; j < n; j++ ){
       printf("%d", M[i][j]);
      if ( j < n-1 ) printf(" ");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 640
n = int(input())
ans=[]
if n==0:
    print(0)
    exit()
while not(n==0):
    amari=-(n%(-2))
    shou=(n-amari)//(-2)
    n=shou
    ans.append(str(amari))
ans=[ans[-i-1] for i in range(len(ans))]
print(''.join(ans))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int sub[200001]={};
  for(int i=0;i<n-1;i++){
    int a;
    cin>>a;
    sub[a]++;
  }
  for(int i=1;i<=n;i++){
    cout<<sub[i]<<endl;
  }
}


Measured memory_bytes: 4372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._600problems
{
    class ARC081_E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string a = Read();

            int c = 26;
            List<char>[] valids = new List<char>[c];
            for(int i = 0; i < c; i++)
            {
                valids[i] = new List<char>();
                valids[i].Add((char)('a' + i));
            }

            for(int i = a.Length - 1; i >= 0; i--)
            {
                int index = 0;
                for(int j = 0; j < c; j++)
                {
                    if (valids[index].Count <= valids[j].Count) continue;

                    index = j;
                }

                List<char> next = new List<char>();
                next.Add(a[i]);
                next.AddRange(valids[index]);
                valids[a[i] - 'a'] = next;
            }

            int resIndex = 0;
            for(int i = 0; i < c; i++)
            {
                if (valids[resIndex].Count <= valids[i].Count) continue;

                resIndex = i;
            }
            WriteLine(valids[resIndex].ToArray());
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 58428
n,l = map(int,input().split())
ans = 0
if l > 0:
    for i in range(l+1,l+n):
        ans += i
elif n + l -1 < 0:
    for i in range(l,l+n-1):
        ans += i
else:
    for i in range(l,l+n):
        ans += i
print(ans)

Measured memory_bytes: 9080
#include <stdio.h>
// #include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;
P Q[LEN+1];

int head, tail, n;
void enqueue();
P dequeue();
void initialize();
int isEmpty();
int isFull();
int min(int, int);
int main(){
    int elaps = 0, c;
    int i,q;
    P u;
    scanf("%d%d", &n, &q);
    for(i=1; i<=n; i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if( u.t > 0 ){
            enqueue(u);
        }
        else {
            printf("%s %d\n",u.name, elaps);
        }
    }

    return 0;
}

void enqueue(P x){
    if( isFull()==0 ){
        fprintf(stderr,"error:isEmpty\n");
    }
    Q[tail] = x;
    if(tail + 1  == LEN) {
        tail = 0;
    }
    else {
        tail++;
    }
}

P dequeue(){
    P x;
    if( isEmpty()==0 ){
        fprintf(stderr,"error:isEmpty\n");
    }
    x = Q[head];
    if(head + 1 == LEN) {
        head = 0;
    }
    else {
        head++;
    }
    return x;
}

void initialize(){
    head = tail = 0;
}

int isFull(){
    if(head == (tail + 1) % LEN){
        return 0;
    }
    else return 1;
}

int isEmpty(){
    if( head == tail ){
        return 0;
    }
    else return 1;
}

int min(int a, int b){
    return a<b ? a:b;
}



Measured memory_bytes: 11892
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a, a) {
		int sum=0; 
		int d;
		int f;
		int e = 0;
		for (int i = 0; i < a; i++) {
			cin >> d;
			if (i == 0) {
				f = d;
				e = d;
			}
			if (d > e) {
				e = d;
			}
			if (f > d) {
				f = d;
			}
			sum += d;
		}
		sum = sum - (e + f);
		sum = sum / (a-2);
		cout << sum << endl;
	}
}




Measured memory_bytes: 3084
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1 << 32


def solve(N: int, S: str):
    m = 0
    for i in range(1, N - 1):
        m = max(m, len(set(list(S[:i])) & set(list(S[i:]))))
    print(m)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 
int main()
{
    fastio;
    string s;
    string t;
    cin>>s>>t;

    int n = s.length(),m = t.length();

    int ans = n;
    rep(i,n - m + 1,0){
        int count = 0;
        rep(j,m,0)if(s[i+j] == t[j])count++;
        ans = min(ans,m - count);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n,k;
    cin>>n>>k;
    vi a(n);
    cin>>a;

    ll index=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==1)
        {
            index=i;
            break;
        }
    }
    ll ans=n;
    for(ll i=max(0ll,index-k+1);i<=index;i++)
    {
        ll j=min(n-1,i+k-1);
        //0..i-1
        //j+1..n-1

        ll left=i;
        ll right=n-1-j;

        left=(left+k-2)/(k-1);
        right=(right+k-2)/(k-1);
        ans=min(ans,1+left+right);
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3904
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    K=I()
    X=I()
    Y=I()
    if N<=K:
        print(N*X)
    else:
        print(K*X+(N-K)*Y)

main()


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

using namespace std;
int n;
int x,ans;
int f[10005];
int main()
{
    for(int i=1;i<=100;i++)
    {
        for(int j=i;j<=100;j++)
        {
            for(int k=j;k<=100;k++)
            {
                int res=i*i+j*j+k*k+i*j+j*k+i*k;
                if(res>10000)continue;
                if(i==j && j==k)
                    f[res]+=1;
                else if(i!=j&&i!=k&&j!=k)
                    f[res]+=6;
                else
                    f[res]+=3;
            }
        }
    }
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        printf("%d\n",f[i]);
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>

int main() {
  using namespace std;

  int N, D, X;
  cin >> N >> D >> X;

  int sum = 0;
  for (int i=0; i<N; i++) {
    int A;
    cin >> A;

    sum++;

    int day = A + 1;
    while (day <= D) {
      day += A;
      sum++;
    }
  }

  cout << sum + X << endl;

  return 0;
}

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

int main(){
    double a,b,c,d=0,e=0,x=0,y=0,z=0;
    cin>>a>>b;
    x=a+b;
    y=a-b;
    z=a*b;
    x=max(x,y);
    y=max(x,z);
    cout<<y;
    return 0;
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int n, k, p[3];
	char t[112345];
	std::cin >> n >> k >> p[1] >> p[2] >> p[0] >> t;
	unsigned long long ans = 0;
	RC(i, k){
		int prev = -1;
		for(int j = i; j < n; j += k){
			int tmp;
			switch(t[j]){
				case 'r': tmp = 0; break;
				case 's': tmp = 1; break;
				case 'p': tmp = 2;
			}
			if(prev == tmp){
				prev = -1;
			}else{
				prev = tmp;
				ans += p[tmp];
			}
		}
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vector<P> data(n);
    rep(i,n) {
        int a, b; cin >> a >> b;
        data[i] = P(a,b);
    }
    bool ok = false;
    for (int i = 0; i <= n-3; i++) {
        if (data[i].first == data[i].second && data[i+1].first == data[i+1].second && data[i+2].first == data[i+2].second) {
            ok = true;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628