akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n";

int RoundedUp(ll i){if(i%10!=0) i=(i/10)*10+10; return i;}


void Main()
{
	ll N=5;
	ll result=0;
	VPLL vp(N);
	REP(i, N){
		ll a,b;
		cin >> a;
		b=a%10;
		if(b==0) b=10;
		vp[i]=make_pair(b,a);
	}
	SORT(vp);
	result+=vp[0].second;
	REP(i,N){
		if(i!=0)
		result+=RoundedUp(vp[i].second);
	}
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define memc(X) memset(X,0,sizeof(X))
#define ll long long
#define ic(i, a, b) for(int i=(a);i<(b);i++)
#define dc(i, a, b) for(int i=(a);i>(b);i--)

using namespace std;

int arr[9]={111,222,333,444,555,666,777,888,999};

int main() {
    int n;
    cin>>n;
    for(int i=0;i<9;i++){
        if(arr[i]>=n){
            cout<<arr[i]<<endl;
            break;
        }
    }
    return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int,vector<int>,greater<int>> s;
	vector<pair<int, int>> c;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push(a);
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		c.push_back(make_pair(-1 * b,a));
	}
	sort(c.begin(), c.end());
	int k = 1;
	
	for (int i = 0; i < m; i++) {
		pair<int, int>key;
		key = c[i];
		int a = key.first * (-1);
		int b = key.second;
		for (int j = 0; j < b; j++) {
			if (s.top() < a) {
				s.pop();
				s.push(a);
			}
			else {
				long long int sum = 0;
				for (int x = 0; x < n; x++) {
					sum = sum + s.top();
					s.pop();
				}
				cout << sum;
				return 0;
			}
		}
		
	}
	long long int sum = 0;
	for (int x = 0; x < n; x++) {
		sum = sum + s.top();
		s.pop();
	}
	cout << sum;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main()
{
	int ans = 0;
	char c[114514];
	cin >> c;
	REP(i, 4) if (c[i] == '2') ans++;
	cout << ans << endl;
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

const int MOD = 1e9 + 7;
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int sz = S.size();
    if(sz == 1){
        cout << S << endl;
        return 0;
    }
    int al = 0;
    for (int i = 0; i < S.size(); ++i) {
        al += S[i] - '0';
    }
    int ans = 0;
    if(S[0] == '1'){
        ans = (sz - 1) * 9;
    }else{
        ans = (S[0] - '0') - 1 + (sz - 1) * 9;
    }
    ans = max(al, ans);
    int tmp = 0;
    for (int i = 1; i < sz - 1; ++i) {
        if(S[i] != '0'){
            tmp = S[0] - '0' + S[i] - '0' - 1 + 9 * (sz - i -1);
            break;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=list(map(int,input().split()))

H=[True]*n
for i in range(m):
    a,b=map(int,input().split())
    if A[a-1]>=A[b-1]:
        H[b-1]=False
    if A[a-1]<=A[b-1]:
        H[a-1]=False

cnt=0
for i in range(n):
    if H[i]:
        cnt+=1
print(cnt)

Measured memory_bytes: 20112
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double[] lengthIndex = new double[4];
        for(int i = 0; i < lengthIndex.length; i++){
            lengthIndex[i] = sc.nextDouble();
        }
        
        Point pt1 = new Point();
        pt1.setXPoint(lengthIndex[0]);
        pt1.setYPoint(lengthIndex[1]);
        
        double px1 = pt1.getXPoint();
        double py1 = pt1.getYPoint();
        
        Point pt2 = new Point();
        pt2.setXPoint(lengthIndex[2]);
        pt2.setYPoint(lengthIndex[3]);
        
        double px2 = pt2.getXPoint();
        double py2 = pt2.getYPoint();
        
        double ans = Math.sqrt(Math.pow((px2-px1), 2) + Math.pow((py2-py1), 2));
        System.out.println(ans);
    }
}

class Point{
    private double x;
    private double y;
    
    public void setXPoint(double x){
        this.x = x;
    }
    
    public double getXPoint(){
        return x;
    }
    
    public void setYPoint(double y){
        this.y = y;
    }
    
    public double getYPoint(){
        return y;
    }
}


Measured memory_bytes: 28096
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n , k, s= 0 ,ans =1;
	cin>>n;
	ll arr[n];
	for(int i = 0;i<n;i++)
	{
	    cin>>arr[i];
	}
	int min = arr[0];
	for(int i = 1;i<n;i++)
	{
	    if(arr[i]<=min)
	    {
	        ans++;
	        min = arr[i];
	    }
	}
	cout<<ans;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n;
vvi to;
vi grn;

void dfs(int v = 0, int p = -1){
    for(auto u : to[v]){
        if(u == p) continue;
        dfs(u, v);
        grn[v] ^= (grn[u] + 1);
    }
}

void Main(){
    cin >> n;
    to.resize(n); grn.resize(n, 0);
    rep(i, n-1){
        int x, y; cin >> x >> y; x--; y--;
        to[x].pb(y);
        to[y].pb(x);
    }
    dfs();
    cout << (grn[0] == 0 ? "Bob" : "Alice") << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 15264
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0]
    var x = data.split('A').length - 1
    if (x === 0 || x === 3) {
        console.log('No')
    } else {
        console.log('Yes')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
N = int(input())
S = input()

dp = S[1 : N].count('E')
ans = dp
for i in range(N - 1):
    if S[i] == 'W':
        dp += 1
    if S[i + 1] == 'E':
        dp -= 1
    ans = min(dp, ans)
print(ans)

Measured memory_bytes: 3672
#include<stdio.h>
#define MAX 100000
#define SENTINEL 1000000001

typedef struct Card {
    char suit;
    int value;
} Card;

Card L[MAX/2 + 2], R[MAX/2+2];

int partition(Card A[], int p, int r) {
    Card x, y;
    int i, j;
    x = A[r];
    i = p-1;
    for (j=p; j<r; j++) {
        if (A[j].value<=x.value) {
            i++;
            y = A[j];
            A[j] = A[i];
            A[i] = y;
        }
    }
    i++;
    A[r] = A[i];
    A[i] = x;

    return i;
}

void quickSort(Card A[], int p, int r) {
    int q;
    if (p<r) {
        q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

void merge(Card A[], int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i=0; i<n1; i++) L[i]=A[left+i];
    for (i=0; i<n2; i++) R[i]=A[mid+i];
    L[n1].value=SENTINEL;
    R[n2].value=SENTINEL;
    i = 0;
    j = 0;
    for (k=left; k<right; k++) {
        if (L[i].value<=R[j].value) {
            A[k] = L[i];
            i+=1;
        } else {
            A[k] = R[j];
            j+=1;
        }
    }
}

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

int main() {
    Card A[MAX], B[MAX];
    int n, i, j;
    bool stable=true;
    char S[10];

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%s %d", S, &j);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = j;
    }

    quickSort(A, 0, n-1);
    merge_sort(B, 0, n);
    
    for (i=0; i<n; i++) {
        if (A[i].suit != B[i].suit) {
            stable = false;
        }
    }
    if (stable) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }
    for (i=0; i<n; i++) {
        printf("%c %d\n", A[i].suit, A[i].value);
    }
    return 0;
}


Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<int,pii>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 2e5 + 5;
const LL INF = 0x3f3f3f3f3f3f3f3f;
int a[N];
LL sum[N];
LL get_s(int l, int r) {
    if(l > r) return INF;
    return sum[r] - sum[l-1];
}
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
    LL ans = INF;
    int l1 =1, l2 = 3;
    for (int i = 2; i < n-1; i++) {
        while(l1+1 < i && abs(get_s(1, l1) - get_s(l1+1, i)) >= abs(get_s(1, l1+1) - get_s(l1+2, i))) l1++;
        l2 = max(l2, i+1);
        while(l2+1 < n && abs(get_s(i+1, l2) - get_s(l2+1, n)) >= abs(get_s(i+1, l2+1) - get_s(l2+2, n))) l2++;
        LL mn = INF, mx = 0;
        mn = min(mn, get_s(1, l1)); mx = max(mx, get_s(1, l1));
        mn = min(mn, get_s(l1+1, i)); mx = max(mx, get_s(l1+1, i));
        mn = min(mn, get_s(i+1, l2)); mx = max(mx, get_s(i+1, l2));
        mn = min(mn, get_s(l2+1, n)); mx = max(mx, get_s(l2+1, n));
        ans = min(ans, mx - mn);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
main(){for(;;){int d[5],s=0,i=0,h,k,c;for(;i<5;i++){scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];c=s^k;printf("%d\n",s>12|s==k?3:c&k*2|c&k/4?1:2);}}}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n;
    cin >> n;
    ll ans = 0;
    for (i = 1; i <= n; i++) {
        ans += i * (n / i) * (n / i + 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll dp[MAXn][5];
ll cal(ll x,ll pos){
  if (pos == 0 || pos == 4) return x;
  else if (pos == 1 || pos == 3) return (x == 0 ?2:x%2);
  return !(x%2);
}
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n) cin >> d[i];
  REP (i,n+1) REP (j,5) dp[i][j] = INF;
  dp[0][0] = 0;

  REP (i,n) {
    REP (j,5) {
      if (j) dp[i][j] = min(dp[i][j],dp[i][j-1]);
      dp[i+1][j] = min(dp[i+1][j],dp[i][j] + cal(d[i],j));
    }
  }

  ll ans = *min_element(dp[n],dp[n]+5);
  cout << ans << endl;
}


Measured memory_bytes: 9600
#include <cstdio>
int n, m, tot, x[505][505];
int a[250005], b[250005], c[250005], d[250005];
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) scanf("%d",&x[i][j]);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(x[i][j]%2)
	{
		if(j!=m) ++tot,++x[i][j+1],a[tot]=i,b[tot]=j,c[tot]=i,d[tot]=j+1;
		else if(i!=n) ++tot,++x[i+1][j],a[tot]=i,b[tot]=j,c[tot]=i+1,d[tot]=j;
	}
	printf("%d\n",tot);
	for(int i=1;i<=tot;++i) printf("%d %d %d %d\n",a[i],b[i],c[i],d[i]);
	return 0;
}

