akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;

int a, b, sum, x, y,minn;

int main()
{
	scanf("%d%d%d", &a, &b, &sum);
	minn = a + b;
	for (int i = 0; i <= a; i++)
		for (int j = 0; j < b; j++)
			if (a * i + b * j - i * j >= sum) 
				minn = minn < i + j ? minn : i + j;
	printf("%d", minn);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>

using namespace std;

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int cnt = 0;
    while (true)
    {
        bool has_odd = false;
        int b[3] = {};
        for (int i = 0; i < 3; i++)
            if (a[i] & 1)
                has_odd = true;
            else
                for (int j = 0; j < 3; j++)
                    if (j != i)
                        b[j] += a[i] / 2;

        if (has_odd)
            break;

        cnt++;

        for (int i = 0; i < 3; i++)
            a[i] = b[i];

        if (cnt == 500000)
            break;
    }

    cout << (cnt < 500000 ? cnt : -1);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n,k;
 cin>>n;
 vector<ll>a;
 ll b;
 ll m=1000,st=0;
 rep(i,0,n){
  sc(b);
  push(a,b);
 }
 //一回目の株購入
 st+=m/a[0];
 m%=a[0];
// cout<<a[0]<<" "<<m<<" "<<st<<endl;
  
 ll ans;
 rep(i,0,n-1){
  if(a[i]<a[i+1]){
   st+=m/a[i];
   m%=a[i];
 //  cout<<a[i]<<" "<<m<<" "<<st<<endl;
  }
  else if(a[i]>a[i+1]){
   m+=a[i]*st;
   st=0;
  // cout<<a[i]<<" "<<m<<" "<<st<<endl;
  }
 }
 m+=st*a[n-1];
// cout<<a[i]<<" "<<m<<" "<<st<<endl;
 st=0;
 m=max((ll)1000,m);
 pr(m);
return 0;}

Measured memory_bytes: 3556
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

ll K, A, B;
ll vis[100005];
int main() {
	cin >> K >> A >> B;

	if (K < A - 1 || B - A < 2) {
		cout << 1 + K << endl;
		return 0;
	}
	else if (B - A >= 2) {

		cout << A + (B - A) * ((K - A + 1) / 2) + ((K - A + 1) % 2);

	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

const int  INF=1e9;
long long mod=1000000007;
using namespace std;


int main(){
int n,m;
cin>>n>>m;
vector<pair<int,int>>key;
rep(i,m){
    int a,b;
    cin>>a>>b;
    int s=0;
    rep(j,b){
        int c;
        cin>>c;
        --c;
        s|=1<<c;
    }
    key.emplace_back(s,a);
}
vector<int>dp(1<<n,INF);
dp[0]=0;
rep(s,1<<n){
    rep(i,m){
    int t=s|key[i].first;
    int cost=dp[s]+key[i].second;
    dp[t]=min(dp[t],cost);
    }
}
int ans=dp.back();
if(ans==INF)ans=-1;
cout<<ans<<endl;

 return 0;
}
/*

*/

Measured memory_bytes: 256
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=(1e7+7);
const ll mod=1e9+7;

ll spf[szz];
void sieve()
{
	ll st=1;
	rep(i,2,szz)
	{
		spf[i]=i;
	}
	for(ll i=2;i<szz;i+=2)
	{
		spf[i]=2;
	}
	rep(i,3,(ll)sqrt(szz))
	{
		if(spf[i]==i)
		{
			for(ll j=i*i;j<szz;j+=i)
			{
				if(spf[j]==j)
				{
					spf[j]=i;
				}
			}
		}
	}
}

ll f(ll n)
{
	if(n==1)
		return 1;
	map<ll,ll> mp;
	while(n!=1)
	{
		ll x=spf[n];
		while(n%x==0)
		{
			mp[x]++;
			n/=x;
		}
	}

	ll ans=1;
	for(auto x:mp)
	{
		ans*=(x.second+1);
	}
	return ans;

}

int main()
{
	Ryuga;

	
	clock_t startTime=clock();

	sieve();
	ll n;
	cin>>n;
	ll tot=0;
	rep(i,1,n+1)
	{
		tot+=i*f(i);
	}
	cout<<tot<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 81968
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		if (a[0] == 0) {
			System.out.println(0);
		} else {
			BigInteger ans = BigInteger.ONE;
			for (int i = 0; i < n; i++) {
				ans = ans.multiply(BigInteger.valueOf(a[i]));
				if (ans.compareTo(BigInteger.valueOf(1000000000000000000L)) > 0) {
					System.out.println(-1);
					return;
				}
			}
			System.out.println(ans);
		}
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 49084
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import sys
inf = 10**9+7
mod = 10**9+7
V = 10**5
n,W = map(int, input().split())
dp = [[inf for j in range(V+1)] for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    dp[i+1][0] = 0
    w,v = map(int, input().split())
    for j in range(V):
        if j+1-v >= 0:
            dp[i+1][j+1] = min(dp[i][j+1-v]+w, dp[i][j+1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], w)
for j in range(V+1):
    if dp[n][j] > W:
        print(j-1)
        sys.exit()
        break
print(V)

Measured memory_bytes: 173428
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] v = new int[n];
		for(int i = 0; i < n; i++){
		    v[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    v[i] -= sc.nextInt();
		}
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    result += max(0, v[i]);
		}
		// 出力
        System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int A,B;

	cin >> A >> B;

	int ans = A - 2*B;
	if (ans<0) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), A;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    A.push_back(a[i]);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(A.begin(), A.end(), a[i]) - A.begin();
  }
  int ret = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] % 2) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 1276
