akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll INF = 1e9;

ll S[3];
ll ans = INF;
void calc_half(int a, int b){
    S[1] = ll (a)*(b/2);
    S[2] = ll (a)*(b-b/2);
    ans = min(ans, max(S[0],max(S[1],S[2]))-min(S[0],min(S[1],S[2])));
    //cout << a<<" "<< b<<" " <<S[0] << " " << S[1] << " " << S[2] << " " <<ans << endl;
}

void calc(int H, int W){
    for (int h=1;h<H;h++){
        S[0] = ll (H-h)*W;
        calc_half(h,W);
        calc_half(W,h);
    }
}
int main(){
    int H, W;
    cin >> H >> W;
    calc(H, W);
    calc(W, H);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int[] c = in.Int(9);
            int[] a = new int[3];
            int[] b = new int[3];
            for (int i = 0; i <= 100; i++) {
                for (int j = 0; j <= 100; j++) {
                    for (int k = 0; k <= 100; k++) {
                        a[0] = i;
                        a[1] = j;
                        a[2] = k;
                        b[0] = c[0] - a[0];
                        b[1] = c[4] - a[1];
                        b[2] = c[8] - a[2];
                        if (a[0] + b[1] == c[1] &&
                                a[0] + b[2] == c[2] &&
                                a[1] + b[0] == c[3] &&
                                a[1] + b[2] == c[5] &&
                                a[2] + b[0] == c[6] &&
                                a[2] + b[1] == c[7]) {
                            out.println("Yes");
                            return;
                        }
                    }
                }
            }
            out.println("No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 23252
n = int(input())
ans = 0

#########################  ネットから拾ってきた
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
######################### 

pf = prime_factorize(n)

import collections
c = collections.Counter(pf)

for i in sorted(set(pf)):
    res = c[i]
    for j in range(1,50):
        res -= j
        
        if res >= 0:
            ans += 1
            
        else:
            break
            
print(ans)

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

int main() {

	int num; //???????????\???????????°

	int t;   //????¨?
	int a;   //?¶??????°

	int ans; //??????

	while (true) {

		cin >> num;

		if (num == 0)
			break;

		ans = 0;

		for (int i = 1; i < num; i++) {

			t = i;
			a = i;

			while (t < num) {

				a++;
				t = t + a;


			}

			if (t == num)
				ans++;


		}

		cout << ans << endl;

	}

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int V, E;
int dp[1 << 15][20];
signed main() {
    cin >> V >> E;
    vector< vector<pii> > G(V);
    rep(i,0,E) {
        int s, t, d; cin >> s >> t >> d;
        G[s].pb(pii(t, d));
    }
    memset(dp, 0, sizeof(dp));
    rep(i,0,(1<<V)) rep(j,0,V) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(bit,0,1<<V) {
        rep(i,0,V) {
            rep(j,0,G[i].size()) {
                int to = G[i][j].fr, cost = G[i][j].sc;
                if(bit >> to & 1) continue;
                int nbit = bit | (1 << to);
                dp[nbit][to] = min(dp[nbit][to], dp[bit][i] + cost);
            }
        }
    }
    int ans = dp[(1<<V)-1][0];
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 8164
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x))%modulo)
#define Inf 10000000000000000



int main(){
	int N,K;
	cin>>N>>K;
	
	vector<int> a(N);
	vector<int> b(0);
	for(int i=0;i<N;i++){
		cin>>a[i];
		if(a[i]<K)b.push_back(a[i]);
	}
	
	int ans = 0;
	
	vector<vector<int>> dp1(b.size()+1,vector<int>(K+1,0));
	dp1[0][0] = 1;
	for(int i=1;i<=b.size();i++){
		for(int j=0;j<=K;j++){
			dp1[i][j] = max(dp1[i][j],dp1[i-1][j]);
			int a = j-b[i-1];
			if(a>=0)dp1[i][j] = max(dp1[i][j],dp1[i-1][a]);
		}
	}
	/*
	for(int i=0;i<=b.size();i++){
		for(int j=0;j<=K;j++){
			cout<<dp1[i][j]<<',';
		}
		cout<<endl;
	}
	*/
	for(int i=0;i<=b.size();i++){
		for(int j=1;j<=K;j++){
			dp1[i][j] += dp1[i][j-1];
		}
	}
	
	reverse(b.begin(),b.end());
	
	vector<vector<int>> dp2(b.size()+1,vector<int>(K+1,0));	
	dp2[0][0] = 1;
	for(int i=1;i<=b.size();i++){
		for(int j=0;j<=K;j++){
			dp2[i][j] = max(dp2[i][j],dp2[i-1][j]);
			int a = j-b[i-1];
			if(a>=0)dp2[i][j] = max(dp2[i][j],dp2[i-1][a]);
		}
	}
	
	reverse(dp2.begin(),dp2.end());
	reverse(b.begin(),b.end());
	for(int i=0;i<=b.size();i++){
		for(int j=1;j<=K;j++){
			dp2[i][j] += dp2[i][j-1];
		}
	}
	/*
	for(int i=0;i<=b.size();i++){
		for(int j=0;j<=K;j++){
			cout<<dp1[i][j]<<',';
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<=b.size();i++){
		for(int j=0;j<=K;j++){
			cout<<dp2[i][j]<<',';
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	for(int i=1;i<=b.size();i++){
		bool f = false;
		for(int j=0;j<=K;j++){
			int x = dp1[i-1][j];
			if(j!=0)x-=dp1[i-1][j-1];
			if(x<=0)continue;
			int mini = max(0,K-b[i-1]-j);
			if(K-1-j<0)break;
			int maxi = K-1-j;
			int k = dp2[i][maxi];
			
			
			if(mini!=0)k-=dp2[i][mini-1];
			if(k>0){
				f=true;
				break;
			}
		}
		if(!f){
			ans ++;
		}
		
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 196096
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e5+10;
char ch[N];
int main()
{
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i+=2) {
		cout<<ch[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S[i] == 'A'){
      cout << 'T';
    }
    else if(S[i] == 'T'){
      cout << 'A';
    }
    else if(S[i] == 'G'){
      cout << 'C';
    }
    else if(S[i] == 'C'){
      cout << 'G';
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 1000000000
using namespace std;


int main(void){
	int n, s;
	cin >> n >> s;
	vector<int> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	sort(x.begin(),x.end());
	int ans = INF;
	for(int i = 0; i < n; ++i){
		ans = min(ans, abs(x[i] - s));
	}
	for(int i = 1; i < n; ++i){
		ans = min(ans, x[i] - x[i-1]);
	}
	x.resize(n+1);
	x[n] = s;
	sort(x.begin(),x.end());
/*
	for(int i = 0; i < n+1; ++i){
		cout << x[i] << " ";
	}
	cout << ans << endl;
*/
	while(true){
		int a = 0;
		for(int i = 1; i < n+1; ++i){
			if((x[i] - x[i-1])%ans!=0){
				a = 1;
				ans--;
				break;
			}
		}
		if(a == 0)break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, m, c;
  readf("%s %s %s\n", &n, &m, &c);
  auto b = readln.chomp.split.to!(int[]);
  int cnt;
  foreach (_; 0..n) {
    int sum;
    auto a = readln.chomp.split.to!(int[]);
    foreach (i; 0..m) {
      sum += a[i] * b[i];
    }
    if (sum + c > 0) {
      cnt++;
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
using std::vector;
using std::sort;

int main(){
	int n;
	scanf("%d",&n);
	while( n > 0 ){
		int x=0, y=0;
		for(int i=0;i<n;++i){
			int tx, ty;
			scanf("%d%d",&tx,&ty);
			if( tx == ty )
				x+=tx, y+=tx;
			else
				tx>ty?x+=tx+ty:y+=tx+ty;
		}
		printf("%d %d\n", x, y);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[][] hapiness = new int[N][3];
        int[][] dp = new int[N][3];
        for(int i = 0; i < N ; i++) {
            hapiness[i][0] = scanner.nextInt();
            hapiness[i][1] = scanner.nextInt();
            hapiness[i][2] = scanner.nextInt();
        }

        dp[0][0] = hapiness[0][0];
        dp[0][1] = hapiness[0][1];
        dp[0][2] = hapiness[0][2];
        for(int i = 1; i < N; i++) {
            for(int j = 0; j < 3; j++) {
                if(j != 0) dp[i][j] = Math.max(dp[i][j], dp[i-1][0] +  hapiness[i][j]);
                if(j != 1) dp[i][j] = Math.max(dp[i][j], dp[i-1][1] +  hapiness[i][j]);
                if(j != 2) dp[i][j] = Math.max(dp[i][j], dp[i-1][2] +  hapiness[i][j]);
            }
        }
        int ret = 0;
        ret = Math.max(dp[N-1][0], dp[N-1][1]);
        ret = Math.max(ret, dp[N-1][2]);
        System.out.println(ret);
    }
}


Measured memory_bytes: 101144
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};

int main(){

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

    int h, w; cin >> h >> w;
    string mat[h];
    rep(i, h){
        cin >> mat[i];
    }

    rep(i, h){
        rep(j, w){
            if(mat[i][j] == '.') continue;

            queue<P> que;
            que.push({i, j});
            int cnt = 0;

            while(!que.empty()){
                cnt++;
                P now = que.front();
                que.pop();
                ll inow = now.first;
                ll jnow = now.second;
                mat[inow][jnow] = '.';

                rep(k, 4){
                    ll inxt = inow + di[k];
                    ll jnxt = jnow + dj[k];
                    if(inxt == -1 || inxt == h) continue;
                    if(jnxt == -1 || jnxt == w) continue;

                    if(mat[inxt][jnxt] == '#'){
                        mat[inxt][jnxt] = '.';
                        que.push({inxt, jnxt});
                    }
                }
            }

            if(cnt == 1){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var es [][]int

func all(searched []bool) bool {
	for i := 0; i < len(searched); i++ {
		if searched[i] != true {
			return false
		}

	}
	return true
}

func dfs(searched []bool, now int) bool {
	searched[now] = true
	if all(searched) {
		return true
	}
	for i := 0; i < len(es[now]); i++ {
		if searched[es[now][i]] != true && dfs(searched, es[now][i]) {
			return true
		}
	}
	return false
}

func main() {
	nm := strings.Split(nextLine(), " ")
	n, _ := strconv.Atoi(nm[0])
	m, _ := strconv.Atoi(nm[1])
	for i := 0; i < n; i++ {
		esTmp := []int{}
		es = append(es, esTmp)
	}

	a := make([]int, m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		ab := strings.Split(nextLine(), " ")
		tmp, _ := strconv.Atoi(ab[0])
		a[i] = tmp
		tmp, _ = strconv.Atoi(ab[1])
		b[i] = tmp
	}

	ret := 0
	for i := 0; i < m; i++ {
		es = make([][]int, n)
		for j := 0; j < n; j++ {
			es[j] = []int{}
		}
		for j := 0; j < m; j++ {
			if i != j {
				es[a[j]-1] = append(es[a[j]-1], b[j]-1)
				es[b[j]-1] = append(es[b[j]-1], a[j]-1)
			}
		}
		searched := make([]bool, n)
		if !dfs(searched, 0) {
			ret++
		}
	}

	fmt.Println(ret)

}


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

ll cal(ll a,ll b,ll x){
    ll p, start, ans;
    p = x;
    if(a%x != 0) p = a % x;
    start = a + (x-p);
    if(start > b){
        ans = 0;
    }else{
        ans = (b - start) / x + 1;
    }
    return ans; 
}

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

int main(){
    ll a, b, c, d;
    cin >>a >> b >> c >> d;
    ll c_d = c * d / gcd(c,d);
    ll ans;
    if(c!=d){
        ans = (b-a+1) - cal(a,b,c) - cal(a,b,d) + cal(a,b,c_d);
    }else{
        ans = (b-a+1) -cal(a,b,c);
    }
  
    /*cout << cal(a,b,c) << endl;
    cout << cal(a,b,d) << endl;
    cout << cal(a,b,c_d) << endl;*/
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	int suf[n + 1];
	suf[n] = 0;
	
	for(i = n - 1; i >= 0; i--)
	suf[i] = (suf[i + 1] + arr[i]) % MOD;
	
	int sum = 0, ans = 0;
	fo(i, 0, n) {
		int curr = (sum + suf[i + 1]) % MOD;
		curr = (1LL * curr * arr[i]) % MOD;
		ans = (ans + curr) % MOD;
	}
	cout << ans;
}


Measured memory_bytes: 5240
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n, q;
    scanf("%d %d", &n, &q);

    fenwick_tree<long long> fw(n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        fw.add(i, a);
    }

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int p, x;
            scanf("%d %d", &p, &x);
            fw.add(p, x);
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", fw.sum(l, r));
        }
    }
}

Measured memory_bytes: 8232
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
int N;
 
int main(){
    ll N, K;
	cin >> N >> K;
	vector<ll> a(N), b(N);
	rep(N){
		ll tmp;
		cin >> tmp;
		if(i == 0){
			if(tmp > 0){
				b[0] = tmp;
			}else{
				b[0] = 0;
			}
			a[0] = tmp;
		}else{
			if(tmp > 0){
				b[i] = b[i-1] + tmp;
			}else{
				b[i] = b[i-1];
			}
			a[i] = a[i-1] + tmp;
		}
	}

	ll ans = b[N-1] - b[K-1];
	if(a[K-1] > 0) ans += a[K-1];
	reppp(i, K, N-1){
		ll tmp = b[i-K] + b[N-1] - b[i];
		if(a[i] - a[i-K] > 0) tmp += a[i] - a[i-K];
		if(tmp > ans) {
			ans = tmp;
		}
	}
	cout << (ans>0?ans:0) << endl;
}

Measured memory_bytes: 1920
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

if -(-C//B)  > -(-A//D):
	print("No")
else:
	print("Yes")

Measured memory_bytes: 10044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int m, n; cin>>m>>n;
        if(m == 0) return 0;

        vector<bool> useYear(7370010, true);
        int cnt=0;
        for(int i=m; i<=7370000; i++){
            if(useYear[i]){
                cnt++;

                if(cnt == n + 1){
                    cout << i << endl;
                    break;
                }

                for(int j=2; i*j<=7370000; j++){
                    useYear[i*j] = false;
                }
            }
        }
    }
}


Measured memory_bytes: 3936
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    t <- getLine
    putStrLn $ map (\c->if c=='?' then 'D' else c) t

Measured memory_bytes: 11760
#include <bits/stdc++.h>
using namespace std;
int a[12][12];

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  
  for(int i=0;i<n;i++){
   cin>>c[i];
   for(int j=0;j<m;j++){
   cin>>a[i][j];
   }
  }
  
  int ans = 123456789;
  int all = 1<<n;
  for(int mask=0; mask<all; mask++){
  	vector<int> level(m);
    int cost = 0;
    for(int i=0; i<n; i++){
      if((mask>>i)&1){
      cost += c[i];
    	for(int j=0;j<m;j++){
       	level[j]+=a[i][j];
       	}
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++){
    	if(level[j]<x) ok = false;
    }
    if(ok) ans = min(ans,cost);
  }
  
  if(ans == 123456789) cout<<-1<<endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  int N = S.size();

  int dp[N + 1][13];
  memset(dp, 0, sizeof(dp));

  if (S[N - 1] == '?') {
    for (int i = 0; i < 10; ++i) {
      dp[1][i] = 1;
    }
  } else {
    int i = S[N - 1] - '0';
    dp[1][i] = 1;
  }

  int base = 10;
  int MOD = 1000000007;

  for (int idx = 1; idx < N; ++idx) {
    char s = S[N - idx - 1];
    int n = s - '0';

    if (s == '?') {
      for (int i = 0; i < 13; ++i) {
        for (int j = 0; j < 10; ++j) {
          int k = (i + (j * base) % 13) % 13;
          dp[idx + 1][k] = (dp[idx + 1][k] + dp[idx][i]) % MOD;
        }
      }
    } else {
      for (int i = 0; i < 13; ++i) {
        int j = (i + (n * base) % 13) % 13;
        dp[idx + 1][j] = (dp[idx + 1][j] + dp[idx][i]) % MOD;
      }
    }

    base = (base * 10) % 13;
  }

  cout << dp[N][5] << endl;

  return 0;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int n,m,a[310][310];
int c[310],u[310],ans;
struct node{
    int x,y;
}k[310];

int cmp(node a,node b){
    return a.x>b.x;
}

int main(){
    scanf("%d %d",&n,&m);
    ans=n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int x=1;x<=m;x++){
    	memset(u,0,sizeof(u));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(c[a[i][j]]) continue;
                u[a[i][j]]++;
                break;
            }
        }
        int maxn=0,p;
        for(int i=1;i<=m;i++){
            if(u[i]>maxn)  maxn=u[i],p=i;
        }
        c[p]=1;
        ans=min(ans,maxn);
    }
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int a, b, c;
    cin >> a >> b >> c;

    bool res = (a <= c && c <= b) || (a >= c && c >= b);
    
    cout << (res ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int n, k, a[N];

int main() {
   cin>>n>>k;
   for0(i, n) cin>>a[i];
   sort(a, a+n);
   int ans=0;
   for0(i, k) ans += a[i];
   cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl; 
}
    
    

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


int a[3005][3005];
ll dp[3005][3005][4];

int main(){
   int R,C,K;
   cin >> R >> C >> K;
   rep(i,K){
      int r,c,v;
      cin >> r >> c >> v;
      a[r-1][c-1] = v;
   }

   rep(i,R) rep(j,C){
      for(int k=2;k>=0;k--){
         chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      }
      rep(k,4){
         chmax(dp[i+1][j][0],dp[i][j][k]);
         chmax(dp[i][j+1][k],dp[i][j][k]);
      }
   }

   ll ans=0;
   rep(k,4) chmax(ans,dp[R-1][C-1][k]); 

   cout << ans << endl;
   return 0;  
}

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


int main() {
  ll n;
  cin >> n;
  queue<ll> q;
  rep(i,9){
    q.push(i+1);
  }
  ll count = 0;
  while(1){
    ll x;
    x = q.front();
    count++;
    if(count == n){
      cout << x;
      return 0;
    }
    q.pop();
    if(x % 10 == 0){
      q.push(x*10);
      q.push(x*10+1);
    }
    else if(x % 10 == 9){
      q.push(x*10+8);
      q.push(x*10+9);
    }
    else{
      ll a;
      a = x % 10;
      q.push(x*10+a-1);
      q.push(x*10+a);
      q.push(x*10+a+1);
    }
  }
    
  return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 30;
const ll mod = 1e9+7;

int main(){
    FASTIO;

    ll n;
    cin>>n;


    vector<string>a(n);
    vector<ll>b(n);

    ll ans= 0;

    string s;


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

    cin>>s;

    ll found = 0;

    for(int i=0;i<n;i++){
        if(found){
            ans+=b[i];
        }

        if(s==a[i])
            found=1;
    }

    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int ma = max(n, m);
  int mi = min(n, m);
  if (ma > mi + 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> fact;
  fact.push_back(1);
  int a = (ma == mi ? 2 : 1);
  for (int i = 1; i <= ma; i++) {
    fact.push_back(fact[i - 1] * i % MOD);
  }
  ll answer = fact[ma] * fact[mi] % MOD * a % MOD;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double to_rad(double degree){
	const double PI = 3.1415926535;

	return degree * PI / 180;
}

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

	cin >> a >> b >> c;

	cout << fixed << setprecision(5) << a * b * sin(to_rad(c)) / 2 << endl;
	cout << fixed << setprecision(5) << a + b + sqrt(a * a + b * b - 2 * a * b * cos(to_rad(c))) << endl;
	cout << fixed << setprecision(5) << b * sin(to_rad(c)) << endl;

	return 0;
}


Measured memory_bytes: 3440
import sys

input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    stro = []; remain = K
    start = H; end = 0
    idx = 0
    ans = []
    for i in range(H):
        tmp = list(input()[:-1])
        cnt = 0
        for j in tmp:
            cnt += j == '#'
        stro.append(cnt)
        remain -= cnt
        if cnt > 0:
            start = min(start, i)
            end = max(end, i)
        if cnt == 1:
            idx += 1
            ans.append([idx]*W)
        elif cnt >= 2:
            idx += 1
            cnttmp = 0
            anstmp = []
            for j in tmp:
                cnttmp += j=='#'
                idx += (cnttmp != 1 and j == '#' and cnt > 0)
                cnt -= (j == '#' and cnt > 0)*1
                anstmp.append(idx)
            ans.append(anstmp)
        else:
            if remain == K:
                continue
            anstmp = ans[-1].copy()
            ans.append(anstmp)
    
    for _ in range(start):
        print(*ans[0])
    for i in range(len(ans)):
        print(*ans[i])
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 7504
//
// Created by sark2 on 08-07-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cases int t;cin>>t;while(t--)
typedef long double ld;

string LCSQ(string s1, string s2){

    int dp[s1.length()+1][s2.length()+1];
    memset(dp,0,sizeof dp);
    string s = "";

    for(int i = s1.length()-1; i>=0; i--){
        for(int j = s2.length()-1; j>=0; j--){
            if(s1[i]==s2[j]){
                dp[i][j] = dp[i+1][j+1] + 1;

            }
            else{
                dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    int i , j = i = 0;
    while(i < s1.length() && j < s2.length()){
            if(s1[i] == s2[j]){
                s += s1[i];
                i++;
                j++;
            }
            else{
                if(dp[i+1][j] > dp[i][j+1])
                    i++;
                else j++;
            }
        }
    return s;
    }

   /* for(int i = 0; i <= s1.length(); i++){
        for(int j = 0; j <= s2.length(); j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
*/




int main() {
    IOS


     string s1,s2;
     cin>>s1>>s2;
     cout<<LCSQ(s1,s2);

}


Measured memory_bytes: 35456
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	string s;
	cin >> s;
	bool check[2] = {false};
	
	if(s[0] >= '2' || (s[0] == '1' && s[1] >= '3') || (s[0] == '0' && s[1] == '0')) check[0] = true;
	if(s[2] >= '2' || (s[2] == '1' && s[3] >= '3') || (s[2] == '0' && s[3] == '0')) check[1] = true;
	
	if(check[0] && check[1]) cout << "NA" << endl;
	else if(check[0]) cout << "YYMM" << endl;
	else if(check[1]) cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;
    return 0;
}

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

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

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int num;
			cin >> num;
			a[num - 1]++;
		}
	}

	int cnt = 0;

	for (int i = 0; i < m; i++) {
		if (a[i] == n) cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    transform(s.begin() + k - 1,s.begin() + k, s.begin() + k - 1, ::tolower);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	long long	N;
  	int	num;
 
  	num = scanf("%lld", &N);
  	if (num != 1)
      	return (0);
  
  	printf("%lld", N * (N - 1) / 2);
  	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int r, g, b;
    cin >> r >> g >> b;
    if((100*r+10*g+b)%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf1 = 1000000000;
const long long inf2 = 1ll<<55;

int n, k;
string str;

int main(){
	scanf("%d%d", &n, &k);
	cin >> str;

	char mn_c = 'z';
	int mx = 0, pos = 0;
	for (int i = 0; i < n; i++) mn_c = min(mn_c, str[i]);
	string str_rev = str;
	reverse(str_rev.begin() ,str_rev.end());

	str += str_rev;
	str += '0';
	for(int i = 1;i <= (n << 1); i++) {
		if (str[i] != str[i - 1]) {
			if (str[pos] == mn_c) mx = max(mx, i - pos);
			pos = i;
		}
	}

	string res("z");
	int M = min(n, (k >= 14 ? n : mx << (k - 1)));

	for(int i = 0; i < n; i++) {
		string s;
		for (int j = 0; j < mx; j++) s += mn_c;
		if (str.substr(i, mx) == s) {
			string t;
			for (int j = 0; j < M; j++) t += mn_c;
			for (int j = 0; j < n - M; j++) t += str[i + j + mx];
			res = min(res, t);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())


def saiki(tgt, i, count, ans):
    if i == 0 or tgt == 0:
        ans = min(tgt+count, ans)
        return ans

    num = tgt//temp[i]
    while num >= 0:
        nn = tgt - num*temp[i]
        ans = saiki(nn, i-1, count+num, ans)
        if ans < count+num:
            return ans
        num -= 1
    return ans


temp = [1]
a = 1
while n >= 6**a:
    temp.append(6**a)
    a += 1

b = 1
while n >= 9**b:
    temp.append(9**b)
    b += 1

temp.sort()
#print(temp)
print(saiki(n, len(temp)-1, 0, 10**9))


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
char reval(int n)	
{
	return (char)(n+96);
}
string base(ll n)
{
	string ans="";
	while(n>0)
	{
		int rem=n%26;
		if(rem!=0){
		char x=reval(rem);
		ans=ans+x;
		n=n/26;}
		else
		{
			ans=ans+'z';
			n=(n/26)-1;
		}
	}
	reverse(ans.begin(),ans.end());
	return ans;
}          
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	cout<<base(n)<<endl;
	return 0;
}

Measured memory_bytes: 3600
//#include <bits/stdc++.h>
 #include <algorithm>
  #include <bitset>
  #include <complex>
  #include <deque>
  #include <exception>
  #include <fstream>
  #include <functional>
  #include <iomanip>
  #include <ios>
  #include <iosfwd>
  #include <iostream>
  #include <istream>
  #include <iterator>
  #include <limits>
  #include <list>
  #include <locale>
  #include <map>
  #include <memory>
  #include <new>
  #include <numeric>
  #include <ostream>
  #include <queue>
  #include <set>
  #include <sstream>
  #include <stack>
  #include <stdexcept>
  #include <streambuf>
  #include <string>
  #include <typeinfo>
  #include <utility>
  #include <valarray>
  #include <vector>
  #include <array>
  #include <atomic>
  #include <chrono>
  #include <condition_variable>
  #include <forward_list>
  #include <future>
  #include <initializer_list>
  #include <mutex>
  #include <random>
  #include <ratio>
  #include <regex>
  #include <scoped_allocator>
  #include <system_error>
  #include <thread>
  #include <tuple>
  #include <typeindex>
  #include <type_traits>
  #include <unordered_map>
  #include <unordered_set>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

  ini(n);
  ini(n1);
  if(n>=13){
    out(n1);
  }
  else if(n>=6){
    out(n1/2);
  }
  else{
    out(0);
  }
  
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]
ct = 0
i = 0
while(i <= N):
  if i == N:
    ct += 1
    i = 0
  elif L[i] % 2 == 0:
    L[i] //= 2
    i += 1
  else:
    print(ct)
    break

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, k; string s;
    cin >> n >> s >> k;

    rep(i, 0, n) if (s[i] != s[k - 1]) s[i] = '*';
    cout << s << endl;
}

Measured memory_bytes: 256
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    string x;
    cin >> x;
    int n = x.size(),sum = 0;
    rep(i,0,n/2){
        if(x[i]!=x[n-i-1]){
            sum++;
        }
    }
    cout << sum;
}
// Abcd1234?

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()%2==1){
        cout<<s.size()<<endl;
    }else{
        cout<<s.size()-1<<endl;
    }
}

Measured memory_bytes: 4992
#include <iostream>
#include <climits>
#include <vector>
#include <cstring>
using namespace std;

#define V_MAX 10040
int N,E;
int INF = INT_MAX/4;

struct edge {
    int to,cap,rev;
    edge(int _to, int _cap, int _rev) {to = _to; cap=_cap; rev=_rev;}
};

vector<edge> G[V_MAX];
bool used[V_MAX];


void add_edge(int from, int to, int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size()-1));
}

int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap>0){
            int d = dfs(e.to, t, min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used,0,sizeof(used));
        int f = dfs(s,t,INF);
        if(f==0) return flow;
        flow += f;
    }
}

