akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e4 + 50;
const int mod = 996873654;
int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s,t;
    cin >> s >> t;
    t+=s;
    cout << t;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 1000000007
#define nonod numberofnodes
#define pr pair <ll,ll>
#define mx 1000001
#define max 1001
#define prin(x) cout<<setprecision(7)<<fixed<<x<<endl;
using namespace std;


void masterstroke(){
  		ll n;
  		cin>>n;
cout<<180ll*(n-2)<<endl;

}
int main(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
#define mp(x,y) make_pair(x,y)
using namespace std;

// const int mod=1e9+7;

/*  author: H3XoRuSH  */

signed main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol N,K;
    cin >> N >> K;
    lol x[N],dp[N];
    for(lol i=0; i<N; i++) cin >> x[i];
    for(lol i=0; i<N; i++){
        if(i==0) dp[i]=0;
        else{
            dp[i]=INT_MAX;
            lol cur=INT_MAX;
            for(lol j=1; j<=K; j++){
                if(i-j<0) break;
                dp[i]=min(dp[i],dp[i-j]+abs(x[i]-x[i-j]));
            }
        }
    }
    cout << dp[N-1];
    return 0;
}


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

void p_list(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i != 0) cout << " ";
		cout << a[i];
	}
	cout << "\n";
}

void insertionSort(int a[], int n) {
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		p_list(a, n);
	}
}

int main() {
	int num;
	cin >> num;
	int list[100];
	for (int i = 0; i < num; i++) {
		cin >> list[i];
	}
	p_list(list, num);
	insertionSort(list, num);

	return 0;
}


Measured memory_bytes: 3088
def solve(N):
    if N <= 0:
        return 0
    cnt = 0
    while (1 << cnt) <= N:
        cnt += 1

    out = 0 if (N % 4 == 0) or (N % 4 == 3) else 1
    for i in reversed(range(1,cnt)):
        T = 1 << i
        if N < T:
            out += 0
        else:
            N -= T
            if N % 2 == 0:
                out += T
            else:
                out += 0

    return out

A, B = map(int, input().split())
B = solve(B)
A = solve(A-1)

