akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
        long long h,w; cin>>h>>w;
        long long ans = 1e12;
 
        for (int i = 1; i <= h; i++) {
                long long c1,c2;
                c1 = max(i*w, (h-i-(h-i)/2)*w) - min(i*w, ((h-i)/2)*w);
                c2 = max(i*w, (w-w/2)*(h-i)) - min(i*w, (w/2)*(h-i));
                ans = min(ans,min(c1,c2));
        }
 
        for (int i = 1; i <= w; i++) {
                long long c1,c2;
                c1 = max(i*h, (w-i-(w-i)/2)*h) - min(i*h, ((w-i)/2)*h);
                c2 = max(i*h, (h-h/2)*(w-i)) - min(i*h, (h/2)*(w-i));
                ans = min(ans,min(c1,c2));
        }
 
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 310;

int n, m, p[MAXN][MAXN];
int cnt[MAXN], fin[MAXN];

int main() {
	scanf("%d %d",&n,&m);
	REP(i, n) REP(j, m) scanf("%d",&p[i][j]);
  REP(i, n) REP(j, m) p[i][j]--;

  int sol = MAXN*MAXN;
  REP(t, m) {
    memset(cnt, 0, sizeof cnt);
    REP(i, n) {
      REP(j, m) {
        if (fin[p[i][j]]) continue;
        cnt[p[i][j]]++;
        break;
      }
    }

    int x = -1;
    REP(i, m) {
      if (!fin[i] && (x == -1 || cnt[x] < cnt[i])) x = i;
    }
    sol = min(sol, cnt[x]);
    fin[x] = 1;
  }

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


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 50
#define inf 4*1e18
int main(){
    int N,K;
    cin >> N >> K;
    ll x[50],y[50];
    vector<ll> xl;
    vector<ll> yl;
    REP(i,N){
        cin >> x[i] >> y[i];
        xl.push_back(x[i]);
        yl.push_back(y[i]);
    }
    sort(xl.begin(),xl.end());
    sort(yl.begin(),yl.end());
    ll min = inf;
    REP(i,N){
        FOR(j,i+1,N){
            REP(k,N){
                FOR(l,k+1,N){
                    if(min > (xl[j]-xl[i])*(yl[l]-yl[k])){
                        int count = 0;
                        REP(m,N) if(xl[i] <= x[m] && x[m] <= xl[j] && yl[k] <= y[m] && y[m] <= yl[l]) count++;
                        if(count >= K) min = (xl[j]-xl[i])*(yl[l]-yl[k]);
                    }
                }
            }
        }
    }
    cout << min << endl;
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    double n, k;
    cin >> n >> k;
    cout << ceil(log(n) / log(k) + 1e-9) << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		String s = sc.nextLine();

		int count = 0;
		for (int i = 0; i < 4; i++) {
			if (s.charAt(i) == '2') {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}
}



Measured memory_bytes: 21972
#include <stdio.h>
int cccc;

void merge(int a[],int left,int mid,int right){
    int n1,n2,i,j,k;
    int l[250002],r[250002];
    n1 = mid-left; n2 = right-mid;
    for(i=0;i<n1;i++){
        l[i] =a[i+left];
    }
    for(i=0;i<n2;i++){
        r[i] =a[i+mid];
    }
    l[n1]=1000000001;r[n2]=1000000001;
    i=0;j=0;
    for(k=left;k<right;k++){
        if(l[i]<=r[j]){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            j++;
        }
        cccc++;
    }
    
}

void mergesort(int a[],int left,int right){
    int mid;
    if(left+1<right){
        mid = (left+right)/2;
        mergesort(a,left,mid);
        mergesort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(void){
    int n,i;
    int a[500000];
    cccc=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    mergesort(a,0,n);
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i!=n-1){printf(" ");}
    }
    printf("\n%d\n",cccc);
}



Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define toInt(x) (x - '0')
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;

  int min = INF;
  rep(i, s.size() - 2) {
    int num  = toInt(s[i]) * 100 + toInt(s[i + 1]) * 10 + toInt(s[i + 2]);
    int diff = abs(753 - num);
    if (diff < min) min = diff;
  }
  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    string joi;
    int k;
    int j, o, i;
    int a=0;
    cin >> joi;
    while(a < joi.size())
    {
        j=0;
        while(a < joi.size() && joi[a]=='J')
        {
            o=0;
            i=0;
            ++a;
            ++j;
            while(a < joi.size() && joi[a]=='O')
            {
                i=0;
                ++a;
                if(++o > j) break;
                while(o > 0 && a < joi.size() && joi[a]=='I')
                {
                    ++a;
                    if(++i == o)
                    {
                        k = max(k, o);
                        break;
                    }
                }
                if(i > 0)
                {
                    i=0;
                    break;
                }
            }
            if(o > 0) j = 0;
        }
        ++a;
    }
    cout << k << endl;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;

    set<string> s;
    string x;

    for (int i=0; i<n; i++) {
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << "\n";
}


Measured memory_bytes: 19168
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    if(q * 2 < h) h = q * 2;
    if(h * 2 < s) s = h * 2;
    if(s * 2 < d) d = s * 2;
    int ans = 0;
    if(n%2==1) ans = d * (n / 2) + s;
    else ans = d * (n / 2);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0;
char a[100005];
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='B')
		{
			a[++cnt]=s[i];	
		} 
        else 
        {
            cnt--;
           	if(cnt<0)
			{
				cnt=0;
       	  	}
     	}
	}
    for(int i=1;i<=cnt;i++)
    {
     	cout<<a[i];	
	}
    cout<<endl;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int H, W, D;
  cin >> H >> W >> D;
  vector<vector<int>> A(H, vector<int>(W));
  vector<pair<int,int>> P(H * W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      A[i][j]--;
      P[A[i][j]] = {i, j};
    }
  }

  vector<int> dist(H * W);
  for(int k = D; k < H * W; k++) {
    int y1 = P[k - D].first;
    int x1 = P[k - D].second;
    int y2 = P[k].first;
    int x2 = P[k].second;
    dist[k] = dist[k - D] + abs(x1 - x2) + abs(y1 - y2);
  }

  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    cout << dist[r] - dist[l] << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 2560
