akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  int a,b;
  cin>>a>>b;
  int k;
  cin>>k;
  vector<int> ans;
  int cnt=0;
  for(int i=1;i<=100;i++)
  {
      if(a%i==0 && b%i==0) {ans.pb(i);}
  }
  cout<<ans.at(ans.size() - k);
  return 0;
   
 

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

ll comb(ll n,ll k){
    if(n<k||n<0||k<0)return 0;
    ll ret=1;
    rep(i,k){
        ret*=n%mod;
        ret%=mod;
        ret*=powmod(i+1,mod-2);
        ret%=mod;
        --n;
    }
    return ret;
}

void solve(ll n,ll d,ll x){
    vector<vector<ll>> dp(n+1,vector<ll>(n+1));
    dp[0][0]=1;
    rep(i,n){
        rep(j,n){
            dp[i+1][j+1]+=dp[i][j];
            if(j+x<=n)dp[i+1][j+x]+=mod-dp[i][j];
        }
        rep(j,n){
            dp[i+1][j+1]+=dp[i+1][j];
            dp[i+1][j+1]%=mod;
        }
    }
    ll ans=0;
    rep(i,n+1){
        ans+=dp[i][n]*comb(d,i)%mod;
    }
    cout<<ans%mod<<endl;

}
int main(){
    ll n,d,x;
    while(cin>>n>>d>>x,n!=0)solve(n,d,x);
    return 0;
}


Measured memory_bytes: 34176
import scala.io.StdIn

object Main extends App {
  val a = StdIn.readLine().split(" ").map(_.toInt)

  def gr2(n: Int) = n == 4 || n == 6 || n == 9 || n == 11
  
  val r = if(a(0) == 2 || a(1) == 2) "No"
  else if(gr2(a(0)) && gr2(a(1))) "Yes"
  else if(gr2(a(0)) || gr2(a(1))) "No"
  else "Yes"
  