Measured memory_bytes: 5888
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int K=in();
	queue<ll> Q;
	REP(i,9) Q.push(i+1);
	REP(i,K){
		auto P=Q.front();
		Q.pop();
		if(i==K-1){
			out(P);
			return 0;
		}
		ll M=P%10LL;
		if(M>0) Q.push(10LL*P+M-1LL);
		Q.push(10LL*P+M);
		if(M<9) Q.push(10LL*P+M+1LL);
	}
	return 0;
}


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

#define rep(i,n) for (int i = 0; i < int(n); i++)
#define show(x) #x " = " << x

int n;
vector<int> G[100];
int d[100];

int main() {
    cin >> n;
    rep (i,n) {
        int u, k, v;
        cin >> u >> k;
        rep (i,k) cin >> v, G[u-1].push_back(v-1);
    }
    rep (i,100) d[i] = -1;

    queue<int> q;
    q.push(0);
    d[0] = 0;
    while (!q.empty()) {
        int v = q.front(); q.pop();
        rep (i,G[v].size()) {
            int x = G[v][i];
            if (d[x] == -1) {
                d[x] = d[v] + 1;
                q.push(x);
            }
        }
    }
    rep (i,n) cout << i+1 << " " << d[i] << endl;
        
}

Measured memory_bytes: 1228
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    string s;
    cin >> s;
    cout << 700 + ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o')) * 100 << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll func(vvl &T, ll now) {
  if (T[now].empty()) {
    return 0;
  }
  vl nums;
  AUTO(t, T[now]) nums.push_back(func(T, t));
  sort(ALL(nums), REV(ll));
  REP(i, nums.size()) nums[i] += i + 1;

  return MAX(nums);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vvl T(N);
  REP(i, N - 1) {
    ll a = 0;
    cin >> a;
    a--;
    T[a].push_back(i + 1);
  }
  cout << func(T, 0) << endl;
  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