x1,y1,x2,y2=map(int,input().split())

vec1=[(x2-x1),(y2-y1)]
vec2=[-vec1[1],vec1[0]]

ans=[x2+vec2[0],y2+vec2[1]]+[x1+vec2[0],y1+vec2[1]]
print(*ans)

Measured memory_bytes: 3060
N = int(input())
S = input()
#RGBそれぞれのペアを1個ずつ取ったあと、等間隔なやつを排除する

R=[]
G=[]
B=[]
for n,s in enumerate(S):
    if s=="R":
        R.append(n)
    elif s=="G":
        G.append(n)
    else:
        B.append(n)

ans = len(R)*len(G)*len(B)

for i in range(1,N//2 + 1):
    for s in range(N -i*2):#N=100,i=3 93,96,99
        if S[s]!=S[s+i] and S[s+i]!=S[s+2*i] and S[s] != S[s+2*i]:
            ans -= 1
print(ans)

Measured memory_bytes: 68524
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define ll long long
#define reg register
#define inf 0x7fffffff
#define MOD 1000000007
#define clr(a) memset(a,sizeof(a),0);
#define rep(i,l,r) for(reg int i=l;i<=r;i++)
#define dow(i,l,r) for(reg int i=l;i>=r;i--)
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
template<class T>inline T power(T a,T b){T ans=1;while(b){if(b&1){ans=ans*a%MOD;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	int a=read(),b=read();
	puts((a*b==15)?"*":((a+b==15)?"+":"x"));
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

s = list(input())
ans = 10**9
for i in range(len(s) - 3):
    temp = s[i:i+3]
    temp = ''.join(temp)
    temp = int(temp)
    temp = abs(753 - temp)

    if ans > temp:
        ans = temp

print(ans)

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n, k, s;

int main() {
    fastio();

    cin >> n >> k >> s;

    vi ans;
    forn(i, k) {
        ans.push_back(s);
    }

    forn(i, n - k) {
        if (s == TEN(9)) {
            ans.push_back(1);
        } else {
            ans.push_back(TEN(9));
        }
    }

    for (int v : ans) {
        cout << v << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <string>

using namespace std;

int main () {
   string s; cin >> s;

   int count = 0;
   for(int i = 0; i < 4; i++) {
      if(s[i] == '+') {
         count ++;
      } else {
         count --;
      }
   }

   cout << count << endl;
}


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

signed main() {
vector<vector<int>> C(3, vector<int>(3));
for( int i = 0; i < 3; i++ ){
for( int j = 0; j < 3; j++ ){
cin >> C.at(i).at(j);
}
}
bool sa = true;

for( int i = 0; i < 2; i++ ){
for( int j = 0; j < 2; j++ ){

if( C.at(i).at(j) - C.at(i+1).at(j) != C.at(i).at(j+1) - C.at(i+1).at(j+1) ){
sa = false;
}

if(C.at(j).at(i) - C.at(j).at(i+1) != C.at(j+1).at(i) - C.at(j+1).at(i+1) ){
sa = false;
}

}
}

if( sa == true ) cout << "Yes" << endl;
else cout << "No" << endl;

}


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

long long dp[105][4][4][4];
long long const MOD = 1000000007;

int main(void){
    char AGCT[] = {'A', 'C', 'G', 'T'};
    int N; cin >> N;
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if (i == 0 && j == 2 && k == 1) continue; // AGC
                if (i == 0 && j == 1 && k == 2) continue; // ACG
                if (i == 2 && j == 0 && k == 1) continue; // GAC
                dp[3][i][j][k] = 1;
            }
        }
    }
    
    for (int len = 4; len <= N; len++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int l = 0; l < 4; l++) {
                        if (j == 0 && k == 2 && l == 1) continue; // ?AGC
                        if (j == 0 && k == 1 && l == 2) continue; // ?ACG
                        if (j == 2 && k == 0 && l == 1) continue; // ?GAC
                        if (i == 0 && j == 2 && l == 1) continue; // AG?C
                        if (i == 0 && k == 2 && l == 1) continue;// A?GC
                        dp[len][j][k][l] += dp[len-1][i][j][k];
                        dp[len][j][k][l] %= MOD;
                    }
                }
            }
        }
    }
    
    long long ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const int MAX_LOG = (int)(335 + 5);

