akhauriyash/Code-Regression huggingface dataset:
/*input
1

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int a,b,c,n;
    cin>>a;
    if(a==0) cout<<1;
    else cout<<0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238
typedef long long ll;
int main() {
  double a, b, h, m;
  cin>>a>>b>>h>>m;
  double x=6*m;//分針
  double y=30*h+m/2;
  x=x*PI/180.00000;
  y=y*PI/180.00000;
  double c=cos(x-y);
  cout << fixed << setprecision(12);
  cout << sqrt(a*a+b*b-2*a*b*c);
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

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

int h, w, n;
string board[33];
bool van[33][33];
string sub[33];

void fall() {
	for (int i = h - 2; i >= 0; --i) {
		for_(j,0,w) {
			if (board[i][j] != '.') {
				int k = i + 1;
				while (k < h && board[k][j] == '.') {
					swap(board[k][j], board[k - 1][j]);
					k++;
				}
			}
		}
	}
	//for_(i,0,h) cout << board[i] << endl;
}

bool vanish() {
	minit(van, 0);
	
	for_(i,0,h) {
		int pre = board[i][0];
		int pj = 0;
		int cnt = 1;
		
		for_(j,1,w) {
			if (board[i][j] != '.' && pre == board[i][j]) cnt++;
			else {
				if (cnt >= n) for_(k,pj,pj + cnt) van[i][k] = true;
				pre = board[i][j];
				cnt = 1;
				pj = j;
			}
			if (j == w - 1) {
				if (cnt >= n) for_(k,pj,pj + cnt) van[i][k] = true;				
			}
		}
	}
	
	for_(j,0,w) {
		int pre = board[0][j];
		int pi = 0;
		int cnt = 1;
		
		for_(i,1,h) {
			if (board[i][j] != '.' && pre == board[i][j]) cnt++;
			else {
				if (cnt >= n) for_(k,pi,pi + cnt) van[k][j] = true;
				pre = board[i][j];
				cnt = 1;
				pi = i;
			}
			if (i == h - 1) {
				if (cnt >= n) for_(k,pi,pi + cnt) van[k][j] = true;
			}
		}
	}
	
	bool isvan = false;
	for_(i,0,h) for_(j,0,w) {
		isvan |= van[i][j];
		if (van[i][j]) board[i][j] = '.';
	}
	
	return isvan;
}

bool simulate() {
	fall();
	while (vanish()) {
		fall();
	}
	//cout << endl;
	
	//for_(i,0,h) cout << board[i] << endl;
	bool isok = true;
	for_(i,0,h) for_(j,0,w) if (board[i][j] != '.') isok = false;
	return isok;
}

void restart() {
	for_(i,0,h) board[i] = sub[i];
}

void solve() {
	for_(i,0,h) sub[i] = board[i];
	
	for_(i,0,h) for_(j,0,w) {
		/*
		if (i < h - 1) {
			swap(board[i][j], board[i + 1][j]);
			if (simulate()) {
				cout << "YES" << endl;
				return;
			}		
			restart();
		}
		*/
		
		if (j < w - 1) {
			swap(board[i][j], board[i][j + 1]);
			if (simulate()) {
				cout << "YES" << endl;
				return;
			}	
			restart();
		}
	}	
	
	cout << "NO" << endl;
}

int main() {
	cin >> h >> w >> n;
	for_(i,0,h) cin >> board[i];
	solve();
	return 0;
}

Measured memory_bytes: 1212
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n, k = mi()
    p = list(map(lambda x: int(x)-1, input().split()))
    c = li()
    ans = -10**18
    for i in range(n):
        v = i
        cycle_cnt = 0
        cycle_sum = 0
        while True:
            cycle_cnt += 1
            cycle_sum += c[v]
            v = p[v]
            if v == i:
                break
        
        cnt = 0
        tmp = 0
        while True:
            tmp += c[v]
            cnt += 1
            if cnt > k:
                break
            r = (k-cnt)//cycle_cnt
            score = tmp+r*max(0, cycle_sum)
            ans = max(ans, score)
            v = p[v]
            if v == i:
                break
    print(ans)



if __name__ == '__main__':
    main()

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