void solve()
{
   ll n;
   cin>>n;
   ll h[n];
   f(i,0,n)
   cin>>h[i];
   ll dp[n];
   dp[0]=0;
   dp[1] = abs(h[1]-h[0]);
   f(i,2,n)
   {
       dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   }
   cout<<dp[n-1]<<"\n"
;}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int i,j;
        while(true) {
            i = sc.nextInt();
            j = sc.nextInt();
            
            if(i==0 && j==0) break;
            
            if(i>j) {
                System.out.printf("%d %d\n", j, i);
            } else {
                System.out.printf("%d %d\n", i, j);
            }
        }

    }
}



Measured memory_bytes: 43040
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		if(A+B+C >= 22){
			System.out.println("bust");
		}else{
			System.out.println("win");
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
double n;
    cin >> n; 
    double x=(n/1.08),y=((n+1)/1.08);
    int i;
    for( i=(int)x-5;i<=(int)y+5;i++) {
        if((int)(i*1.08)==n){
        cout << i;
        return 0;
        }
    }
    cout << ":(";
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong h, hh, k, kk, a, b, c, d;
	cin >> h >> hh >> k >> kk >> a >> b >> c >> d;

	llong s = h*a + h/10*c + hh*b + hh/20*d;
	llong ss = k*a + k/10*c + kk*b + kk/20*d;

	if(s < ss)
		cout << "kenjiro" << endl;
	else if(s > ss)
		cout << "hiroshi" << endl;
	else
		cout << "even" << endl;

	return 0;
}


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

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1e9+7 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }

