akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a,b,c,d,e,f;
    
    cin >> a >> b >> c >> d >> e >> f;
    
    a*=100;
    b*=100;
    
    double ansA = 0,ansB = 0;
    
    vector<int> vec;
    
    vec.push_back(0);
    
    for(int i = 0; i < vec.size(); i++){
        if(vec[i]+c <= 3000)
            vec.push_back(vec[i]+c);
    }
    for(int i = 0; i < vec.size(); i++){
        if(vec[i]+d <= 3000)
            vec.push_back(vec[i]+d);
    }
    
    sort(vec.begin(),vec.end());
    
    for(int i = 0; i*a <= f ; i++){
        for(int j = 0; i*a+j*b <= f ; j++){
            
            int tokeru = (i*a+j*b)/100*e;
            
            
            auto itr = upper_bound(vec.begin(),vec.end(),min(tokeru, f - (i*a+j*b) ));
            
            //cout << tokeru << ":" << f - (i*a+j*b) << ":" << *itr << endl;
            
            if(itr != vec.begin()){
                itr--;
                
                if((double)(*itr) * ansA >= ansB * (*itr + (i*a+j*b) )){
                    ansA = (*itr + (i*a+j*b) );
                    ansB = *itr;
                }
                
            }
            
        }
    }
    
    cout << ansA << " " << ansB << endl;
    
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n' //toggle off for interactive problems
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e2+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			for(int k=j+1; k<n; k++){
				if (a[i] == a[j] || a[j] == a[k]) continue;
				if (a[i] + a[j] > a[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll binPowM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
return ans%m;
}
ll f(ll x,ll y,ll a)
{
  return (a&x)*(a&y);
}

int main()
{
ll n;cin>>n;
ll a=0,b=0,c=0;
ll x,y,z;
vector<vector<int>>dp(n+1,vector<int>(3,0));
for(int i=1;i<=n;i++)
{
  cin>>x>>y>>z;
  ll temp1=x+max(b,c);
  ll temp2=y+max(a,c);
  ll temp3=z+max(a,b);
  a=temp1;
  b=temp2;
  c=temp3;
}

cout<<max({a,b,c})<<"\n";
  return 0;
}





Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;

int64_t N;

bool Include(string S, int n){
    char c='0'+n;
    if(S.find(c)==string::npos) return false;
    else return true;
}

bool Check(int64_t num){
    string S=to_string(num);
    return Include(S,3) && Include(S,5) && Include(S,7);
}

void Solve(int64_t &ans, int64_t n=0, int i=1){
    if(i>10) return;

    if(n<=N && Check(n)) ans++;

    Solve(ans,10*n+3,i+1);
    Solve(ans,10*n+5,i+1);
    Solve(ans,10*n+7,i+1);
}

int main()
{
    cin >> N;

    int64_t ans = 0;
    Solve(ans);

    cout<<ans<<endl;
}

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

int main() {
    char a, b;
    cin >> a >> b;

    char ans;
    if (a == 'H' && b == 'H') ans = 'H';
    if (a == 'H' && b == 'D') ans = 'D';
    if (a == 'D' && b == 'H') ans = 'D';
    if (a == 'D' && b == 'D') ans = 'H';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,f[30];
  for (i = 0; i < 30; i++) {
    f[i]=0;
  }
  for(i=0;i<28;i++){
    scanf("%d",&n);
    f[n-1]=1;
  }
  for(i=0;i<30;i++){
    if(f[i]==0) printf("%d\n",i+1);
  }
  return 0;
}

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

int selectionSort(int A[], const int N)
{
    int cnt = 0;

    for( int i = 0; i < N; ++i ){
        int min = i;

    //iより後でA[i]より最も小さい値の添字を求める
        for( int j = i; j < N; ++j )
            if( A[j] < A[min] )
                min = j;

    //iとminが異なれば交換
        if( i != min ){
       swap(A[i], A[min]);
       ++cnt;
    }
    }

    return cnt;
}

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

    int cnt = selectionSort(A, N);

    for( int i = 0; i < N; ++i ){
        if( i ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);

    return 0;
}


Measured memory_bytes: 3232
import static java.lang.Math.pow;
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();
        int c = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) != 'S' && s.charAt(i) != 'C' && s.charAt(i) != 'R') {
                break;
            } else if (t.charAt(i) != 'S' && t.charAt(i) != 'C' && t.charAt(i) != 'R') {
                break;
            } else {
                if (s.charAt(i) == t.charAt(i)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 21588
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9){
        cout << a*b;
    }
    else
    {
        cout << -1; 
    }
    
        
    cout << endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,c,m,s,m1,s1,m2,s2,m3,s3;
  while(cin>>n&&n){
    vector<pii> v(n);
    rep(i,n){
      cin >> c >> m >> s >> m1 >> s1 >> m2 >> s2 >> m3>>s3;
      v[i].se = c;
      v[i].fi = (m+m1+m2+m3)*60 + s+s1+s2+s3;
    }
    sort(all(v));
    cout << v[0].se << endl;
    cout << v[1].se << endl;
    cout << v[v.size()-2].se << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

// Extended Print Func
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& input){
    os << "[ ";
    REP(i, input.size()){
        os << input[i];
        if (i < input.size()-1) { os << " "; }
    }
    os << " ]";
    return os;
}
void print() { std::cout << "\n"; }
template<class T, class... A> void print(const T& first, const A&... rest) { std::cout << first << " "; print(rest...); }
template<class... A> void print(const A&... rest) { print(rest...); }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,B,C;
  cin >> A >> B >> C;

  if (A==B){
    std::cout << ((A!=C) ? "Yes" : "No") << "\n";
  } else if (B==C) {
    std::cout << ((A!=C) ? "Yes" : "No") << "\n";
  } else if (C==A){
    std::cout << "Yes" << "\n";    
  } else {
    std::cout << "No" << "\n";
  }
  return 0;
}


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