ll X=1000000007;

ll gyakugenn(ll a){
  ll b=X,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b;swap(a,b);
    u-=t*v;swap(u,v);
  }
  u%=X;
  if(u<0)u+=X;
  return u;
}

int main() {
  ll N;
  cin>>N;
  
  ll NNN=1;//N-1!
  for(ll i=2;i<N;i++){
    NNN*=i;
    NNN%=X;
  }
  
  vector<ll> x(N);
  for(ll i=0;i<N;i++){
    cin>>x.at(i);
  }
  vector<ll> d(N-1);
  for(ll i=0;i<N-1;i++){
    d.at(i)=x.at(i+1)-x.at(i);
  }//隣り合うスライムの距離
  
  
  for(ll i=N-3;i>=0;i--){
    d.at(i)+=d.at(i+1);
  }//i番目の項に1/(i+1)をかけたものの和が期待値
  
  /*
  vector<ll> weight(N-1,1);
  for(ll i=0;i<N-1;i++){
    for(ll j=1;j<N;j++){
      if(j!=i+1){
        weight.at(i)*=j;
        weight.at(i)%=X;
      }
    }
  }//時間かかる
  */
  
  vector<ll> weight(N-1,NNN);
  for(ll i=0;i<N-1;i++){
    weight.at(i)*=gyakugenn(i+1);
    weight.at(i)%=X;
  }
  
  ll ans=0;
  for(ll i=0;i<N-1;i++){
    ans+=(d.at(i)*weight.at(i))%X;
    ans%=X;
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
int res = 0;
string s;
void dfs(int i, int sum, int psum, string &s) {
  int n = s.size();
  int si = s.at(i) - '0';
  if (i == n - 1) {
    res += sum + si + 10 * psum;
    return;
  }
  dfs(i + 1, sum + si + 10 * psum, 0, s);
  dfs(i + 1, sum, 10 * psum + si, s);
}
signed main() {
  cin >> s;
  dfs(0, 0, 0, s);
  cout << res << endl;
}
 

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main() {
    int n;
    cin >> n;
    vector<ll>t(n);
    rep(i,n) cin >> t[i];
    ll ans = t[0];
    rep(i,n-1) {
        ans = lcm(ans,t[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000], max1 = 0, max2 = -1;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        if (A[i] > max1) {
            max2 = max1;
            max1 = A[i];
        } else if (A[i] > max2) {
            max2 = A[i];
        }
    }
    REP(i, N) {
        if (A[i] == max1) cout << max2 << endl;
        else cout << max1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;
import java.util.function.IntPredicate;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        System.out.println( solve(X) );
    }

    private static int solve(int X) {
        return upperBound(0, Integer.MAX_VALUE, i -> {
            long n;
            if( i % 2 == 0 ) {
                n = (long)(i + 1) * (i / 2);
            } else {
                n = ((long)(i + 1) * (i / 2)) + ((long)(i + 1) / 2);
            }
            if( n > Integer.MAX_VALUE ) return false;

            return X > n;
        });
    }

    private static int upperBound(int low, int high, IntPredicate more) {
        while(low < high) {
            int mid = low + (high - low) / 2;
            if( more.test(mid) ) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }
}

Measured memory_bytes: 29012
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
  
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1,  x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1    
    print(result)

Measured memory_bytes: 7576
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
double dist(int x1,int y1, int x2, int y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main() {
    int N; cin>>N;
    vi x(N),y(N);
    for (int i = 0; i < N; i++){
        cin>>x[i]>>y[i];
    }
    vi perm(N);
    for (int i = 0; i < N; i++){
        perm[i]=i;
    }
    double sum=0;
    do{
        for (int i = 0; i < N-1; i++){
            sum+=dist(x[perm[i]],y[perm[i]],x[perm[i+1]],y[perm[i+1]]);
        }
    }while(next_permutation(perm.begin(),perm.end()));
    int fact=1;
    for (int i = 1; i <= N; i++){
        fact*=i;
    }
    printf("%.7f\n",sum/(double)fact);
}

Measured memory_bytes: 3840
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    cout<<n*n*n<<endl;
}


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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		set<int> ans;
		int a,b,n;
		cin >> a >> b >> n;
		if(n > b-a+1) n = b-a+1;
		for(int i=0;i<n;i++){
				ans.insert(a);
				ans.insert(b);
				a++;
				b--;
		}
		for(auto& A : ans){
				cout << A << endl;
		}
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll N, M, V, P;
vector<ll> A;

bool judge(ll idx){
	ll t = A[idx];
	ll X = A.end() - upper_bound(A.begin(), A.end(), t+M);

	if(idx>=N-P){
		return true;
	}else if(X>=P){
		return false;
	}else{
		ll sum = 0;
		REP(i, N-(P-1)){
			if(i==idx) continue;
			if(A[i]<=t+M){
				sum += min(t+M-A[i], M);
			}
		}
		if(sum>=M*(V-P)) return true;
		else return false;
	}
}

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

    cin >> N >> M >> V >> P;
    A.resize(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    //cerr << A << endl;

    ll lb = -1;
    ll ub = N;
    while(ub-lb>1){
    	ll md = (ub+lb)/2;
    	if(judge(md)) ub = md;
    	else lb =md;
    }
    cout << N - ub << endl;
    return 0;
}

Measured memory_bytes: 1024
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long x){
    cout << (x >= 30 ? YES : NO) << endl;
}


signed main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

#define M 100
#define INT(X) \
  ( *( (const int *)(X) ) )

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

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    struct
    {
      int fv;
      int no;
    } h[ M ];
    int n, m;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < M; ++i )
    {
      h[ i ].fv = 0;
      h[ i ].no = i + 1;
    }

    while ( n-- )
    {
      for ( i = 0; i < m; ++i )
      {
        int d;

        scanf ( "%d", &d );
        h[ i ].fv += d;
      }
    }

    qsort ( h, m, sizeof ( h[ 0 ] ), comparator );

    for ( i = 0; i < m; ++i )
    {
      if ( i )  putchar ( ' ' );
      printf ( "%d", h[ i ].no );
    }
    puts ( "" );
  }

  return ( 0 );
}

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