int arr[15][15];
int c[15];
int ver[15];
int n,m,x;


int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m>>x;
    for(int i =0;i<n;++i){
        cin>>c[i];
        for(int j = 0;j<m;++j){
            cin>>arr[i][j];
            ver[j] += arr[i][j];
        }
    }
    for(int i =0;i<m;++i){
        if(ver[i] < x){
            cout << -1;
            return 0;
        }
    }
    int ans = INT_MAX;
    for(int i =0;i<(1<<n);++i){
        int vv[m] = {0};
        int val = 0;
        for(int j = 0;j<n;++j){
            if(i&(1<<j)){
                for(int k = 0;k<m;++k){
                    vv[k] += arr[j][k];
                }
                val += c[j];
            }
        }
        int f= 0;
        for(int k = 0;k<m;++k){
            if(vv[k] < x){
                f = 1; break;
            }
        }
        if(f == 0){
            ans = min(ans,val);
        }
    }
    cout << ans;
    
    

    
    return 0;
 }

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

ll x,y;
ll a,b,c;
ll solve(vector<ll> p,vector<ll> q,vector<ll> r){
 ll count=0;
 ll pi=0,qi=0,ri=0;
 ll sum=0;
 while(count<x+y)
 {
     ll max=-1;
     ll cur1=0,cur2=0,cur3=0;
     if(pi<a&&pi<x)cur1=p[pi];
     if(qi<b&&qi<y)cur2=q[qi];
     if(ri<c)cur3=r[ri];
     max=std::max(cur1,cur2);
     max=std::max(max,cur3);
     if(max==cur1){
         sum+=cur1;
         pi++;
         count++;
        if(count==x+y)break;
     }
     if(max==cur2)
     {
         sum+=cur2;
         qi++;
         count++;
        if(count==x+y)break;
     }
    if(max==cur3){
         sum+=cur3;
         ri++;
         count++;
         if(count==x+y)break;
     }
    }
      return sum;
}

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

cin>>x>>y>>a>>b>>c;
vector<ll>p(a),q(b),r(c);
rep(i,a)cin>>p[i];
rep(i,b)cin>>q[i];
rep(i,c)cin>>r[i];

sort(p.begin(),p.end(),greater<ll>());
sort(q.begin(),q.end(),greater<ll>());
sort(r.begin(),r.end(),greater<ll>());
cout<<solve(p,q,r)<<endl;
return 0;
}

Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(n int64, m int64, x int64, cs []int64, as [][]int64) int64 {
	ret := int64(-1)
	bMax := int(1 << n);
	for b := 1; b < bMax; b ++ {
		ss := make([]int64, m)
		c := int64(0)
		for i := int64(0); i < n; i++ {
			if ((1 << i) & b) == 0 {
				continue
			}

			c += cs[i]
			for j := int64(0) ; j < m; j++ {
				ss[j] += as[i][j]
			}
		}
		j := int64(0)
		for  ; j < m; j++ {
			if ss[j] < x {
				break
			}
		}
		if j < m {
			continue
		}
		if ret == -1 ||  c < ret {
			ret = c
		}
	}
	return ret
}