#define MAXN 100005
#define ll long long int


int main(){
    int n;
    cin>>n;
    vector<ll> f(n+1,1);
    for(int i=1;i<=n/2;i++){
        for(int j=i*2;j<=n;j+=i){
            f[j]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        //cout<<f[i]<<"\n";
        ans+=(f[i]*i);
    }
    cout<<ans<<"\n";
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool b = false;
  for (int i = 0; i < B; i++) {
    if (A*i % B == C) {
      b = true;
      break;
    }
  }
  
  if (b) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

char s[100123];
bool is[26];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 0; i < n; ++i) {
		is[s[i]-'a'] = true;
	}
	for(int i = 0; i < 26; ++i) {
		if(!is[i]) {
			printf("%c", 'a' + i);
			return 0;
		}
	}
	puts("None");
}


Measured memory_bytes: 3804
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
const int MOD=1e9+7;
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
ll stp(int x,int y)
{return fac[x+y]*rfac[x]%MOD*rfac[y]%MOD;}
int main()
{
	fac[0]=rfac[0]=1;
	for(int i=1;i<SZ;++i) fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i>=1;--i)
		rfac[i-1]=rfac[i]*i%MOD;
	int h,w,a,b; ll ans=0;
	cin>>h>>w>>a>>b;
	for(int s=1;s<=w-b;++s)
		ans+=stp(a-1,s-1)*stp(h-a-1,w-s)%MOD;
	cout<<ans%MOD<<"\n";
}

Measured memory_bytes: 10624
module S = Set.Make (struct type t = int let compare = compare end)