string s;

int n;
int doubling[MAX_LOG][MAX_N];

string binexp = "100100100100110101101001001011001010011000011011111010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

void make_doubling() {
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      doubling[0][i] = i + 1;
    } else {
      doubling[0][i] = i - 1;
    }
  }

  for (int i = 1; i < MAX_LOG; ++i) {
    for (int j = 0; j < n; ++j) {
      int fst = doubling[i - 1][j];
      int snd = doubling[i - 1][fst];
      doubling[i][j] = snd;
    }
  }
}

int after[MAX_N];

int ans[MAX_N];

int main(void) {
  // Here your code !
  cin >> s;

  n = s.size();

  reverse(binexp.begin(), binexp.end());

  make_doubling();

  for (int i = 0; i < n; ++i) {
    after[i] = i;
  }

  for (int i = 0; i < binexp.size(); ++i) {
    if (binexp[i] == '0') continue;

    for (int j = 0; j < n; ++j) {
      after[j] = doubling[i][j];
    }
  }

  for (int i = 0; i < n; ++i) {
    ans[after[i]] += 1;
  }

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

  return 0;
}


Measured memory_bytes: 134272
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

typedef long long LL;

int T;
LL A, B, C, D;

LL gcd(LL x, LL y) {
    if (x == 0) return y;
    if (x > y) return gcd(y, x);
    return gcd(y % x, x);
}

bool calc() {
    if (B > D) return false;
    if (B > A) return false;
    if (B <= C) return true;

    LL a = A % B;
    LL d = D % B;
    // a + n*d
    LL g = gcd(d, B);
    LL cm = B - g + (A % g);
    return cm <= C;
}