func main() {
	defer out.Flush()

	n := nextInt()
	m := nextInt()
	x := nextInt()
	cs := make([]int64, n)
	as := make([][]int64, n)
	for i := int64(0); i < n; i++ {
		cs[i] = nextInt()
		as[i] = make([]int64, m)
		for j, _ := range as[i] {
			as[i][j] = nextInt()
		}
	}

	res := solve(n, m, x, cs, as)
	fmt.Fprintln(out, res)
	//fmt.Fprintln(os.Stderr, n)
	//fmt.Fprintln(os.Stderr,m)
	//fmt.Fprintln(os.Stderr,x)
	//fmt.Fprintln(os.Stderr,cs[n - 1])
	//fmt.Fprintln(os.Stderr,as[n - 1][m - 1])
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
#define pb push_back


int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double r;
    cin >> r;
    cout << 44*r/7;
    return 0;                                                  

  
}

Measured memory_bytes: 3788
n=int(input())
s1=input()
s2=input()
ans=0
i=0
prev=None#左のドミノの状態
if s1[0]==s2[0]:#縦
    ans=3
    i+=1
    prev='tate'
else:#横
    ans=6
    i+=2
    prev='yoko'
    
mod=10**9+7
while i<n:
    if s1[i]==s2[i]:#縦
        ans=(ans*2)%mod if prev=='tate' else ans 
        i+=1
        prev='tate'
    else:#横
        ans=(ans*2)%mod if prev=='tate' else (ans*3)%mod 
        i+=2
        prev='yoko'
print(ans)

Measured memory_bytes: 9108
#include <stdio.h>

#define PI 3.141592653589

int main(void)
{
    double r;
    double square, length;

    scanf("%lf", &r);
    square = PI * r * r;
    length = 2 * PI * r;
    printf("%lf %lf\n", square, length);

    return 0;
}

Measured memory_bytes: 1076
S = input()
N = len(S)
X = []
x = 0
while x<N-1:
    if S[x]=="B" and S[x+1]=="C":
        X.append("D")
        x+=1
    else:
        X.append(S[x])
    x+=1
ans = 0
N = len(X)
a = 0
for i in range(N):
    if X[i]=="A":
        a+=1
    elif X[i]=="D":
        ans+=a
    else:
        a=0
print(ans)

Measured memory_bytes: 5096
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

Measured memory_bytes: 256
use std::io::stdin;


fn is_prime(num: i32) -> bool {
    if num == 2 { return true }
    let n = num as f32;
    let r = n.sqrt().floor() as i32;
    for i in 2..(r+1) {
        if num % i == 0 { return false }
    }
    true
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let lim: i32 = s.trim_right().parse().unwrap();
    for i in lim.. {
        if is_prime(i) {
            println!("{}", i);
            break;
        }
    }
}


#[test]
fn test() {
    assert_eq!(is_prime(2), true);
    assert_eq!(is_prime(3), true);
    assert_eq!(is_prime(12), false);
    assert_eq!(is_prime(29), true);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string N;
  cin>>N;
  int ans=N[0]-'0'-1+9*(N.size()-1);
  int tmp=0;
  for(char t:N){
    tmp+=t-'0';
  }
  cout<<max(ans,tmp)<<endl;
  




  
}





  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int64 long long int
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

int main() {
    int64 N,K;
    cin >> N>>K;
	int64 diff=N%K;
	int64 cmin=diff;
	while(1) {
		diff=std::abs(diff-K);
		bool change=chmin(cmin,diff);
		if (change) {
			cmin=diff;
		}
		else{
			break;
		}

	}
    cout << cmin << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n;
    if (n % 2 == 0) {
        cout << n << endl;
    } else {
        cout << 2 * n << endl;
    }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class CIntervalGame {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,L,R;
        in>>n;
        ll ans=0,k1=0,k2=0;
        priority_queue<int> l,r;
        fr(i,n){
            in>>L>>R;
            l.push(-2*R);
            r.push(2*L);
        }
        fr(i,n){
            int lt=l.top(),rt=r.top();l.pop(),r.pop();
            k1+=lt;
            k2+=rt;
            ans=max({ans,k1,k2});
            k1+=rt;
            ans=max(ans,k1);
            k2=k1;
        }
        out<<ans<<endl;
    }
};

