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

int N , K , M , C[303][303] , f[303][303] , sum[303][303]; bool visf[303][303] , vissum[303][303];

int getf(int , int);
int getsum(int , int);

int main(){
	cin >> N >> K >> M;
	for(int i = 0 ; i <= N ; ++i){
		C[i][0] = 1;
		for(int j = 1 ; j <= i ; ++j)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;
	}
	cout << getf(N + 1 , 0) << endl; return 0;
}

int getf(int x , int y){
	if(y > K) return 0;
	if(visf[x][y]) return f[x][y];
	visf[x][y] = 1; if(x == 1) return f[x][y] = 1;
	for(int i = 1 ; i < x ; ++i)
		f[x][y] = (f[x][y] + 1ll * C[x - 2][i - 1] * getf(x - i , y) % M * getsum(i , y + 1)) % M;
	return f[x][y];
}

int getsum(int x , int y){
	if(y > K) return 0;
	if(vissum[x][y]) return sum[x][y];
	vissum[x][y] = 1; return sum[x][y] = (getsum(x , y + 1) + getf(x , y)) % M;
}

Measured memory_bytes: 1536
/**
 * author  : UshanGhosh
 * created : 2020-08-31 20:36:59
**/ 

#include<bits/stdc++.h>
using namespace std;

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     1e9+7
#define    inf     1e18
#define    endl    '\n'

ll cnt[2000000];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    while(t--){
        long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
        cin>>n;
        ll ar[n];
        ll ans;
        for(i=0;i<n;i++){
            cin>>ar[i];
            cnt[ar[i]]++;
            if(i==0) ans = ar[i];
            else ans = __gcd(ans, ar[i]);
        }
        if(ans!=1){
            cout<<"not coprime\n";
            return 0;
        }
        ll err = 0;
        for(i=2;i<=1000000;i++){
            ll cc = 0;
            for(j=i;j<=1000000;j+=i){
                cc+=cnt[j];
            }
            if(cc>1){
                err++;
                break;
            }
        }
        if(err) cout<<"setwise coprime\n";
        else cout<<"pairwise coprime\n";
    }
}

Measured memory_bytes: 19240
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	sum1 := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
		sum1 += tmp
	}
	mn := math.MaxInt32
	sum2 := 0
	for i := 0; i < n - 1; i++ {
		sum2 += arr[i]
		sum1 -= arr[i]
		tmp := abs(sum1 - sum2)
		if mn > tmp {
			mn = tmp
		}
	}
	fmt.Println(mn)
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 6912
/* C */

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

int main(){
	int nz = 0, no = 0;
	string s;

	cin >> s;
    
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '0') nz++;
		else no++; 
	}

	cout << min(nz, no) * 2 << endl;

}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
queue<string> que;
bool solve(int a, int b, int c, int d){
  if(a < b || d < b)return false;
  if(c >= b)return true;
  int j = b-__gcd(b,d)+(a%__gcd(b,d));
  if(j > c)return false;
  return true;
}
signed main(){
  int t;cin>>t;
  rep(i,t){
    int a, b, c, d;cin>>a>>b>>c>>d;
    que.push((solve(a,b,c,d) ? "Yes" : "No"));
  }
  while(!que.empty()){
    cout << que.front() << endl;
    que.pop();
  }
}


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

int main(){
    int n,m,x;  cin>>n>>m>>x;
    int ansZ=0;
    int ansN=0;

    for(int i=0;i<m;i++){
        int a;  cin>>a;
        if(x<a)ansN++;
        else if(a<x)ansZ++;
    }

    cout<<min(ansZ,ansN)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,k;
char c[6][6];
char temp[6][6];
void copy(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			temp[i][j]=c[i][j];
	}
}
void color(int i,int j){
	for(int x=0;x<h;x++){
		if(i & (1<<x)){
			for(int y=0;y<w;y++)
				temp[x][y]='R';
		}
	}
	for(int y=0;y<w;y++){
		if(j & (1<<y)){
			for(int x=0;x<h;x++)
				temp[x][y]='R';
		}
	}
}
bool check(){
	int cnt=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(temp[i][j]=='#')
				cnt++;
		}	
	}
	if(cnt==k)
		return true;
	return false;
}
int main() {
	
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			cin>>c[i][j];
	}
	int trp=(1<<h);
	int tcp=(1<<w);
	int ans=0;
	for(int i=0;i<trp;i++){
		for(int j=0;j<tcp;j++){
			copy();
			color(i,j);
			if(check())
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3552
N,K = map(int,input().split())
A = list(map(int,input().split()))

dic = {}
for i in A:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

LD = list(dic.values())

L = sorted(LD)

if len(L) <= K:
    print(0)
else:
    print(sum(L[:-K]))

Measured memory_bytes: 32184
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = Math.abs(sc.nextLong());
    long k = sc.nextLong();
    long d = sc.nextLong();
    sc.close();
    long cnt = x / d;
    x = x - (d * Math.min(k, cnt));
    if(cnt >= k){
      System.out.println(x);
    } else {
      k -= cnt;
      if(k % 2 == 0){
        System.out.println(x);
      } else {
        System.out.println(Math.abs(x - d));
      }
    }
  }
}