print(A^B)

         

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    rep(i,5) {
        int a; cin>>a;
        if (a==0) {
            cout << i+1 << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007
#define pii pair<long long,long long>
 
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
unordered_map<char,pii>dir;
ll D=1e9;
 
bool check(ll x,ll y,ll n,ll m){
	return (x>=0 && y>=0 && n>x && m>y);
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;

	int i=0;
	for( i=0;i<=k;i++)
	{
		if((1<<i)*b>a)
			break;
	}
	b*=(1<<i);
	k-=i;
	c*=(1<<k);
	if(a<b && b<c)
		cout<<"Yes";
	else
		cout<<"No";
	cout<<endl;

}



Measured memory_bytes: 3612
bingo_list=[list(map(int,input().split())) for i in range(3)]
n = int(input())
number_li=[int(input()) for i in range(n)]
ans = "No"

for i in range(len(bingo_list)):
    for j in number_li:
        if j in bingo_list[i]:
            bingo_list[i][bingo_list[i].index(j)] = "x"

for k in range(len(bingo_list)):
    if bingo_list[0][k] == bingo_list[1][k] == bingo_list[2][k]:
        ans = "Yes"
for l in bingo_list:
    if l[0] == l[1] == l[2]:
        ans = "Yes"
if bingo_list[0][0] == bingo_list[1][1] == bingo_list[2][2]:
    ans = "Yes"
if bingo_list[0][2] == bingo_list[1][1] == bingo_list[2][0]:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3064
import sys
M = 10 ** 7
s = input()

a = {}
a_i1 = s
a[a_i1] = True
for i in range(1, M + 1):
    if a_i1 % 2 == 0:
        a_i2 = a_i1 / 2
    else:
        a_i2 = 3 * a_i1 + 1
    if a_i2 in a:
        print i + 1
        sys.exit()
    a_i1 = a_i2
    a[a_i1] = True


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

using namespace std;

int main(){
    int N,M,q;
    long long int answer=0;
    cin >> N >> M >> q;
    vector<long long int> a(q),b(q),c(q),d(q);
    vector<vector<int>> ans;

    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    queue<vector<int>> Q;

    for(int i=1;i<=M;i++){
        vector<int> vec(1,i);
        Q.push(vec);
    }

    while(!Q.empty()){
        vector<int> now = Q.front();
        Q.pop();
        if((int)now.size()==N){
            ans.push_back(now);
        }else{
            for(long long int i=now.back();i<=M;i++){
                vector<int> add(now);
                add.push_back(i);
                Q.push(add);
            }
        }
    }

    

    for(long long int i=0;i<(long long int)ans.size();i++){
        long long int anss = 0;

        for(int j=0;j<q;j++){
            if(ans[i][b[j]-1]-ans[i][a[j]-1]==c[j]){
                anss += d[j];
            }
        }

        answer = max(anss,answer);
    }

    cout << answer << endl;
}

Measured memory_bytes: 12980
I = input().split()
H = int(I[0])
W = int(I[1])

while H != 0 or W != 0:
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print()
    print()
    I = input().split()
    H = int(I[0])
    W = int(I[1])

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

bool pair_second(pair<int,int> a, pair<int,int> b){
  return a.second > b.second;
}

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> red;
  vector<pair<int,int>> blue;

  for(int i = 0;i < N;i++){
    int a,b;
    cin >> a >> b;
    red.push_back(make_pair(b,a));//プレディケートを用いる際,yが大きい順にsortするようにする.(firstとsecondを入れ替えてpush_back.)
  }

  for(int i = 0;i < N;i++){
    int c,d;
    cin >> c >> d;
    blue.push_back(make_pair(c,d));
  }

  sort(red.begin(),red.end(),greater<pair<int,int>>());
  sort(blue.begin(),blue.end());


  vector<bool> used_a(N,false);
  vector<bool> used_b(N,false);

  int ans = 0;

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      pair<int,int> b = blue[i];
      pair<int,int> a = red[j];
      if(b.first > a.second && b.second > a.first && used_a[j] == false && used_b[i] == false){
        used_b[i] = true;
        used_a[j] = true;
        ans++;
      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
h,w,m = list(map(int,input().split()))
t = [list(map(int,input().split())) for _ in range(m)]
from collections import Counter
 
x,y = zip(*t)

xcnt = Counter(x)
ycnt = Counter(y)
 
xcmax = max( xcnt.values() )
ycmax = max( ycnt.values() )
xlist = [k for k,v in xcnt.items() if v == xcmax]
ylist = [k for k,v in ycnt.items() if v == ycmax]
if len(xlist) * len(ylist) > m:
  print( xcmax + ycmax )
else:
  xylist = { i*(10**6)+j for i in xlist for j in ylist }
  tlist = { i[0]*(10**6) + i[1] for i in t }
  if len( xylist - tlist ) == 0:
    print( xcmax + ycmax -1 )
  else:
    print( xcmax + ycmax )

Measured memory_bytes: 226892
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int n, d, i, p, k, j, tmp, sum, count=0;
	scanf("%d%d", &n, &d);
	int x[n][d];

	rep(i,n){
		rep(j,d){
			scanf("%d", &x[i][j]);
		}
	}

	rep(i,n-1){
		loop(p, i+1, n){
			sum = 0;
			rep(j,d){
				tmp = abs(x[p][j] - x[i][j]);
				sum += tmp*tmp;
			}
			for(k=0; k<=sum; k++){
				if(sum == k*k) count++;
			}
		}
	}
	printf("%d", count);
	return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;



int main() {
    int n;
    scanf("%d", &n);
    int ans = n;
    rp(i, 0, n+1) {
        int t = i;
        int count = 0;
        while (t > 0) {
            count += t%6;
            t /= 6;
        }
        t = n - i;
        while (t > 0) {
            count += t%9;
            t /= 9;
        }
        if (ans > count) {
            ans = count;
        }
    }
    printf("%d\n", ans);
    return 0;

} 

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    ll ans = 0;
    int N,A[200010]={};
    ll l[200010]={},r[200010]={};
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        int le=i-A[i];
        int ri=i+A[i];

        if(1<=le){
            l[le]++;
        }
        if(ri<=N){
            r[ri]++;
        }
    }

    for(int i=2;i<N;i++){
        ans += l[i]*r[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 7484
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int n, a, b;

int main(){
	cin >> n >> a >> b;
	
	cout << min(a*n,b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let patterns: Vec<Vec<char>> = ["dream", "dreamer", "erase", "eraser"]
        .iter()
        .map(|s| s.chars().rev().collect())
        .collect();

    let s: Vec<char> = read::<String>().chars().rev().collect();

    let mut s = &s[..];
    let mut succeeded = true;

    while s.len() > 0 {
        let matched = patterns.iter().find(|&p| s.starts_with(p));
        if let Some(p) = matched {
            s = &s[p.len()..];
        } else {
            succeeded = false;
            break;
        }
    }

    println!("{}", if succeeded { "YES" } else { "NO" });
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi a(n);
  map<int, int> cnt[2];
  rep(i, 0, n){
    cin >> a[i];
    cnt[i%2][a[i]]++;
  }

  sort(all(a));

  int ans = 0;
  rep(i, 0, n){
    if(cnt[i%2][a[i]] > 0){
      cnt[i%2][a[i]]--;
    }else{
      ans++;
    }
  }

  cout << ans/2 << endl;

  return 0;
}


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

int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    rep(i,n) cin>>l[i];
    ll ans=0;
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(l[i]>abs(l[j]-l[k])&&l[i]<l[j]+l[k]&&l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]) ans++; 
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = int(input())
ans = sum(s)
s.sort()
if ans % 10 == 0:
    for i in s:
        if (ans - i) % 10 != 0:
            print(ans-i)
            exit()
    print(0)
else:
    print(ans)

Measured memory_bytes: 3060
n,y = map(int,input().split())
f = 0
for i in range(n+1):
    for j in range(n+1-i):
        k = n-(i+j)
        t = 10000*i + 5000*j + 1000*k
        if t == y and k >= 0:
            print(i,j,k)
            f = 1
            break
    if f == 1:
        break
if f == 0:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
int n,c,m; cin>>n; int h[n];
for(int i=0;i<n;i++) cin>>h[i];
m=*max_element(h,h+n); c=*min_element(h,h+n);
cout<<m-c;
return 0;
}

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

int main(){
  int r,D,x; cin >>r>>D>>x;
  
  int ans = 1;
  repeat(i,10){
    ans = r*x - D; 
    cout << ans <<endl;
    x = ans;
  }
}

Measured memory_bytes: 256
import sys
from scipy.misc import comb

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()

count = [0 for _ in range(n+1)]
for i in a:
    count[i] += 1
ans_ele = 0
for i in range(1, n+1):
    #print('#', i, count[i])
    if count[i] >= 2:
        ans_ele += comb(count[i], 2, exact=True)
#print(ans_ele)
for i in range(n):
    if count[a[i]] <= 1:
        print(ans_ele)
    elif count[a[i]] == 2:
        print(ans_ele - 1)
    else:
        print(ans_ele - comb(count[a[i]], 2, exact=True) + comb(count[a[i]]-1, 2, exact=True))


Measured memory_bytes: 35928
N, M = map(int, input().split())

halls = [int(input()) for i in range(M)]

dp = [1] * (N + 1)
for i in range(len(halls)):
    dp[halls[i]] = 0

for i in range(2, N + 1):
    if dp[i] == 0:
        continue
    dp[i] = dp[max(0, i - 1)] + dp[max(0, i - 2)]

print(dp[N] % 1000000007)

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<double> v(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));

  dp[1][0] = v.at(0);
  dp[0][1] = 1 - v.at(0);

  for(int i = 2; i <= N; i++){
    double prob = v.at(i-1);
    for(int j= 0; j <= i; j++){
      int k = i - j;
      // dp[j][k] (j+k)を更新する
      if(j-1>=0) dp[j][k] += dp[j-1][k] * prob;
      if(k-1>=0) dp[j][k] += dp[j][k-1] * (1-prob);
    }
  }

  double ans = 0;
  for(int i = 0; i <= N; i++){
    int j = N - i;
    if( i > j ) ans += dp[i][j]; 
  }

  cout << ans << endl;

}


Measured memory_bytes: 72704
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        
        for(int i = 0; i < s.length(); i++){
            
        	if( Character.isUpperCase(s.charAt(i)) ) {
                System.out.print(Character.toLowerCase(s.charAt(i)));}
            
        else if( Character.isLowerCase(s.charAt(i)) ){
            System.out.print(Character.toUpperCase(s.charAt(i)));}
            
            else{System.out.print(s.charAt(i));}
            
        }
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  vector<int> A(200000, 0);
  rep(i,n){
  	int a;
  	cin >> a;
  	A[a - 1]++;
  }
  sort(all(A), greater<int>());
  
  int ans = n;
  rep(i,k){
  	ans -= A[i];
  }
  
  dunk(ans);
  return 0;
}

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