def main():
    h,w,n=map(int,input().split())
    r,c=map(int,input().split())
    r-=1
    c-=1
    s=input()
    t=input()
    rl=[]
    ud=[]
    for i in range(n-1,-1,-1):
        if t[i]=="D":
            ud.append("+"+"S")
        elif t[i]=="U":
            ud.append("-"+"S")
        elif t[i]=="R":
            rl.append("+"+"S")
        else:
            rl.append("-"+"S")
        if s[i]=="D":
            ud.append("+"+"T")
        elif s[i]=="U":
            ud.append("-"+"T")
        elif s[i]=="R":
            rl.append("+"+"T")
        else:
            rl.append("-"+"T")
    #print(rl)
    #print(ud)

    L=0
    R=w-1
    for i in rl:
        if i[1]=="T":
            if i[0]=="-":
                L+=1
            else:
                R-=1
        else:
            if i[0]=="+":
                L=max(L-1,0)
            else:
                R=min(R+1,w-1)
        if L>R:
            print("NO")
            return 0
    if c<L or R<c:
        print("NO")
        return 0

    L=0
    R=h-1
    for i in ud:
        if i[1]=="T":
            if i[0]=="-":
                L+=1
            else:
                R-=1
        else:
            if i[0]=="+":
                L=max(L-1,0)
            else:
                R=min(R+1,h-1)
        if L>R:
            print("NO")
            return 0
    if r<L or R<r:
        print("NO")
        return 0

    print("YES")
main()

Measured memory_bytes: 7216
#include <stdio.h>
#include <string.h>
#define rep(i, a) for(int i = 0; i < a; ++i)