int main(){
    
    cin>>N;
    
    int s, t;
    s = 2 * N;
    t = s + 1;
    
    vector<pair<int,int>> r(N);
    for(int i=0; i<N; i++){
     cin >> r[i].first >> r[i].second;
     add_edge(s, i, 1);
    }
    
    vector<pair<int,int>> b(N);
    for(int i=0; i<N; i++){
      cin >> b[i].first >> b[i].second;
      add_edge(N+i, t, 1);
    }
    
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        if (r[i].first < b[j].first && r[i].second < b[j].second){
          add_edge(i, N+j, 1);
        }
      }
    }
    
    cout << max_flow(s, t) << endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())

l = list(map(int, input().split()))
count = 0

for i in range(n):
    mini = i
    for j in range(i,n):
        if l[j] < l[mini]:
            mini = j
    if i != mini:
        l[i], l[mini] = l[mini], l[i]
        count += 1

print(" ".join(map(str, l)))
print(count)



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  vll p(n);
  REP(i, n){
    cin >> p[i];
    p[i]--;
  }


  ll ans = 0;
  for(int i=0; i<n; i++){
    if(p[i] == i){
      ans++;
      if(i+1<n){
        p[i] = p[i+1];
        p[i+1] = i;
        i++;
      }
      else{
        p[i] = p[i-1];
        p[i-1] = i;
      }
    }
  }

  cout << ans <<  endl;
}


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

typedef long long int ll;

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        std::cout << 6 - (a+b) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
    let mut v: Vec<i32> = read_vec();
    v.sort();
    for (i, w) in v.iter().enumerate() {
        if i == v.len() - 1 {println!("{}", w)} else { print!("{} ", w)}
    }
}



Measured memory_bytes: 5028