#define pb push_back
#define st first
#define nd second


const int N = 1e3+5 , M = 1e9+7;
typedef pair<int,int> pii;
int n , m , h[N][N] , in[N][N];
char A[N][N];
vector<pii> adj[N][N];

void bfs(pii u){
  queue<pii> q;
  q.push(u) , h[u.st][u.nd] = 1;
  while(!q.empty()){
    u = q.front() , q.pop() , in[u.st][u.nd] = 0;
    for(int i = 0 ; i < adj[u.st][u.nd].size() ; i++){
      pii v = adj[u.st][u.nd][i];
      if(in[v.st][v.nd] == 0) q.push(v) , in[v.st][v.nd] = 1;
      h[v.st][v.nd] = (h[v.st][v.nd]+h[u.st][u.nd])%M;
    }
  }
}
      

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

  for(int i = 1 ; i <= n ; i++)
    for(int j = 1 ; j <= m ; j++) cin >> A[i][j];
  
  for(int i = 1 ; i <= n ; i++){
    for(int j = 1 ; j <= m ; j++){
      if(i != n && A[i][j] == '.' && A[i+1][j] == '.') adj[i][j].pb({i+1,j});
      if(j != m && A[i][j] == '.' && A[i][j+1] == '.') adj[i][j].pb({i,j+1});
    }
  }
  
  bfs({1,1});
  cout << h[n][m] << "\n";
}