int main() {
    CIntervalGame solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int n, m, x;
    vector<int> a(m);

    cin >> n >> m >> x;
    rep(i,m) cin >> a.at(i);

    int rcnt=0, lcnt=0;
    for(int i=x+1; i<=n; i++){
        for(int j=0; j<m; j++){
            if(a.at(j)==i) rcnt++;
        }
    }

    for(int i=0; i<x; i++){
        for(int j=0; j<m; j++){
            if(a.at(j)==i) lcnt++;
        }
    }


    int ans = 101;
    ans = min(lcnt, rcnt);
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 16640
N = int(input())
info = [list(map(int,input().split())) for i in range(N)]
def modify(l1,l2):
    # k >= b / a
    # a * k >= b
    k1 = l1[0]//l2[0]
    k2 = l1[1]//l2[1]
    k = max(k1,k2)
    for i in range(k,k+2):
        if l2[0] * i >= l1[0] and l2[1] * i >= l1[1]:
            l2[0] *= i
            l2[1] *= i
            break
for i in range(N-1):
    modify(info[i],info[i+1])
ans = sum(info[-1])
print(ans)

Measured memory_bytes: 3188
N, M = map(int, raw_input().split())

ab = [map(int, raw_input().split()) for _ in xrange(N)]
cd = [map(int, raw_input().split()) for _ in xrange(M)]

for i in xrange(N):
    for j in xrange(M):

        d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])

        if j == 0:
            t = d
            ans = 1

        elif t > d:
            t = d
            ans = j+1

    print ans

Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))

typedef struct{int x,y;}P;

int main(void){
	int h,w;
	scanf("%d%d",&h,&w);
	char A[h][w+1];
	for(int i=0;i<h;i++)scanf("%s",A[i]);
	
	P black[1000000];
	int d[h][w];
	int head=0,tail=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(A[i][j]=='#'){
				black[tail].x=i;
				black[tail++].y=j;
				d[i][j]=0;
			}else d[i][j]=-1;
	
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
	int ans=0;
	while(head<tail){
		int nx=black[head].x;
		int ny=black[head++].y;
		for(int i=0;i<4;i++){
			int px=nx+dx[i];
			int py=ny+dy[i];
			if(0<=px && px<h && 0<=py && py<w){
				if(d[px][py]<0){
					d[px][py] = d[nx][ny]+1;
					ans=MAX(ans,d[px][py]);
					black[tail].x=px;
					black[tail++].y=py;
				}
			}
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 12800
S = input()

def f(x):
  l = len(x)//2
  for i in range(l):
    if x[i] != x[l+i]:
      return False
  else:
    return True

for i in range(2,len(S),2):
  if f(S[:-1*i]):
    print(len(S[:-1*i]))
    break


Measured memory_bytes: 38384
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        cout << b / x + 1LL << endl;
    }
    else {
        cout << b / x - (a - 1LL) / x << endl;
    }
    return 0;
}


Measured memory_bytes: 3572
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [False]*(K+1) #if First loses, "false"
for num in range(K):
  if not(dp[num]):
    for stone in a:
      if num + stone <= K:
        dp[num+stone] = True
if dp[K]:
  print("First")
else:
  print("Second")




Measured memory_bytes: 9604
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	for i := 0; i <= 100; i++ {
		if s == t {
			fmt.Println("Yes")
			return
		}
		s = s[len(s)-1:] + s[0:len(s)-1]
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=10000;

int n;
vector< vector< pair<int,int> > > adj(N,vector< pair<int,int> >());
vi d(N,inf);

void dijkstra();

int main(){
	int k,u,v,c,i,j;
	cin>>n;
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v>>c;
			adj[u].push_back(make_pair(c,v));
		}
	}
	dijkstra();
	loop(i,0,n){
		cout<<i<<" "<<((d[i]==inf)? -1:d[i])<<endl;
	}
}

