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

using namespace std;
int A[100000];
int n ;
set<int> s ;

bool try1(){
    if(s.size()==1 && *s.begin()==n-1)return 1;
    return 0 ;
}

bool try2(){
    /// no body is uniq;
    if(s.size()==2) return 0;
    int c = *s.begin();
    if(n<2*c)return 0;
    return 1;
}

bool try3(){
    /// somebody is uniq;
    if(s.size()!=2) return 0;
    int c = *s.begin()+1;
    int d = *(--s.end());
    if(c!=d)return 0 ;
    int nc = 0 ;
    for(int i = 0 ; i<n ; i++){
        if(A[i]==c-1)nc++;
    }
    if(nc>=c)return 0;
    int rmc = c-nc;
    if(n-nc<2*rmc)return 0;
    return 1;
}

int main()
{
    cin >> n  ;
    for(int i = 0 ; i<n ; i++)cin>> A[i] , s.insert(A[i]);
    if(s.size()>2){
        cout <<"No" ;
        return 0 ;
    }
    if(try1()) {
        cout<< "Yes";
        return 0 ;
    }
    if(try2()) {
        cout<< "Yes";
        return 0 ;
    }
    if(try3()) {
        cout<< "Yes";
        return 0 ;
    }
    cout <<"No";
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
int h,w,n,x,y,sl,sr,su,sd,tl,tr,tu,td,SL,SR,SU,SD,TL,TD,TU,TR,X,Y;
string s,t;
signed main(){
	cin>>h>>w>>n>>x>>y>>s>>t;
	x--,y--;
	rep(i,n){
		if(s[i]=='L')sl++;
		if(s[i]=='R')sr++;
		if(s[i]=='U')su++;
		if(s[i]=='D')sd++;
	}
	rep(i,n){
		if(t[i]=='L')tl++;
		if(t[i]=='R')tr++;
		if(t[i]=='U')tu++;
		if(t[i]=='D')td++;
	}
	X=x,Y=y;
	SL=sl,SR=sr,SU=su,SD=sd;
	TL=tl,TR=tr,TU=tu,TD=td;
	rep(i,n){
		if(s[i]=='L'){
			SL--,Y--;
			if(Y==-1){
				puts("NO");
				
				return 0;
			}
			if(t[i]=='R'){
				TR--,Y++;
			}
		}
		else{
			if(t[i]=='R'&&SR-TL<w-Y&&Y+1!=w){
				TR--,Y++;
			}
		}
		
	}
	X=x,Y=y;
	SL=sl,SR=sr,SU=su,SD=sd;
	TL=tl,TR=tr,TU=tu,TD=td;
	rep(i,n){
		if(s[i]=='R'){
			SR--,Y++;
			if(Y==w){
				puts("NO");
				return 0;
			}
			if(t[i]=='L'){
				TL--,Y--;
			}
		}
		else{
			if(t[i]=='L'&&SL-TR<Y&&Y-1!=-1){
				TL--,Y--;
			}
		}
			
	}
	X=x,Y=y;
	SL=sl,SR=sr,SU=su,SD=sd;
	TL=tl,TR=tr,TU=tu,TD=td;
	rep(i,n){
		if(s[i]=='D'){
			SD--,X++;
			if(X==h){
				puts("NO");
				return 0;
			}
			if(t[i]=='U'){
				TU--,X--;
			}
		}
		else{
			if(t[i]=='U'&&SU-TD<X&&X-1!=-1){
				TU--,X--;
			}
		}
	}
	X=x,Y=y;
	SL=sl,SR=sr,SU=su,SD=sd;
	TL=tl,TR=tr,TU=tu,TD=td;
	rep(i,n){
		if(s[i]=='U'){
			SU--,X--;
			if(X==-1){
				puts("NO");
				return 0;
			}
			if(t[i]=='D'){
				TD--,X++;
			}
		}
		else{
			if(t[i]=='D'&&SD-TU<h-X&&X+1!=h){
				TD--,X++;
			}
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] l = Console.ReadLine().Split((char[])null, StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray();

            Array.Sort(l);
            int count = 0;
            for (int i = 0; i < n - 2; ++i)
            {
                for (int j = i + 1; j < n - 1; ++j)
                {
                    count += LowerBound(l, 0, l.Length, l[i] + l[j]) - j - 1;
                }
            }
            Console.WriteLine(count);
        }

        static int LowerBound(int[] array, int startIndex, int length, int value)
        {
            while (length > 0)
            {
                int newLength = length >> 1;
                int middleIndex = startIndex + newLength;
                if (array[middleIndex] < value)
                {
                    length -= newLength + 1;
                    startIndex = middleIndex + 1;
                }
                else
                {
                    length = newLength;
                }
            }
            return startIndex;
        }
    }
}


Measured memory_bytes: 11604
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
ll max1(ll a, ll b, ll c=-inf, ll d=-inf) {ll mx1=(a>b)?a:b, mx2=(c>d)?c:d; return ((mx1>mx2)?mx1:mx2);}
#define int ll

struct node {
	vector<int> v,w;
};

signed main() {
	fast;

	int n;
	cin>>n;

	int root = sqrt(n);
	int ans = inf;

	for(int i=1;i<=root;i++) {
		if(n%i!=0) continue;
		int x = i;
		int y = n/i;

		ans = min(ans, x+y-2);
	}
	cout<<ans;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int main() {
  int N;
  cin >> N;

  cout << (N*N*N) << BR;
  return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int N=50;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k; cin>>k;
    int a[N];
    F(i,N) a[i] = N-1+k/N;
    F(i,k%N) {
        a[i] += N;
        F(j,N) if (j!=i)
            a[j]--;
    }
    cout<<N<<"\n";
    F(i,N) cout<<a[i]<<" \n"[i==N-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<endl;
using namespace std;
int main(){
	int n;
	double ans=0;
	cin>>n;
	while(n--){
		double x;
		cin>>x;
		ans+=1.0/x;
	}
	printf("%.8lf",1.0/ans);
	return 0;
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();

            var patterns = new int[2];

            // 0101パターン
            patterns[0] = SwapCount(n, '0', '1');

            // 1010パターン
            patterns[1] = SwapCount(n, '1', '0');

            Console.WriteLine(patterns.Min());
        }

        static int SwapCount(string n, char first, char second)
        {
            var loopCount = 0;
            var swapCount = 0;

            foreach (var s in n)
            {
                loopCount++;
                if (loopCount % 2 == 0)
                {
                    if (s == first)
                    {
                        swapCount++;
                    }
                }
                else
                {
                    if (s == second)
                    {
                        swapCount++;
                    }
                }
            }

            return swapCount;

        }

    }
}


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

using namespace std;

const int mod = 1e9 + 7;
string s;
unsigned f[4];

void add(unsigned &a, unsigned b) {
    a += b;
    while (a >= mod) a -= mod;
}

int main(void) {
    cin >> s;
    f[0] = 1;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 3; j >= 0; --j) {
            add(f[j], f[j] * 2 * (s[i] == '?'));
            if (j) add(f[j], f[j-1] * (s[i] == '?' || s[i] == 'A' + j - 1));
        }
    }
    cout << f[3] << endl;
}