Measured memory_bytes: 64000
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1000000007;

fn main() {
    let n: usize = read();
    let s1: String = read();
    let s2: String = read();
    let s1: Vec<char> = s1.chars().collect::<Vec<char>>();
    let s2: Vec<char> = s2.chars().collect::<Vec<char>>();
    
    let mut dp: Vec<i64> = vec![0; n];
    dp[0] = if s1[0] == s2[0] { 3 } else { 6 };

    for i in 1..n {
        let base = dp[i-1];
        if s1[i-1] == s2[i-1] {
            // AB or AB
            // AB    AC
            dp[i] = base * 2 % MOD;
        } else {
            if s1[i-1] == s1[i] {
                // AA
                // BB
                dp[i] = base;
            } else if s1[i] == s2[i] {
                // AC
                // BC
                dp[i] = base;
            } else {
                // AB or AC or AB
                // BA    BA    BC
                dp[i] = base * 3 % MOD;
            }
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N, M, C;
    cin >> N >> M >> C;
    int ans = 0;
    vector<ll>B(M);
    for(int i = 0; i < M; i++)cin >> B[i];
    for(int i = 0; i < N; i++){
        ll tmp = C;
        for(int j = 0; j < M; j++){
            ll a;
            cin >> a;
            tmp += a * B[j];
        }
        if(tmp > 0)ans++;
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;

struct R {
  int i, p;
  string s;
};
int main() {
  cin >> N;
  vector<R> rs(N);
  rep(i, N) {
    cin >> rs[i].s >> rs[i].p;
    rs[i].i = i + 1;
  }
  sort(all(rs), [&](const R& a, const R& b) {
    return a.s == b.s ? a.p > b.p : a.s < b.s;
  });

  rep(i, N) cout << rs[i].i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll total = A + B;
    ll answer = (N / total) * A;
    answer += min(N % total, A);
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
person = [0 for _ in range(5)]
n = int(input())
for _ in range(n):
    name = input()
    if name[0] == "M":
        person[0] += 1
    elif name[0] == "A":
        person[1] += 1
    elif name[0] == "R":
        person[2] += 1
    elif name[0] == "C":
        person[3] += 1
    elif name[0] == "H":
        person[4] += 1

total = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            total += person[i] * person[j] * person[k]
print(total)

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

int main(){
    int r,c,sum,total_sum=0;
    scanf("%d %d", &r,&c);
    int table[r+1][c+1];

    for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            table[i][j] = 0;  //初期化これ重要
        }
    }

    for(int i=0; i<r; i++){
        sum=0;
        for(int j=0; j<c; j++){
            scanf("%d", &table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;

    for(int i=0; i<r+1; i++){
        for(int j=0; j<c; j++){
            printf("%d ", table[i][j]);
        }
        printf("%d\n", table[i][c]);
    }
}



Measured memory_bytes: 2768
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n];
	rep(i, 0, n)
	cin >> a[i];
	ll curmax = a[0], ans = 0;
	rep(i, 1, n)
	{
		if (curmax > a[i])
		{
			ans += (curmax - a[i]);
			// curmax = a[i];
		}
		if (a[i] > curmax)
			curmax = a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5200
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
  
        int[] a = new int[3];
        if(sc.hasNext()){
            for(int i=0;i<3;i++){
                a[i] = sc.nextInt();
            }
            int n = sc.nextInt();

            while(a[0]>=a[1]){
                a[1] *= 2;
                n--;
            }

            while(a[1]>=a[2]){
                a[2] *= 2;
                n--;
            }

            if(n>=0) System.out.println("Yes");
            else System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 35696
import java.util.*;

public class Main {
    
    static int[] x;
    static int[] y;
    static int[] h;
    
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        x = new int[N];
        y = new int[N];
        h = new int[N];
        
        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
        }

        long[] XYH = new long[3];
        for(int cx = 0; cx <= 100; cx++){
            for(int cy = 0; cy <= 100; cy++){
                int H = -1;
                boolean isOK = true;
                for(int i = 0; i < N; i++){
                    if( h[i] == 0 ) continue;
                    if( H == -1 ){
                        H = h[i] + Math.abs(cx - x[i]) + Math.abs(cy - y[i]);
                    } else {
                        if( H != h[i] + Math.abs(cx - x[i]) + Math.abs(cy - y[i]) ){
                            isOK = false;
                            break;
                        }
                    }
                }
                
                if( !isOK ) continue;
                
                for(int i = 0; i < N; i++){
                    if( h[i] == 0 && H > Math.abs(cx - x[i]) + Math.abs(cy - y[i]) ){
                        isOK = false;
                        break;
                    }
                }
                
                if( isOK ){
                    XYH[0] = cx;
                    XYH[1] = cy;
                    XYH[2] = H;
                    break;
                }
            }
        }        
        
        System.out.println( XYH[0] + " " + XYH[1] + " " + XYH[2] );
        
    }
}


Measured memory_bytes: 25172
n, m = map(int, input().split())
ans = ["0", "0", "0"]
flag = True
ansnum = ""
for i in range(m) :
    num = [int(i) for i in input().split()]
    if ans[num[0]-1] == "0" :
        ans[num[0]-1] = num[1]
    elif ans[num[0]-1] == num[1] :
        continue
    else :
        flag = False
        
if n == 2 :
    if ans[0] == 0 :
        flag = False
    elif ans[0] == "0" :
        ans[0] = 1
if n == 3 :
    if ans[0] == 0 :
        flag = False
    elif ans[0] == "0" :
        ans[0] = 1
        
if flag == True :
    for j in range(n) :
        ansnum = ansnum + str(ans[j])
    print(ansnum)
else :
    print(-1)

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int A[N];
    bool ans = true;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
            {
                continue;
            }
            else
            {
                ans = false;
            }
            
        }
    }
    if(ans)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int N;
    cin >> N;
    int a[N];
    REP(i,N){cin>>a[i];}

    int K = 0;
    REP(i,N){
        if(a[i]==K+1){
            K++;
        }
    }
    if(K==0){
        K=N+1;
    }
    cout<<N-K<<endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# ITP1_10_C
import statistics

while 1:
    n = int(input())
    if n == 0 :
        break
    data = map(int, input().split())
    """
    statistics.m = mean(data)
    statistics.median = median(data)
    statistics.variance = variance(data)
    """
    std = float(statistics.pstdev(data))
    
    print(std)
    


Measured memory_bytes: 7068
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       char ch;
       cin>>ch;
       if(ch-'a'>=0 && ch-'a'<=26){
           pp("a");
       } else {
           pp("A");
       }
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
   string S;
   cin >> S;
   if((S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) || (S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) ||(S[0] == S[3] && S[1] == S[2] && S[0] != S[1])){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
*/
typedef long long ll;
#define pb push_back 
#define mp make_pair
#define f first
#define s second
#define sz(x) ((int)x.size())
const ll maxint=2e18;
const ll minint =-2e18;

/*******\
(͡ ° ͜ʖ ͡ °) : Hello there, relax.
\*     */
int main(){
    int x;
    cin>>x;
    if(x >= 30)cout<<"Yes\n";
    else cout<<"No\n";
    
    return 0;
}

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

using namespace std;

vector <pair<long long int,long long int>> v;
int n;
long long int a,b;
const long long int MOD = 1e9 + 7;
map <pair<long long int,long long int>,int> cnt;
vector <pair<long long int,long long int>> arr;

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

long long int mypow(long long int n)
{
	long long int res = 1;
	long long int x = 2;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(x%MOD)%MOD);
			res%=MOD;
		}
		x = ((x%MOD)*(x%MOD)%MOD);
		x%=MOD;
		n/=2;
	}
	return res;
}

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

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}

	long long int countzero = 0;

	for(int i=0;i<n;i++)
	{
		if(v[i].first==0 && v[i].second==0)
		{
			countzero++;
		}
		else if(v[i].first==0)
		{
			if(cnt.find(make_pair(0,1))==cnt.end())
			{
				cnt[make_pair(0,1)] = 0;
				cnt[make_pair(1,0)] = 0;
				arr.push_back(make_pair(1,0));
			}
			cnt[make_pair(0,1)]++;
		}
		else if(v[i].second==0)
		{
			if(cnt.find(make_pair(0,1))==cnt.end())
			{
				cnt[make_pair(0,1)] = 0;
				cnt[make_pair(1,0)] = 0;
				arr.push_back(make_pair(1,0));
			}
			cnt[make_pair(1,0)]++;
		}
		else
		{
			long long int g = gcd(abs(v[i].first),abs(v[i].second));
			v[i].first/=g;
			v[i].second/=g;
			if(v[i].first < 0 && v[i].second < 0 || v[i].first > 0 && v[i].second < 0)
			{
				v[i].first *= -1;
				v[i].second *= -1;
			}
			if(v[i].first < 0)
			{
				if(cnt.find(make_pair(v[i].first,v[i].second))==cnt.end())
				{
					//cout << arr.size() << ' ' << v[i].first << ' ' << v[i].second << '\n';
					cnt[make_pair(v[i].first,v[i].second)] = 0;
					cnt[make_pair(abs(v[i].second),abs(v[i].first))] = 0;
					arr.push_back(make_pair(abs(v[i].second),abs(v[i].first)));
				}
				cnt[make_pair(v[i].first,v[i].second)]++;
			}
			else
			{
				if(cnt.find(make_pair(abs(v[i].first),abs(v[i].second)))==cnt.end())
				{
					//cout << arr.size() << ' ' << v[i].first << ' ' << v[i].second << '\n';
					cnt[make_pair(abs(v[i].first),abs(v[i].second))] = 0;
					cnt[make_pair(-1*abs(v[i].second),abs(v[i].first))] = 0;
					arr.push_back(make_pair(abs(v[i].first),abs(v[i].second)));
				}
				cnt[make_pair(v[i].first,v[i].second)]++;				
			}
		}
	}