A = []
score_list = []

#数列A
for i in range(N):
  A.append(0)

#行列として入力
L = []
l = []
for i in range(Q):
  l = list(map(int, input().split()))
  L.append(l)


#数列を深さ優先探索
def search(x, y):
  if x < 0  or x > N - 1 or y < 0 or y > M - 1:
    return
  A[x] = y + 1
  if x == N - 1:
    sum = 0
    for i in range(Q):
      if A[L[i][1] - 1] - A[L[i][0] - 1] == L[i][2]:
        sum += L[i][3]
    score_list.append(sum)
    
  search(x + 1, y)
  search(x, y + 1)

search(0, 0)
print(max(score_list))

Measured memory_bytes: 12656
#include <stdio.h>

#define WIDTH 8
#define HEIGHT 8

char field[ WIDTH + 2 ][ HEIGHT + 2 ] = {};

int main( void ) {
	char type;
	int x, y;

	for ( ; ungetc( getchar(), stdin ) != EOF; printf( "%c\n", type ) ) {
		for ( y = 1; y <= HEIGHT; y++ )
			for ( x = 1; x <= WIDTH; x++ )
				scanf( "%c ", field[ x ] + y );

		for ( y = 1; y <= HEIGHT; y++ )
			for ( x = 1; x <= WIDTH; x++ )
				if ( field[ x ][ y ] == '1' )
					if ( field[ x + 1 ][ y ] == '1' )
						if ( field[ x + 2 ][ y ] == '1' ) {
							type = 'C';
							goto contin;
						} else if ( field[ x + 1 ][ y + 1 ] == '1' )
							if ( field[ x + 2 ][ y + 1 ] == '1' ) {
								type = 'E';
								goto contin;
							} else {
								type = 'A';
								goto contin;
							}
						else {
							type = 'G';
							goto contin;
						}
					else if ( field[ x + 1 ][ y + 1 ] == '1' ) {
						type = 'F';
						goto contin;
					} else if ( field[ x ][ y + 2 ] == '1' ) {
						type = 'B';
						goto contin;
					} else {
						type = 'D';
						goto contin;
					}

		contin :;
	}

	return 0;
}