int main(void) {
  char s[1500];
  int i, ans[300];
  rep(i, 300) ans[i] = 0;
  while(scanf("%s", s) != EOF) {
    rep(i, strlen(s)) ans[s[i]]++;
  }
  rep(i, 26) printf("%c : %d\n", (char)i + 'a', ans[i + 'a'] + ans[i + 'A']);
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> L(N);

    REP(i, N){
        cin >> L[i];
    }

    ll ans = 0;
    for(ll i=0; i<N-2; i++){
        for(ll j=i+1; j<N-1; j++){
            for(ll k=j+1; k<N; k++){
                if(L[i] + L[j] <= L[k]){
                    continue;
                }
                if(L[j] + L[k] <= L[i]){
                    continue;
                }
                if(L[k] + L[i] <= L[j]){
                    continue;
                }
                if(L[i] == L[j]) continue;
                if(L[j] == L[k]) continue;
                if(L[k] == L[i]) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	int total = 0;
	for ( int i = 1; i <= N; i++ )
	{
		int tmp = ( i / 10000 ) % 10 + ( i / 1000 ) % 10 + ( i / 100 ) % 10 + ( i / 10 ) % 10 + i % 10;
		if ( tmp >= A && tmp <= B )
		{
			total += i;
		}
	}

	cout << total << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	for(int i=0;i<=x;i++)
	{
		if(2*i+4*(x-i)==y)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else if(2*i+4*(x-i)<y)  break;
	}
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using ll = long long;
using std::cout;
using std::cin;
using std::endl;
using std::string;

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) + "..." << endl;
    }
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
int a[10010],b[10010];

map<P,int> dp[31];

int dfs(int l,int r,int t,int rank){
  if(rank==t&&dp[t].find(P(l,r))!=dp[t].end())return dp[t][P(l,r)];
  int idx=lower_bound(a,a+m+1,r)-a;
  int res=-1;
  if(idx>0&&a[idx-1]<=l&&r<=a[idx]){
    if(b[idx-1]>=rank+1){
      res=r-l-(1<<(b[idx-1]-rank-1));
    }else{
      if(b[idx-1]==t)res=r-l-1;
      else res=r-l;
    }
  }else{
    int mid=(l+r)/2;
    res=min(dfs(l,mid,t,rank+1)+dfs(mid,r,rank+1,rank+1),dfs(l,mid,rank+1,rank+1)+dfs(mid,r,t,rank+1));
  }
  if(rank==t)return dp[t][P(l,r)]=res;
  else return res;
}

int main(){
  scanf("%d%d",&n,&m);
  rep(i,m+1)scanf("%d",a+i);
  rep(i,m)scanf("%d",b+i);
  printf("%d\n", dfs(0,1<<n,0,0));
  return 0;
}



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


int main() {
	int N;
	cin >> N;
	int A[N];
	int A_sort[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A_sort[i] = A[i];
	}
	sort(A_sort, A_sort + N);
	int max = A_sort[N-1];
	int second_to_max = A_sort[N-2];
	for (int i = 0; i < N; i++) {
		cout << ((A[i] == A_sort[N-1]) ? second_to_max : max) << endl;
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

vector<int> adj[200010];
int val[200010];
int ans[200010];
int tree[800010];
int tab[200010];
int n,sz;

void upd(int node,int l,int r,int ix)
{
	// cout << l << " " << r << endl;
	if (l == r)
	{
		tree[node] = tab[l];
		return;
	}
	int mid = (l + r) >> 1;
	int child = node << 1;
	if (ix > mid)
	{
		// cout << "yo\n";
		// return;
		upd(child | 1,mid + 1,r,ix);
	}
	else
	{
		// cout << "yo\n";
		// return;
		upd(child,l,mid,ix);
	}
	tree[node] = max(tree[child],tree[child | 1]);
}

int query(int node,int nodeL,int nodeR,int queryL,int queryR)
{
	if (queryL > queryR) return 0;
	if (queryL > nodeR || queryR < nodeL) return 0;
	if (queryL <= nodeL && nodeR <= queryR) return tree[node];
	int mid = (nodeL + nodeR) >> 1;
	int child = node << 1;
	return max(query(child,nodeL,mid,queryL,queryR),query(child | 1,mid + 1,nodeR,queryL,queryR));
}

void dfs(int node,int par)
{
	int tmp = query(1,1,sz,1,val[node] - 1) + 1;
	ans[node] = tmp;
	if (par != -1)
		ans[node] = max(ans[par],tmp);
	int bef = tab[val[node]];
	tab[val[node]] = tmp;
	upd(1,1,sz,val[node]);
	// cout << "yo\n";
	// return;
	for (auto it : adj[node]) if (it != par)
		dfs(it,node);
	tab[val[node]] = bef;
	upd(1,1,sz,val[node]);
}

map<int,int> mp;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	vector< int > compress;
	for (int i = 1 ; i <= n ; i++)
	{
		cin >> val[i];
		compress.push_back(val[i]);
	}
	sort(compress.begin(),compress.end());
	compress.erase(unique(compress.begin(),compress.end()),compress.end());
	sz = compress.size();
	// cout << sz << endl;
	for (int i = 0 ; i < compress.size() ; i++)
		mp[compress[i]] = i + 1;
	for (int i = 1 ; i <= n ; i++)
		val[i] = mp[val[i]];
	for (int i = 1 ; i < n ; i++)
	{
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	// return 0;
	// return 0;
	dfs(1,-1);
	for (int i = 1 ; i <= n ; i++)
		cout << ans[i] << endl;
	return 0;
}

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

int main(){
	int a,b,c,goukei,hi;
	hi=1;
	cin >> a>>b>>c;
	while(goukei<c){
	    if(hi%7!=0){
	    goukei += a;
	    hi++;
	    }
	    else{
	       goukei =goukei+a+b;
	       hi++;
	    }
	        
	    }
	    cout<<hi-1<<endl;
	    
	   
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }
 
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };
 
    for (string t: blue) {
        ans = max(ans, calc(t));
    }
 
    cout << ans << endl;
    return 0;   
}




Measured memory_bytes: 256
def main():
    N = int(input())
    result = 0
    for n in range(105, N + 1, 2):
        cnt = 0
        for i in range(1,200):
            if n % i == 0:
                cnt += 1
            if n < i or cnt > 8:
                break
        if cnt == 8:
            result += 1
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

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

      if(a>=3200){
        System.out.println(s);
      }else{
        System.out.println("red");
      }
  }
}