Measured memory_bytes: 512
sx, sy, tx, ty = map(int, input().split())
print("L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"*(ty-sy+1)+"L"*(tx-sx)+"D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(ty-sy))


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Security.Principal;
using System.Text;
class Simple {
    private string[] S;
    void Solve() {
        //input
        S = io.String.Split('/');
        //cal
        var ans = "2018/" + S[1] + "/" + S[2];
        //ret
        Console.WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] {' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

Measured memory_bytes: 13140
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

int main(void) {

	int K, X;

	scanf("%d %d", &K, &X);

	int min_x = -1000000;
	int max_x = 1000000;

	min_x = max(min_x, X - K + 1); //   4 5 6 7 8 9 10,  X = 7, K = 3  1 2 3 4 5
	max_x = min(max_x, X + K);

	REP(i, min_x, max_x) {
		if ( i > min_x ) printf(" ");
		printf("%d", i);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
n,u,v = map(int,input().split())
u,v = u-1,v-1
link = [[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  link[a].append(b)
  link[b].append(a)
tree = [[] for i in range(n)]
for i in [u,v]:
  stack = [i]
  vi = [0] * n
  tree[i].append(0)
  vi[i] = 1
  while stack:
    cur = stack.pop()
    for j in link[cur]:
      if vi[j] == 0:
        stack.append(j)
        vi[j] = 1
        tree[j].append(tree[cur][-1]+1)
m = 0
c = 0
for i,j in tree:
  if i < j:
    if m < j:
      m = j
      #c = (j-i) % 2
print(m-1)

Measured memory_bytes: 40156
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut h: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    for i in 0..n {
        while h[i] % 2 == 0 {
            h[i] /= 2;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

string T, D;
string S;

bool left_down(int l){
    int i = 0;
    while(i < T.size()) {
        if(l < 0) return true;
        if (S[l] == T[i]) {
            if (D[i] == 'L') { l--; }
            else { l++; }
        }
        i++;
    }
    if(l < 0) return true;
    return false;
}

bool right_down(int l){
    int i = 0;
    while(i < T.size()) {
        if(l >= S.size()) return true;
        if (S[l] == T[i]) {
            if (D[i] == 'L') { l--; }
            else { l++; }
        }
        i++;
    }
    if(l >= S.size()) return true;
    return false;
}

void sub_main(istream &cin) {
    ll N, Q;
    cin >> N >> Q;
    if(!cin) return;
    cin >> S;
    T = D = "";
    for (int i = 0; i < Q; ++i) {
        char t, d;
        cin >> t >> d;
        T.push_back(t);
        D.push_back(d);
    }// i
    int ok, ng;
    ok = -1; ng = N;
    while(ng - ok > 1){
        int mid = (ok + ng)/2;
        if(left_down(mid)){ ok = mid; }
        else { ng = mid; }
    }
    int l = ok + 1;
    ok = N; ng = -1;
    while(ok - ng > 1){
        int mid = (ok + ng)/2;
        if(right_down(mid)){ ok = mid; }
        else { ng = mid; }
    }
    int r = ok;
    
    
    ll ans = r - l;
    if(ans <= 0) ans = 0;
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test_C.txt";
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#\n";
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 1044
#include<stdio.h>

int func(int n);

int main(void){
    int s, i, j;
    int ans = -1;
    int a[1000001];

    scanf("%d", &s);

    a[1] = s;
    for(i=2;i < 1000001;i++){
	a[i] = func(a[i-1]);
    }

    for(i=2;i < 1000001;i++){
	for(j = i-1;j >0;j--){
	    if(a[i] == a[j]){
		ans = i;
		break;
	    }
	}
	if(ans != -1) break;
    }

    printf("%d", ans);
    return 0;
}


int func(int n){
    int ans;
    
    if(n%2 == 0) ans = n/2;
    else ans = 3*n + 1;
    
    return ans;
}


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

string s[200005];
map<string,int>  mp;
vector<string> v;

int main(){
    ios::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        mp[s[i]]++;
        ans=max(ans,mp[s[i]]);
    }
    for(int i=1;i<=n;i++){
        if(mp[s[i]]==ans){
            //cout<<s[i]<<'\n';
            v.push_back(s[i]);
            mp[s[i]]=0;
        }
    }
    sort(v.begin(),v.end());
    for(auto s:v){
        cout<<s<<'\n';
    }
}


Measured memory_bytes: 27120
#include <iostream>

using namespace std;

const long MOD = 2019;

int main(){
    long L, R;
    long ans = 2019;
    cin >> L >> R;
    if((R - L) >= 2019){
        cout << 0 << endl;
    }else{
        for(long i = L; i <= R; i++){
            for(long j = i+1; j <= R; j++){
                long l = i%MOD;
                long r = j%MOD;
                //cout << l << ' ' << r << endl;
                ans = min(ans, (l*r)%MOD);
            }
        }
        cout << ans << endl;
    }
    // cout << 2020*2021%MOD << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b; cin>>a>>b;
  if(a<=5) cout<<0<<endl;
  else if(a<=12) cout<<b/2<<endl;
  else cout<<b<<endl;


}


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

int main(void) {
    int N;
    map<int, int> m;
    cin >> N;
    REP(i, N) {
        int j;
        cin >> j;
        m[j]++;
    }
    int ans = 0;
    for(auto k : m) {
        if (k.second >= k.first) {
            ans += k.second - k.first;
        } else {
            ans += k.second;
        }

    } 
    cout << ans << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__() for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); debug("Time:%.4fs\n",(double)(clock()-blockTime)/CLOCKS_PER_SEC))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e9
#define MOD 1000000007
#define MAXN 111111
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m;	cin>>n>>m;
	char arr[n+1][m+1];
	ll dp[n+1][m+1]; 
	fore(i,1,n)	fore(j,1,m)	cin>>arr[i][j];
	fore(i,0,n)	fore(j,0,m){
		dp[i][0]=0;
		dp[0][j]=0;
	}
	
	fore(i,1,n)	fore(j,1,m){
		if(i==1&&j==1)
			dp[1][1]=1;
		else if(arr[i][j]=='#')
			dp[i][j]=0;
		else
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
		dp[i][j]%=MOD;
	}
	
	cout<<dp[n][m];
	
	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	ll A;
	double B;
	cin >> A >> B;
	B=B + 0.005;
	ll c = B * 100;
	ll tmp = A * c;
	tmp = tmp / 100;
	cout << tmp;
}


Measured memory_bytes: 3756
def main():
  N=int(input())
  A=list(set(list(map(int,input().split()))))

  if min(A)==1:
    print(1)
    exit()

  while len(A)>1:
    monster_min = A.pop(A.index(min(A)))
    for i in range(len(A)):
      A[i] %= monster_min
    A.sort()
    for i in A[:]:  
      if i == 0: A.remove(i)
      else: continue
    A.append(monster_min)

  print(A[0])

if __name__ == "__main__":
  main()

Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long long a, b, k; cin >> a >> b >> k;
  if (k >= a + b) cout << 0 << " " << 0 << endl;
  else if (k >= a) cout << 0 << " " << b - (k - a) << endl;
  else cout << (a - k) << " " << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 5e5 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int mul(int a, int b) {
	return (ll)a * b % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(f[i - 1], i);
	}
}

int C(int n, int k) {
	if (k < 0 || k > n) return 0;
	return divv(f[n], mul(f[k], f[n - k]));
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	init();

	int n, m;
	cin >> n >> m;
	int ans = 0;
	for (int sh = 0; sh <= n; sh++) {
		int poss_sel = C(m, sh);
		int poss_plc = C(n, sh);
		poss_plc = mul(poss_plc, f[sh]);
		int poss_oth = mul(C(m - sh, n - sh), C(m - sh, n - sh));
		int all = mul(f[n - sh], f[n - sh]);
		// cerr << all << '\n';
		all = mul(all, poss_sel);
		all = mul(all, poss_plc);
		all = mul(all, poss_oth);
		// cerr << all << '\n';
		// cerr << poss_sel << ' ' << poss_plc << ' ' << poss_oth << endl;
		if (sh & 1) {
			ans = sub(ans, all);
		} else {
			ans = add(ans, all);
		}
	}
	// cerr << endl;
	cout << ans << '\n';
}


Measured memory_bytes: 5120
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

//int n, m, x;
//
//vector<int> c(12,0);
//vector<vector<int>> A(12, vector<int>(12, 0));



int main()
{
    int a, b, ab, x, y;
    cin >> a >> b >> ab >> x >> y;
    int sum;
    int min = 2147483647;

    int dai = (x > y ? x : y);

    for (int i = 0; i < dai+1; i++) {
        int x2 = (x - i > 0 ? x - i : 0);
        int y2 = (y - i > 0 ? y - i : 0);

        sum = a * (x2) + b * (y2) + ab * i * 2;

        if (sum < min) {
            min = sum;
        }
    }


    printf("%d", min);


    return 0;

}

Measured memory_bytes: 256
X, N = gets.split.map(&:to_i)
ary = gets.split.map(&:to_i)
val = 100000
-1.upto(101) do |n|
    next if ary.include?(n)
    d = (X - n).abs
    if d < (X-val).abs
        val = n
    end
end
puts val

Measured memory_bytes: 14272
INF = float('inf')

D, G = map(int, input().split())
pcs = [tuple(map(int, input().split())) for i in range(D)]

sumP = sum([p for p, c in pcs])

def max2(a, b):
    return a if a >= b else b


# 【配るDP】
# dp[i+1][j]: pcs[i]まで考慮したとき、j問で達成できるスコアの最大値
dp = [[-INF] * (sumP + 1) for i in range(D + 1)]
dp[0][0] = 0
for i, (p, c) in enumerate(pcs):
    for j in range(sumP + 1):
        if dp[i][j] != -INF:
            for k in range(p):
                dp[i + 1][j + k] = max2(dp[i + 1][j + k], dp[i][j] + 100 * (i + 1) * k)
            dp[i + 1][j + p] = max2(dp[i + 1][j + p], dp[i][j] + 100 * (i + 1) * p + c)

for j in range(sumP + 1):
    if dp[D][j] >= G:
        print(j)
        break


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int main(){
    lli a,b,c,k;
    cin>>a>>b>>c>>k;
    lli ans=0;
    ans+=min(k,a);
    k-=min(a,k);
    k-=min(b,k);
    ans-=min(k,c);
    k-=min(k,c);
    cout<<ans<<endl;

       
}

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


result=[]
if m%2==1:
    j=1
    for i in range(m//2):
        result.append((j,2*(m//2-i)+j))
        j+=1
    j=2*(m//2)+2
    for i in range(m//2+1):
        result.append((j,2*(m//2+1-i)+j-1))
        j+=1

else:
    j=1
    for i in range(m//2):
        result.append((j,2*(m//2-i)+j))
        j+=1
    j=2*(m//2)+2
    for i in range(m//2):
        result.append((j,2*(m//2-i)+j-1))
        j+=1

    
for item in result:
    print(item[0],item[1])


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

int main() {

int N;
string S;
string T;
  
  cin >> N;
  
  for (int i = 0; i < N; i++){
    T = "Three";
    cin >> S;
    if (S == "Y"){
      T = "Four";
      break;
    }
  }
  
  cout << T << endl;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
ll chk[200001] = {0};
ll ans[200001] = {0};

int main(){
  ll n;
  cin >> n;
  ll a;
  ll memo[n];
  rep(i,n){
    cin >> a;
    memo[i] = a;
    chk[a]++;
  }
  ll sum = 0;
  for(int i = 1; i <= 200000; i++){
    ans[i] = chk[i]*(chk[i]-1)/2;
    sum += ans[i];
  }
  ll p;
  rep(i,n){
    p = sum - ans[memo[i]];
    p += ans[memo[i]]*(chk[memo[i]]-2)/chk[memo[i]];
    printf("%lld\n", p);
  }
  return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n,sn=0,m;

    scanf("%d",&n);

    m=n;
    while(m!=0)
    {
        sn+=m%10;
        m=m/10;
    }

    if(n%sn==0) printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,c,d = LI()

    dp = [[0] * (d+1) for _ in range(c+1)]
    dp[a][b] = 1

    for i in range(a,c+1):
        for j in range(b,d+1):
            if a < i:
                dp[i][j] += dp[i-1][j] * j % mod2
            if b < j:
                dp[i][j] += dp[i][j-1] * i % mod2
            if a < i and b < j:
                dp[i][j] -= dp[i-1][j-1] * (i-1) * (j-1) % mod2

    return dp[c][d] % mod2


print(main())




Measured memory_bytes: 154736
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N,M,i,sig=0;
    int* A;
    scanf("%d %d",&N,&M);
    A=(int*)malloc(sizeof(int)*M);
    for(i=0;i<M;i++){
        scanf("%d",&A[i]);
        sig=sig+A[i];
    }
    if(sig<=N){
        printf("%d\n",N-sig);
    }else{
        printf("-1\n");
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;


	int ans = 0;

	int x = a;
	int y = b;
	int z = c;


	if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && a == b && b == c) {
		cout << 0 << endl;
		return 0;
	}
	else if (a == b && b == c) {
		cout << -1 << endl;
		return 0;
	}
	else {
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			int x = (b + c) / 2;
			int y = (a + c) / 2;
			int z = (a + b) / 2;

			a = x;
			b = y;
			c = z;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define int long long
int a[215614];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < n; i++)ans1 += abs(a[n / 2] - a[i]);
	for (int i = 0; i < n; i++)ans2 += abs(a[n / 2 - 1] - a[i]);
	cout << min(ans2, ans1) << endl;
	cin >> n;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <utility>
using namespace std;

class Dice{
  int T,S,E,W,N,D;

  public:
  Dice(int T, int S, int E,
      int W, int N, int D)
    : T(T), S(S), E(E),
    W(W), N(N), D(D) {}

  int get_top(){ return T; }
  int get_south(){ return S; }
  int get_east() { return E; }

  void rot(char c){
    int tmp;
    tmp = T;
    switch(c){
      case 'N':
        T = S; S = D; D = N; N = tmp;
        break;
      case 'S':
        T = N; N = D; D= S; S = tmp;
        break;
      case 'E':
        T = W; W = D; D = E; E = tmp;
        break;
      case 'W':
        T = E; E = D; D = W; W = tmp;
        break;
    }
  }
};

int main(){
  int num[6];
  for(int i=0;i<6;i++) cin>>num[i];
  Dice dice(num[0],num[1],num[2],num[3],num[4],num[5]);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int front,top;
    cin>>top>>front;;
    int counter = 0;
    while(front!=dice.get_south()){
      if(counter == 3) dice.rot('W');
      dice.rot('S');
      counter ++;
    }
    while(top!=dice.get_top()){
      dice.rot('W');
    }
    cout<<dice.get_east()<<endl;
  }

  return 0;

}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int len = 0, l = 0, i = 1;
	while(i<n){
		if(a[i] > a[i-1]){
			len = max(l, len);
			l = 0;
		}
		else
			l++;
		i++;
	}
	len = max(l, len);
	cout<<len;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, A, B; cin >> N >> A >> B;

  int ans = 0;
  
  rep(i, N+1) {
    int k = 0;
    string s = to_string(i);
    rep(j, s.size()) {
      k += s[j]-'0';
    }
    if(k >= A && k <= B) ans+=i;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
while True:

    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    for i in range(a):
        for j in range(b):
            if (i % 2 == 1 and j % 2 == 0) or (i % 2 == 0 and j % 2 == 1):
                print(".", end="")
            else:
                print("#", end="")

        print()
    print()



Measured memory_bytes: 7004
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int X;
	cin >> X;

	int ans = 0;
	for (int i = 0; i <= A; i++)
	{

		for (int j = 0; j <= B; j++)
		{

			for (int k = 0; k <= C; k++)
			{
				int sum = i * 500 + j * 100 + k * 50;
				if (sum == X) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
long long n,m,i,j,col[100005],fa[100005],c0,c1,c2,f;
vector<long long> bi[100005];
long long fnd(long long x)
{
	if(fa[x]==x) return x;
	return fa[x]=fnd(fa[x]);
}
void dfs(long long x)
{
	ff(bi[x],it){
		if(col[*it]==col[x]) f=0;
		if(col[*it]==0){
			col[*it]=3-col[x];
			dfs(*it);
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	fz1(i,n){
		fa[i]=i;
	}
	fz1(i,m){
		long long x,y;
		scanf("%lld%lld",&x,&y);
		bi[x].push_back(y);
		bi[y].push_back(x);
		fa[fnd(x)]=fnd(y);
	}
	fz1(i,n)if(fa[i]==i){
		if(bi[i].empty()){c0++;continue;}
		f=1;col[i]=1;dfs(i);
		if(f) c2++; else c1++;
	}
	cout<<c0*c0+2*c0*(n-c0)+(c1+c2)*(c1+c2)+c2*c2<<endl;
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <map>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.qc", "r", stdin );
	int a,b,c;
	int ca, cb, cc, d;
	enum {  FAIL = 0, NORMAL = 1, UNKNOWN = 2 };
	while (cin >> a >> b >> c && a && b && c ){
		int n,m;
		cin >> n;
		multimap <int, pair <int, pair <int, int> > > ti;  
		for (int i = 0; i < n; ++i){
			cin >> ca >> cb >> cc >> d;
			ti.insert (make_pair (ca, make_pair (cb, make_pair (cc, d ) ) ) );
		} // end for
		m = a + b + c;
		vector <int> t (m + 1, UNKNOWN );
		vector <int> pre_t;
		do{
			pre_t = t;
			multimap <int, pair <int, pair <int, int> > >::iterator it = ti.begin();
			for (; it != ti.end(); ++it){
				a = (*it).first;
				b = (*it).second.first;
				c = (*it).second.second.first;
				d = (*it).second.second.second;

				if (d == 1 ){	// case exam passed
					t[a] = t[b] = t[c] = NORMAL;
				}else{ // if (d == 0 ) case exam not passed
					if ( t[a] == NORMAL && t[b] == NORMAL && t[c] == UNKNOWN ){
						t[c] = FAIL;
					}else 
					if ( t[a] == UNKNOWN && t[b] == NORMAL && t[c] == NORMAL ){
						t[a] = FAIL;
					}else
					if ( t[a] == NORMAL && t[b] == UNKNOWN && t[c] == NORMAL ){
						t[b] = FAIL;
					} // end if
				} // end if
			} // end for
		}while (t != pre_t ); // end while

		for (int i = 1; i <= m; ++i){
			cout << t[i] << endl;
		} // end for

	} // end loop
		
	return 0;
}

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

#define IO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define m(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=3e5+10;

int main(){
	IO;
	string s;
	cin>>s;
	int ans=0;
	int vis[3];
	m(vis,0);
	for(int i=0;i<3;i++)
		if (s[i]=='a'&&!vis[0]){
			vis[0]=1;
			ans++;
		}
		else if (s[i]=='b'&&!vis[1]){
			ans++;
			vis[1]=1;
		}
		else if (s[i]=='c'&&!vis[2]){
			vis[2]=1;
			ans++;
		}
	if (ans==3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [a, b, _] <- map read <$> readString
  print $ a * b `div` 2


Measured memory_bytes: 508
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;

//是质数就输出 1，否则输出 0 

int prime(int x){
	if(x==1 || x==0)return 0;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return 0;
	}
	return 1;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	int start=10;
	for(int i=0;i<n;i++){
		for(int j=start;j<55555;j++){
			if(prime(j)==1 && j%5==1){
				printf("%d ",j);
				start=j+1;
				//printf("start=%d\n",start);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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 Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    rep(i, n){
        if((i+1)%3 == 0 || (i+1)%5 == 0){
            
        }
        else {
            sum += i+1;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n)
b[0]=(a[0]+(k-a[n-1]))
for i in range(1,n):
    b[i] = a[i]-a[i-1]
print(sum(b)-max(b))

Measured memory_bytes: 26420
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> dp(n + k + 10, 1e9 + 10);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N,M,C,count=0;
    cin >> N >> M >> C ;
    int sum;
    vector<int>b(M);
    for(auto &x:b){
        cin>>x;
    }
    
    vector<int>a(M);
    for(int i=0;i <N; i++){
        for(auto &y:a){
            cin>>y;
        }
        
        sum=0; 
        for(int j=0;j<M;j++){
            sum+=a[j]*b[j];
        }
        
        if(sum+C>0){
            count++;
        }
    }
    
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a, b, c, d, e = 0; 
  cin >> a >> b >> c; 
  for (int i = a; i <= b; ++i) {
    d = c % i;
    if (d == 0) {
      e = e + 1;
    }
  }
  cout << e << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    ll ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y;
    cin>>x>>y;
    int x1,y1;
    y1 = (y-2*x)/2;
    x1 = x-y1;
    if((y-2*x)/2.0==float((y-2*x)/2))
    {
        if((x1+y1==x)&&x1>=0&&y1>=0)
            cout<<"Yes";
        else
        {
            cout<<"No";
        }
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ans;
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0) ans = true;
        else{
            a -= d;
            if(a <= 0) ans = false;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    string S;
    cin >> N >> S;

    vector<ll> w(N), b(N);
    b[0] = (S[0]=='#') ? 1 : 0;
    w[N-1] = (S[N-1]=='.') ? 1 : 0;
    for(int i=1; i<N; i++){
        b[i] = b[i-1];
        if(S[i]=='#') b[i]++; 
    }
    for(int i=N-2; i>=0; i--){
        w[i] = w[i+1];
        if(S[i]=='.') w[i]++;
    }

    ll ans = min(w[0], b[N-1]);
    for(int i=0; i<N-1; i++) ans = min(ans, b[i]+w[i+1]);

    cout << ans << endl;
}

Measured memory_bytes: 3716