  println(r)
  
}


Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i=0; i<N; i++) cin >> A[i] >> B[i];
  ll ans = 0LL;
  for (int i=N-1; i>=0; i--) {
    if (i!=0&&A[i]%B[i]!=0) {
      ans += abs(A[i]-B[i]*(A[i]/B[i]+1));
      A[i-1] += ans;
    }
    else if (i==0&&A[i]%B[i]!=0) ans += abs(A[i]-B[i]*(A[i]/B[i]+1));
    else if (i!=0&&A[i]%B[i]==0) A[i-1] += ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X = getint(), Y = getint(), A = getint(), B = getint(), C = getint();

	int abc[400000];
	auto a = abc;
	auto b = abc + A;
	auto c = abc + A + B;

	rep(i, A + B + C) a[i] = getint();

	nth_element(a, b - X, b);
	nth_element(b, c - Y, c);
	if (X + Y > B) memcpy(b, b - X, (B - Y) * sizeof(int));
	else memcpy(c - X - Y, b - X, X * sizeof(int));
	nth_element(c - X - Y, c + C - X - Y, c + C);

	ll kotae = accumulate(c + C - X - Y, c + C, 0ll);
	//for (auto kari = c + C - X - Y; kari < c + C; kari++) kotae += *kari;
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "YES";
string no = "NO";

int main(){
  ll a,b,c; cin >> a >> b >> c;
  string ans = no;
  rep(i,b){
    if((i*a)%b==c) ans=yes;
  }
  cout << ans;
  return 0;
}


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

#define INF64 1LL << 60;
#define INF32 1 << 29;

using namespace std;

void execute()
{
	int N;
	int ans = 0;
	cin >> N;

	vector<int> input_u(N);
	vector<int> input_d(N);
	vector<int> cum_u(N + 1, 0);
	vector<int> cum_d(N + 1, 0);

	for (int i = 0; i < N; i++)
		cin >> input_u[i];
	for (int i = 0; i < N; i++)
		cin >> input_d[i];

	for (int i = 0; i < N; i++)
	{
		cum_u[i + 1] = cum_u[i] + input_u[i];
		cum_d[i + 1] = cum_d[i] + input_d[N - i - 1];
	}

	for (int i = 0; i < N; i++)
	{
		ans = max(ans, cum_u[i + 1] + cum_d[N - i]);
	}

	cout << ans << endl;
	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int cnt=n,sum=0;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=n-1;i>=0;i--){
        if(sum+a[i]<k) sum+=a[i];
        else cnt=i;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 F PIC 9(15).
      	01 E PIC ZZZZZZZZZZZZ.
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		IF A < B THEN
      			DISPLAY "0"
      		ELSE 
      			DISPLAY "10"
      		END-IF.
		STOP RUN.

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;
int main (){
    int n;
    cin >> n;
    int t[n];
    int sum=0;
    for (int i = 0; i < n; i++){
        cin >> t[i];
        sum+=t[i];
    }
    int m;
    cin >> m;
    int p[m],x[m];
    for (int i = 0; i < m; i++){
        cin >> p[i] >> x[i];
    }

    int reduce;
    for (int i = 0; i < m; i++){
        reduce=t[p[i]-1]-x[i];
        cout << sum-reduce << "\n";
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MAX 2000000000
using namespace std;
static int C[20000];
static int x[20000];
static int dp[20000][256];
int main()
{
	int N, M;
	
	while (cin >> N >> M && N != 0 || M != 0)
	{

		for (int i = 0; i < M; i++)
		{
			cin >> C[i];
		}
		for (int i = 0; i < N; i++)
		{
			cin >> x[i];
		}

		for (int i = 0; i < N + 1; i++)
		{
			for (int j = 0; j < 256; j++)
			{
				if(i == 0)dp[i][j] = 0;
				else dp[i][j] = MAX;
			}
		}
		for (int i = 0; i < N; i++)
		{
			if (i == 0)
			{
				for (int k = 0; k < M; k++)
				{
					int y = 128 + C[k];
					if (y < 0)y = 0;
					else if (y > 255)y = 255;
					int next = y - x[i];
					dp[i + 1][y] = min(dp[i + 1][y], dp[i][128] + next * next);
				}
				continue;
			}
			for (int j = 0; j < 256; j++)
			{
				if (dp[i][j] == MAX)continue;
				for (int k = 0; k < M; k++)
				{
					int y = j + C[k];
					if (y < 0)y = 0;
					else if (y > 255)y = 255;
					int next = (y - x[i]);
					dp[i + 1][y] = min(dp[i + 1][y], dp[i][j] + next * next);
				}
			}
		}

		int ans = MAX;
		for (int i = 0; i < 256; i++)
		{
			ans = min(ans, dp[N][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 21244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  vector<int> diff;
  for (int i = 0; i < N; i++) {
    diff.push_back((A[(i+1)%N] + K - A[i]) % K);
  }
  int ans = K - *max_element(diff.begin(), diff.end());
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5068
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: String = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };

    let ans = if S.starts_with("YAKI") { "Yes" } else { "No" };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
  int N, i, flag=1, work, count=0, A[100];

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

  while(flag==1){
    flag=0;
    for(i=N-1;i>0;i--){
      if(A[i]<A[i-1]){
	work=A[i];
	A[i]=A[i-1];
	A[i-1]=work;
	flag=1;
	count++;
      }
    }
  }

  for(i=0;i<N;i++){
    if(i==N-1){
      printf("%d",A[i]);
      break;
    }
    printf("%d ", A[i]);
  }

  printf("\n%d\n", count);
  
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s[45][45];
signed main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(s[i][j]=="snuke"){
                cout<<char(j+'A')<<i+1<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int T;
inline bool solve () {
	long long A, B, C, D;
	scanf ("%lld%lld%lld%lld", &A, &B, &C, &D);
	if (A < B) return false;
	if (D < B) return false;
	if (C >= B - 1) return true;
	long long x = __gcd (B, D);
	A %= x; // num = kx + A
	long long k1 = C / x;
	if (k1 * x + A > C) k1--;
	if ((k1 + 1) * x + A < B) return false;
	return true;
}
int main () {
	scanf ("%d", &T);
	while (T--) printf (solve () ? "Yes\n" : "No\n");
	return 0;
}

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

int main() {
	int n;
	int x,y;
	int ans;

	cin >> n ;

	ans=-2e9-10;
	rep(i,4) m_max[i]=ans;
	rep(i,4) m_min[i]=-ans;

	rep(i,n){
		cin >> x >> y ;
		m_max[0]=max(m_max[0],x+y);
		m_min[0]=min(m_min[0],x+y);
		m_max[1]=max(m_max[1],x-y);
		m_min[1]=min(m_min[1],x-y);
		m_max[2]=max(m_max[2],-x+y);
		m_min[2]=min(m_min[2],-x+y);
		m_max[3]=max(m_max[3],-x-y);
		m_min[3]=min(m_min[3],-x-y);
	}
	rep(i,4){
		if(ans<m_max[i]-m_min[i])ans=m_max[i]-m_min[i];
	}

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

Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;

int
main() 
{
  int n; cin >> n;
  vector<int> arr(n);
  rep(i, 0, n)cin >> arr[i];

  int interbal = 0;
  while(true){
    rep(index, 0, n){
      if(arr[index] == 0) continue;
      else {
        interbal++;
        while(index < n && arr[index] > 0){
          arr[index]--;
          index++;
        }
      }
    }
    if(*max_element(arr.begin(), arr.end()) == 0) break;
  }
  cout << interbal << endl;

}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int A, B; cin >> A >> B;
	if(A > B) cout << A + A - 1 << endl;
	else if(B > A) cout << B + B - 1 << endl;
	else cout << A + B << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N, K, Q, M;
    
    unsigned long long sum = 0LL;
    
    cin >> N;
    cin >> M;
    vector<int> A(N);
    priority_queue<int> pque;
    
    
    for (int i = 0; i < N; i++){
        cin >> A[i];
        pque.push(A[i]);
    }
    
    for (int i = 0; i < M; i++){
        int a = pque.top();
        pque.pop();
        pque.push(a/2);
    }
    while (!pque.empty()){
        sum += pque.top();
        pque.pop();
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 1276
import numpy as np

H, W = map(int, input().split())
lst = []
for _ in range(H):
    a = list(input())
    lst.append(a)
lst = np.array(lst)

for i in range(H-1, -1, -1):
    if not '#' in lst[i]:
        lst = np.delete(lst, i, 0)
lst = lst.T
for i in range(W-1, -1, -1):
    if not '#' in lst[i]:
        lst = np.delete(lst, i, 0)
lst = lst.T

for x in lst:
    for y in x:
        print(y, end='')
    print()


Measured memory_bytes: 14436
#include<stdio.h>
#define N 100
int main(){
  int a[N],x,i,j,flag=0,flag1=0,num,num1=0,min;

  scanf("%d",&x);
  for(i=0;i<x;i++)
    scanf("%d",&a[i]);
    
  for(i=0;i<x;i++){
    flag=0;
    flag1=0;
    min=i;
    for(j=i;j<x;j++){
      if(a[j]<a[min]){
	min=j;
	flag=1;	  
      }	
    }
    if(flag==1){
      num=a[i];
      a[i]=a[min];
      a[min]=num;
      num1++;
    }
      
  }
    
  for(i=0;i<x;i++){
    if(i==x-1){
      printf("%d",a[i]);
      break;
    }
    printf("%d ",a[i]);
  }
  printf("\n");
  printf("%d\n",num1);
  return 0;
}
    
	
		 
  



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

int main() {
	int n, k, ans = 1e9;
	int h[100005];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h, h+n);
	int l = 0, r = k-1;
	while (r < n) {
		ans = min(ans, h[r] - h[l]);
		l++;
		r++;
	}
	cout << ans;
	return 0;
}

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

typedef long long lli;

int n;
lli m,C[61][61];

void init(){
  for(int i=0;i<=60;i++) C[i][i] = C[i][0] = 1LL;
  for(int i=2;i<=60;i++)
    for(int j=1;j<i;j++)
      C[i][j] = C[i-1][j] + C[i-1][j-1];
}

void solve(){
  int one;
  lli sum = 1;
  string str = "";
  for(int i=1;i<=n;i++){
    //cout << sum << " <= " << m << " < " << sum+C[n][i] << endl;
    if(sum <= m && m < sum+C[n][i]){
      one = i;
      break;
    }
    sum += C[n][i];
  }

  m -= sum;
  sum = 0;
  for(int i=1;i<=n;i++){
    //cout << m << " < " << C[n-i][one-1] << endl;
    if(one == 0) break;
    if(m-sum < C[n-i][one]) str += '0';
    else{
      str += '1';
      sum += C[n-i][one];
      one--;
    }
  }
  for(int i=str.size();i<n;i++) str += '0';
  cout << str << endl; 
}

int main(){
  init();
  while(cin >> n >> m && (n|m)){
    if(m == 1){
      for(int i=0;i<n;i++) cout << '0';
      cout << endl;
    } else {
      m--;
      solve();
    }
  }
}

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

using namespace std;
int main(){
    int n,a,i,count=0;
    cin >> n;
    for(i=1; i<=n; i++){
       cin >> a;
       if(i%2==1 && a%2==1)
         count++;
    } 
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	lli data[2]={0};

	REP(i,0,s.size()){
		char tmp;
		tmp = s.at(i);
		data[tmp-'0']++;
	}

	cout<<min(data[0],data[1])*2<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
	cin >> a >> b;
	if ( a + b == 15) cout << "+" << endl;
	if ( a * b == 15) cout << "*" << endl;
	if ( a + b != 15 and a * b != 15) cout << "x" << endl;
 	return 0;
}

Measured memory_bytes: 384
a,b,c=map(int,input().split())
cnt=0
while True:
    if a%2==0 and b%2==0 and c%2==0:
        if a==(b+c)//2 and b==(a+c)//2 and c==(a+b)//2:
            print(-1)
            exit(0)
        a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
        cnt+=1
    else:
        break
print(cnt)

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

using namespace std;

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#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 fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	string s,t;
	cin>>s>>t;
	int s_length = s.length();
	int t_length = t.length();
	int dp[s_length+1][t_length+1];
	int next[s_length+1][t_length+1];
	rep(i,0,s_length) dp[i][0] = 0;
	rep(i,0,t_length) dp[0][i] = 0;
	rep(i,1,s_length){
		rep(j,1,t_length)
		{
			//dp[i][j] = max(dp[i][j-1],dp[i-1][j],dp[i-1][j-1] + 1/0);
			int i_forward = dp[i-1][j];
			int j_forward = dp[i][j-1];
			int both_forward = dp[i-1][j-1];

			int res = 0;
			if(s[i-1] == t[j-1]){
				res = both_forward + 1;
				next[i][j] = 1;
			} else if(i_forward >= j_forward){
				res = i_forward;
				next[i][j] = 2;
			} else if(j_forward >= i_forward){
				res = j_forward;
				next[i][j] = 3;
			}
			dp[i][j] = res;
		}
	}
	// cout<<dp[s_length][t_length]<<"\n";
	int x = s_length,y = t_length;
	stack<char> st;
	while(x != 0 and y != 0)
	{
		if(s[x-1] == t[y-1])
		{
			st.push(s[x-1]);
			x--;y--;
		} else if(dp[x][y-1] > dp[x-1][y])
			y--;
		else
			x--;
	}
	while(!st.empty()) cout<<st.top(),st.pop();
	nl;
}

Measured memory_bytes: 70656
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];

        char[][] jagA = new char[n][];
        for (int i = 0; i < n; i++)
        {
            jagA[i] = Console.ReadLine().ToCharArray();
        }

        char[][] jagB = new char[n][];
        for (int i = 0; i < m; i++)
        {
            jagB[i] = Console.ReadLine().ToCharArray();
        }

        var ans = "No";
        for (int i = 0; i < n-m+1; i++)
        {
            for (int k = 0; k < n-m+1; k++)
            {
                if (jagA[i][k] == jagB[0][0])
                {
                    var flag = true;
                    for (int t = 0; t < m; t++)
                    {
                        for (int x = 0; x < m; x++)
                        {
                            if(jagA[i+t][k+x] != jagB[t][x]) flag = false;
                        }
                    }

                    if(flag) ans = "Yes";
                }

            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import math
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    ans = a[0]
    tmp = 0
    while True:
        for i in range(1,n):

            a[i] %= ans
            if a[i] != 0:
                tmp = min(ans,a[i])
        if sum(a) == ans:
            print(ans)
            return
        a.sort()
        ans = tmp
        a[0] = tmp

if __name__=='__main__':
    main()


Measured memory_bytes: 15148
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

signed main() {
    int n, k;
    cin >> n >> k;

    vector<double> vp;
    rep(i, n) {
        capi(p);
        vp.push_back((p + 1) / 2.0);
    }

    double res = 0.0;
    rep(j, k) {
        res += vp[j];
    }
    double ans = res;

    for (int i = 0; i + k < n; ++i) {
        res += vp[i + k];
        res -= vp[i];

        ans = max(ans, res);
    }

    printf("%.12lf", ans);

    return 0;
}

Measured memory_bytes: 4824
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	LL n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	LL tmp=min(a,min(b,min(c,min(d,e))));
	cout<<4+(n+tmp-1)/tmp<<endl;
	rt0;
}

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

a = list(map(int, input().split()))

a.sort()
a.reverse()

Alice = 0
Bob = 0

# print(a)


for i in range(len(a)):
  if i % 2 == 0:
    Alice+=a[i]
  else:
    Bob+=a[i]

print(Alice -Bob)




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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF (INT_MAX)/2-1
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

// 0->nan 1-> A 2->C 3->G 4->T
int main(){
  int N;
  cin>>N;
  using v1=vector<ll>;
  using v2=vector<v1>;
  using v3=vector<v2>;
  using v4=vector<v3>;
  using v5=vector<v4>;
  v5 dp(N,v4(5,v3(5,v2(5,v1(5,0)))));
  for(int i=0;i<N;i++){
    if(i==0)for(int j=1;j<=4;j++){
      dp[i][j][0][0][0]=1;
    }
    else if(i==1)for(int j=1;j<=4;j++)for(int k=1;k<=4;k++){
      dp[i][j][k][0][0]+=dp[i-1][k][0][0][0];
      dp[i][j][k][0][0]%=MOD;
    }
    else if(i==2)for(int j=1;j<=4;j++)for(int k=1;k<=4;k++)for(int l=1;l<=4;l++){
      if(j==2&&k==3&&l==1){}
      else if(j==3&&k==2&&l==1){}
      else if(j==2&&k==1&&l==3){}
      else dp[i][j][k][l][0]+=dp[i-1][j][l][0][0];
      dp[i][j][k][l][0]%=MOD;
    }
    else if(i==3)for(int j=1;j<=4;j++)for(int k=1;k<=4;k++)for(int l=1;l<=4;l++)
      for(int m=1;m<=4;m++){
        if(j==2&&k==3&&l==1){}
        else if(j==3&&k==2&&l==1){}
        else if(j==2&&k==1&&l==3){}
        else if(j==2&&k==3&&m==1){}
        else if(j==2&&l==3&&m==1){}
        else dp[i][j][k][l][m]+=dp[i-1][k][l][m][0];
        dp[i][j][k][l][m]%=MOD;
    }
    else for(int j=1;j<=4;j++)for(int k=1;k<=4;k++)for(int l=1;l<=4;l++)
      for(int m=1;m<=4;m++)for(int n=1;n<=4;n++){
        if(j==2&&k==3&&l==1){}
        else if(j==3&&k==2&&l==1){}
        else if(j==2&&k==1&&l==3){}
        else if(j==2&&k==3&&m==1){}
        else if(j==2&&l==3&&m==1){}
        else dp[i][j][k][l][m]+=dp[i-1][k][l][m][n];
        dp[i][j][k][l][m]%=MOD;
    }
  }
  ll sum=0;
  for(int j=0;j<5;j++){
    for(int k=0;k<5;k++){
      for(int l=0;l<5;l++){
        for(int m=0;m<5;m++){
          sum+=dp[N-1][j][k][l][m];
          sum%=MOD;
        }
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9 + 7;

vector<int> G[100000];

int grundy[100000];

int calc(int v, int p) {
	if (grundy[v] != -1) return grundy[v];
	int x = 0;
	for (int to : G[v]) {
		if (to == p) continue;
		x ^= calc(to, v) + 1;
	}
	return grundy[v] = x;
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	memset(grundy, -1, sizeof(grundy));
	if (calc(0, -1) == 0) printf("Bob\n");
	else printf("Alice\n");
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
int box[1000000] = {0};
int ball[1000000] = {0};
int n;
int main(){
    cin >> n;
    rep(i,n){
        cin >> box[i];
    }
    int cnt = 0;
    rep(i,n){
        int c = 0;
        FOR(j,1,n/(n-i)+1){
            c += ball[j*(n-i)-1];
        }
        if (box[n-i-1] == 0){
            ball[n-i-1] = c%2;
        }
        else{
            ball[n-i-1] = 1-c%2;
        }
        if (ball[n-i-1]) cnt++;
    }
    PRINT(cnt);
    rep(i,n){
        if (ball[i]) cout << i+1 << ' ';
        if (i == n-1 && cnt > 0) cout << '\n';
    }
}


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

namespace ConsoleApp72 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = st[0];
            int K = st[1];

            long ans = K;

            for (int i = 0; i < N - 1; i++) {
                ans *= (K - 1);
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
import Control.Monad
import Control.Applicative

data Op = S | E | N | W deriving (Show, Eq, Enum)

fromChar c | c == 'S' = S
           | c == 'E' = E
           | c == 'N' = N
           | c == 'W' = W
           | otherwise = error $ "Invalid char " ++ [c]

fromString [] = []
fromString (x:xs) = (fromChar x):(fromString xs)

data Dice = Dice { top :: Int, front :: Int, right :: Int, left :: Int, back :: Int, bottom :: Int }
  deriving (Show, Eq)

makeDice [t, f, r, l, ba, bo] = Dice t f r l ba bo

roll (Dice t f r l ba bo) S = Dice ba t r l bo f
roll (Dice t f r l ba bo) N = Dice f bo r l t ba
roll (Dice t f r l ba bo) E = Dice l f t bo ba r
roll (Dice t f r l ba bo) W = Dice r f bo t ba l
rolls = foldl roll :: Dice -> [Op] -> Dice

equal dice1 dice2 = foldr (||) False [(> 0) $ length $ filter (\x -> x == dice2) $ scanl rolls d [[N, E, S], [N, E, S], [N, E, S]] | d <- ds]
  where ds = scanl roll dice1 [N, E, N, E, N]

solve [x,y] | equal x y = "Yes"
            | otherwise = "No"

main = do
  dices <- map (makeDice . map read . words) <$> replicateM 2 getLine :: IO [Dice]
  putStrLn . solve $ dices




Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] DX = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long cnt = 0;
            for (int j = 0; j < N; j++)
            {
                long A = long.Parse(Console.ReadLine());
                if(DX[0] % A != 0)
                {
                    cnt += DX[0] / A + 1;
                }
                else
                {
                    cnt+= DX[0] / A ;
                }
            }
            Console.WriteLine(cnt + DX[1]);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28200
#include <stdio.h>
#define max 50010

int main(void) {
  long long i, j, k, n;
  bool prime[max];
  for(i = 0; i < max; ++i) prime[i] = true;
  prime[0] = prime[1] = false;
  for(i = 2; i < 250; ++i) if(prime[i]) for(j = 2; i * j < max; ++j) prime[i * j] = false;
  while( 1 ) {
    int ans = 0;
    scanf("%lld", &n);
    if(!n) break;
    for(i = 2; i <= n / 2; ++i) if(prime[i] && prime[n - i]) ++ans;
    printf("%d\n", ans);
  }
  return 0;
} 


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

int main() {
	int n, l;
	cin >> n >> l;
	vector<int> a(n), res(n-1);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int x = 0, y = n-1;
	int cnt = 0;
	while(y - x > 1){
		if(a[y] + a[y-1] >= l){
			res[cnt] = ++x;
		}else if(a[x] + a[x+1] >= l){
			res[cnt] = y--;
		}else{
			if(a[x] < a[y]){
				res[cnt] = ++x;
			}else{
				res[cnt] = y--;
			}
		}
		cnt++;
	}
	if(a[x] + a[y] < l){
		cout << "Impossible" << endl;
	}else{
		res[cnt] = y;
		cout << "Possible" << endl;
		for(int i = 0; i < n - 1; i++){
			cout << res[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n;cin>>n;
  int h[n];rep(i,n)cin>>h[i];
  vector<int> dp(n,1e9+7);
  dp[0]=0;dp[1]=abs(h[1]-h[0]);
  rep(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

  
          


    



  


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

using namespace std;

int main(int argc, const char *argv[]) {
  int A, B;
  vector<int> max(3);
  cin >> A >> B;

  max[0] = A * B;
  max[1] = A + B;
  max[2] = A - B;

  vector<int>::iterator iter = max_element(max.begin(), max.end());
  size_t index = distance(max.begin(), iter);

  cout << max[index] << endl;
  return 0;
}


Measured memory_bytes: 888
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}

int main(void) {
  int N;
  int L[2010];
  cin >> N;
  REP(i,N) cin >> L[i];
  int ans=0;
  sort(L, L+N, greater<int>());
  REP(i,N) {
    for(int j=i+1;j<N;++j) {
      for(int k=j+1;k<N;++k) {
        if (L[i]<L[j]+L[k]) {
          ans++;
        }
      }
    }
  }
  pr(ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
    ll n,m;cin>>n>>m;
	
	ll ans=0;
	
	if(n==1&&m==1){
		cout<<1<<endl;return 0;
	}
	
	if(n==1||m==1){
		if(n==1){
		   cout<<m-2<<endl;return 0;	
		}
		else{
		   cout<<n-2<<endl;return 0;	
		}
	}
	
	//ans+=(n-2)*2+(m-2)*2;
	
	ans+=(n-2)*(m-2);
	
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class Fenwick {
private:
  int n;
  vector<T> bit;
public:
  Fenwick() : n(-1) {}
  Fenwick(int n_, T d = T()) : n(n_), bit(n + 1, d) {}

  inline void add(int i, T val) {
    if (i == 0) return;
    for (int x = i; x <= n; x += (x & -x)) bit[x] += val;
  }

  // [1, i];
  inline T get(int i) {
    T res = T();
    for (int x = i; x > 0; x -= (x & - x)) res += bit[x];
    return res;
  }

  // return [i, j);
  inline T get(int i, int j) {
    return get(j - 1) - get(i - 1);
  }

  inline int lower_bound(int val) {
    if (val <= 0) return 0;
    int x = 0, r = 1;
    while (r < n) r <<= 1;
    for (int k = r; k > 0; k >>= 1) {
      if (x + k <= n && bit[x + k] < val) {
        val -= bit[x + k];
        val += k;
      }
    }
    return x + 1;
  }

  const T& operator[](const int &i) const {
    return bit[i];
  }
};
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<Fenwick<int>> bit(26, Fenwick<int>(n + 10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i] == 'a' + j) {
        bit[j].add(i + 1, 1);
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int idx;
      cin >> idx;
      char c;
      cin >> c;
      int pre = s[idx - 1] - 'a';
      s[idx - 1] = c;
      bit[pre].add(idx, -1);
      bit[c - 'a'].add(idx, 1);
    } else {
      int l, r;
      cin >> l >> r;
      r++;
      int ans = 0;
      for (int i = 0; i < 26; i++) if (bit[i].get(l, r) > 0) ans++;
      cout << ans << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 53788
import numpy as np
from numpy import linalg as LA
import math

a,b,h,m=input().split()
a=float(a)
b=float(b)
h=float(h)
m=float(m)

hh=-(h/12+m/720)*360+90
mm=-m/60*360+90
hx=math.cos(math.radians(hh))*a
hy=math.sin(math.radians(hh))*a
mx=math.cos(math.radians(mm))*b
my=math.sin(math.radians(mm))*b

x=np.array([hx-mx,hy-my])
print(LA.norm(x))


Measured memory_bytes: 27168
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long  N,j;
    long long kaisuu;
    cin >> N;
    kaisuu = 5 + N;
    for(long long i=1;i<=pow(N,0.5);i++){
       
        if(N % i == 0){
          j = N / i;
         if(kaisuu > i + j -2){
       

        kaisuu = i + j -2;
        }
        }

    }

   

    cout << kaisuu;

    return 0;
}

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

int main() {
	ll sum,n;
	cin >>sum >> n;
	ll a[n];
	ll sum1 = 0;
	for(ll i=0;i<n;i++)
	{
	    cin >> a[i];
	    sum1 += a[i];
	}
	if(sum1 <= sum)
	{
	    cout << sum-sum1 << "\n";
	}
	else
	{
	    cout << -1 << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



int main(){
  ll N;
  cin>>N;
  ll c=0;
  vector<ll> A(N);
  ll sum =0;
  for(ll i=0;i<N;i++){
  cin>>A[i];
  sum +=A[i];
  }

  ll tmp=0,tmp1=0;
  ll mid;
  ll lleft;
ll rright;

  for(ll i=0;i<N;i++){
    tmp+=A[i];
    if(tmp*2==sum){
      cout<<0<<endl;
      return 0;
    }
    else if(tmp*2>sum){
      mid = A[i];
      lleft=tmp-A[i];
      rright= sum-tmp;
      tmp1=i;
      break;
    }
  }






ll pp = min(lleft+mid-rright,rright+mid-lleft);
//cout<<rright<<lleft<<mid;
cout<<pp<<endl;

  



}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNING
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <queue>

// #include <stack>
// #include <queue>
// #include <set>
// #include <tuple>
// #include <list>
// #include <numeric>
// #include <random>
// #include <regex>
// #include <utility>

using namespace std;
const int INF = (int)1e9;

//#define DEBUG

void solution() {
	int n, m, q;
	cin >> n >> m;
	priority_queue<int> a;
	for (int i = 0; i < n; ++i) {
		int val;
		cin >> val;
		a.push(val);
	}
	for (int i = 0; i < m; ++i) {
		int max = a.top();
		a.pop();
		a.push(max / 2);
	}
	long long sum = 0;
	while (!a.empty()) {
		sum += a.top();
		a.pop();
	}
	cout << sum;
}

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
	solution();
  return 0;		
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   	ll n;
   	cin >> n;
   	vector <vector<ll>> dp(n,vector<ll>(3));
    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
   	for (int z=1;z<n;z++){
		ll a,b,c;
    	cin >> a >> b >> c;
    	dp[z][0] = max(dp[z-1][1]+a,dp[z-1][2]+a);
    	dp[z][1] = max(dp[z-1][0]+b,dp[z-1][2]+b);
    	dp[z][2] = max(dp[z-1][0]+c,dp[z-1][1]+c);
   	}
   	cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
   	cin >> n;
}


Measured memory_bytes: 5760
def N():
    return int(input())
def L():
    return list(map(int,input()))
def NL(n):
    return [list(map(int,input())) for _ in range(n)]
import math
k = N() + 1
sum = 0
for i in range(1,k):
    for j in range(1,k):
        for l in range(1,k):
            #print(sum)
            sum += math.gcd(math.gcd(i,j),l)
print(sum)


Measured memory_bytes: 78508
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var output = [];
  var data = input.split( '\n' );
  for( var i=0; i<data.length; i+=2 ) {
    var n = parseInt( data[i] );
    if( 0 == n ) { break; }
    
    var s = data[ i+1 ].split( " " ).map( Number );
    var sum = 0;
    for( var j=0; j<n; j++ ) {
      sum += s[j];
    }
    var ave = sum/n;
    sum = 0;
    for( var j=0; j<n; j++ ) {
      sum += Math.pow( s[j]-ave, 2 );
    }
    output.push( Math.sqrt( sum/n ) );
  }
    
  console.log( output.join( '\n' ) );
});

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

int main(){
  int n;
  cin >> n;
  bool ok=true;
  string s;
  char c;
  map<string,int>alr;
  for(int i=0;i<n;i++){
    cin >> s;
    alr[s]++;
    if(alr[s]>1)
      ok=false;
    if(i>0){
      if(s.at(0)!=c)
        ok=false;
    }
    c=s.at(s.size()-1);
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3612
/**
 *    author:  whohet
 *    created: 11-07-2020 17:29:12
**/

#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

signed main()
{
	fasterthanlight;
	int d;
	int l, r;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
			ans++;
	}
	cout << ans;



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans=0;
  int ANS=0;
  int a=0;
  int s=0;
  int A=0;
  int S=0;
  vector<int>X(N);
  for(int i=0;i<N;i++){
    cin>>X[i];
    ans+=X[i];
  }
  ans/=N;
  a+=(ans-1);
  s+=(ans+1);
  for(int i=0;i<N;i++){
    ANS+=(X[i]-ans)*(X[i]-ans);
  }
  for(int i=0;i<N;i++){
    A+=(X[i]-a)*(X[i]-a);
  }
  for(int i=0;i<N;i++){
    S+=(X[i]-s)*(X[i]-s);
  }
  cout<<min((A,S),ANS)<<endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 0;
  
  for(int i = 1;i <= N;i+=2){
      int num = i;
      vector<int> x(N + 1);
      for(int j = 2;j <= N;j++){
          while(num % j == 0){
              x.at(j)++;
              num /= j;
          }
      }
      int cnt = 1;
      for(int j = 2;j <= N;j++){
          cnt *= x.at(j) + 1;
      }
      if(cnt == 8)ans++;
  }

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
	int m = s.nextInt();
	int sum = 0;
	int[] arr = new int[n];
	for (int i = 0; i < n; i++) {
		int input = s.nextInt();
		sum += input;
		arr[i] = input;
	}
	double con = ((double)1/(4*m)) * sum;
	int count = 0;
	for (int i = 0; i < arr.length; i++) {
		if (arr[i] >= con) count++;
	}
	
	if (count >= m) {
		System.out.println("Yes");
	} else {
		System.out.println("No");	
	}
  }
	

}


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

char s[21][21];

int main() {
	int h, w;
	cin >> h >> w;
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				continue;
			}
			
			int mark[20][20] = { 0 };
			int step[20][20] = { 0 };
			
			int dx[4] = { 0, 1, 0, - 1};
			int dy[4] = { -1, 0, 1, 0 };
			
			int qx[4010] = { 0 };
			int qy[4010] = { 0 };
			int head = 0;
			int tail = 0;
			
			qx[head] = j;
			qy[head] = i;
			head++;
			
			mark[i][j] = 1;
			
			while (head != tail) {
				int x = qx[tail];
				int y = qy[tail];
				tail++;
				
				for (int k = 0; k < 4; k++) {
					int tx = x + dx[k];
					int ty = y + dy[k];
					
					if (tx < 0 || ty < 0 || tx >= w || ty >= h) {
						continue;
					}
					
					if (mark[ty][tx]) {
						continue;
					}
					
					if (s[ty][tx] == '.') {
						qx[head] = tx;
						qy[head] = ty;
						head++;
						
						mark[ty][tx] = 1;
						step[ty][tx] = step[y][x] + 1;
						
						ans = max(ans, step[ty][tx]);
					}
				}
			}
			
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
	char s[10];
	int i,d=753;
	scanf("%s",s);
	for(i=0;s[i+2]!='\0';i++){
		int n=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
		if(abs(n-753)<d){d=abs(n-753);}
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int ar[N + 5];
int main(){
	int n;
	scanf("%d", &n);
	int tot = 0;
	int seq = 0;
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &ar[i]);
		if(ar[i] == i){
			seq++;
		}
		else{
			tot += (seq + 1) / 2;
			seq = 0;
		}
	}
	tot += (seq + 1) >> 1;
	printf("%d\n", tot);

	return 0;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
use std::collections::HashMap;
fn main(){
    input!{
        n:usize,
        sn:[chars;n],
    }
    let mut map = HashMap::new();
    for s in sn {
        *map.entry(s[0]).or_insert(0) += 1;
    }
    let master:Vec<i64> = "MARCH".chars().map(|c| *map.entry(c).or_insert(0)).collect();
    // println!("{:?}",master);
    let mut ans = 0;
    for bit in 0usize..(1<<5) {
        if bit.count_ones() != 3 {
            continue;
        }
        let mut sub = 1; 
        for j in 0..5 {
            if  bit&(1<<j) != 0 {
                sub *= master[j];
            }
        }
        ans += sub;
    }
    println!("{}",ans);
}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c;
           cin>>a>>b>>c;
           YES(b-a==c-b);
}

Measured memory_bytes: 3584
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


N = int(input())
primes = factorization(N)
ans = 0
for p in primes:
    num = p[1]
    for i in range(1, N):
        if num >= i:
            num -= i
            ans += 1
        else:
            break
print(ans)


Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
using Int = long long;
int main()
{
    int N;
    cin >> N;
    vector<int> count(N+1);
    fill(count.begin(), count.end(), INT_MAX);
    count[0] = 0;
    for (int i = 0; i <= N; i++) {
        if (i+1 <= N) count[i+1] = min(count[i]+1, count[i+1]);
        for (int j = 6; i + j <= N; j*=6) count[i+j] = min(count[i]+1, count[i+j]);
        for (int j = 9; i + j <= N; j*=9) count[i+j] = min(count[i]+1, count[i+j]);
    }
    cout << count[N] << endl;
    return 0;
}


Measured memory_bytes: 640