Measured memory_bytes: 23252
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	int n, k;
	cin >> n >> k;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t >= k) {
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>
int main(){
  int a,b,x;
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  x=x-a;
  
  while(x>=b){
    x-=b;
  }
  
  printf("%d",x);
  
  
return 0;
}

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

namespace ConsoleApp15
{
    class Class394
    {
        static void Main()
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = abc[0], b = abc[1], c = abc[2];
            Console.WriteLine(Math.Min(b/a,c));
        }
    }
}


Measured memory_bytes: 28236
#include <iostream>
#include <map>

using namespace std;

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

    map<int, bool> A;
    map<int, int> C;
    
    int right = 0, wrong = 0;
    for (int i = 0; i < M; i++) {
        int d;
        string s;
        cin >> d >> s;
        if (A[d] == true) {
            continue;
        }
        if (s == "WA") {
            C[d]++;
        } else {
            A[d] = true;
            wrong += C[d];
            right++;
        }
    }

    cout << right << " " << wrong << endl;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int mini(int a,int b){
  if(a>b) return b;
  return a;
}

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,k,i;
  scanf("%d %d",&n,&k);
  int h[n],sub[n-1],min;
  for(i=0;i<n;i++) scanf("%d",&h[i]);
  qsort(h,n,sizeof(int),cmp);
  min = h[k-1]-h[0];
  for(i=k;i<n;i++) min = mini(min,h[i]-h[i-k+1]);
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
namespace mp=boost::multiprecision;
typedef long long ll;
typedef unsigned long long ull;
using bint=mp::cpp_int;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0 && c>0){
    c-=b;
    a-=d;
  }
  if(c<=0) co("Yes");
  else co("No");
  return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, Q, K;
typedef pair<int, ll> P;
vector<P> Tree[100005];
ll dp[100005], Ans[100005][2];

void bfs() {
  queue<P> que;
  que.push(P(K, 0));
  while(!que.empty()) {
    P q = que.front();que.pop();
    dp[q.first] = q.second;
    for (auto p: Tree[q.first]) {
      if (dp[p.first]<0ll) que.push(P(p.first, q.second+p.second));
    }
  }
}