int main(void) {
    scanf("%d", &T);
    while (T--) {
        scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        printf("%s\n", calc() ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            int a = input.nextInt();
            int b = input.nextInt();
            if (a == 0 && b == 0)
                break;
            if (a < b)
                System.out.println(a+" "+b);
            else
                System.out.println(b+" "+a);
        }
    }
}


Measured memory_bytes: 34868
n, k = map(int, input().split())

if k%2 != 0:
    print((n//k)**3)
    exit()
else:
    k = k//2
    n_max = n//k
    n_even = n_max//2
    n_odd = n_max-n_even
    print(n_even**3 + n_odd**3)
    exit()



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const long long maxn=5e6,mod=1e9+7;
long long jc[5555555],injc[5555555],n,k,dp[4444][2222];
long long binpow(long long a,long long t)
{
	long long res=1,p=a;
	for (long long i=t;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=1;
	for (long long i=1;i<=maxn;i++) jc[i]=jc[i-1]*i%mod;
	injc[maxn]=binpow(jc[maxn],mod-2);
	for (long long i=maxn-1;i>=0;i--) injc[i]=injc[i+1]*(i+1)%mod;
}
long long C(long long n,long long k)
{
	if (n<k) return 0;
	return (jc[n]*injc[k]%mod)*injc[n-k]%mod;
}
long long bino(long long n,long long k)
{
	return C(n+k,k);
}
int main()
{
	cin>>n>>k;
	if (k==1) 
	{
		printf("1\n");
		return 0;
	}
	Init();
	dp[1][1]=1;
	for (long long i=2;i<=2*n;i++)
	{
		for (long long j=1;j<=n;j++)
		{
			if (j<i-j || j>i) continue;
			dp[i][j]=(dp[i-1][j-1]+(dp[i-1][j]*(n-i+1+j)%mod)*bino((n-i+j)*(k-1)+n-j,k-2))%mod;
		}
	}
	cout<<dp[2*n][n]<<endl;
	return 0;
}

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

constexpr int INF = 1e9;

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

  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];

  int cost = INF;
  for (int target = -100; target <= 100; target++) {
    int tmp = 0;
    for (int idx = 0; idx < N; idx++) {
      tmp += (a[idx] - target) * (a[idx] - target);
    }
    cost = min(cost, tmp);
  }

  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
	int n,m,a,b,c,s;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF)
	{
		s=a*b;
		if(s<c)
		printf("%d\n",s);
		else
		printf("%d\n",c);
	}

}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>

int top = 0, Stack[1000];

void push(int x) {
    top++;
    Stack[top] = x;
}

int pop() {
    top--;
    return Stack[top + 1];
}

int main() {
    int a, b;
    char s[100];

    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(b + a);
        } else if (s[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(b * a);
        } else if (s[0] == '/') {
            a = pop();
            b = pop();
            push(b / a);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
}



Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
long long n,k,curr[2][51][51];

void mult(int tag1 , int tag2){
	long long nwcurr[n][n];
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < n ; j += 1){
			nwcurr[i][j] = 0;
			int i1 = 0 , j1 = 0;
			for(int q = 0 ; q < n ; q += 1){
				nwcurr[i][j] += curr[tag1][i][j1]*curr[tag2][i1][j];
				//cout << i1 << " " << j1 << endl;
				nwcurr[i][j] %= 1000000007;
				i1 += 1;
				j1 += 1;
			}
		}
	}
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < n ; j += 1){
			curr[tag1][i][j] = nwcurr[i][j];
		}
	}
}

int solve(){
	while(k){
		while(k % 2 == 1){
			mult(1,0);
			k -= 1;
		}
		mult(0,0);
		k /= 2;
	}
	long long ret = 0;
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < n ; j += 1){
			ret += curr[1][i][j];
			ret %= 1000000007;
		}
	}
	return ret;
}

int main(){
	cin >> n >> k;
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < n ; j += 1){
			cin >> curr[0][i][j];
			if(i == j){
				curr[1][i][j] = 1;
			}
		}
	}
	cout << solve() << endl;
}