Measured memory_bytes: 548
import sys
input = sys.stdin.readline
def main():
    N, M, K=map(int, input().split())
    friend_or_block = [0] * N
    parent = [-1] * N

    def root(x):
        p, s = parent[x], list()
        while p >= 0:
            s.append(x)
            x, p = p, parent[p]
        for c in s: parent[c] = x
        return x

    def same(x, y): return root(x) == root(y)

    def count(x): return -parent[root(x)]

    def unite(x, y):
        xr, yr = root(x), root(y)
        if xr == yr: return
        if parent[xr] > parent[yr]: xr, yr = yr, xr
        parent[xr] += parent[yr]
        parent[yr] = xr

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        unite(a, b)
        friend_or_block[a] += 1
        friend_or_block[b] += 1

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if same(c, d):
            friend_or_block[c] += 1
            friend_or_block[d] += 1

    print(*[count(i) - friend_or_block[i] - 1 for i in range(N)])

if __name__ == '__main__':
    main()



Measured memory_bytes: 61912
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int D,N;
  cin>>D>>N;
  if(N!=100){
  if(D==0)
    cout<<N<<endl;
  else if(D==1)
    cout<<N*100<<endl;
  else
    cout<<N*10000<<endl;
  }
  else{
     if(D==0)
    cout<<101<<endl;
  else if(D==1)
    cout<<10100<<endl;
  else
    cout<<1010000<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair<int,int>                   PII;
#define ordered_set Tree<PII, null_type,less<PII>, rb_Tree_tag,Tree_order_statistics_node_update>
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main()
{
    IOS
    //READ("0test.txt");
    // WRITE("0out.txt");
    int x, y ;
    cin >> x >> y ;
    int cnt = 0 ;
    for(int i = 0 ; i <= x ; i++)
    {
        for(int j = 0 ; j <= x ; j++)
        {
            int temp = y - (i + j) ;
            if(temp >= 0 && temp <= x)
                cnt++;
        }
    }
    cout<<cnt<<endl;


}


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

void call(int n){
	for(int i = 1;i<=n;i++) {
		if ( i % 3 == 0 || i % 10 == 3 ){
			cout << " " << i;
		}else {
			int x = i;
			while(x>=10) {
				x /= 10;
				if(x%10==3) {
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0; 
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
typedef long long lint;

int main() {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main() {
int k,s,c=0;
cin>>k>>s;
for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
        if(s-i-j>=0&&s-i-j<=k){
            c++;
        }
    }
}
cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

template<class T>
bool binary_search(T* xs, int st, int ed, T v){
    //cout << "v = " << v << " ," << st << ' ' << ed << '\n';
    if(ed-st <= 1){
        return xs[st] == v;
    }
    int mid = (st+ed)/2;
    if(xs[mid] > v){
        return binary_search(xs, st, mid, v);
    } else if(xs[mid] < v){
        return binary_search(xs, mid, ed, v);
    } else {
        return true;
    }
}

int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        cin >> xs[i];
    }
    int q;
    cin >> q;
    int v = 0;
    int cnt = 0;
    for(int i = 0; i < q; ++i){
        cin >> v;
        if(binary_search(xs, 0, n, v)){
            ++cnt;
        }
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 1544
while True:
	t = input().split()
	a = int(t[0])
	b = t[1]
	c = int(t[2])
	d = 0
	if (b == "?"):
		break
	if (b == "+"):
		d = a + c
	if (b == "-"):
		d = a - c
	if (b == "*"):
		d = a * c
	if (b == "/"):
		d = int(a / c)
	print(str(d))
	

Measured memory_bytes: 7640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int ans = 0;
    while(n > 0){
        n /= 2;
        ++ ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
typedef std::vector<pl> vpl;
const long double EPS = 1e-9;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
#define rsort(a,n) sort(a,a+n,greater<>())

const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 200;

int main(void){
    str s,t;
    ll n;
    ll a[MAX_N];

    in1(n);
    rin1(i,n,a);

    ll cnt = 0;
    bool finish = false;
    while(!finish){
        rep(i,n) if (a[i]%2==0) a[i]/=2; else finish = true;
        if (!finish) cnt ++;
    }
    prl(cnt);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double Pi=acos(-1.0); 
const int N=3005;
double ans1,ans2;
int a[N],n,L;
int main(){
	scanf("%d%d",&n,&L);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			double x1=cos(2*Pi*(a[i]+a[j])/L/2),y1=sin(2*Pi*(a[i]+a[j])/L/2);
			ans1+=(double)x1*(n-1-(j-i));
			ans2+=(double)y1*(n-1-(j-i));
			x1=cos(Pi+2*Pi*(a[i]+a[j])/L/2),y1=sin(Pi+2*Pi*(a[i]+a[j])/L/2);
			ans1+=(double)x1*(j-i-1);
			ans2+=(double)y1*(j-i-1);
		}
	printf("%.10lf %.10lf\n",ans1/((double)n*(n-1)*(n-2)/6),ans2/((double)n*(n-1)*(n-2)/6));	
}

Measured memory_bytes: 512
N,K,*hs=$<.read.split.map(&:to_i)
hs.sort!

i = 0
j = K-1
min = 10**9
while j < N
  n = hs[j] - hs[i]
  min = n if n < min
  i += 1
  j += 1
end

puts min


Measured memory_bytes: 12024
#include<cstdio>
using namespace std;
long long a[210000];
long long abs(long long x)
{
	return x<0?-x:x;
}
long long min(long long x,long long y)
{
	return x<y?x:y;
}
int main()
{
	int n;
	long long sum=0,ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	ans=abs(a[1]*2-sum);
	long long s=a[1];
	for(int i=2;i<n;i++)
	{
		s+=a[i];
		ans=min(ans,abs(s*2-sum));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }

    int ans = INT_MAX;
    /*
    if (n-k > 0){
        ans = INT_MAX;
    } else {
        ans = x[x.size()-1] - x[0];
    }
    */
    for (int i = 0; i < n-k+1; i++){
        int minN = x[i];
        int maxN = x[i+k-1];
        if (maxN < 0){
            maxN = 0;
        } else if (minN > 0){
            minN = 0;
        } else {
            if (abs(maxN) > abs(minN)){
                minN *= 2;
            } else {
                maxN *= 2;
            }
        }
        int tmp = maxN - minN;
        ans = min(ans,tmp);
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}

//=======================================================================================================

int main()
{
    ll n;
    cin >> n;
    string str;
    ll cnt = 0;
    for(ll i=1; i<=n; i++) {
        str = to_string(i);
        if(str.size()&1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int INF = 1e9 + 5;

int main(){
    int n,x,k;
    cin>>n>>k;
    vector<int> h;
    for(int i=0;i<n;i++){
        cin>>x;
        h.push_back(x);
    }
    
    vector<int> dp(n,INF);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++){
        for(int j=i-1;j>=0 && j>=i-k;j--){
            int cur = dp[j] + abs(h[i]-h[j]);
            if(cur<dp[i])
                dp[i] = cur;
        }
        
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

int main() {
    ll N; cin >> N;
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    string S; cin >> S;
    S = '#' + S + '#';

    bool ans = false;
    for(int i=1; i<S.size(); i++){
        if(A < i && (i < D || i < C)){
            if(S.at(i) == '#'&& S.at(i+1) == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    if(C < D){
        cout << "Yes" << endl;
        return 0;
    }

    bool change = false;
    ll tmp = 0;
    for(ll i=B; i<=D; i++){
        if(S.at(i-1) == '.' && S.at(i) == '.' && S.at(i+1) == '.') tmp = i+1, change = true;
    }

/*
    if(C < tmp || A > tmp){
        for(int i=0; i<S.size(); i++){
            if(S.at(i) == '#' && S.at(i+1) == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
*/

    if(change){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 772
#include <bits/stdc++.h> 
 
using namespace std; 
 
 
int main() 
{ 
    int N,R;

    cin >> N >> R;


    if(N>=10){
        cout << R << endl;
    }else{
        cout << R+100*(10-N) << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int m,d;
int main(){
	cin>>m>>d;
	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j%10;
			int d10=j/10;
			if(d1<2||d10<2)continue;
			if(d1*d10==i)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,k;
    cin>>k>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll mx=k-a[n-1]+a[0];
    for(int i=1;i<n;i++)
    {
        ll temp=a[i]-a[i-1];
        mx=max(mx,temp);
    }
    cout<<k-mx<<endl;

    
}
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    VEC(string) G(3);
    READVEC(G);
    cout << G[0][0] << G[1][1] << G[2][2] << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   string a,b,c;cin>>a>>b>>c;
   if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])cout<<"YES";
   else cout<<"NO";
}



Measured memory_bytes: 256
//============================================================================
// Name        : ITP_1_2_B.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if ( a < b && b < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	char S[n+1];
	scanf("%s",S);
	if(S[k-1] =='A')S[k-1]='a';
	if(S[k-1] =='B')S[k-1]='b';
	if(S[k-1] =='C')S[k-1]='c';
	 printf("%s",S);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}


signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl x[m],y[m];
    rep(i,m){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    bool f[n];
    m0(f);
    f[0] = true;
    intl z[n];
    rep(i,n)z[i] = 1;
    rep(i,m){
        f[y[i]] |= f[x[i]];
        z[x[i]]--;
        z[y[i]]++;
        if(!z[x[i]])f[x[i]] = false;
    }
    intl cnt = 0;
    rep(i,n)cnt += f[i];
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5900
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

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


int distance(vi&l, int a, int b, int c)
{
	int n=l.size();
	int ans=10000;

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				int x=abs(a-l[i])+abs(b-l[j])+abs(c-l[k]);
				if(ans>x) ans=x;
			}
		}
	}
	return ans;
}


int solve(vi&l, int a, int b, int c)
{
	int n=l.size();

	sort(l.rbegin(), l.rend());
	int ret=distance(l, a, b, c);

	if(n>3)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				vi t=l;
				t[i]+=t[j];
				t[j]=t.back();
				t.pop_back();
				int x=solve(t, a, b, c)+10;
				if(ret>x) ret=x;
			}
		}
	}

	return ret;
}


int main(void)
{
	int n, a, b, c;

	while(scanf("%d%d%d%d", &n, &a, &b, &c)==4)
	{
		vi l(n);
		for(int i=0;i<n;i++)
		{
			scanf("%d", &l[i]);
		}

		printf("%d\n", solve(l, a, b, c));
	}
	return 0;
}


Measured memory_bytes: 256
def resolve():
    s=int(input())
    l=[s]
    for i in range(10**6):
        if l[i]%2==0:
            l.append(l[i]//2)
            if (len(set(l)))!=len(l):
                print(i+2)
                break
        else:
            l.append(3*l[i]+1)
            if (len(set(l)))!=len(l):
                print(i+2)
                break
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <set>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
const double EPS = 1e-12;

int main(){
  int W, H;
  int dx[] = {0, -1, 0, 1};
  int dy[] = {1, 0, -1, 0};
  
  while(cin >> W >> H && W + H){
    int count = 0;
    vector<string> sb(H);
    vector<int> b_size;
    vector<int> total_y;
    
    REP(i, H) cin >> sb[i];
    vector<vector<int> > ib(H, vector<int>(W, -1));
    
    REP(i, H)REP(j, W)if(isdigit(sb[i][j])){
      queue<int> quex, quey;
      quex.push(i);
      quey.push(j);
      char	c    = sb[i][j];
      int	sz   = 1;
      int	toty = j;

      sb[i][j] = '.';
      ib[i][j] = count;
      while(!quex.empty()){
	int x = quex.front(); quex.pop();
	int y = quey.front(); quey.pop();
	
	REP(k, 4){
	  int nx = x + dx[k];
	  int ny = y + dy[k];
	  if(0 <= nx && nx < H &&
	     0 <= ny && ny < W &&
	     sb[nx][ny] == c){
	    sb[nx][ny] = '.';
	    ib[nx][ny] = count;
	    sz++;
	    toty += ny;
	    quex.push(nx);
	    quey.push(ny);
	  }
	}
      }

      b_size.push_back(sz);
      total_y.push_back(toty);
      count++;
    }
    
    bool stable = true;
    REP(i, b_size.size()){
      double yl = 100;
      double yr = -100;
      
      int &tot = total_y[i];
      int &cnt = b_size[i];

      set<int> used;
      
      REP(x, H)REP(y, W)if(ib[x][y] == i){
	if(x == H - 1 || (ib[x+1][y]!=-1 && ib[x+1][y]!=i)){
	  yl = min(yl, (double)y);
	  yr = max(yr, (double)y);
	}
	
	if(x > 0){
	  int id = ib[x-1][y];
	  if(id >= 0 && used.count(id) == 0 && id != i){
	    tot += total_y[id];
	    cnt += b_size[id];
	    used.insert(id);
	  }
	}
      }
      double g = (double)tot / cnt + 0.5;
      if(g < yl + EPS ||  g > yr + 1 - EPS) stable = false;
    }
    cout << (stable ? "STABLE" : "UNSTABLE") << endl;
  }  
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,k,h,w,sum,mi,ma;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main(void){
    cin>>a>>b>>c>>d;
    cout << fixed << setprecision(15) << ((double)a)*((double)b)/2.0;
    ps(" ");
    p((a==c*2 && b==d*2)?1:0);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
 m=i
 for j in range(i,n):
  if a[m]>a[j]:m=j
 if i!=m:a[m],a[i]=a[i],a[m];c+=1
print(*a)
print(c)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int t=1;

    while(t--)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);

        string s;
        cin>>s;
        string t;
        cin>>t;

        int n = s.size();
        int m = t.size();

        if(m<=n)
            cout<<"No\n";
        else
        {
            if((m-n)>2)
                cout<<"No\n";
            else if(m==(n+1))
            {
                int flag=0;
                for(int i=0;i<n;++i)
                {
                    if(s[i]!=t[i])
                    {
                        flag=1;
                        break;
                    }

                }
                if(flag)
                    cout<<"No\n";

                else
                    cout<<"Yes\n";
            }
        }
    }
}


Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
long long int a,b,c,d,e;
  scanf("%lld %lld %lld",&a,&b,&c);
  e=a/(b+c);
  if(a%(b+c) >b) d=e*b+b;
  else d=e*b+a%(b+c);
  
  printf("%lld",d);
return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

top = 0
S = [0] * 1000


def push(x):
    global top
    top += 1
    S[top] = x


def pop():
    global top
    top -= 1
    return S[top + 1]


expr = input().split()
for s in expr:
    if s == '+':
        a = pop()
        b = pop()
        push(b + a)
    elif s == '-':
        a = pop()
        b = pop()
        push(b - a)
    elif s == '*':
        a = pop()
        b = pop()
        push(b * a)
    elif s == '/':
        a = pop()
        b = pop()
        push(b / a)
    else:
        push(int(s))

print(pop())




Measured memory_bytes: 5604
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			std::cout << *p << ' ';
		}
		std::cout << std::endl;
	}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;


int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	rep1(i,n){
		ll y = n/i;
		ans+=y*(y+1)*i/2;
	}
	prints(ans);

	return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n;
    cin >> n;
    long ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type point struct {
	x int
	y int
}

type points []point

func (p points) Len() int {
	return len(p)
}
func (p points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var N int
	fmt.Scan(&N)

	r := make([]point, N)
	for i := 0; i < N; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		r[i] = point{x: x, y: y}
	}

	b := make([]point, N)
	for i := 0; i < N; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		b[i] = point{x: x, y: y}
	}

	// sort.Slice(b, func(i, j int) bool {
	// 	return b[i].x < b[j].x
	// })
	sort.Sort(points(b))

	ans := 0
	for i := 0; i < N; i++ {
		bp := b[i]
		tr := point{x: -1, y: -1}
		ji := -1
		for j := 0; j < len(r); j++ {
			rp := r[j]
			if rp.x < bp.x && rp.y < bp.y {
				if tr.y <= rp.y {
					tr = rp
					ji = j
				}
			}
		}
		if ji != -1 {
			r = append(r[:ji], r[ji+1:]...)
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512