int main() {
  INCANT;
  cin >> N;
  int a,b;ll c;
  rep(i, N-1) {
    cin >> a >> b >> c;
    a--;b--;
    Tree[a].push_back(P(b,c));
    Tree[b].push_back(P(a,c));
  }
  cin >> Q >> K;
  rep(i, Q) {
    cin >> a >> b;
    a--;b--;
    Ans[i][0]=a;Ans[i][1]=b;
  }
  rep(i, N) dp[i]=-1;
  K--;
  bfs();
  rep(i, Q) {
    cout << dp[Ans[i][0]] + dp[Ans[i][1]] << endl;
  }
  
  return 0;
}

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

int main(void){
    int a,b;
    double f, A, B;
    cin >>a>>b;
    A=a;
    B=b;
    f = a / b;
    cout <<a/b<<endl;
    cout <<a%b<<endl;
    printf("%.8lf\n", A/B);
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,sum=0;
    cin>>n>>a>>b;
    for (int i=1;i<=n;i++) {
        if (i<10) {
            if (i>=a&&i<=b) {
                sum+=i;
            }
        } else if (i<100) {
            int tmp10=i/10;
            tmp10+=i%10;
            if (tmp10>=a&&tmp10<=b) {
                sum+=i;
            }
        } else if (i<1000) {
            int tmp100=i/100;
            tmp100+=(i-tmp100*100)/10;
            tmp100+=i%10;
            if (tmp100>=a&&tmp100<=b) {
                sum+=i;
            }
        } else if (i<10000) {
            int tmp1000=i/1000;
            int hoge=(i-tmp1000*1000)/100;
            tmp1000+=(i-tmp1000*1000-hoge*100)/10;
            tmp1000+=hoge;
            tmp1000+=i%10;
            if (tmp1000>=a&&tmp1000<=b) {
                sum+=i;
            }
        } else if (i==10000) {
            if (1>=a&&1<=b) {
                sum+=i;
            }
        }
    }
    cout<<sum<<endl;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char mp[102][102];
    for(int i = 0; i <= h; i++){
        fill(mp[i],mp[i]+w+1,'.');
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> mp[i][j];
        }
    }
    ll streak[102][102];
    for(int i = 0; i <= h; i++){
        fill(streak[i],streak[i]+w+1,INF);
    }
    streak[0][1] = 0;
    streak[1][0] = 0;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int newst_u = 0, newst_l = 0;
            if(mp[i][j] == '#'){
                if(mp[i-1][j] == '.') newst_u = 1;
                if(mp[i][j-1] == '.') newst_l = 1;
            }
            streak[i][j] = min(streak[i][j-1]+newst_l,streak[i-1][j]+newst_u);
        }
    }

    cout << streak[h][w] << endl;

    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python
from collections import deque

def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result

def zero_num(n, k):
    if k == 0:
        return 1
    if len(n) == 0:
        return 0
    if n[0] == 0:
        return zero_num(n[1:], k)

    rest = comb(len(n) - 1, k) * 9 ** k
    rest += (n[0]-1) * comb(len(n) - 1, k-1) * 9 ** (k-1)
    return int(rest + zero_num(n[1:], k-1))


def main():
    N = tuple(map(int, input()))
    K = int(input())

    print(zero_num(N, K))


if __name__ == '__main__':
    main()


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

int main(void){
    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int dp[k+1];
    memset(dp, 0, sizeof dp);

    for(int i=0;i<n;i++){
        int x = arr[i];
        dp[x]=1;
    }
    for(int i=1;i<=k;i++){
        if(dp[i]==0){
            bool winner=false;
            for(int j=0;j<n;j++){

                if(i-arr[j]>=0){
                    if(dp[i-arr[j]]==0) winner=true;
                }
            }
            if(winner) dp[i]=1;
            else dp[i]=0;
        }
    }
    string s;
    s= dp[k]==1? "First": "Second";
    cout<<s<<endl;
    /*for(int i=0;i<=k;i++){
        cout<<dp[i]<<endl;
    }
    */
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		int q = parseInt(sc.next());
		int[] a = new int[q];
		for(i=0;i<q;i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		int[] s = new int[n+1];
//		for (i = 0; i < n; i++) {
//			s[i] = k;
//		}
		for (i = 0; i < q; i++) {
			s[a[i]-1]++;
		}
        PrintWriter pw = new PrintWriter(out);
		for (i = 0; i < n; i++) {
			if(k-q+s[i]>0) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
		}
		pw.flush();
	}
}