//cout << arr.size() << '\n';
	long long int res = 1;
	for(int i=0;i<arr.size();i++)
	{
		auto x = arr[i].first;
		auto y = arr[i].second;
		//cout << x << ' ' << y << '\n';
		//cout << cnt[make_pair(x,y)] << ' ' << cnt[make_pair(-y,x)] << '\n';
		long long int num = mypow(cnt[make_pair(x,y)]) + mypow(cnt[make_pair(-y,x)]) - 1;
		num%=MOD;
		if(num<0)
		{
			num+=MOD;
		}
		res = (res%MOD) * (num%MOD);
		res%=MOD;	
	}
	res -= 1;
	if(res<0)
	{
		res+=MOD;
	}

	res = (res%MOD) + (countzero%MOD);
	res%=MOD;

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 34492
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a,b,n,x,y,flg;
	scanf("%d %d",&a,&b);
	flg=0;
	n=1;
	while(1)	{
		x=n*8/100;
		y=n*10/100;
		if(a==x && b==y)	{
			flg=1;
			break;
		}
		if(x>a && y>b)	break;
		n++;
	}
	if(flg==0)	printf("-1\n");
	else printf("%d\n",n);
	return 0;
}

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

using namespace std;

/*

    bottom up, taking

*/

const int N = 1e5 + 5;
const int INF = 2e9;