void dijkstra(){
	priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > pq;
	int i;
	vi color(n,WHITE);
	
	d[0]=0;
	pq.push(make_pair(0,0));
	color[0]=GRAY;
	
	while(!pq.empty()){
		pair<int,int> f=pq.top();
		pq.pop();
		int u=f.second;
		color[u]=BLACK;
		if(d[u]<f.first){
			continue;
		}
		loop(i,0,adj[u].size()){
			int v=adj[u][i].second;
			if(color[v]!=BLACK && d[v]>d[u]+adj[u][i].first){
				d[v]=d[u]+adj[u][i].first;
				pq.push(make_pair(d[v],v));
				color[v]=GRAY;
			}
		}
	}
}
	

Measured memory_bytes: 8092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  cout << "Christmas ";
  if( s < 25){
    cout << "Eve ";
  }
  if( s < 24){
    cout << "Eve ";
  }
  if( s < 23){
    cout << "Eve ";
  }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	int m, k; std::cin >> m >> k;
	if (k >= (1 << m) || (k == 1 && m == 1)) {
		std::cout << "-1\n";
	}
	else if (k == 0) {
		for (auto i = 0; i < (1 << m); ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << i << ' ' << i;
		}
		std::cout << std::endl;
	}
	else {
		std::vector<int> result; result.reserve(2 << m);
		std::vector<bool> use(1 << m, false);
		std::queue<int> queue;
		for (auto i = 0; i < (1 << m); ++i) queue.push(i);
		while (!queue.empty()) {
			while (!queue.empty() && use[queue.front()]) {
				queue.pop();
			}
			if (queue.empty()) break;
			const auto first = queue.front();
			use[first] = use[first ^ k] = true;
			while (!queue.empty() && use[queue.front()]) {
				queue.pop();
			}
			const auto second = queue.front();
			use[second] = use[second ^ k] = true;
			result.push_back(first); result.push_back(k ^ first);
			result.push_back(second); result.push_back(k ^ second);
			result.push_back(k ^ first); result.push_back(first);
			result.push_back(k ^ second); result.push_back(second);
		}
		for (auto i = 0; i < result.size(); ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << result[i];
		}
		std::cout << std::endl;
	}
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(10000000+1, 0);
	for (long long int i = 1; i <= 10000000; i++) {
		a[i] = a[i-1]+i;
	}
	vector<long long int>::iterator ite = lower_bound(a.begin(), a.end(), n);
	long long int k = ite-a.begin();
	while (k > 0) {
		cout << k << endl;
		n -= k;
		k--;
		k = min(n, k);
	}
	return 0;
}

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

int main()
{
    ll N;
    cin>>N;
    ll h[N];
    for(ll i=0;i<N;i++)
    {
        cin>>h[i];
    }
    ll dp[N];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(ll i=2;i<N;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[N-1];
}

Measured memory_bytes: 5048
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

bingo = [[0,0,0],[0,0,0],[0,0,0]]
# print(bingo)

for i in range(N):
    b = B[i]
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                bingo[i][j] = 1

ans = False
for i in range(3):
    if bingo[i] == [1,1,1]:
        ans = True
        break
    elif bingo[0][i] == 1 and bingo[1][i] == 1 and bingo[2][i] == 1:
        ans = True
        break
    elif bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
        ans = True
        break
    elif bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
        ans = True
        break
print('Yes' if ans else 'No')

Measured memory_bytes: 38256
from heapq import heappush, heappop
N, M = map(int, input().split())
P = [[] for i in range(M+1)]
for i in range(N):
    a, b = map(int, input().split())
    if a <= M:
        P[a].append(b)
que = []
ans = 0
for i in range(M+1):
    for a in P[i]:
        heappush(que, -a)
    if que:
        ans += -heappop(que)
print(ans)

Measured memory_bytes: 18376
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int table[12][1024];

void dfs (int bit, int depth, int sum )
{
	table[depth][sum]++;

	rep (i, 10 ){
		if (bit & (1<<i ) ){
			dfs (bit & ~(1<<i), depth + 1, sum + i*(depth+1) );
		} // end if
	} // end rep
	
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.aoj0070", "r", stdin );
	int n, s;
	memset (table, 0, sizeof (table ) );

	dfs ((1<<10)-1, 0, 0 );

	while (scanf ("%d %d", &n, &s ) != EOF ){
		int res = (s > 330 ? 0 : table[n][s] );
		cout << res << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 1264