Measured memory_bytes: 47204
#include <iostream>
#include <numeric>

using namespace std;

int main() {
    int K;

    cin >> K;

    long long ans = 0;

    for(int i = 1; i <= K; i++) {
        for(int j = 1; j <= K; j++) {
            for(int k = 1; k <= K; k++) {
                int ij = gcd(i, j);
                ans += gcd(ij, k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a,b,n;
    cin>>a>>b>>n;
    lli x;
    if(n<b-1){
        x=n;
    }
    else{
        x=b-1;
    }
    lli ans=floor(a*x/b);
    out(ans);
}

Measured memory_bytes: 3560
from fractions import gcd
from functools import reduce

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
c = 1
while a[0] % 2 == 0:
    a[0] //= 2
    c *= 2
a[0] *= c
for ai in a[1:]:
    if ai % c or (ai // c) % 2 == 0:
        print(0)
        break
else:
    lcm = reduce(lambda x, y: x * y // gcd(x, y), a) // 2
    print(m // lcm - m // (2 * lcm))

Measured memory_bytes: 16232
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
s = set([1])
d = {}
d[1] = 1

for _ in range(m):
    x,y = map(int, input().split())
    if x not in d:
        d[x] = 0
    else:
        d[x] -= 1
    if y not in d:
        d[y] = 2
    else:
        d[y] += 1
    if x in s:
        if x in d and d[x]==0:
            s.remove(x)
        s.add(y)
# print(d)
# print(s)
print(len(s))


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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> a(n);
  rep(i,n){
    string s;
    int p;
    cin >> s >> p;
    a.at(i).first = make_pair(s,-p);
    a.at(i).second = i+1;
  }
  sort(a.begin(),a.end());
  rep(i,n) cout << a.at(i).second << endl;
  
}


Measured memory_bytes: 3600
#include<stdio.h>
int main()
{

int i,n,m;

scanf("%d%d",&n,&m);

double s[n];
double sum=0;
int c=0,x;
for(i=0;i<n;i++){

    scanf("%d",&x);
   s[i]=(double) x;
    sum+=s[i];
}

for(i=0;i<n;i++){
    if(s[i]>=(sum/(4*m)))
        c++;

}



if(c>=m)
    printf("Yes");
else
    printf("No");

}


Measured memory_bytes: 128
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=510;
int n,m; 
char A[maxn][maxn],B[maxn][maxn],C[maxn][maxn];
int main() {
	n=read();m=read();
	rep(i,1,n) scanf("%s",A[i]+1);
	rep(i,1,n) rep(j,1,m) B[i][j]=C[i][j]='.';
	rep(i,1,n) {
		B[i][1]=C[i][m]='#';
	}
	rep(i,1,n) rep(j,2,m-1) {
		if(i&1) B[i][j]='#';
		else C[i][j]='#';
	}
	rep(i,1,n) rep(j,2,m-1) if(A[i][j]=='#') {
		if(i&1) C[i][j]='#';
		else B[i][j]='#';
	}
	rep(i,1,n) {rep(j,1,m) putchar(B[i][j]);putchar('\n');}
	putchar('\n');
	rep(i,1,n) {rep(j,1,m) putchar(C[i][j]);putchar('\n');}
	return 0;
}


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

D = [(A[i], i) for i in range(N)]
D.sort(reverse=True)

dp = [[0 for j in range(N + 1)] for i in range(N + 1)]

for j in range(1, N + 1):
    dp[0][j] = dp[0][j - 1] + D[j - 1][0] * abs(D[j - 1][1] - (N - j))

for i in range(1, N + 1):
    dp[i][0] = dp[i - 1][0] + D[i - 1][0] * abs(D[i - 1][1] - (i - 1))

for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i + j > N:
            continue
        dp[i][j] = max(dp[i][j - 1] + D[i + j - 1][0] * abs(D[i + j - 1][1] - (N - j)), dp[i - 1][j] + D[i + j - 1][0] * abs(D[i + j - 1][1] - (i - 1)))

res = 0

for i in range(N + 1):
    for j in range(N + 1):
        if i + j == N:
            res = max(res, dp[i][j])

print(res)

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

double z, f[320][33], t;
int n, c, m, a[9];
inline char nc()
{
	static char buf[1000000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}

inline int read()
{
	int res = 0, neg = 1;
	char ch;
	do 
	{
		ch = nc(); 
		if (ch == '-') neg = -1;
	} while (ch < 48 or ch > 57);
	do res = res * 10 + ch - 48, ch = nc(); while (ch >= 48 and ch <= 57);
	return res * neg;
}
int main() 
{
	n = read(), c = read(), m = n * c;
	for (int i = 1; i <= n; i++) a[i] = read();
	std::sort(a + 1, a + n + 1);
	do 
	{
		memset(f, 0, sizeof f);
		f[n * a[n]][0] = 1;
		for (int i = 0; i < m; i++) for (int j = i; j <= m; j++) for (int k = 0; k < (1 << (n - 1)); k++) 
		if (i % n && (k >> (i % n - 1) & 1) == 0) f[std::min(std::max(j, i + n * a[i % n]), n * c)][k | (1 << (i % n - 1))] += f[j][k];
		z += f[m][(1 << (n - 1)) - 1];
		++t;
	} while (std::next_permutation(a + 1, a + n));
	printf("%.15f", z / t / pow(c, n - 1));
	return 0;
}


Measured memory_bytes: 384
def score(pts):
    a = sum(pts)
    if a%10 != 0:
        return a
    else:
        rem = [i for i in pts if i%10 != 0]
        if rem == []:
            return 0
        else:
            return a - min(rem)
N = int(input())

pts = []
for i in range(N):
    pts.append(int(input()))

print (score(pts))

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
map<ll,int> mp;
using T=tuple<int,int,int>;
using PP=pair<int,P>;
int main(){
    int n,q;
    cin>>n>>q;
    set<int> v;
    
    vector<PP> line;
   for(int i=0;i<n;i++){
     int a,b,x;
     cin>>a>>b>>x;
     line.push_back(PP(a-x,P(-1,x)));
     line.push_back(PP(b-x-1,P(1,x)));
}
vector<ll> ans(q);
for(int i=0;i<q;i++){
  int a;cin>>a;
  line.push_back(PP(a,P(0,i)));
  }
  sort(all(line));
  for(int i=0;i<line.size();i++){
    ll a=line[i].fi,b=line[i].se.fi,c=line[i].se.se;
    if(b==-1)v.insert(c);
    else if(b==1)v.erase(v.find(c));
    else ans[c]=(v.empty()?-1:*v.begin());
}
for(int i=0;i<q;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 28264
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n;
LL w[100005][4];
LL dp[100005][4];

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++)
		for(LL j = 1;j <= 3;j ++)
			scanf("%lld",&w[i][j]);
	for(LL i = 1;i <= n;i ++)
		for(LL j = 1;j <= 3;j ++)
			for(LL k = 1;k <= 3;k ++)
				if(j != k) dp[i][j] = max(dp[i][j],dp[i - 1][k] + w[i][j]);
	printf("%lld\n",max(dp[n][1],max(dp[n][2],dp[n][3])));
	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a = 0, b = 0;
  string astr, bstr;
  cin >> n;
  while (n--) {
    cin >> astr >> bstr;
    if (astr > bstr) {
      a += 3;
    } else if (astr < bstr) {
      b += 3;
    } else {
      a++;
      b++;
    }
  }
  cout << a << ' ' << b << '\n';
  return 0;
}



Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)
const LL mod = 1e9 + 7;

// i番目までにj個配る方法の数
LL dp[101][TENS(5)];
int N, K;
int a[101];
LL cum[TENS(5)];

void solve()
{
    cin >> N >> K;
    REP1(i, N)
    {
        cin >> a[i];
    }
    dp[0][0] = 1;

    // REP1(i, N)
    // { // i 番目までの子に
    //     REP0(j, K + 1)
    //     { // 飴を j 個配るときの場合の数は
    //         REP0(k, a[i] + 1)
    //         { // i-1 番目までの子に max(0, j-a[i])~j 個 配る配り方の和
    //             if (j >= k)
    //             {
    //                 dp[i][j] += (dp[i - 1][j - k] % mod);
    //                 dp[i][j] %= mod;
    //             }
    //         }
    //     }
    // }

    REP1(i, N)
    {
        // cum[j]: 半開区間累積和 = dp[i-1][j-1] + dp[i-1][j-1] + ... + dp[i-1][0]
        cum[0] = 0;
        REP1(j, K + 1)
        {
            cum[j] = (cum[j - 1] % mod + dp[i - 1][j - 1] % mod) % mod;
            cum[j] %= mod;
        }
        REP0(j, K + 1)
        {
            dp[i][j] += (cum[j + 1] - cum[max(0, j - a[i])] + mod) % mod;
            dp[i][j] %= mod;
        }
    }

    cout << dp[N][K] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 79232
MOD = 10 ** 9 + 7

N = int(input())
S = input()

if S[0] == 'W':
    print(0)
    exit()

right = [True] * (2 * N)
for i in range(1, 2 * N):
    if S[i] == S[i - 1]:
        right[i] = (not right[i - 1])
    else:
        right[i] = right[i - 1]
    
if right.count(True) != N:
    print(0)
    exit()

ans = 1
for i in range(2, N+1):
    ans *= i
    ans %= MOD
current_lines = 0
for r in right:
    if r:
        current_lines += 1
    else:
        ans *= current_lines
        ans %= MOD
        current_lines -= 1

print(ans)

Measured memory_bytes: 74840
a, b, c = map(int, input().split())

counter = 0
while a%2==b%2==c%2==0:
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    counter += 1
    if counter > 100000:
        counter = -1
        break
print(counter)

Measured memory_bytes: 38640
#include<stdio.h>

int main(){
  int N = 100, K, scan, i;
  int move = 0;
  scan = scanf("%d %d", &N, &K);
  int x[N], th = K / 2;
  for(i = 0; i < N; i ++){
    scan = scanf("%d", x+i);
  }
  for(i = 0; i < N; i ++){
    if(x[i] <= th) move += 2*x[i];
    else move += 2*(K - x[i]);
  }
  printf("%d\n", move);
  return 0;
}


Measured memory_bytes: 128
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val bt: BTree = Empty
  
  (0 until n).foldLeft[BTree](bt){(t, _) =>
    val ops: Array[String] = io.StdIn.readLine().split(" ")
    if (ops.length == 1) {t.show; t}
    else t.insert(ops(1).toInt)
  }
}

sealed trait BTree {
  def insert(x: Int): BTree
  def preorder: List[Int]
  def inorder: List[Int]
  def show: Unit = {
    println(" " + this.inorder.mkString(" "))
    println(" " + this.preorder.mkString(" "))
  }
}
object Empty extends BTree {
  def insert(x: Int): BTree = new Node(x, Empty, Empty)
  def preorder: List[Int] = Nil
  def inorder: List[Int] = Nil
}
class Node(v: Int, l: BTree, r: BTree) extends BTree {
  def insert(x: Int): BTree =
    if (x < v) new Node(v, l.insert(x), r)
    else new Node(v, l, r.insert(x))
  def preorder: List[Int] = v :: (l.preorder ::: r.preorder)
  def inorder: List[Int]  = l.inorder ::: (v :: r.inorder)
}


Measured memory_bytes: 477156