int n , k;
int h[N];
int jumpCost[N];

main(){

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

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &h[i]);
    }

    // initialize dp table (jump table)
    for(int i = 0 ; i < n ; i ++){
            jumpCost[i] = INF;
    }
    jumpCost[0] = 0;

    for(int i = 0 ; i < n ; i ++){
            for(int j = 1 ; j <= k ; j ++){
                    if(i - j >= 0){
                            jumpCost[i] = min(jumpCost[i] , abs(h[i] - h[i - j]) + jumpCost[i-j]);
                    }
            }
    }

    printf("%d\n" , jumpCost[n-1]);

    return 0;
}



Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int x;
bool isbeki[1010];

int main() {
	cin >> x;
	isbeki[1] = true;
	for (int i = 2;i<=1000; i++) {
		for (int j = 2; pow(i, j) <= 1000; j++) {
			isbeki[(int)pow(i, j)] = true;
		}
	}
	for (int i=x; i >= 0; i--) {
		if (isbeki[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;

const int NUM_MAX=200000;

int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n), x(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			x[i]=a[i];
		}
		sort(x.begin(), x.end());

		int h=(n-1)/2;
		for(int i=0;i<n;i++)
		{
			if(a[i]<=x[h]) printf("%d\n", x[h+1]);
			else printf("%d\n", x[h]);
		}
	}

	return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

vector<ll> a,b;
vector<ll> preA , preB;

ll BS(ll rem)
{
    ll l=0 , h=preB.size()-1 , mid , idx=0;
    while(l<=h)
    {
        mid = (l+h)/2;
        if (preB[mid] > rem) h = mid-1;
        else
        {
            idx = max(idx , mid);
            l = mid+1;
        }
    }
    return idx;
}

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

    ll n,m,k;
    cin >> n >> m >> k;


    preA.push_back(0) , preB.push_back(0);
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin >> x;
        a.push_back(x);
        preA.push_back(preA.back()+x);
    }

    for(int i=1; i<=m; i++)
    {
        ll x;
        cin >> x;
        b.push_back(x);
        preB.push_back(preB.back()+x);
    }

    ll ans = 0 , tmp , rem;
    for(int i=0; i<preA.size(); i++)
    {
        if (preA[i] > k) break;
        rem = k - preA[i];
        tmp = i + BS(rem);
        ans = max(ans , tmp);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 11436
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a_list = list(map(int,input().split()))
if sum(a_list) >= 22:
    print('bust')
else:
    print('win')

Measured memory_bytes: 13644
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng {
    using namespace boost;
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    double r;
    cin >> r;
    cout << (2 * M_PI * r) << nl;
}


Measured memory_bytes: 3788
#include <iostream>

using namespace std;

int getCoin(int &A, int &B)
{
    int coin;
    if (A > B) {
        coin = A;
        A--;
    } else {
        coin = B;
        B--;
    }

    return coin;
}

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

    int coin = 0;
    coin += getCoin(A, B);
    coin += getCoin(A, B);

    cout << coin << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
C0 = S.count('AC')
C1 = S.count('WA')
C2 = S.count('TLE')
C3 = S.count('RE')
print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

Measured memory_bytes: 16280