Measured memory_bytes: 35776
import java.util.*;

class Main {

    static int answer = 0;

    static void solve(int n, int s, int k) {

        if (n == 0) {
            if (s == 0) {
                answer += 1;
                return;
            } else {
                return;
            }
        } else if (s < k) {
            return;
        } else if (k >= 10) {
            return;
        }
        
        solve(n, s, k+1);
        solve(n-1, s-k, k+1); 

    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(true) {
            int n = sc.nextInt();
            int s = sc.nextInt();
            answer = 0;

            if(n == 0 && s == 0)    break;

            solve(n, s, 0);
            System.out.println(answer);
        }

    }
}

Measured memory_bytes: 12000
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		int n =  sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Long> al = new ArrayList<>();
		for(int i=0;i<n;i++)
			al.add(sc.nextLong());
		
		PriorityQueue<Long> pr = new PriorityQueue<>(Collections.reverseOrder());
		for(int i=0;i<n;i++){
			pr.add(al.get(i));
		}
		
		while(m>0){
			m--;
			long val = pr.poll();
			if(val%2==0){
				pr.add(val/2);
			}else pr.add(val/2);
		}
		long total=0;
		while(pr.size()!=0){
			total+=pr.poll();
		}
		System.out.println(total);
		
		
		
	}
	
	public static class pair{
		int pos;
		int bomb;
	}
	
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	

	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bomb-o2.bomb;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 44632
//Silk Road AOJ:0611
//???????¨???????????????????
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

#define min 2100000000

int a,b,c[1000],d[1000],dp[1001][1001];

int main(){
	
	scanf("%d %d",&a,&b);
	
	for(int i=0;i<=b;i++){
		for(int j=0;j<=a;j++){
			dp[i][j]=min;
		}
	}
	
	for(int i=1;i<=a;i++) cin >> c[i];
	
	for(int i=1;i<=b;i++) cin >> d[i];
	
	dp[0][0]=0;
	
	for(int i=0;i<b;i++){
		for(int j=0;j<=a;j++){
			if(dp[i+1][j]>dp[i][j]){
				dp[i+1][j]=dp[i][j];
			//	printf(" d[%d][%d] %d",i+1,j,dp[i+1][j]);
			}
			if(dp[i+1][j+1]>c[j+1]*d[i+1]+dp[i][j]){
				dp[i+1][j+1]=c[j+1]*d[i+1]+dp[i][j];
			//	printf(" d[%d][%d] %d",i+1,j+1,dp[i+1][j+1]);
			}
		}
		//printf("\n");
	}

	cout << dp[b][a] <<endl;
	
	return 0;
}

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

int n;

vector<int> x;
vector<int> y;
vector<int> h;