Measured memory_bytes: 256
n = int(input())
rest = []
for i in range(n):
    s, p = input().split()

    rest.append([s,int(p),i+1])

rest.sort(key = lambda x: x[1],reverse = True)
rest.sort(key = lambda x: x[0],reverse = False)

for i in range(n):
    print(rest[i][2])

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

#define M_PI       3.14159265358979323846

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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//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 SQ(a) ((a)*(a))
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

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


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

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

    
    string s; cin >> s;

    int ans = INT_MAX;

    int n = s.size();
    for(int i=0; i<n-1; ++i){
        if(s[i] != s[i+1]){
            ans = min(ans, max(i+1, n-(i+1)));
        }
    }
    if(ans == INT_MAX) ans = n;
    cout << ans << endl;
    return 0;

}

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

int main(){
    ios_base::sync_with_stdio(false);
	vector<int> ansvec;

	for(;;){
		int n, p;
		cin >> n >> p;
		if (n == 0) break;
		
		int bowlp = p;
		int turn = 0;
		int mayors[50]{0};
		for(;;){
			if (bowlp == 1 && mayors[turn] == p - 1) break;
			else if (bowlp == 0){
				bowlp += mayors[turn];
				mayors[turn] = 0;
			}
			else{
				mayors[turn]++;
				bowlp--;
			}

			if (turn == n - 1) turn = 0;
			else turn++;
		}
		ansvec.push_back(turn);
	}

	for (int ans : ansvec){
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol];cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
int n,m,i,j,vis[N],v[N];
string s[N],a[N],b[N];
pair<int,int> p[N];
char ch[N];
void check()
{
	//pr(666);
	//for (i=0;i<n/2;i++) printf("%d <=> %d\n",p[i].fi,p[i].se);cout<<endl;
	for (i=0;i<n/2;i++) a[i]=s[p[i].fi],a[n-i-1]=s[p[i].se];
	for (i=0;i<n;i++) if (vis[i]==0) a[n/2]=s[i];
	for (i=0;i<m;i++) b[i].clear();
	for (i=0;i<=m;i++) for (j=0;j<n;j++) b[i].pb(a[j][i]);
	
	//for (i=0;i<n;i++) pri(a[i],m);cout<<endl;
	//for (i=0;i<m;i++) pri(b[i],n);
	int f;if (m&1) f=1;else f=0;
	for (i=0;i<m;i++) v[i]=0;
	for (i=0;i<m;i++)
	{
		if (v[i]==0)
		{
			v[i]=1;
			string tmp=b[i];reverse(tmp.begin(),tmp.end());
			int flag=0;
			for (j=0;j<m;j++) if (v[j]==0) if (tmp==b[j]) {flag=1;v[j]=1;break;}
			//pr(i);pr(j);
			if (flag==0)
			{
				if (f==0) return ;
			//	pr(i);
			//	pr(tmp),pr(b[i]);
				if (tmp!=b[i]) return ;
				else f=0;
			}
		}
	}
	printf("YES\n");exit(0);
}
void dfs(int x)
{
	if (x>=n/2+1) {check();return ;}
	int t=0;
	for (int i=n-1;i>=0;i--) if (vis[i]==0) t=i;
	vis[t]=1;
	for (int i=0;i<n;i++) if (vis[i]==0)
	{
		p[x-1]=mp(t,i);
		vis[i]=1;
		dfs(x+1);
		vis[i]=0;
	}
	vis[t]=0;
}
int main()
{
	scanf("%d %d",&n,&m);
	for (i=0;i<n;i++)
	{
		scanf("%s",ch);
		s[i]=ch;
	}
	dfs(1);
	reverse(s,s+n);
	dfs(1);
	random_shuffle(s,s+n);
	dfs(1);
	printf("NO\n");
}
		

Measured memory_bytes: 900
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cassert>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
vector<int> b(200003);
int main(){
  int n,k,a,m=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a;
    if(b[a]==0)m++;
    b[a]++;
  }
  sort(b.begin(),b.begin()+n+1);
  int t=0,ans=0;
  for(int i=0;i<=n;i++){
    if(t>=m-k)break;
    if(b[i]!=0){
      t++;ans+=b[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int[] d = new int[N];
    	for(int i=0; i<N; i++) {
    		d[i] = sc.nextInt();
    	}
    	Arrays.sort(d);
    	System.out.println(d[N/2] - d[(N-1)/2]);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


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


void solve(){
	
	ll n,d ;
	cin>>n>>d ;

	int count=0 ;

	for(int i=0;i<n;i++)
	{
		ll x,y ;
		cin>>x>>y ;

		if(x*x+y*y<=d*d)
			count++ ;
	
		//cout<<ans<<"\n" ;
	}

	cout<<count ;
}	

int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second << endl;
#define printv(v) for(auto x : v) cout << x << " "; cout << endl;

const int N = 1e5 + 7;
int a,b;

int main() {

    cin >> a;

    int ans = 0;
    for (int i = 1; i <= a; i += 2) {
        int c = 0;
        for(int j = 1; j <= i; j++)
            if (i % j == 0){
                c++;
            }
        if (c == 8){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *p, const void *q) {
  return *(long *)p - *(long *)q;
}

long Abs(long);

int main(int argc, char const *argv[]) {
  long N, A[200000], temp, mean, ans = 0;
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &temp);
    temp -= i + 1;
    A[i] = temp;
  }
  qsort(A, N, sizeof(long), cmp);
  mean = A[N / 2];
  for (int i = 0; i < N; i++) {
    ans += abs(A[i] - mean);
  }
  printf("%ld", ans);
  return 0;
}

long Abs(long a) {
  if (a < 0) a *= -1;
  return a;
}

Measured memory_bytes: 3324
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
//        String s = sc.next();
//        int n = Integer.parseInt(s.substring(s.length()-1,s.length()));
//        if (n == 3)System.out.println("bon");
//        else if (n == 0 ||n == 1 ||n == 6 ||n == 8) System.out.println("pon");
//        else System.out.println("hon");
        int k = sc.nextInt();
        String s = sc.next();
        if (s.length() <= k) System.out.println(s);
        else
        {
            StringBuilder sb = new StringBuilder(s.substring(0,k));
            sb.append("...");
            System.out.println(sb.toString());
        }
        sc.close();
    }
}

Measured memory_bytes: 35844
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, n-1) {
		if (x >= a[i]) {
			ans++;
			x -= a[i];
		}
		else {
			break;
		}
	}
	if (a[n - 1] == x)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int h, w;
	int i, j;
	int masu[1000000] = {0};
	int kuro[1000000] = {0};
	int index = 0;
	int count = 0;
	int sum = 0;
	int work;
	int work2;
	int ans = 0;
	char str[1000][1001];
	
	scanf("%d%d", &h, &w);
	
	for(i = 0; i < h; i++) {
		scanf("%s", str[i]);
	}
	
	for(i = 0; i < h; i++) {
		for(j = 0; j < w; j++) {
			if(str[i][j] == '#') {
				sum++;
				masu[i * w + j] = 1;
				kuro[index] = i * w + j;
				index++;
				count++;
			}
		}
	}
	
	while(sum < h * w) {
		work = index - count;
		work2 = count;
		count = 0;
		for(i = 0; i < work2; i++) {
			if(kuro[work + i] - w < 0) {
				;
			} else if(masu[kuro[work + i] - w] == 0) {
				masu[kuro[work + i] - w] = 1;
				sum++;
				count++;
				kuro[index] = kuro[work + i] - w;
				index++;
			}
			if(kuro[work + i] % w == 0) {
				;
			} else if(masu[kuro[work + i] - 1] == 0) {
				masu[kuro[work + i] - 1] = 1;
				sum++;
				count++;
				kuro[index] = kuro[work + i] - 1;
				index++;
			}
			if(kuro[work + i] + w >= h * w) {
				;
			} else if(masu[kuro[work + i] + w] == 0) {
				masu[kuro[work + i] + w] = 1;
				sum++;
				count++;
				kuro[index] = kuro[work + i] + w;
				index++;
			}
			if( (kuro[work + i] + 1) % w == 0) {
				;
			} else if(masu[kuro[work + i] + 1] == 0) {
				masu[kuro[work + i] + 1] = 1;
				sum++;
				count++;
				kuro[index] = kuro[work + i] + 1;
				index++;
			}
		}
		ans++;
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 8960
<?php
list($n) = ints();
$a = ints();
// 尺取法
$ans = 0;
$r = 0;
$x = 0;
for ($l = 0; $l < $n; ++$l) {
    $r = max($r, $l);
    while ($r < $n && ($x ^ $a[$r]) === ($x + $a[$r])) {
        $x += $a[$r];
        ++$r;
    }
    $ans += $r - $l;
    $x -= $a[$l];
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 36108
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 2000 + 10;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
int cnt[maxn][maxn][2];
char st[maxn][maxn];

int fa[maxn], sz[maxn];
int findset(int u) {
    return (u == fa[u]) ? u : fa[u] = findset(fa[u]);
}
int merge(int u, int v) {
    u = findset(u);
    v = findset(v);
    fa[u] = v;
    return sz[v] += sz[u];
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; ++i) { scanf("%s", st[i]); }
    for(int i = 0; i<n-1; ++i) {
        for(int j = m-1; j >= 0; --j) {
            if(st[i][j] == st[i+1][j]) {
                cnt[i][j][0] = cnt[i][j+1][0] + 1;
            }else {
                cnt[i][j][1] = cnt[i][j+1][1] + 1;
            }
        }
    }

    int ans = max(n, m);
    for(int i = 0; i < m; ++i) {
        static pii tmp[maxn];
        for(int j = 0; j<n-1; ++j) {
            fa[j] = j;
            sz[j] = 1;
            tmp[j] = pii(cnt[j][i][0] ? cnt[j][i][0] : cnt[j][i][1], j);
        }
        sz[n-1] = 1;
        fa[n-1] = n-1;

        sort(tmp, tmp + n-1, greater<pii>());

        for(int j = 0; j < n-1; ++j) {
            int p = tmp[j].snd; 
            chkmax(ans, tmp[j].fst * merge(p, p + 1));
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline bool ok(ll ra,ll rb,ll k,ll tag)
{ll rm=ra+rb,nda=rm/(k+1),ndb=rm-nda;
if (tag==0&&nda==ra) return 0;
return (nda<=ra);
}
inline char getf(ll pos,ll k)
{return (pos%(k+1)==0?'B':'A');}
inline char getb(ll pos,ll k)
{return (pos%(k+1)==0?'A':'B');}
int main (){
	ll q,a,b,c,d;
	scanf ("%lld",&q);
	while (q--)
	{scanf ("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll k=(max(a,b)-1)/(min(a,b)+1)+1;
	ll l=0,r=a+b;
	while (l<=r)
	{ll mid=(l+r)>>1ll;
	ll rod=mid/(k+1),rm=mid-rod*(k+1);
	ll ra=a-(rod*k+rm),rb=b-rod;
	if (ok(ra,rb,k,rm)) {l=mid+1;}
	else {r=mid-1;}
	}
	for (ll i=c;i<=min(r,d);i++) putchar(getf(i,k));
	for (ll i=max(c,r+1);i<=d;i++) putchar(getb(a+b-i+1,k));
	puts("");
	}
	return 0;
}
	

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

const int N = (1 << 19) + 10;
int n, m, a[N], ans[N], mvp[N], bin[30];

template <class T> inline void in(T &x) {
	x = 0; int f = 0; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x = f ? -x : x;
}

int main() {
	in(m), bin[0] = 1;
	for (int i = 1; i < 30; ++i) bin[i] = bin[i - 1] << 1;
	n = bin[m];
	for (int i = 0; i < n; ++i) in(a[i]);
	for (int i = 0; i < n; ++i)
		for (int j = i; j < n; j = (j + 1) | i)
			ans[j] = max(ans[j], mvp[j] + a[i]), mvp[j] = max(mvp[j], a[i]);
	for (int i = 1; i < n; ++i) printf("%d\n", ans[i] = max(ans[i], ans[i - 1]));
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=100010;

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

    string s;
    cin>>s;
    if(s.back()=='s'){
        s+="es";
    }
    else{
        s+="s";
    }
    cout<<s;

    return (0);
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int d, n;
  scanf("%d%d", &d, &n);
  if(n == 100) {
    if(d == 0) {
      printf("101\n");
    }
    else if(d == 1) {
      printf("10100\n");
    }
    else {
      printf("1010000\n");
    }
    return 0;
  }
  printf("%d", n);
  while(d--) {
    printf("00");
  }
  printf("\n");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long input = scanner.nextInt();
        scanner.close();

        long ans = 0l;
        for (long i = 1l; i <= input; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 35820
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;
ll d[200][200];
int R;
ll ans=INF;
int visited[8];
void dfs(int depth,int id,ll cost,vector<int> v){
  if(depth==R){
    ans=min(ans,cost);
  }else{
    REP(i,0,v.size()){
      int idx=v[i];
      vector<int> v2(v.size());
      copy(v.begin(),v.end(),v2.begin());
      v2.erase(v2.begin()+i);
      dfs(depth+1,idx,cost+d[id][idx],v2);
    }
  }
}
int main()
{
  cin>>N>>M>>R;

  vector<int> r(R);
  REP(i,0,N){
    REP(j,0,N){
      if(i==j){
        d[i][j]=0;
      }else{
        d[i][j]=INF;
      }
    }
  }

  REP(i,0,R){
    cin>>r[i];
    r[i]--;
  }

  REP(i,0,M){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--;b--;
    d[a][b]=c;
    d[b][a]=c;
  }
  REP(k,0,N){
    REP(i,0,N){
      REP(j,0,N){
        if(d[i][j]>d[i][k]+d[k][j]){
          d[i][j]=d[i][k]+d[k][j];
        }
      }
    }
  }

  
  REP(i,0,R){
    dfs(0,r[i],0,r);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 512
import sys


def solve():
    a = []
    for line in sys.stdin:
        digit_list = line.split(' ')
        new_list = []
        for s in digit_list:
            new_list.append(int(s))
        a.append((new_list))
    for j in a:

        print str(len(str(sum(j))))	

if __name__ == '__main__':
    solve()

Measured memory_bytes: 6228
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



string s;
ll a[110000], b[110000], ans[110000];
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'R') {
			a[i] = i;
		}
		else a[i] = a[i - 1];
	}
	REPR(i, s.size()) {
		if (s[i] == 'L') {
			b[i] = i;
		}
		else b[i] = b[i + 1];
	}
	REP(i, s.size()) {
		if (s[i] == 'R') {
			if ((b[i] - i) % 2 == 1) ans[b[i] - 1]++;
			else ans[b[i]]++;
		}
		else {
			if ((i - a[i]) % 2 == 1) ans[a[i] + 1]++;
			else ans[a[i]]++;
		}
	}
	REP(i, s.size()) {
		if (i != 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}
	


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    string s;
    cin >> s;
    bool f = false;
    for(ll i=0; i < ll(s.size()-1); i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            f = true;
        }
    }
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int[] ary = new int[5];
	while(sc.hasNext()){
	    for(int i = 0; i < 5; i++)
		ary[i] = sc.nextInt();

	    Arrays.sort(ary);
	    System.out.print(Integer.toString(ary[4]));
	    for(int i = 3; i >= 0; i--)
		System.out.print(" " + Integer.toString(ary[i]));
	    System.out.println();
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
N = int(input())
H = [int(i) for i in input().split()]
def f(N,H):
    dp = [0] * (N+1)
    for i in range(N):
        if i >1:
            N1 = dp[i-1] + abs(H[i]-H[i-1])
            N2 = dp[i-2] + abs(H[i]-H[i-2])        
            dp[i] = min(N1,N2)
            
        if i==1:
            dp[i] = abs(H[0]-H[1])
    return dp[N-1]
print(f(N,H))

Measured memory_bytes: 13980