akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m; cin >> n >> m;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	vector<int> adj[n];
	for(int i = 0; i < m; i++){
		int x,y; cin >> x >> y;
		adj[--x].push_back(--y);
		adj[y].push_back(x);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(adj[i].size() == 0){ ans++; continue;}
		bool good = true;
		for(int e : adj[i]){
			good &= h[i] > h[e];	
		}
		if(good) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 9120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int i;
		int[] array = new int[n];
		String[] line = br.readLine().split(" ");
		for(i=0; i<n; i++)
			array[i] = Integer.parseInt(line[i]);
		
		int[] result = new int[n];
		int j;
		int m = 0;
		ArrayList<String> resultNums = new ArrayList<>(0);
		for(i=n; 0<i; i--){
			for(j=i; j<=n; j+=i)
				result[i-1] += result[j-1];
			result[i-1] = (result[i-1]%2)^array[i-1];
			if(result[i-1] == 1){
				m++;
				resultNums.add(Integer.toString(i));
			}
		}
		
		System.out.println(m);
		System.out.println(String.join(" ", resultNums));
	}
}


Measured memory_bytes: 55792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum A = "AKIHABARA";

void main()
{
    auto S = readln.chomp;
    size_t i, j;
    while (i < S.length && j < A.length) {
        if (S[i] == A[j]) {
            ++i; ++j;
        } else if (A[j] == 'A') {
            ++j;
        } else {
            writeln("NO");
            return;
        }
    }
    writeln((i == S.length && j >= A.length-1) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[2][n];
    for(int i=0; i<n; i++) cin >> a[0][i];
    for(int i=0; i<n; i++) cin >> a[1][i];

    for(int i=1; i<n; i++) a[0][i] += a[0][i-1];
    for(int i=n-2; i>=0; i--) a[1][i] += a[1][i+1];

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

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
const int M=2001*2001;
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    bitset<M> dp;
    dp.reset();
    dp[0]=1;
    ll total=0;
    for(int i=1;i<=n;i++)
    {
        int c=v[i];
        dp=(dp|(dp<<c));
        total+=c;
    }
    if((total%2)==0)
        total/=2;
    else
        total=(total+1)/2;
    for(int i=total;;i++)
    {
        if(dp.test(i))
        {
            cout<<i<<'\n';
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;cin>>s;
    int n=s.size();
    rep(i,n-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i==n-1)break;
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
using namespace std;
int main()
{
	int n,f=1;
	cin>>n;
	string t[105];
	map<string,int> q;
	for(int i=0;i<n;i++){
		cin>>t[i];
		if(q.count(t[i])==0){
			q[t[i]]=1;
		}
		else f=0;
		if(i>0){
			int x=t[i-1].length();
			if(t[i][0]!=t[i-1][x-1])
				f=0;
		}
	}
	if(f==1)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

int main() {
  int n,k,r,s,p;
  string t;
  cin >>n>>k>>r>>s>>p>>t;
  long long sum=0;
  for(int i=0;i<t.size();i++){
    if(t[i]=='r')sum+=p;
    else if(t[i]=='s')sum+=r;
    else sum+=s;
  }
  for(int i=0;i<t.size()-k;i++){
    if(t[i]=='r'&&t[i+k]=='r'){
      sum-=p;
      t[i+k]='a';
    }else if(t[i]=='s'&&t[i+k]=='s'){
      sum-=r;
      t[i+k]='b';
    }else if(t[i]=='p'&&t[i+k]=='p'){
      sum-=s;
      t[i+k]='c';
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

int main() {
  int a,b,ans = 0;
  cin >> a >> b;
  for(int i = a;i <= b;i++){
    if(i/10000 == i%10 && (i%10000)/1000 == (i%100)/10){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char K[10][6]={
  {"no"},
  {".,!? "},
  {"abc"},
  {"def"},
  {"ghi"},
  {"jkl"},
  {"mno"},
  {"pqrs"},
  {"tuv"},
  {"wxyz"}};

char Henkan(int, int);
int main()
{
  int N,i,j,sum=0,SSS;
  char S[1025],SS;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",S);
    for(j=0;j<strlen(S);j++){
      if(S[j]!=48)sum++;
      else if(S[j-1]!=48 && j>0){
        SSS=S[j-1]-'0';
        SS=Henkan(SSS,sum-1);
	printf("%c",SS);
        sum=0;
      }
    }
    printf("\n");
  }
  return 0;
}

char Henkan(int mo,int sum)
{
  if(mo==0)return '0';
  return K[mo][sum%(strlen(K[mo]))];
}
   

Measured memory_bytes: 580
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		String t=sc.next();
		
		//char n=t.charAt(0);
		//t.substring(t.length() - 切り出したい文字列の長さ);
				
		if(t.length()==s.length()+1&&t.indexOf(s)==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}		
	sc.close();
	}

}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
// ll mod = 998244353;
 ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,d,e,h,r,l,q;
ll w, ans;
ll k;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];

int main(){
    cin >> n >> k;
    ll ans = 0;
    while(n){
        ans ++;
        n /= k;
    }
    p(ans);
    return 0;

}


















Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

char in[510000];
int t[510000];
int main(){
	int a;scanf("%s",in);
	a=strlen(in)+1;
	set<int>S;
	// for(int i=0;i<a;i++)t[i]=mod;
	// for(int i=0;i<a;i++){
	// 	bool ok=true;
	// 	if(i&&in[i-1]=='<')ok=false;
	// 	if(i<a-1&&in[i]=='>')ok=false;
	// 	if(ok){
	// 		t[i]=0;
	
	// 	}
	// }
	for(int i=0;i<a-1;i++){
		if(in[i]=='<')t[i+1]=max(t[i+1],t[i]+1);
	}
	for(int i=a-1;i>0;i--){
		if(in[i-1]=='>')t[i-1]=max(t[i-1],t[i]+1);
	}
	long long ret=0;
	for(int i=0;i<a;i++)ret+=t[i];printf("%lld\n",ret);
}

Measured memory_bytes: 2688
#include<iostream>
#include<stdio.h>
#include<queue>
#include<stack>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
using namespace std;
long long n,k,a[105],ans=0,b[105],c[105];
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		b[i]=a[i]*2;
		c[i]=abs(k-a[i]);
		c[i]*=2;
		ans+=min(b[i],c[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+100;
int main(){
	string s;
	cin >> s;
	if (s[3] == s[2] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[]count = new int[9];
		int min = 0;
		int max = 0;
		int tmp = 0;
		for(int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if(tmp <= 399) 	count[0] = 1;
			else if(tmp <= 799) 	count[1] = 1;
			else if(tmp <= 1199) 	count[2] = 1;
			else if(tmp <= 1599) 	count[3] = 1;
			else if(tmp <= 1999) 	count[4] = 1;
			else if(tmp <= 2399) 	count[5] = 1;
			else if(tmp <= 2799) 	count[6] = 1;
			else if(tmp <= 3199) 	count[7] = 1;
			else count[8]++;
		}

		for(int i = 0; i < 8; i++)	min += count[i];
		if(min == 0) min =1;
		for(int i = 0; i < 9; i++)	max += count[i];

		System.out.println(min + " " + max);

	}
}

Measured memory_bytes: 21588
def readinput():
    s=input()
    return s

def main(s):
    i=len(s)-2
    while(i>0):
        lensub=i//2
        sub1=s[:lensub]
        sub2=s[lensub:lensub*2]
        if sub1==sub2:
            return i
        i-=2
    return 0

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


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

int F[102][102];

void
DFS (int Y, int X, int A)
{
  if (F[Y][X] != A)
    return;

  F[Y][X] = 7;

  DFS (Y - 1, X, A);
  DFS (Y, X + 1, A);
  DFS (Y + 1, X, A);
  DFS (Y, X - 1, A);
}

int
main ()
{
  int w, h;
  int xs, ys;
  int xg, yg;
  int n;
  int c, d, x, y;

  while (true)
    {
      cin >> w >> h;
      if (w == 0 && h == 0)
	break;
      cin >> xs >> ys;
      cin >> xg >> yg;
      cin >> n;

      for (int i = 0; i < n; i++)
	{
	  cin >> c >> d >> x >> y;
	  if (d == 0)
	    {
	      for (int a = 0; a < 4; a++)
		{
		  for (int b = 0; b < 2; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}

	    }
	  else
	    {
	      for (int a = 0; a < 2; a++)
		{
		  for (int b = 0; b < 4; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}
	    }

	}


      if (F[ys][xs] == 0 || F[ys][xs] == 1 || F[ys][xs] == 2 || F[ys][xs] == 3
	  || F[ys][xs] == 4 || F[ys][xs] == 5)
	{
	  DFS (ys, xs, F[ys][xs]);
	}

      if (F[yg][xg] == F[ys][xs])
	{
	  cout << "OK" << endl;
	}
      else
	{
	  cout << "NG" << endl;
	}
   
    /*for (int y = 0; y < h; y++)
	{
	  for (int x = 0; x < w; x++)
	    {
	      cout << F[y][x];
	    }
         cout << endl;
	}*/
   
    /*for (int y = 1; y <= h; y++)
	{
	  for (int x = 1; x <= w; x++)
	    {
	      F[y][x] = 0;
	    }
	}*/

    
   
    }

  return 0;
}

Measured memory_bytes: 3080
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	
	void main()
	{
		int n=qread(),m=qread();
		write( n*(n-1)/2+m*(m-1)/2 );
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	// freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	//debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b; std::cin >> a >> b;
    std::cout << max(0, a - 2 * b) << "\n";
}


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

long gcd(long a, long b) {
	while (b) swap(a %= b, b);
	return a;
}
int main() {
	long a, b, c, d;
	cin >> a >> b >> c >> d;
	long l = c * d / gcd(c, d);
	a--;
	cout << b - (b / c + b / d - b / l) - a + (a / c + a / d - a / l) << endl;
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
ans = float("inf")
for i in range(1,h+1):
    if w % 2 == 1 and (h-i) % 2 == 1:
        ans = min(ans, max(w*i, (h-i)*(w//2), (h-i)*(w//2+1))-min(w*i, (h-i)*(w//2), (h-i)*(w//2+1)))
    elif (h-i) % 2 == 0:
        ans = min(ans, max(w*i, (h-i)//2*w)-min(w*i, (h-i)//2*w))
    else:
        ans = min(ans, max(w*i, (h-i)*(w//2))-min(w*i, (h-i)*(w//2)))
h, w = w, h
for i in range(1,h+1):
    if w % 2 == 1 and (h-i) % 2 == 1:
        ans = min(ans, max(w*i, (h-i)*(w//2), (h-i)*(w//2+1))-min(w*i, (h-i)*(w//2), (h-i)*(w//2+1)))
    elif (h-i) % 2 == 0:
        ans = min(ans, max(w*i, (h-i)//2*w)-min(w*i, (h-i)//2*w))
    else:
        ans = min(ans, max(w*i, (h-i)*(w//2))-min(w*i, (h-i)*(w//2)))
print(ans)

Measured memory_bytes: 9316
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vll v(n);
		lop(i, n) cin >> v[i];
		ll ans = 0;
		for (int i = 1; i < n; i++) {
			if (v[i] < v[i - 1]) ans += v[i - 1] - v[i], v[i] = v[i - 1];
		}
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 4780
H, W, K = map(int, input().split())
MOD = 10**9 + 7
if W == 1:
    print(1)
    exit()
MR = [0] * W
ML = [0] * W
MS = [0] * W
for i in range(1 << (W-1)):
    S = bin(i)[2:]
    S = "0"*(W-1-len(S)) + S
    if S.find("11") >= 0:
        continue
    for j, s in enumerate(S):
        if s == "1":
            MR[j] += 1
            ML[j+1] += 1
    for j, (s1, s2) in enumerate(zip("0"+S, S+"0")):
        if s1 == s2 == "0":
            MS[j] += 1

DP = [[0] * W for _ in range(H+1)]
DP[0][0] = 1
for h in range(H):
    for w in range(W-1):
        DP[h+1][w+1] += DP[h][w] * MR[w] % MOD
        DP[h+1][w] += DP[h][w+1] * ML[w+1] % MOD
    for w in range(W):
        DP[h+1][w] += DP[h][w] * MS[w] % MOD

print(DP[H][K-1] % MOD)

Measured memory_bytes: 3064
n = int(input())
s = [input() for _ in range(2)]
MOD = 1000000007
i = 0
res = 1
if s[0][i] == s[1][i]:
    res *= 3
else:
    res *= 3*2
    i += 1
i += 1
while i < n:
    if s[0][i-1] == s[1][i-1]:
        res *= 2
        res %= MOD
        if s[0][i] != s[1][i]:
            i+=1
        i+=1
    else:
        if s[0][i] != s[1][i]:
            res *= 3
            res %= MOD
            i+=1
        i+=1
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
 
struct Point {
  double x, y;
};
 
void printPoint(Point p) {
  cout << fixed << p.x << " " << p.y << endl;
}
 
void KochCurve(Point p1, Point p2, int rec, int n) {
  if (rec < n) {
    Point s, t, u;
    double deg = 60.0*(M_PI/180.0);
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = s.x + (t.x - s.x) * cos(deg) - (t.y - s.y) * sin(deg);
    u.y = s.y + (t.x - s.x) * sin(deg) + (t.y - s.y) * cos(deg);
    rec++;
    KochCurve(p1, s, rec, n);
    printPoint(s);
    KochCurve(s, u, rec, n);
    printPoint(u);
    KochCurve(u, t, rec, n);
    printPoint(t);
    KochCurve(t, p2, rec, n);
  }
}
 
int main () {
  int n;
  Point p1, p2;
  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;
 
  cin >> n;
  printPoint(p1);
  KochCurve(p1, p2, 0, n);
  printPoint(p2);
  return 0;
}

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

long long q, h, s, d, n, d2;
long long ans;

int main() {
	cin >> q >> h >> s >> d >> n;

	d2 = min(q * 4, h * 2);
	d2 = min(d2, s);

	if (n == 1) {
		ans = d2;
	}
	else {
		if (d2 * 2 > d) {
			ans = n / 2 * d;
			if (n % 2 == 1)ans += d2;
			//cout << "a" << endl;
		}
		else {
			ans = n * d2;
			//cout << "d2:" << d2 << endl;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;

class Main {
    public static void main(String[] args){
        try {

        BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        String str[] = (br.readLine()).split("\\s+");
        int A = Integer.parseInt(str[0]);
        int P = Integer.parseInt(str[1]);
        PrintWriter pw = new PrintWriter(System.out);

        pw.print((P+3*A)/2);
        pw.flush();

        } catch(IOException e) {
            System.out.println("Exception :" + e);
        }

    }
}

Measured memory_bytes: 21204
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += s[i] == t[i] ? 0 : 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3876
s = gets.chomp
k = gets.to_i

if s.size == 1
  puts k / 2
  exit
end

c = s[0]
count = 1
count_arr = []
1.upto(s.size - 1) do |i|
  if c == s[i]
    count += 1
  else
    count_arr << count
    count = 1
  end
  c = s[i]
end

count_arr << count

if count_arr.size == 1
  puts count_arr[0] * k / 2
  exit
end

ans = 0
count_arr.each do |count|
  ans += (count / 2) * k
end

if s.size > 1 && s[0] == s[-1] && count_arr[-1] % 2 == 1 && count_arr[0] % 2 == 1
  ans += k - 1
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
ll a[maxn];

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    printf("%lf %d\n",double(w) * double(h) / 2.0 , x + x == w && y + y == h);
    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
def out(i):
  print(i,flush=True)
  s=input()
  if s=="Male":return 0
  elif s=="Female":return 1
  else:exit()
f=out(0)
ng=0
ok=n
while ng+1!=ok:
  mid=(ng+ok)//2
  if (mid+f)%2==out(mid)%2:ng=mid
  else:ok=mid

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int f = 1;
    rep(i,n){
        if(a[i]==f) f++;
    }
    if(f!=1) cout << n-f+1 << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
int number[4];
for(int i = 0; i < 4; i++){
cin >> number[i];
}
sort(number, number + 4);
if((number[0] == number[1]) && (number[2] == number[3])){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c,k;
  cin>>n>>c>>k;
  ll t[111111];
  for(int i=0;i<n;i++)cin>>t[i];
  sort(t,t+n);
  int ans=0;
  for(int i=0;i<n;){
    ans++;
    ll r=t[i]+k;
    int cnt=0;
    while(t[i]<=r&&cnt<c){
      cnt++;
      i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    int s[N];
    int sum = 0;
    for (int i=0; i<N; i++){
        scanf("%d", &s[i]);
        sum += s[i];
    }
    int ans = 0;
    float ness = float(sum)/float(4*M);
    for (int i=0; i<N; i++){
        float x = float(s[i]);
        if (x >= ness) ans += 1;
    }
    if (ans >= M) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll a,ans;
double b;

int main(){ 
	ios::sync_with_stdio(false);
	cin>>a>>b;
	ans=(a/1000000)*ll(b*1000000.0)+ll(b*(a%1000000));
	cout<<ans<<"\n";
	
	
	return 0;
}

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

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

    static class CStep {
        public void solve(int testNumber, MyScanner sc, PrintWriter out) {
            int N = sc.nextInt();
            int[] vals = sc.nextIntArray(N);
            long ans = 0, max = vals[0];
            for (int i = 1; i < N; i++) {
                ans += Math.max(0, max - vals[i]);
                max = Math.max(max, vals[i]);
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer tokenizer;

        public MyScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

    }
}



Measured memory_bytes: 55624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 100010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a[N];
signed main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int p=0;
	for (int i=1;i<=n;i++) if (a[i]<0) p=i;
	p=max(p,1);p=min(p,n-1);
	//让前p个被减掉
	int s=0;
	for (int i=1;i<=p;i++)  s-=a[i];
	for (int i=p+1;i<=n;i++) s+=a[i];
	cout<<s<<endl;
	for (int i=p+1;i<n;i++)
	{
		printf("%d %d\n",a[p],a[i]);
		a[p]-=a[i];
	}
	printf("%d %d\n",a[n],a[p]);a[n]-=a[p];
	for (int i=1;i<p;i++)
	{
		printf("%d %d\n",a[n],a[i]);
		a[n]-=a[i];
	}
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
const int MAX_N = 210;
int a[MAX_N];

int main(){
	scanf("%d",&N);
	N<<=1;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+N);

	int ans=0;
	for(int i=0;i<N;i+=2){
		ans+=a[i];
	}
	
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

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

Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
c=Counter(lis)
lis=list(set(lis))
m=10**6+1
dp=[0 for i in range(m)]
#print(dp)
for i in range(len(lis)):
    x=lis[i]
    #print(x)
    for j in range(2,((m-1)//x)+1):
        dp[x*j]=1
        #print(x*j)
#print(5*j)
#print(dp)
ans=0
#print(dp[10**6])
for y in lis:
    if c[y]<=1:
        ans+=1-dp[y]
print(ans)
#print(dp)
#print(dp[2*(10**5)])


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

int main(){
  int K;
  cin >> K;
  
  string s, u;
  u = "ACL";
  
  for(int i = 0; i < K; i++){
    if(i == 0) s = u;
    else s += u;
  }
  
  cout << s << endl;
  
  return 0;
}

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

// https://atcoder.jp/contests/abc126/tasks/abc126_a

string solver(string inS,int pos){
    string answer;
    inS.at(pos-1) = inS.at(pos-1)+32;
    answer = inS;
    return answer;
}

int main(void){
    int N,K;
    string result;
    cin >> N >> K ;
    string S;
    cin >> S;
    result = solver(S,K);
    cout << result << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            sum += Integer.parseInt(sc.next());
        }
        System.out.println(sum >= 22 ? "bust" : "win");
    }
}


Measured memory_bytes: 24916
import java.util.*;

public class Main {
	public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[]p = new int[n];

        int ans = 0;
        for(int i=0; i<n; i++){
		p[i] = sc.nextInt();
}
        for(int i=1; i<n-1; i++){ 
        if(p[i]>=p[i-1] && p[i]<p[i+1]){
            ans++;
        }else if(p[i]<p[i-1] && p[i]>=p[i+1]){    
            ans++;
    }
}
        System.out.print(ans);    
        }
}


Measured memory_bytes: 21972
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj1174/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/aoj1172/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);

		while (sc.hasNext()) {
			solve();
		}
	}

	int H, W, C;
	void solve() {
		H = sc.nextInt();
		W = sc.nextInt();
		C = sc.nextInt();
		if (H == 0) return;

		int[][] table = new int[H][W];
		for (int h = 0; h < H; h++)
			for (int w = 0; w < W; w++) {
				table[h][w] = sc.nextInt();
			}

		int[][] t = new int[H][W];

		int ans = 0;
		int limit = 6 * 6 * 6 * 6 * 6;
		for (int process = 0; process < limit; process++) {

			for (int h = 0; h < H; h++)
				for (int w = 0; w < W; w++)
					t[h][w] = table[h][w];

			int[] cs = new int[5];
			int p = process;
			for (int i = 0; i < 5; i++) {
				cs[i] = 1 + (p % 6);
				p /= 6;
			}
			if (cs[4] != C) continue;
			if (cs[0] == cs[1] || cs[1] == cs[2] || cs[2] == cs[3] || cs[3] == cs[4]) continue;

			for (int i = 0; i < 5; i++) {
				paint(0, 0, t, cs[i], t[0][0]);
			}
			int cur = count(0, 0, t, C);
			ans = max(ans, cur);
		}
		System.out.println(ans);
	}

	void paint(int r, int c, int[][] t, int updated, int init) {
		if (0 <= r && r < H && 0 <= c && c < W) {
			if (t[r][c] == init && init != updated) {
				t[r][c] = updated;
				paint(r + 1, c, t, updated, init);
				paint(r - 1, c, t, updated, init);
				paint(r, c + 1, t, updated, init);
				paint(r, c - 1, t, updated, init);
			}
		}
	}

	int count(int r, int c, int[][]t, int target) {
		int ans = 0;
		if (0 <= r && r < H && 0 <= c && c < W) {
			if (t[r][c] == target) {
				t[r][c] = -1;
				ans++;
				ans += count(r + 1, c, t, target);
				ans += count(r - 1, c, t, target);
				ans += count(r, c + 1, t, target);
				ans += count(r, c - 1, t, target);
			}
		}
		return ans;
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

void f(int &A, int &B, int x, int y, int a, int b, int c, int d){
  if(x > a || y > b){
    A = c; B = d;
    return;
  }
  if(x > c || y > d){
    A = a; B = b;
    return;
  }
  if(a < c){
    A = a; B = b;
  }else{
    A = c, B = d;
  }
}

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

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];

  FOR(i, 1, N){
    int a = (A[i-1]+A[i]-1)/A[i]*A[i];
    int b = a/A[i]*B[i];

    int d = (B[i-1]+B[i]-1)/B[i]*B[i];
    int c = d/B[i]*A[i];

    f(A[i], B[i], A[i-1], B[i-1], a, b, c, d);
  }

  cout << A[N-1]+B[N-1] << endl;

  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
v = gets.chomp.split
n.times do |i|
    v[i] = v[i].to_i
end
v.sort!.reverse!

(n-1).times do |i|
    mix = (v[n-1-i] + v[n-2-i]) / 2.0
    v.slice!(n-1-i,1)
    v[n-2-i] = mix
end

puts v[0]

Measured memory_bytes: 1788
# 14:50

N = int(input())
# 100000
MAX = 100000

dp = [0]*(N+1)

coins = [1]
for d in range(1,10):
    t = 6 ** d
    if t > MAX:
        break
    coins.append(t)

for d in range(1,10):
    t = 9 ** d
    if t > MAX:
        break
    coins.append(t)

coins.sort()

# coins | 0 | 1 | 6 | 7 | 8 | 9 |
# 1     | 0 | 1 | 6 | 7 |
# 6     | 0 | 1 | 1 | 2 |
# 9     |   |   |   |
def solve(N):
    for i in range(0,N+1):
        dp[i] = i

    for c in coins[1:]:
        for i in range(c, N+1):
            if dp[i-c] + 1 < dp[i]:
                dp[i] = dp[i-c]+1
    return dp[N]
print(solve(N))


Measured memory_bytes: 6900
import sys
# sys.setrecursionlimit(200010)
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    L = [list(map(int,input().split())) for _ in range(N)]
    L = sorted(L)
    M = sorted(L,key=lambda x: x[1])
    if N%2 == 1:
        print(max(0,M[N//2][1]-L[N//2][0]+1))
    else:
        a = (L[N//2-1][0]+L[N//2][0])
        b = (M[N//2-1][1]+M[N//2][1])
        print(b-a+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 49672
private class Stack<T> {
    val values = emptyList<T>().toMutableList()

    fun push(value: T) = values.add(value)

    fun pop() = values.removeAt(values.size - 1)

    override fun toString() = values.toString()
}

private class Queue<T> {
    val values = emptyList<T>().toMutableList()

    fun enqueue(value: T) = values.add(value)

    fun dequeue() = values.removeAt(0)

    override fun toString() = values.toString()
}

private fun <T> List<T>.get1Origin(index: Int) = this[index - 1]
private fun <T> List<T>.subList1Origin(fromIndex: Int, toIndex: Int) = this.subList(fromIndex - 1, toIndex - 1)
private fun <T> MutableList<T>.set1Origin(index: Int, element: T) = this.set(index - 1, element)
private fun <T> MutableList<T>.removeAt1Origin(index: Int) = this.removeAt(index - 1)

private fun String.splitToString() = this.split(" ")
private fun String.splitToInt() = this.split(" ").map { toInt() }

fun main(args: Array<String>) {
    val (S, T) = readLine()!!.splitToString()

    println(T + S)
}

Measured memory_bytes: 36012
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool flag=0;
    for(ll i=0;;i++){
        if(i%2==0){
            c-=b;
            if(c<=0){
                flag=1;
                break;
            }
        }else{
            a-=d;
            if(a<=0){
                flag=0;
                break;
            }
        }
    }
    cout<<(flag?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3632
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int n;cin >>n;
    vector<int> a(100999);//ignore 0
    rep(i,n){
        int t;cin >>t;
        a[t]++;
    }
    vector<int> sum(100999);//1~
    rep(i,100001){
        sum[i+2]=sum[i+1]+a[i+1]*(i+1);
    }
    int ans=sum[100001];
    int q;cin >>q;
    rep(_,q){
        int b,c;cin >>b>>c;
        ans+=(c-b)*a[b];
        a[c]+=a[b];
        a[b]=0;
        cout <<ans<<endl;
    }
}

Measured memory_bytes: 4840
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n=sc.nextInt(),p=sc.nextInt(),counto=0,counte=0;
    for(int i=0;i<n;i++) {
    	if(sc.nextInt()%2==0)counte++;
    	else counto++;
    }
    if(p==0) {
    	double res=1;
    	for(int i=2;i<=counto;i+=2) {
    		res+=f(i,counto);
    		//System.out.println(i+" "+f(i,counto));
    	}
    	System.out.println((long)((res)*(Math.pow(2, counte))));
    }else {
    	double res=0;
    	for(int i=1;i<=counto;i+=2) {
    		res+=f(i,counto);
    		//System.out.println(i+" "+f(i,counto));
    	}
    	System.out.println((long)(res*Math.pow(2, counte)));
    }
  }
  public static long f(long i,long n) {
	  double d=1,u=1;
	  if(i>n/2)i=n-i;
	  for(int j=1;j<=i;j++) {
		  d*=j;
	  }
	  for(int j=0;j<i;j++) {
		  u*=(n-j);
	  }
	  //System.out.println(u);
	  return (long)(u/d);
  }
}


Measured memory_bytes: 21076
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String x;
        int i=1;
        
        while(true){
            x = reader.readLine();
            if(Integer.parseInt(x)==0){
                break;
            }
            System.out.println("Case "+i+": "+Integer.parseInt(x));
            i++;
        }
    }
}

Measured memory_bytes: 31540