int main() {
	cin >> n;
	x.resize(n);
	y.resize(n);
	h.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> x.at(i) >> y.at(i) >> h.at(i);
	}

	for (int cx = 0; cx <= 100; ++cx)
	{
		for (int cy = 0; cy <= 100; ++cy)
		{
			for (int he = h.at(0)-200 ; he <= h.at(0)+200; ++he)
			{
				int ac = 0;
				for (int i = 0; i < n; ++i)
				{
					if (max(he-abs(x.at(i)-cx)-abs(y.at(i)-cy), 0)  == h.at(i)) ac++;
				}
				if (ac==n)
				{
					cout << cx << " " << cy << " " << he<< endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
x = input()

a = int(x[:2])
b = int(x[2:])

if (a > 12 and b > 12) or (a > 12 and 0 == b) or (b > 12 and 0 == a)or (a == 0 and b == 0):
    print("NA")
elif 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif a > 12 or a == 0:
    print("YYMM")
else:
    print("MMYY")

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

H,W=map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input().strip()))

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        c = 0
        for ii in range(i-1,i+2):
            if ii < 0 or ii >= H:
                continue
            for jj in range(j-1,j+2):
                if jj < 0 or jj >= W:
                    continue
                if S[ii][jj] == '#':
                    c += 1
        S[i][j] = str(c)

for row in S:
    print("".join(row))


Measured memory_bytes: 68304
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

/*
 * ref. http://drken1215.hatenablog.com/entry/2018/06/08/210000
 *
 * usage:
 *
 * Combination *c;
 * 
 * const int MOD = 1000000007;
 * const int MAX_N = 100000;
 * 
 * int main(void) {
 *     int n, k;
 *     cin >> n >> k;
 *     c = new Combination(2 * MAX_N, MOD);
 *     cout << c->com(n + k - 1, k) << endl;
 *     delete(c);
 *     return 0;
 * }
 */
class Combination {
    public:
        const int max;
        const int mod;
        vector<ll> fac, finv, inv;

        Combination(int max, int mod) : max(max), mod(mod), fac(max), finv(max), inv(max) {
            init();
        }

        ll com(int n, int k) {
            if (n < k) return 0LL;
            if (n < 0 || k < 0) return 0LL;
            // return (fac[n] * ((finv[k] * finv[n - k]) % mod)) % mod;
            return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
        }

    private:
        void init() {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < max; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
};

Combination *c;

const int MOD = 1000000007;
const int MAX_N = 1000000;

int main(void) {
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    const int move_cnt = (X + Y) / 3;
    int n = -1, m = -1;
    for (int i = 0; i <= move_cnt; i++) {
        int cand_n = i;
        int cand_m = move_cnt - cand_n;
        int y = cand_n * 2 + cand_m;
        int x = cand_n + cand_m * 2;
        if (x == X && y == Y) {
            n = cand_n;
            m = cand_m;
            break;
        }
    }
    if (n < 0 && m < 0) {
        cout << 0 << endl;
        return 0;
    }
    // printf("n: %d, m: %d\n", n, m);

    c = new Combination(2 * MAX_N, MOD);
    cout << c->com(n + m, n) << endl;
    delete(c);

    return 0;
}


Measured memory_bytes: 47104
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N, W = map(int, input().split())
    weight, value = [0] * N, [0] * N
    for i in range(N):
        weight[i], value[i] = map(int, input().split())



    # この前段階で、荷物の数N、ウェイトの上限W、
    # weightの表weightとvalueの表valueは用意しておく。
    def knapsack(N, W, weight, value):

        V=sum(value)
        # dp[i][v]はvを運べる最小のウェイトを意味する。
        # 求めたいのは、dp[N][v]<=Wなるvのmax
        dp = [[float('inf')] * (V + 1) for _ in range(N + 1)]
        dp[0][0]=0

        for i in range(N):
            for v in range(V + 1):
                if v >= value[i]:
                    dp[i + 1][v] = min(dp[i][v], dp[i][v - value[i]] + weight[i])
                else:
                    dp[i + 1][v] = dp[i][v]

        # dp[N][j]がW以下であるようなjの最大値が答えになる
        ans = 0
        for v in range(V + 1):
            if dp[N][v] <= W:
                ans = v

        return ans




    print(knapsack(N, W, weight, value))


resolve()

Measured memory_bytes: 300904
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll A = 0;
	ll ans = 0;
	ll Amin = 10;
	REP(i, 5) {
		cin >> A;
		if (A % 10 > 0) Amin = min(Amin, A % 10);
		A = (A + 9) / 10;
		A *= 10;
		ans += A;

	}
	ans -= (10 - Amin);

	cout << ans << endl;

	return 0;
}

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

int H,W,M;
int numh[300005], numw[300005];
map<pair<int, int>,int>m;
vector<int>h,w;
int main()
{
	int i,j;
    scanf("%d%d%d", &H, &W, &M);
    for(i=1;i<=M;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        m[make_pair(x,y)]=1;
        numh[x]++;
        numw[y]++;
    }
    int mx=0,mmx;
    for(i=1;i<=H;i++)
        if(mx<numh[i])
            mx=numh[i];
    for(i=1;i<=H;i++)
        if(numh[i]==mx)
            h.push_back(i);
    mmx=mx; mx=0;
    for(i=1;i<=W;i++)
        if(mx<numw[i])
            mx=numw[i];
    for(i=1;i<=W;i++)
        if(numw[i]==mx)
            w.push_back(i);
    int sh=h.size(),sw=w.size(),ans;
    for(i = 0;i < sh;i++)
    {
        int hh = h[i];
        for(j = 0;j < sw;j++)
        {
            int ww = w[j];
            if(m[make_pair(hh, ww)]==0)
            {
                printf("%d\n",mmx+mx);
                return 0;
            }
        }
    }
    printf("%d\n",mmx+mx-1);
    return 0;
}


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

int main() {
    ll MOD = 1e9 + 7;
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> cnt(100000, 0);
    cnt[0] = 3;
    ll ans = 1;
    for (ll a : A) {
        ll p = cnt[a] - cnt[a + 1];
        cnt[a + 1]++;
        ans = (ans * p) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int i;
  vector<int> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  int sum=0;
  for(i=0;i<n;i++){
	sum+=min(2*vec.at(i),2*(k-vec.at(i)));
             }
  cout << sum;
             }

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int a, b;
    cin >> a >> b;
    set<int> s;
    s.insert(a);
    s.insert(b);
    REP(i, 1, 4) if (!s.count(i)) {cout << i << endl; return 0;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is_prime(int x){
	if(x<1)return false;
	for(int i=2; i*i<x; ++i){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	int x;
	cin>>x;
	while(!is_prime(x)){
		x++;
	}
	cout<<x<<endl;
	return 0;
}



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

#define ll long long int
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b, c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    
	// your code goes here
	return 0;
}


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

int k,head=99;
int a[105];

inline void change()//112,head=99
{
	int j=101;
	for (int k=j-1;k>=head+1;k--)
	{
		if (a[k]!=a[k-1]+1&&a[k]!=9)
		{
			j=k;
			break;
		}//j=97
	}
	if (j!=101)//222100
	{
		a[j]++;
		for (int k=j+1;k<=100;k++)
		{
			if (a[k-1]-1>=0)  a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	if (j==101&&a[head]!=9)
	{
		a[head]++;
		for (int k=head+1;k<=100;k++)
		{
			if (a[k-1]-1>=0)  a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	else if (a[head]==9&&j==101)
	{
		head--;
		a[head]=1;
		for (int k=head+1;k<=100;k++)  a[k]=0;
	}
}

signed main()
{
	cin>>k;
		
	if (k<=9)  return cout<<k<<endl,0;
	k-=10;
	a[head]=1,a[head+1]=0;
	
	for (int i=1;i<=k;i++)  change();
	for (int i=head;i<=100;i++)  cout<<a[i];
	
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	string s;
	cin>>s;
	int ans=0;
	int cnt=0;
	rep(i,s.size()){
		if(i%2==0){
			if(s[i]=='0')cnt++;
		}
		else{
			if(s[i]=='1')cnt++;
		}

	}
	ans=cnt;
	cnt=0;
	rep(i,s.size()){
		if(i%2==0){
			if(s[i]=='1')cnt++;
		}
		else{
			if(s[i]=='0')cnt++;
		}
	}
	ans=min(ans,cnt);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll a,b,x;
  cin >> a >> b >> x;
  if(a==0) {
    cout << b/x + 1 << endl;
    return 0;
  }
  if(x==1){
    cout << b-a+1 << endl;
    return 0;
  }
  ll ans = b/x - (a-1)/x;
  cout << ans << endl;

  return 0;
    

}


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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	map<int,int> mp;
	for (int i = 1; i <= n; ++i)
	{
		mp[i] = 0;
	}
	for (int i = 0; i < k; ++i)
	{
		int sz;
		cin>>sz;

		for (int i = 0; i < sz; ++i)
		{
			int x;
			cin>>x;

			mp[x]++;
		}
	}
	int ans=0;
	for (int i = 1; i <= n; ++i)
	{
		if(mp[i] == 0)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  int k,x;
  cin>>k>>x;
  k*500>=x ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

typedef  long long ll;
ll inf = (ll)20000000000000;
vector<ll>x,y,z;
int n,k,s;
ll calc(int i,int j){
    ll tx=0,ty=0,tz=0;    
    if(x[i]<=x[j]&&x[j]<=x[i]+s){
        tx = x[i]+s-x[j];
    }
    if(y[i]<=y[j]&&y[j]<=y[i]+s){
        ty = y[i]+s-y[j];
    }
    if(z[i]<=z[j]&&z[j]<=z[i]+s){
        tz = z[i]+s-z[j];
    }
    if(x[j]<=x[i]&&x[i]<=x[j]+s){
        tx = x[j]+s-x[i];
    }
    if(y[j]<=y[i]&&y[i]<=y[j]+s){
        ty = y[j]+s-y[i];
    }
    if(z[j]<=z[i]&&z[i]<=z[j]+s){
        tz = z[j]+s-z[i];
    }
    if(tx==0||ty==0||tz==0){
        return -1;
    }
    return 2*(tx*ty+ty*tz+tz*tx);
}

ll saiki(int st,int i,int b,int c,vector<vector<pair<int,ll> > > &g){
    if(c==k){
        ll p = 0;
        for(auto x:g[i]){
            if(x.first==st&&k!=2){
                p = x.second;
            }
        }
        return p;
    }
    ll p = -inf;
    for(auto x:g[i]){
        if(x.first!=st&&x.first!=b){
            p = max(p,x.second+saiki(st,x.first,i,c+1,g));
        }
    }
    return p;
}

int main(){
    
    while(scanf("%d %d %d",&n,&k,&s)&&n!=0){
        x.resize(n);y.resize(n);z.resize(n);
        for(int i=0;i<n;i++)scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
        vector<vector<pair<int,ll> > >g(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i<j){
                    ll sm = calc(i,j);
                    if(sm!=-1){
                        g[i].push_back(make_pair(j,sm));
                        g[j].push_back(make_pair(i,sm));
                    }
                }
            }
        }
        ll ans = -1;
        if(k==1){
            cout << s*s*6 << endl;
            continue;
        }
        for(int i=0;i<n;i++){
            ans = max(ans,saiki(i,i,-1,1,g));
        }
        if(ans ==-1)cout << -1 << endl;
        else cout << s*s*k*6-ans << endl;

    }
    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vii;
typedef pair<int, int> pi;
typedef tuple<int, int, int> t3;
typedef map<int, int> mi;
#define fi first
#define se second
#define vt vector
#define be begin()
#define ed end()
#define sz size()
#define cl clear()
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define lbi(v, x) (lb(v, x) - v.begin())
#define tp(t, x, y) t x, y; tie(x, y)
#define tp3(t, x, y, z) t x, y, z; tie(x, y, z)
#define mp make_pair
#define mt make_tuple
#define co const
#define fc(x) for(int x = 1, _end = ri(); x <= _end; x++)
void uni(vi &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }

db rd() { db x; cin >> x; return x; }
ll ri() { ll x; cin >> x; return x; }
string rs() { string s; cin >> s; return s; }
pi rpi() { pi x; cin >> x.fi >> x.se; return x; }
vi rvi(int n, int f = 0) { vi v(n + f); for (int i = f; i < v.size(); i++) cin >> v[i]; return v; }
vii rvii(int n, int m, int f = 0) { vii v(n + f, vi(n + f)); for (int i = f; i < v.size(); i++) for (int j = f; j < v[0].size(); j++) cin >> v[i][j]; return v; }
void pr() {}; template <class T, class ...U> void pr(T x, U ...y) { cout << x << ' ', pr(y...); }
void prl() { cout << '\n'; }; template <class T, class ...U> void prl(T x, U ...y) { cout << x << ' ', prl(y...); }
void pr(const vi &v, int f = 0) { for (int i = f; i < v.size(); i++) cout << v[i] << ' '; }
void prl(const vi &v, int f = 0) { pr(v, f); cout << '\n'; }
void pr(const pi &x) { cout << x.fi << ' ' << x.se; };
void prl(const pi &x) { pr(x); cout << '\n'; }

#define rep(i, l, r) for (int i = l; i < r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

const int N = 2e5 + 5, M = 1e9 + 7;

ll qpow(ll x, ll n) {
  ll res = 1;
  for (; n; n >>= 1, x = x * x % M) if (n & 1) res = res * x % M;
  return res;
}

int main() {
  ll n = ri(), k = ri();
  vi a;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a.pb(i);
      if (n / i != i) a.pb(n / i);
    }
  }
  sort(all(a));
  vt<ll> dp(a.sz);
  ll ans = 0;
  rep(i, 0, a.sz) {
    dp[i] = qpow(k, (a[i] + 1) / 2);
    rep(j, 0, i) {
      if (a[i] % a[j] == 0) {
        dp[i] = (dp[i] - dp[j]) % M;
      }
      dp[i] = (dp[i] + M) % M;
    }
    if (a[i] & 1) ans = (ans + dp[i] * a[i]) % M;
    else ans = (ans + dp[i] * a[i] / 2) % M;
  }
  pr(ans);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323



void solve()
{
       string s;
       ll n, k;
       cin>>n>>k>>s;
       if(s[k-1]=='A') s[k-1]='a';
       if(s[k-1]=='B') s[k-1]='b';
       if(s[k-1]=='C') s[k-1]='c';
       cout<<s<<endl;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> p(n);
    vector<ll> ip(n+1);
    vector<pair<ll,ll>> le(n,{-1,-1});
    vector<pair<ll,ll>> ri(n,{n,n});
    set<ll> now;
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        ip[p[i]-1] = i;
    }
    ll res = 0;
    for (int i = n; i >= 1; i--) {
        auto itr = now.lower_bound(ip[i-1]);
        if(itr != now.end()){
            ri[i-1].first = *itr;
            ++itr;
        }
        if(itr != now.end()){
            ri[i-1].second = *itr;
        }
        itr = now.lower_bound(ip[i-1]);
        
        if(itr != now.begin()){
            --itr;
            le[i-1].first = *itr;
        }
        if(itr != now.begin()){
            --itr;
            le[i-1].second = *itr;
        }
        now.insert(ip[i-1]);
        
        // std::cout << i << std::endl;
        // std::cout <<le[i-1].second <<" "<<le[i-1].first<<" "<<ip[i-1]<<" "<<ri[i-1].first <<" "<<ri[i-1].second << std::endl;
        
        res += (ri[i-1].second-ri[i-1].first)*(ip[i-1]-le[i-1].first)*i;
        res += (ri[i-1].first-ip[i-1])*(le[i-1].first-le[i-1].second)*i;
    }
    std::cout << res << std::endl;
    
    
}


Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
from collections import deque
k = int(input())

dq = deque(list(range(1, 10)))
rep = 0
while rep < k:
    now = dq.popleft()
    rep+=1
    for i in (-1, 0, 1):
        if 0<=now%10+i<10:
            dq.append(now*10+now%10+i)
print(now)


Measured memory_bytes: 11956
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
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;
}
const ll INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    vector<ll> dp(N+10, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++)
    {
        ll c1 = dp[i] + abs(h[i+1]-h[i]);
        chmin(dp[i+1], c1);
        ll c2 = dp[i] + abs(h[i+2]-h[i]);
        chmin(dp[i+2], c2);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S,T;int N,M;
  cin>>N>>M>>S>>T;
  int G=gcd(N,M),L=lcm(N,M);
  for(int i=0;(i/M<N)&&(i/N<M);i+=L){
    if(S.at((i/M))!=T.at(i/N)){
      // print(i,S.at((i/M)),T.at(i/N));
      print(-1);
      re 0;
    }
  }
  // string a="";
  // REP(i,0,L){
  //   if(ans.at(i)=='1'){
  //     ans.at(i)='a';
  //   }
  //   a+=ans.at(i);
  // }
  print(L);


}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using namespace __gnu_pbds;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using pl = pair<ll, ll>;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll t, n;
ll step = 45000;

vector<ll> anw;
vector<ll> ssums;

ll mod = 998244353;

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n;

  vector<ll> a;
  vector<ll> b;

  ll cur = 1;

  for (int i = 0; i < n; i++) {
    a.push_back(cur);
    cur += step;
  }

  for (int i = n-1;  i>=0; i--) {
    b.push_back(a[i]);
  }

  cur = 1;
  ll x; cin >> x;
  for (int i = 1; i < n; i++) {
    cin >> x; x--;
    b[x] += cur;
    cur++;

  }

  for (int i = 0; i < n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
  for (int i = 0; i < n; i++) {
    cout << b[i] << ' ';
  } cout << endl;
}



Measured memory_bytes: 1148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int n;
int f(int b,int c){
  return c*((n-1)/b+1);
}
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
  PRN(min(f(a,b),f(c,d)));
  return 0;
}



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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e3 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2], dp[N][N];
vector<pii> vec;

int get(int s, int e)
{
	if ( s > e ) return 0;

	int rem = e - s + 1;
	int &mafia = dp[s][e];
	if (mafia != -1) return mafia;

	int id = rem - 1;
	int a1 = abs(vec[id].ss - e) * vec[id].ff + get(s, e - 1);
	int a2 = abs(vec[id].ss - s) * vec[id].ff + get(s + 1, e);

	return mafia = max(a1, a2);
}


void solve()
{
	cin >> n;
	lop(i, 0, n) cin >> arr[i];
	lop(i, 0, n) vec.pb( {arr[i], i} );
	sort( all(vec));
	memset(dp, -1, sizeof dp);

	cout << get(0, n - 1);

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 74496
function Main(input) {
  const args = input.trim().split("\n");
  let n = args.length;

  for (let i = 0; i < n; i++) {
    let tmp = args[i].split(" ");
    let a = Number(tmp[0]);
    let op = tmp[1];
    let b = Number(tmp[2]);

    if (op === "+") {
      console.log(a + b);
    } else if (op === "-") {
      console.log(a - b);
    } else if (op === "*") {
      console.log(a * b);
    } else if (op === "/") {
      console.log(parseInt((a / b).toFixed(10), 10));
    } else {
      break;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	cout << (1000 - n % 1000) % 1000 << endl;

	return 0;
}


Measured memory_bytes: 3596
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
p1 = 0
p2 = 0
p3 = 0
pi = 0
n.times do |i|
	d = (x[i] - y[i]).abs
	p1 += d
	p2 += d ** 2
	p3 += d ** 3
	pi = d if pi <d
end
puts p1
puts p2 ** (1 / 2.0)
puts p3 ** (1 / 3.0)
puts pi

Measured memory_bytes: 8776
#include <stdio.h>
int f, i;
char s[12];
char t[12];
int main() {
	scanf(" %s", s);
	scanf(" %s", t);
	while (s[i] != NULL) {
		if (s[i] != t[i])f++;
		i++;
	}
	if (f)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;

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

  int x[n];
  memset(x, 0, n*sizeof(int));
  for(int i=0;i<n;i++){
    cin >> x[i];
    cout << x[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }

  for(int i = 1; i< n;i++){
    int key = x[i];

    int j= i-1;
    while(j>=0 && x[j] > key){
      x[j+1] = x[j];
      j--;
    }
    x[j+1] = key;

    for(int j=0;j<n;j++){
      cout << x[j];
      if(j==n-1) cout << endl;
      else cout << " ";
    }
  }
  
}



Measured memory_bytes: 3084
import math 
a, b, x = map(int, input().split())

if x <= a ** 2 * b / 2:
    bottom = (x * 2 / (a * b))
    hype = math.sqrt(bottom ** 2 + b ** 2)
    print(math.degrees(math.atan2(b, bottom)))
else:
    x = a ** 2 * b - x
    height = x * 2 / (a ** 2)
    print(math.degrees(math.atan2(height, a)))

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

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

    int N, K;
    cin >> N >> K;

    vector<long> hp(N);
    rep(i, N) cin >> hp[i];

    sort(hp.begin(), hp.end());

    long sum = 0;
    for (int i = 0; i < (N - K); i++) {
        sum += hp[i];
    }
    cout << sum << endl;

    return 0;
}

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


int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>a(n+1,1);
    vector<bool>b(n+1,true);
    rep(i,m) {
        ll x;
        cin >> x;
        b[x]=false;
        a[x]=inf;
    }
    for(ll i=1;i<n+1;i++){
        if(b[i]==false) continue;
        if(i==1) a[i]=1;
        else {
            if(b[i-2]==true&&b[i-1]==true) a[i]=a[i-2]%mod+a[i-1]%mod;
            else if(b[i-2]==true&&b[i-1]==false) a[i]=a[i-2]%mod;
            if(b[i-2]==false&&b[i-1]==true) a[i]=a[i-1]%mod;
            if(b[i-2]==false&&b[i-1]==false) a[i]=0;
        }
    }
    cout << a[n]%mod << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

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

	vector<int_least32_t> a( n ), b( n );
	for(auto i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}

	int_fast32_t count{ 0 }, temp;
	for(auto i = n - 1; i >= 0; --i) {
		temp = (count + a[i]) % b[i];
		if(temp == 0) {
			continue;
		}
		count += b[i] - temp;
	}

	cout << count << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
map<string,int> S;
map<P,int> D;
string s;
int p;

int getNum(){
  if('0'<=s[p]&&s[p]<='9'){
    int res=0;
    while('0'<=s[p]&&s[p]<='9')
      res=res*10+s[p++]-'0';
    return res;
  }
  string str;
  while(s[p]!='[')str+=s[p++];
  p++;
  int r=getNum();
  if(r<0||S[str]<=r)return -1;
  if(!D.count(P(str,r)))return -1;
  return D[P(str,r)];
}

bool check(){
  for(int i=0;i<s.size();i++)
    if(s[i]=='='){
      string t;
      p=i+1;
      int num1,num2=getNum();
      for(int j=0;j<i;j++)
	if(s[j]=='['){
	  t=s.substr(0,j);
	  p=j+1;
	  num1=getNum();
	  if(S[t]<=num1)num1=-1;
	  break;
	}
      if(num1<0||num2<0)return false;
      D[P(t,num1)]=num2;
      return true;
    }
  int idx,num=0;
  for(int i=0;i<s.size();i++)
    if(s[i]=='[')idx=i;
  string A=s.substr(0,idx);
  for(int i=idx+1;i<s.size()-1;i++)
    num=num*10+s[i]-'0';
  S[A]=num;
  return true;
}

int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    int ans=1,flag=0;
    while(1){
      if(!flag&&!check())flag=1;
      if(!flag)ans++;
      cin>>s;
      if(s==".")break;
    }
    cout<<(flag?ans:0)<<endl;
    S.clear();
    D.clear();
  }
  return 0;
}

Measured memory_bytes: 3324
N,M=map(int,input().split())
S=[]
C=[]
A=[0]*N
if N>1:
  A[0]=1
X=[]
Y=[]
Z=[]
for i in range(M):
	x,y=map(int,input().split())
	S.append(x)
	C.append(y)
for i in range(M):
	if S[i]==1:
		X.append(C[i])
	if S[i]==2:
		Y.append(C[i])
	if S[i]==3:
		Z.append(C[i])
if len(set(X))>1:
	print(-1)
	exit()
if len(set(Y))>1:
	print(-1)
	exit()
if len(set(Z))>1:
	print(-1)
	exit()
for i in range(M):
	A[(S[i]-1)]=C[i]

ans=0
for i in range (1,N+1):
	ans+=A[-i]*10**(i-1)
if len(str(ans))!=N:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 3064
from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)


Measured memory_bytes: 9044
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=300150;
///
int mod=1000000007;


int main()
{
//    SPEED;
//    mem(dp,-1);
    int t,tc=1;
//    sf(t);
    t=1;

    while(t--)
    {
        int n;
        sf(n);
        if(n>=30)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;

    }


    return 0;
}



Measured memory_bytes: 3760
#include <stdio.h>
#include <string>
using namespace std;

const int MAX = 1001;

int main(){
  char str[MAX];
  while(true){
    for(int i=0;i<MAX;i++){
      scanf("%c",&str[i]);
      if(str[i] == '\n') break;
    }
    if(str[0] == '0') break;
    int sum=0;
    for(int i=0;str[i]!='\n';i++){sum += str[i]-'0';}
    printf("%d\n",sum);
  }

  return 0;
}


Measured memory_bytes: 2700
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#define INF INT_MAX
using namespace std;

long long N, K;
long long ans;

int main(){
	cin >> N >> K;
	if (K % 2 == 0){
		ans += ((N + K / 2) / K)*((N + K / 2) / K)*((N + K / 2) / K);
	}
	ans += (N / K)*(N / K)*(N / K);
	cout << ans << endl;

	return 0;
}

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

using namespace std;
#define  F first
#define  S second
#define  pii pair<int,int>
const int MAX = 1e6+6;

int n , a[MAX] , sol;

int main() {
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a , a+n);
    cout<<a[n/2] - a[n/2-1];

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,k;
vector<int> G[2010];
int a[2010], b[2010];
bool used[2010];
int dfs(int nd, int d) {
    int ans = (d > k / 2);
    for (int i = 0; i < G[nd].size(); i++) {
        if (used[G[nd][i]]) continue;
        used[G[nd][i]] = 1;
        ans += dfs(G[nd][i], d+1);
    }
    return ans;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int ans = n;
    if (k&1) {
        for (int i = 0; i < n - 1; i++) {
            memset(used,0,sizeof(used));
            used[a[i]] = 1;
            used[b[i]] = 1;
            ans = min(ans, dfs(a[i], 0) + dfs(b[i], 0));
        }
    } else {
        for (int i = 0; i < n; i++) {
            memset(used,0,sizeof(used));
            used[i] = 1;
            ans = min(ans, dfs(i,0));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3848