let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let s = read_line () in
        let s0 = S.singleton 0 in
        let add d sa sb = S.fold (fun v acc -> S.add (v * 10 + d) acc) sb sa in
        let rec loop i s1 s2 s3 =
            if i = n then S.cardinal s3 else (
                let k = int_of_char s.[i] - int_of_char '0' in
                let s3 = add k s3 s2 in
                let s2 = add k s2 s1 in
                let s1 = add k s1 s0 in
                loop (i + 1) s1 s2 s3
            )
        in
        let r = loop 0 S.empty S.empty S.empty in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 4864
#include<cstdio>

int a,b,c,N;

int main()
{
    scanf("%d %d %d %d",&a,&b,&c,&N);
	N/=10;
	int ans=0;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*50+j*10+k*5==N)
					ans++;
	printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;
 
main(){
  int A,B,H,M;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  long double theta=(H+M/(long double)60)*11/6*3.14159265358979;
  printf("%.20Lf",sqrt(A*A+B*B-2*A*B*cos(theta)));
//  cout<<sqrt(A*A+B*B-2*A*B*cos(theta))<<endl;
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int ans1=0,ans2=0;
const int N=1e5+5;
int arr[N];
int recur(int n)
{
  int dp[n];
    dp[0]=0;

    for(int i=1;i<n;i++){
        if(i==1){
            dp[i]=abs(arr[0]-arr[1]);
        }

        else{
            dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
        }
    }
    return dp[n-1];
}
signed main()
{


    int n;
    cin>>n;

    for(int i=0;i<n;i++)cin>>arr[i];

    cout<<recur(n)<<endl;


    return 0;
}

Measured memory_bytes: 1792
a = []
for i in range(3):
    a += map(int, input().split())

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int n = int(s.size());
	long long res = 0;
	for(auto i = 0, acnt = 0, were_b = 0; i < n; ++ i){
		if(s[i] == 'A'){
			if(were_b){
				acnt = 0;
				were_b = false;
			}
			++ acnt;
		}
		else if(s[i] == 'B'){
			if(were_b){
				acnt = 0;
			}
			were_b = true;
		}
		else{
			if(were_b){
				res += acnt;
				were_b = false;
			}
			else{
				acnt = 0;
			}
		}
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 720
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    map<char, int> mp;
    for (char i='a'; i<='z'; i++) mp[i] = INT_MAX;

    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        map<char, int> tmp;
        for (const auto& c : s) tmp[c]++;

        for (char j='a'; j<='z'; j++) mp[j] = min(mp[j], tmp[j]);
    }

    for (char i='a'; i<='z'; i++) {
        cout << string(mp[i], i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ll n,k;
    cin >> n >> k;
    cout << min(n % k, k - n % k) << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	char[] c;

	public void solve() {
		c = next().toCharArray();
		N = c.length;
		int p = 0;
		int g = 0;
		int win = 0;
		int lose = 0;
		for(int i = 0;i < N;i++){
			if(c[i] == 'p'){
				if(p < g){
					p++;
				}else{
					lose++;
					g++;
				}
			}else{
				if(p < g){
					win++;
					p++;
				}else{
					g++;
				}
			}
		}
		out.println(win - lose);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

struct Point {
  int x,y,top;
  Point(int x, int y): x(x),y(y),top(0) {}
};
ostream& operator<<(ostream& s, const Point& x) {
  return s<< "(" << x.x << "," << x.y << ")";
}

struct Data {
  int x,y,h;
  Data(): x(0),y(0),h(0) {}
  Data(int x, int y, int h): x(x),y(y),h(h) {}
};
ostream& operator<<(ostream& s, const Data& x) {
  return s<< "(" << x.x << "," << x.y << "," << x.h << ")";
}
void p(const vector<Data>& xs) {
  cout<< xs.size() << ": ";
  for (const auto& x:xs) cout<< x <<",";
  cout<<endl;
}

int N;
list<Point> pyramids;
vector<Data> datas;
int main() {
  for(int y=0;y<=100;y++) for(int x=0;x<=100;x++) pyramids.push_back(Point(x,y));
  Point x = pyramids.front();
  scanf("%d", &N);
  Data t;
  for(int n=0;n<N;n++) {
    int x,y,h; scanf("%d%d%d",&x,&y,&h); datas.push_back(Data(x,y,h));
    if(h>=1) t=datas.back();
  }
  for(auto it = pyramids.begin(); it != pyramids.end(); ++it) {
    Point& pyramid=*it;
    pyramid.top = t.h + abs(pyramid.x-t.x) + abs(pyramid.y-t.y);
    for(const auto& data:datas) {
      const int h = max(pyramid.top - abs(data.x - pyramid.x)
                                    - abs(data.y - pyramid.y),
                        0);
      if (h != data.h) {
        it = pyramids.erase(it);
        --it;
        break;
      }
    }
  }
  Point pyramid = pyramids.front();
  printf("%d %d %d\n", pyramid.x, pyramid.y, pyramid.top);
}

Measured memory_bytes: 768
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N;
  cin >> N;
  double ans;
  if(!(N%2)) ans = (double)1/2;
  if(N%2) ans = (double)((N+1)/2)/N;
  cout << ans << endl;
 
}

Measured memory_bytes: 256
tops = []
s = []
v = 0
h = 0

gets.chomp.each_char do |c|
  case c
  when '\\'
    tops << {h: h, v: v}
    v += 1
    h -= 1
    s << 0 if s[s.size-1] != 0
  when '/'
    v += 1
    h += 1

    hit = false
    i = tops.size - 1
    top = {}
    merge = 0
    while 0 <= i
      top = tops[i]
      if h <= top[:h]
        hit = true
        break
      elsif (h - 1) == top[:h]
        merge += 1
      end
      i -= 1
    end
    if hit
      s[s.size-1] += (v - top[:v]) - 1
      s << s.pop(merge).inject(:+) if 2 <= merge
    end
  when '_'
    v += 1
  end
end
s.pop if s[s.size-1] == 0

puts (sum = s.inject(:+)) ? sum : 0
print "#{s.size}"
puts (s.size == 0) ? '' : ' ' + s * ' '

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

int main(){
    int n;
    cin >> n;
    char suit;
    int rank;
    int table[5][14];
    for(int i = 1; i <= 4; i++){
        for(int j = 1; j <= 13; j++){
                table[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        cin >> suit >> rank;
        if(suit == 'S'){
            table[1][rank] = 1;
        }
        else if(suit == 'H'){
            table[2][rank] = 1;
        }
        else if(suit == 'C'){
            table[3][rank] = 1;
        }
        else if(suit == 'D'){
            table[4][rank] = 1;
        }
    }
    for(int i = 1; i <= 4; i++){
        for(int j = 1; j <= 13; j++){
            if(!table[i][j]){
                if(i == 1){
                    cout << "S " << j << endl;
                }
                else if(i == 2){
                    cout << "H " << j << endl;
                }
                else if(i == 3){
                    cout << "C " << j << endl;
                }
                else if(i == 4){
                    cout << "D " << j << endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3052
def distance(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

def nearest(x, y, checkpoints):
    distances = list(map(lambda c: distance(x, y, c[0], c[1]), checkpoints))
    return 1 + distances.index(min(distances))


if __name__ == '__main__':
    n, m = map(int, input().split())
    students = [list(map(int, input().split())) for _ in range(n)]
    checkpoints = [list(map(int, input().split())) for _ in range(m)]
    for x, y in students:
        print(nearest(x, y, checkpoints))

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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m, t, a[MAX];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        scanf("%d", &t);
        int x;
        for(int j = 1; j <= t; j++){
            scanf("%d", &x);
            a[x] += i;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!a[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

    using namespace std;
 
int b[200010]={1};

    int main(){
      int n,T;
      cin >> n >> T;
      int c[n],t[n];
      rep(i,n)cin >> c[i] >> t[i];
      int ans=inf;
      rep(i,n){
       if(t[i]<=T)ans=min(ans,c[i]); 
      }
      if(ans!=inf){
       cout << ans << endl;
      }else cout << "TLE" << endl;
      return 0;}


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


int n,m;
string S,T;
int main()
{
	getline(cin,S);
	getline(cin,T);
	int ans = 1010;
	for(int i=0;i<=S.length()-T.length();i++)
	{
		int now = 0;
		for(int j=0;j<T.length();j++)
		{
			if(S[i+j]!=T[j])	now++;
		}
		ans = min(ans,now);
	
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  vector<int> s(10);
  while (cin >> s[0] >> s[1]) {
    if ((s[0]|s[1]) == 0)
      break;

    for (int i = 2; i < 10; ++i)
      cin >> s[i];

    int minIndex = 0;
    for (int i = 2; i < 10; i += 2) {
      if (s[i]+s[i+1] > s[2*minIndex]+s[2*minIndex+1])
	minIndex = i/2;
    }

    cout << static_cast<char>('A'+minIndex) << " " << s[2*minIndex]+s[2*minIndex+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        if(n < 1200)System.out.println("ABC");
        else if(n < 2800)System.out.println("ARC");
        else System.out.println("AGC");
    }
}

Measured memory_bytes: 35696
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long N,i,ans;

long f(long n){
  return log10(n)+1;
}

inline void solve(){
  IN(N);
  ans=LONG_MAX;
  for(i=1;i<=sqrt(N);i++){
    if(N%i==0){
      chmin(ans,max(f(i),f(N/i)));
    }
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));

list($N, $X) = explode(' ', $input);

$input = trim(fgets(STDIN));
$xs = explode(' ', $input);

$distances = [];
$begin = $X;
foreach($xs as $x) {
    $distance = abs($x - $begin);
    $distances[] = $distance;
    $begin = $x;
}

$distanceA = array_pop($distances);
foreach($distances as $distanceB) {
    $distanceA = gcd($distanceA, $distanceB);
}

echo $distanceA;

function gcd($a, $b) {
    if ($b === 0)
        return $a;

    return gcd($b, $a % $b);
}


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

int main() {
  int n,a;
  cin>>n>>a;
  vector<long long int> c(n);
  for (int i=0;i<n;++i) {
    cin>>c[i];
  }
  sort(c.begin(), c.end());
  long long int sum=0;
  if (n>a) {
    for (int i=0;i<n-a;++i) {
      sum+=c[i];
    }
  }
  cout<<sum<<endl;
}



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

using std::cin;
using std::cout; 
using std::vector; 

int main() { 
    int h, w; 
    cin >> h >> w; 
    vector<vector<int>> strings(h); 
    for (auto& string : strings) { 
        string.assign(w, '#'); 
        for (auto& symbol : string) { 
            char input_symbol; 
            cin >> input_symbol; 
            symbol = input_symbol; 
        }
    }
    if (strings[0][0] != '#') { 
        cout << "Impossible\n"; 
        return 0; 
    }
    int i = 0; 
    int j = 0; 
    while (!((i == h - 1) && (j == w - 1))) { 
        bool down = false; 
        if (i < h - 1) { 
            down = (strings[i + 1][j] == '#'); 
        }
        bool right = false; 
        if (j < w - 1) { 
            right = (strings[i][j + 1] == '#'); 
        }
        if (down && right) { 
            cout << "Impossible\n"; 
            return 0; 
        }
        strings[i][j] = '.'; 
        if (down) { 
            ++i; 
        } else if (right){ 
            ++j; 
        } else { 
            cout << "Impossible\n"; 
            return 0;
        }
    }
    if (strings[h - 1][w - 1] != '#') { 
        cout << "Impossible\n"; 
        return 0; 
    } 
    strings[h - 1][w - 1] = '.'; 
    for (const auto& string : strings) { 
        for (const auto symbol : string) { 
            if (symbol != '.') { 
                cout << "Impossible\n"; 
                return 0; 
            }
        }
    }
    cout << "Possible\n"; 
    return 0; 
}
                        
                    
                    


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	ll N;
	scanf("%lld",&N);


	stack<char> S;

	while(N > 0){

		N -= 1;
		S.push('a'+(N%26));
		N /= 26;
	}

	while(!S.empty()){

		printf("%c",S.top());
		S.pop();
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = Integer.parseInt(scanner.nextLine());
        int n = Integer.parseInt(scanner.nextLine());
        int a[] = new int[n];
        int b[] = new int[n];
        int z[] = new int[w];
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            String t[] = s.split(",");
            a[i] = Integer.parseInt(t[0]);
            b[i] = Integer.parseInt(t[1]);
        }
        for (int i = 0; i < w; i++) {
            int p = i + 1;
            for (int j = 0; j < n; j++) {
                if(p == a[j]) {
                    p = b[j];
                } else if (p == b[j]) {
                    p = a[j];
                }
            }
            z[p-1] = i + 1;
        }
        for (int i = 0; i < w; i++) {
            System.out.println(z[i]);
        }
    }
}


Measured memory_bytes: 26124
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
ll n; int vs[SZ],*h=vs+SZ/3,*t=h,cnt=0;
void md(ll s)
{
	if(s==1) return;
	md(s/2); *(t++)=++cnt;
	if(s&1) *(--h)=++cnt;
}
int main()
{
	cin>>n; ++n; md(n); int sz=t-h;
	printf("%d\n",sz+sz);
	for(int i=0;i<sz;++i) printf("%d ",*(h+i));
	for(int i=0;i<sz;++i) printf("%d ",i+1);puts("");
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int l[M] = {0};
  int r[M] = {0};
  for(int i = 0;i < M;i++){
    cin >> l[i] >> r[i];
  }
  for(int j = 0;j < M;j++){
    if(l[j + 1] < l[j]){
      l[j + 1] = l[j];
    }
    if(r[j + 1] > r[j]){
      r[j + 1] = r[j];
    }
  }
  if(r[M-1] > (l[M-1] - 1)){
    cout << r[M-1] - l[M-1] + 1 << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
map<ll, ll> m;
ll go(ll x) {
    if (x == 0)return 0;
    if (m.find(x) != m.end())return m[x];
    return m[x] = go(x / 2) + go(x / 2) + (ll)1;
}
int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    ll x; cin >> x;
    cout << go(x) << '\n';





}

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

#define all(x) x.begin(),x.end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    vector<ll> num;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll temp;
        scanf("%lld",&temp);
        num.push_back(temp);
    }
    sort(all(num),greater<ll>());
    int count=0; // maksimal 2;
    int index=0; // num[index]
    ll res=0;
    for(int i=1;i<=1&&i<n;i++){
        res+= num[0];
        index++;
        //printf("res %lld\n",res);
    }
    for(int i=2;i<n;i++){
        count++;
        res+=num[index];
        if(count==2){
            index++;
            count=0;
        }
        //printf("res %lld\n",res);
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 5328
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

E={}
for d in D:
    if d in E:
        E[d]+=1
    else:
        E[d]=1

U={}
for t in T:
    if t in U:
        U[t]+=1
    else:
        U[t]=1

F=True
for u in U:
    if u in E:
        F&=(U[u]<=E[u])
    else:
        F=False

if F:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 166780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A == B){
			System.out.println("Draw");
		}else if(A == 1){
			System.out.println("Alice");
		}else if(B == 1){
			System.out.println("Bob");
		}else if(A > B){
			System.out.println("Alice");
		}else{
			System.out.println("Bob");
		}

		sc.close();
	}

}


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

int main () {
  int  N ;
  cin >> N ;
  int ans = 0 ;
  for(int i = 1 ; i <= 1+N ; i++ ){
    for(int j = 2 ; j <= 2+N ; j++ ){
      int pre = pow(i,j) ;
      if( pre <= N ) ans = max(ans,pre) ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c)) - min(a, min(b, c)) << endl;
    
    return 0;
}

Measured memory_bytes: 3576
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	
	REP(i, n) {
		cin >> w[i];
	}

	int min = INT_MAX;

	REP(i, n) {
		int a = accumulate(w.begin(), next(w.begin(), i), 0);
		int b = accumulate(next(w.begin(), i), w.end(), 0);
		if (abs(b - a) < min) {
			min = abs(b - a);
		}
	}
	cout << min << endl;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    if n%1000 == 0:
        print(0)
    else:
        print(1000-n%1000)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char* argv[]) {
  int s;
  cin >> s;

  set<int> pasts;
  int i;
  for (i = 0; i < 1000000; ++i) {
    if (pasts.find(s) == pasts.end())
      pasts.insert(s);
    else
      break;
    if (s % 2 == 1) {
      s = 3 * s + 1;
    } else {
      s = s / 2;
    }
  }

  cout << i + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[400010];
ll b[111];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%lld",a+i);
            for(ll j=0; j<=60; ++j){
                if((1ll<<j)&a[i]){
                    ++b[j];
                }
            }
        }
        ll mod=1e9+7;
        for(int i=0; i<n; ++i){
            for(ll j=0; j<=60; ++j){
                if((1ll<<j)&a[i]){
                    --b[j];
                    ans+=(ll((n-i-1)-b[j]))*((1ll<<j)%mod);
                    ans%=mod;
                }
                else{
                    ans+=b[j]*((1ll<<j)%mod);
                    ans%=mod;
                }
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll a, b;
    cin(a); cin(b);
    print(a * b);
    return 0;
}

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

using namespace std;

const int maxn = (1 << 18);

int a[maxn + 1];
int usd[maxn];

int main() {
	int k; cin >> k;
  	int n = (1 << k);
  	for (int i = 0; i < n; i++)
    	cin >> a[i];
  	sort(a, a + n);
  	for (int i = 0; i < n; i++)
      	usd[i] = -1;
	usd[n - 1] = 0;
	for (int q = 0; q < k; q++) {
        int l = n - 1, r = n - 1, cnt = 0;
        while (r >= 0) {
            if (usd[l] == -1 || usd[l] == q + 1) {
                l--; r = min(l, r);
                continue;
            }
            if (usd[r] == -1 && a[l] != a[r]) {
                ++cnt; usd[r] = q + 1;
                --l; --r; continue;
            }
            --r;
        }
        if (cnt < (1 << q)) {
            cout << "No";
            return 0;
        }
    }
  	cout << "Yes";
  	return 0;
}


Measured memory_bytes: 5680
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,i,k;
    string s;
    cin>>n>>s;

    for(i=0;i<s.length();i++){
        if(s[i] + n > 'Z'){
            s[i] = 'A' + (s[i]+n)%'Z' -1;
        }else{
            s[i] += n;
        }
    }

    cout<<s;

    return 0;
}

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

int main(){
    int n,m,X,Y;cin>>n>>m>>X>>Y;
    int maxx=-101;
    int miny=101;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        maxx=max(maxx,x);
    }
    for(int i=0;i<m;i++){
        int y;cin>>y;
        miny=min(miny,y);
    }
    bool war=true;
    for(int z=X+1;z<=Y;z++){
        if(X<z&&z<=Y&&maxx<z&&z<=miny) war=false;
    }
    if(war) cout<<"War"<<endl;
    else cout<<"No War"<<endl;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;

namespace y.miyoshi
{

    public class Queen8
    {
        static int Max = 8;
        static bool[] vertical;
        static bool[] diagonal1;
        static bool[] diagonal2;
        static Dictionary<byte, byte> queenDic;
        static byte[] skip;

        public static void Main()
        {
            var n = byte.Parse(Console.ReadLine());
            skip = new byte[n];
            queenDic = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split();
                skip[_] = byte.Parse(line[0]);
                return new Queen{ x = byte.Parse(line[0]), y = byte.Parse(line[1])};
            }).ToDictionary(e => e.x, e=>e.y);

            Initialize();
            queenDic.ToList().ForEach(q => MarkBoad(q.Key, q.Value, true));

            Search8Queens(0);

        }

        public static void Search8Queens(byte x)
        {
            if (x == Max)
            {
                Display();
                return;
            }
            //var dic = queenDic;

            if (!skip.Contains(x))
            {
                for (byte i = 0; i < Max; i++)
                {
                    //????????????????
                    if (queenDic.ContainsKey(x)
                        || vertical[i] == true
                        || diagonal1[x + i] == true
                        || diagonal2[x - i + Max - 1] == true)
                        continue;


                    //diagonal2.Dump();
                    //??????
                    MarkBoad(x, i, true);
                    Search8Queens((byte)(x + 1));
                    MarkBoad(x, i, false);
                }
            }
            else
            {
                Search8Queens((byte)(x + 1));
            }

        }

        public static void Display()
        {
            for (byte i = 0; i < Max; i++)
            {
                for (byte j = 0; j < Max; j++)
                {
                    if (queenDic[i] == j)
                        Console.Write('Q');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
        }

        public static void MarkBoad(byte x, byte y, bool mark)
        {
            vertical[y] = mark;
            diagonal1[x + y] = mark;
            diagonal2[x - y + Max - 1] = mark;
            if (mark) queenDic[x] = y;
            else queenDic.Remove(x);
        }

        public static void Initialize()
        {
            vertical = new bool[Max];
            diagonal1 = new bool[2 * Max - 1];
            diagonal2 = new bool[2 * Max - 1];
        }

        public struct Queen
        {
            public byte x;
            public byte y;
        }
    }
}

Measured memory_bytes: 16956
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N],B[N];
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
  vector<int> pos;
  vector<int> neg;
  for(int i=0;i<N;i++){
     if(A[i] > B[i]) pos.push_back(A[i]-B[i]);
     if(A[i] < B[i]) neg.push_back(B[i]-A[i]);
  }
  sort(pos.begin(),pos.end());
  reverse(pos.begin(),pos.end());
  sort(neg.begin(),neg.end());
  int ind = 0;
  bool used = false;
  for(int i = 0 ; i < (int)neg.size(); i++){
     //cout << neg[i] <<" ... "<< endl;
     while(ind < (int)pos.size() && neg[i] > 0){
        if(pos[ind] > neg[i]){
           //cout << pos[ind] << "->" << pos[ind]-neg[i]<<endl;
           pos[ind]-=neg[i];
           neg[i] = 0;
           used = true;
        }
        else{
           neg[i]-=pos[ind];
           ind++;
           used = false;
        }
     }
  }
  if((int)neg.size() > 0 && neg[(int)neg.size()-1]!=0){
     cout << -1 << endl;
  }
  else{
     int ans =neg.size();
     ans += ind;
     if(used) ans++;
     cout <<ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1660
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator


def IA(): return [int(x) for x in input().split()]


def IM(N): return [IA() for _ in range(N)]


N = int(input())
B = IA()

sys.setrecursionlimit(500)


def f(b, n):
    if n == 0:
        return []
    for i, x in enumerate(b, 1):
        if i < x or n < x:
            return None
    for i, x in enumerate(b, 1):
        if i == x:
            ret = f(tuple(b[:i-1] + b[i:]), n-1)
            if ret is not None:
                return ret + [i]
    return None


ans = f(B, N)
if ans:
    print(*ans, sep="\n")
else:
    print(-1)


Measured memory_bytes: 3804