akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

string str;
int w, h, ans;
VVI ar;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

void solve( int y, int x ) {
	ar[ y ][ x ] = 0;
	for ( int i = 0; i < 8; i++ ) {
		if ( ar[ y + dy[ i ] ][ x + dx[ i ] ] ) {
			solve( y + dy[ i ], x + dx[ i ] );
		}
	}
}

int main() {
	while ( ~scanf("%d %d", &w, &h) && w && h ) {
		ar.resize( h + 2 );
		for ( int i = 0; i < h + 2; i++ ) {
			ar[ i ].resize( w + 2 );
		}
		ans = 0;
		for ( int i = 0; i < w + 2; i++ ) {
			ar[ 0 ][ i ] = 0;
			ar[ h + 1 ][ i ] = 0;
		}
		for ( int i = 1; i < h + 1; i++ ) {
			for ( int j = 1; j < w + 1; j++ ) {
				scanf( "%d", &ar[ i ][ j ] );
			}
		}
		for ( int i = 0; i < h + 2; i++ ) {
			for ( int j = 0; j < w + 2; j++ ) {
				if ( ar[ i ][ j ] ) {
					ans++;
					solve( i, j );
				}
			}
		}
		printf( "%d\n", ans );
		ar.clear();
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;


int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll n,m,k,ans = 0; cin >> n >> m >> k;
        vector<ll> a(n), b(m),ruia(n+1,0),ruib(m+1,0);
        rep(i,n){
                cin >> a[i];
                ruia[i+1] = ruia[i] + a[i];
        }
        rep(i,m){
                cin >> b[i];
                ruib[i+1] = ruib[i] + b[i];
        }
        
        rep(i,n+1){
                auto key = k - ruia[i];
                int l = 0, r = m, mid = (l+r)/2;
                while(l<r-1){
                        mid = (l+r)/2;
                        if(ruib[mid] > key){
                                r = mid;
                        }else{
                                l = mid;
                        }
                }
                if(ruib[r] <= key) chmax(ans,r+i);
                if(ruib[l] <= key) chmax(ans,l+i);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  int64_t L,s=1;
  if(n%2==0 || n%5==0){
    cout << -1 << endl;
  }else if(n%7==0){
    L=9*n/7;
    s=10%L;
    for(int64_t i=1;;i++){
      if(s%L==1){
        cout << i << endl;
        break;
      }
      s=(s%L)*10;
    }
  }else{
    L=9*n;
    s=10%L;
    for(int64_t i=1;;i++){
      if(s%L==1){
        cout << i << endl;
        break;
      }
      s=(s%L)*10;
    }
  }
}
      

Measured memory_bytes: 3616
from collections import deque
n,u,v = map(int,input().split())
Edge = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    Edge[a-1].append(b-1)
    Edge[b-1].append(a-1)

def bfs(s):
    dist = [-1]*n
    que = deque([s-1])
    dist[s-1] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in Edge[v]:
            if dist[w] > -1:
                continue

            dist[w] = d+1
            que.append(w)
    return dist

U,V = bfs(u),bfs(v)

ans = 0

for i in range(n):
    if U[i] < V[i]:
        ans = max(ans,V[i]-1)

print(ans)

Measured memory_bytes: 29336
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	Map<Character, Integer> map = new HashMap<Character, Integer>();
	map.put( 'I', 1 );
	map.put( 'V', 5 );
	map.put( 'X', 10 );
	map.put( 'L', 50 );
	map.put( 'C', 100 );
	map.put( 'D', 500 );
	map.put( 'M', 1000 );

	while ( stdin.hasNextLine() ){
	    char[] line = stdin.nextLine().toCharArray();
	    int[] vals = new int[line.length];
	    for ( int i = 0; i < line.length; i++ ) {
		vals[i] = map.get( line[i] );
	    }
	    int sum = 0;
	    for ( int i = 0; i < line.length - 1; i++ ) {
		if ( vals[i] < vals[i + 1] ) {
		    sum -= vals[i];
		} else {
		    sum += vals[i];
		}
	    }
	    sum += vals[vals.length - 1];
	    System.out.println( sum );
	}
	
    }
    
}

Measured memory_bytes: 17200
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  deque<char> dq;
  string s;
  int q;
  cin>>s;
  cin>>q;
  rep(i,s.size()) {
    dq.push_back(s[i]);
  }
  bool b = true;
  rep(i,q) {
    int t;
    cin>>t;
    if(t==1) {
      b = not b;
    } else {
      int f;
      char c;
      cin>>f>>c;
      if(f==1) {
	if(b)
	  dq.push_front(c);
	else
	  dq.push_back(c);
      } else {
	if(b)
	  dq.push_back(c);
	else
	  dq.push_front(c);
      }
    }
  }
  stringstream ss;
  for(auto& c : dq) {
    ss<<c;
  }
  string ans = ss.str();
  if(not b) {
    reverse(ans.begin(),ans.end());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    
    for (int x = 0; x <= 50000; x++){
        if (int((double)(x) * 1.08) == N){
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

const int INF = 1e9;
const int MOD = 998244353;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

ll powmod(ll n, ll x)
{
    vector<ll> vll(32);
    vll[0] = n;
    FOR(i, 1, 32)
    {
        vll[i] = (vll[i - 1] * vll[i - 1]) % MOD;
    }
    ll ret = 1;
    int cnt = 0;
    while (x > 0) {
        if (x & 1) {
            ret = (ret * vll[cnt]) % MOD;
        }
        x >>= 1;
        cnt++;
    }
    return ret;
}

int main()
{
    int n, s;
    cin >> n >> s;
    vector<int> vi(n);
    REP(i, n)
    cin >> vi[i];
    vector<vector<int>> dp(n+1, vector<int>(s + 1, 0));
    dp[0][0] = 1;
    FOR(i, 1, n+1)
    {
        REP(j, s+1)
        {
            dp[i][j] = (dp[i][j] + ((dp[i - 1][j] * 2) % MOD)) % MOD;

            if (j + vi[i-1] <= s)
                dp[i][j + vi[i-1]] = (dp[i][j + vi[i-1]] + dp[i - 1][j]) % MOD;
        }
    }

    cout << dp[n][s] << endl;
}

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

using ll = long long; 
/*
auto compare = [](const pair<int, int> & a, const pair<int, int> & b) -> bool { 
            return a.first < b.first;
        };
*/
/*
    given array with size N and K stones, each round the person can remove array[i] stones.
    if the next person cannot move, he wins
    
    2 4
    2 3
    
    First 
    
    There can be at most k rounds
    There can be at most k stones
    
    dp[i][j] means at round i to have j stones
    
    dp[i+1][j-arr[i]] = True for i in len(arr).
    
    return current player if j-arr[i] < min
    
    n*k^2 is too slow
    
    
    
    dp[i][k] means we consider up to a[0..i] to have exactly k stones.
    
    dp[k] means we have exactly k stones
    
    dp[k] = max(dp[k-arr[i]] for i in len(arr)) while in player turn
    dp[k] = max(dp[k-arr[i]] for i in len(arr)) while in enemy turn
    
    
    
    dp[i] = {-1, 1} meaning reaching exactly i stones will lead to lose(-1) or win(1) for current player
    
    dp[0] = 1
    dp[k] = 1 for k <= min(arr)
    dp[k] = max(dp[k-arr[i]] for i in len(arr)) while in player turn
    dp[k] = min(dp[k-arr[i]] for i in len(arr)) while in enemy turn
    
    dp[i] = TRUE if player has i stones and wins
    
    
*/
int main() {
    int n;
    int k;
    
    scanf("%d%d", &n, &k);
    
    vector<int> arr(n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    
    vector<bool> dp(k+1);
    
    for (int stones = 0; stones <= k; stones++) {
        for (int x : arr) {
            if (stones-x >= 0 && !dp[stones-x]) {
                dp[stones] = true;
            }
        }
    }
    
	puts(dp[k] ? "First" : "Second");
}

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

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

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    for(int i = 0; i < n; ++i) cin >> h[i];
    
    const int INF = 1001001001;
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            if(i-j < 0) break;
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    
    cout << dp[n-1] << endl;

}

Measured memory_bytes: 3972
x = [1,3,5,7,8,10,12]
y = [4,6,9,11]
z = [2]
a, b=map(int, input().split())
if (a in x and b in x) or (a in y and b in y) or (a in z and b in z):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int fun1(int a[], int n)
{
    sort(a,a+n);
    int c = 0;
    for (int i = 0; i < n-2; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            int k = j+1;
            while (k<n && a[i]+a[j]>a[k])
            {
               k=k+1;
            }
            c += k - j - 1;
        }
    }
    return c;
}
int main()
{
int n,i;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
    cin>>a[i];
}
cout<<fun1(a,n);

}



Measured memory_bytes: 256
N=int(input())
if N%2==1: #Nが奇数ならどうやっても2を因数に持たない
    print(0)

#関数の出力がほぼ無限に2を因数に持つので、因数にもつ10の個数は5の個数で決まる
else: #2^nごとにn個の5を因数に持つが、偶数縛りなので10*5^nで割った答えを足し合わせれば良い
    ans=0
    i=0
    while N>=10*5**i:
        ans+=N//(10*5**i)
        i+=1
    print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
ll const inf = 1LL << 40;

ll dp[20010];

int main() {
  int H, N; cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }
  rep(i, 20010) dp[i] = inf;
  dp[0] = 0;
  rep(S, H) {
    rep(i, N) {
      auto to = S + A[i] > H ? H : S + A[i];
      dp[to] = min(dp[to], dp[S] + B[i]);
    }
  }
  ll ans = inf;
  REP(S, H, 2 * H + 1) {
    ans = min(ans, dp[S]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
class Node:
	def __init__(self):
		self.p = self.l = self.r = -1

def pre_order(nodes, root_id):
	st = []
	st.append(root_id)
	while len(st) > 0:
		cur = st.pop()
		print(' ' + str(cur), end='')
		if nodes[cur].r != -1: st.append(nodes[cur].r)
		if nodes[cur].l != -1: st.append(nodes[cur].l)
	print()
	
def in_order(nodes, root_id):
	st = []
	cur = root_id
	while cur != -1 or len(st) > 0:
		if cur != -1:
			st.append(cur)
			cur = nodes[cur].l
		else:
			cur = st.pop()
			print(' ' + str(cur), end='')
			cur = nodes[cur].r
	print()
		
def post_order(nodes, root_id):
	st = []
	lastVisited = -1
	cur = root_id
	while cur != -1 or len(st) > 0:
		if cur != -1:
			st.append(cur)
			cur = nodes[cur].l
		else:
			peek_id = st[len(st) - 1]
			if nodes[peek_id].r != -1 and nodes[peek_id].r != lastVisited:
				cur = nodes[peek_id].r
			else:
				print(' ' + str(peek_id), end='')
				lastVisited = st.pop()
	print()

n = int(input())
nodes = [Node() for x in range(n)]
for i in range(n):
	id, l, r = map(int, input().split())
	nodes[id].l = l
	nodes[id].r = r
	if l != -1: nodes[l].p = id
	if r != -1: nodes[r].p = id
for i in range(n):
	if nodes[i].p == -1:
		root_id = i
		break

print('Preorder')
pre_order(nodes, root_id)
print('Inorder')
in_order(nodes, root_id)
print('Postorder')
post_order(nodes, root_id)



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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll>G[100000];
  for(int i(0);i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int pathed[100000] = {0};
  int ans[100000] = {0};
  queue<ll> q;
  q.push(0);
  pathed[0] = 1;
  while(!q.empty()){
    int now = q.front();q.pop();
    for(int i(0);i<int(G[now].size());i++){
      int next = G[now][i]; 
      if(pathed[next] == 0){
        ans[next] = now;
        pathed[next] = pathed[now] + 1;
        q.push(next);
      }
    }
  }
  cout << "Yes" << endl;
  for(int i(1);i<N;i++){
    cout << ans[i] + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 13040
#include<stdio.h>
#define W 300
int main(){
    int i,c=0,d=0,j;
    int a[W],b[W];
    for(i=0;i<W;i++){
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
        if(a[i]==0||b[i]==0)break;
    }
    i=0;
    j=0;
    while(a[c]!=0||b[d]!=0){
    for ( i = 0; i < a[c]; i++ ){
        for ( j = 0; j < b[d]; j++ ){
            printf("#");
        }
        printf("\n");
    }
        printf("\n");
        c++;
        d++;
    }
    
	return 0;
}





Measured memory_bytes: 2064
def main():
    n, k = [int(e) for e in input().split()]

    cnt1, cnt2 = 0, 0
    if k%2 == 1:
        for i in range(1, n + 1):
            if i%k == 0:
                cnt1 += 1
    else:
        for i in range(1, n + 1):
            if i%k == 0:
                cnt1 += 1
            elif i%(k//2) == 0:
                cnt2 += 1

    ans = cnt1**3 + cnt2**3
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38896
#include <iostream>
#include <string>
using namespace std;
int main() {

	long long n;
	string x;
	cin >> n;

	long long AC=0, WA=0, TLE=0, RE=0;

	for (int i = 0; i < n; i++)
	{
		cin >> x;
		
		if (x == "AC")
			AC++;
		else if (x == "WA")
			WA++;
		else if (x == "TLE")
			TLE++;
		else if (x == "RE")
			RE++;


	}

	cout << "AC x " << AC;
	cout << endl;
	cout << "WA x " << WA;
	cout << endl;
	cout << "TLE x " << TLE;
	cout << endl;
	cout << "RE x " << RE;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
const int maxn = 300005;
int num[maxn][23];
int pei[20];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        for(int j = 1; j <= 20; j++)
        {
            if((a&(1<<(j-1))))num[i][j] = 1;
        }
    }
    ll l = 1, r = 2;
    for(int i = 1; i <= 20; i++)
    pei[i] = num[1][i];
    ll ans = 0;
    while(r <= n)
    {
//        cout << l << ' ' << r << ' ' << ans << endl;
//        for(int i = 1; i <= 20; i++)
//        cout << pei[i] << ' ';
//        cout << endl;
        bool flag = true;
        for(int i = 1; i <= 20; i++)
        {
            if(pei[i] == 1 && num[r][i] == 1)
            flag = false;
        }
        if(flag)
        {
            for(int i = 1; i <= 20; i++)
            {
                pei[i] ^= num[r][i];
            }
            r++;
        }
        else
        {
            ans += r-l;
            for(int i = 1; i <= 20; i++)
            pei[i] ^= num[l][i];
            l++;
        }
        if(l == r)
        {
            for(int i = 1; i <= 20; i++)
            pei[i] ^= num[r][i];
            r++;
        }
    }
//    cout << l << ' '  << r << endl;
    ans += (r-l)*(1+r-l)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();

		long x = a * c;
		long y = a * d;
		long z = b * c;
		long w = b * d;
		long max = Math.max(x, Math.max(y, Math.max(z, w)));

		if (a <= 0 && 0 <= b) {
			max = Math.max(max, 0);
		}

		if (c <= 0 && 0 <= d) {
			max = Math.max(max, 0);
		}

		System.out.println(max);

		sc.close();

	}
}


Measured memory_bytes: 35692
#include<stdio.h>


int main(int argc, char** argv) {
int i,N,T,min,l;
scanf("%d %d\n",&N,&T);
int c[N-1],t[N-1];
l=0;
min=1000;
for(i=0;i<N;i++){
        	scanf("%d%d\n",&c[i],&t[i]);
		if((c[i]<=min) && (t[i]<=T)){
		l=1;
		min=c[i];
		}
}



if(l==0)
printf("TLE\n");
else
printf("%d\n",min);

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 998244353;
const i64 INF = 2e15;

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

	int n;
	cin >> n;

	int ans = 0, d = 10, g = 1;

	REP(i, 1, n) {
		if (i == d) {
			d *= 10;
			g = (g + 1) % 2;			
		}

		if (g) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
program nice_shopping
  implicit none
  integer :: na, nb, m, x, y, c, i, ans
  integer, dimension(100000) :: a = 0, b = 0
  read(*,*) na, nb, m
  read(*,*) a(1:na)
  read(*,*) b(1:nb)
  ans = minval(a(1:na))+minval(b(1:nb))
  do i = 1, m
    read(*,*) x, y, c
    ans = min(ans,a(x)+b(y)-c)
  end do
  write(*,'(i0)') ans
end program nice_shopping

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll P[N];
  for(ll i=0;i<N;i++){
    cin >> P[i];
  }
  ll ans = 1;
  ll now = P[0];
  for(ll i=1;i<N;i++){
    if(P[i]<now){
      ans++;
      now = P[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4700
inf = 10 ** 9
n = int(input())
h = [int(i) for i in input().split()]
dp = [inf] * (n)
dp[0] = 0
for i in range(n):
    if i + 1 <= n - 1:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    if i + 2 <= n - 1:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[-1])

Measured memory_bytes: 13976
N = int(input())
DS = list(input())
i = 0
DC = []
while i<N:
  cnt = DS.count(DS[i])
  DC.append(cnt)
  i += cnt

ans = 3 * DC[0]
for i in range(1,len(DC)):
  if DC[i-1]==1:
    ans = (ans * 2)% 1000000007
  elif DC[i]==2:
    ans = (ans * 3)% 1000000007
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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 * b) / gcd(a,b); }
int solve(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll tmp = n / (a + b);
  if(n % (a + b) == 0)cout << tmp * a << endl;
  else{cout << tmp * a + min((n % (a + b)),a) << endl;
  }
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[][] a = new int[2][n];
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < n; j++) {
					a[i][j] = in.nextInt();
				}
			}
			int ans = 0;
			for (int i = 0; i < n; i++) {
				int cur = 0;
				for (int j = 0; j < n; j++) {
					if (j <= i) {
						cur += a[0][j];
					}
					if (j >= i) {
						cur += a[1][j];
					}
				}
				ans = Math.max(ans, cur);
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



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

using namespace std;

int main()
{
 	int x1,y1,x2,y2;
 	cin>>x1>>y1>>x2>>y2;
 	vector <char> v1,v2,v3,v4;
 	for(int i=0; i<abs(x1-x2)+abs(y1-y2); i++)
 	{
 		if(i<abs(y2-y1))
 		{
 			if(y2>y1)
 			{
 				v1.push_back('U');
 				v2.push_back('D');			 
			}
			 if(y1>y2)
			 {
			 	v1.push_back('D');
 				v2.push_back('U');
			 }
		}
		 else 
		 {
		 	if(x2>x1)
		 	{
		 		v1.push_back('R');
 				v2.push_back('L');
			 }
			 if(x1>x2)
			 {
			 	v1.push_back('L');
 				v2.push_back('R');
			 }
		 }
	}
	for(int i=0; i<abs(x1-x2)+abs(y1-y2)+4; i++)
	{
		if(i==0)
		{
			if(x1>x2)
			{
				v3.push_back('U');
			}
			if(x2>x1)
			{
				v3.push_back('L');
			}
		}
		if(i>0 && i<abs(y1-y2)+1)
		{
			v3.push_back(v1.at(i-1));
		}
		if(i==abs(y1-y2)+1)
		{
			v3.push_back(v1.at(0));
		}
		if(i==abs(y1-y2)+2)
		{
			v3.push_back(v1.at(abs(y2-y1)));
		}
		if(i>abs(y2-y1)+2 && i<abs(x1-x2)+abs(y1-y2)+3)
		{
			v3.push_back(v1.at(i-3));
		}
		if(i==abs(x1-x2)+abs(y1-y2)+3)
		{
			if(y2>y1)v3.push_back('D');
			if(y1>y2)v3.push_back('U');
		}
		
		
	}
	for(int i=0; i<v3.size(); i++)
	{
		if(v3.at(i)=='U')v4.push_back('D');
		if(v3.at(i)=='D')v4.push_back('U');
		if(v3.at(i)=='R')v4.push_back('L');
		if(v3.at(i)=='L')v4.push_back('R');
	}
	for(int i=0; i<v1.size(); i++)cout<<v1.at(i);
	for(int i=0; i<v2.size(); i++)cout<<v2.at(i);
	for(int i=0; i<v3.size(); i++)cout<<v3.at(i);
	for(int i=0; i<v4.size(); i++)cout<<v4.at(i);
	
}


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

int n, S[100000 + 1];

bool binarySearch(int key) {
	int left = 0, right = n - 1, mid;

	while (left <= right) {
		mid = (left + right) / 2;
		//printf("L, R, M, S[mid]: %d %d %d %d\n", left, right, mid, S[mid]);
		if (key == S[mid]) return true;
		else if (key < S[mid]) right = mid - 1;
		else left = mid + 1;
	}
	return false;
}

int main() {
	int q, key, count = 0;

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

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (binarySearch(key)) count++;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 3480
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(void)
{
    int i,j,l;
    string c;
    cin>>c;
    l=c.length();
    for(i=0;i<l;i++)
    {
        if(c[i]=='C')
        {
            for(j=i+1;j<=l;j++)
            {
                if(c[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll A[M], B[M];
    REP(i, 0, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    unionFind u(N);
    ll ans[M + 1];
    ll now = N * (N - 1) / 2;
    ans[M] = now;
    PER(i, M - 1, -1) {
        if (!u.same(A[i], B[i])) {
            now -= u.rank(A[i]) * u.rank(B[i]);
            u.unite(A[i], B[i]);
        }
        ans[i] = now;
    }
    REP(i, 1, M + 1) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 5005;

int n, k, a[maxn];
int16_t dp[2][maxn][maxn], pref[2][maxn][maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0][0] = dp[1][n + 1][0] = 1;
    pref[0][0][0] = pref[1][n + 1][0] = 1;
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= k; j++)
            if(dp[0][i][j])
            {
                dp[0][i + 1][min(j + a[i + 1], k)] = 1;
                dp[0][i + 1][j] = 1;
            }
    for(int i = n + 1; i > 1; i--)
        for(int j = 0; j <= k; j++)
            if(dp[1][i][j])
            {
                dp[1][i - 1][min(j + a[i - 1], k)] = 1;
                dp[1][i - 1][j] = 1;
            }
    for(int l = 0; l < 2; l++)
        for(int i = 1; i <= n; i++)
        {
            pref[l][i][k] = dp[l][i][k];
            for(int j = k - 1; j >= 0; j--)
                pref[l][i][j] = pref[l][i][j + 1] + dp[l][i][j];
        }
    int ans = n;
    for(int i = 1; i <= n; i++)
    {
        int useful = 0;
        for(int lsum = 0; lsum < k; lsum++)
            if(dp[0][i - 1][lsum])
            {
                int sub = k - lsum;
                int add = max(sub - a[i], 0ll);
                assert(add < sub);
                if(pref[1][i + 1][add] - pref[1][i + 1][sub] > 0)
                    useful = 1;
            }
        ans -= useful;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 199004
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ld long double
#define F first
#define S second
#define ms(x,y) memset(x,y,sizeof(x))
#define F1(i,n) for(int i=1;i<=n;++i)
#define F0(i,n) for(int i=0;i<n;++i)
#define P 998244353
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
const int MAX=4e4;
int main(){
    int m,d,cnt;
    cin>>m>>d;
    F1(j,m)
        F1(i,d){
            int d1=i%10,d10=i/10;
            if (d1>=2&&d10>=2&&d1*d10==j)
                ++cnt;
        }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 768
n = int(input())
tmp = [[0 for i in range(9)] for j in range(9)]

for i in range(1, n + 1):
    strI = str(i)
    if strI[-1] == "0":
        continue
    tmp[int(strI[0]) -1 ][int(strI[-1]) - 1] += 1

ans = 0
for i in range(9):
    for j in range(9):
        ans += tmp[i][j] * tmp[j][i]

print(ans)

Measured memory_bytes: 40524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = ni();
        }
        int[] cand = new int[N+1];
        cand[0] = 3;
        int ans = 1;
        for (int i = 0; i < a.length; i++) {
            ans = mul(ans, cand[a[i]]);
            cand[a[i]]--;
            cand[a[i]+1]++;
        }
 
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 44520
#include <cstdio>
#include <algorithm>

using namespace std;

int u,v,w,x,y;

int main()
{
	scanf("%d%d%d%d%d",&u,&v,&w,&x,&y);
	if (u+v<=w+w)
		printf("%d",u*x+v*y);
	else
		printf("%d",min(min(x,y)*w*2+(x-min(x,y))*u+(y-min(x,y))*v,max(x,y)*w*2));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    string s;
    cin >> s;
    string t,u;
    for(int i = 0; i < s.size(); i++) {
        if(s[i]!='x') t += s[i];
    }
    u=t;
    reverse(u.begin(),u.end());
    if(t != u){
        cout << -1 << endl;
        return 0;
    }

    vector<int> a;
    int d=0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i]=='x') d++;
        else{
            a.push_back(d);
            d=0;
        }
    }

    a.push_back(d);


    ll ans=0;

    for(int i = 0; i < (a.size()+1)/2; i++) {
        ans += abs(a[i]-a[t.size()-i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4168
#include <stdio.h>
int main()
{
    char b;
    scanf("%c",&b);
    if(b=='C')
    printf("G\n");
    if(b=='G')
    printf("C\n");
    if(b=='A')
    printf("T\n");
    if(b=='T')
    printf("A\n");
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      Dice dice2 = new Dice(br.readLine().split(" "));
      int upper,front;
      br.readLine();
      while(true) {

        if( (line = br.readLine()) == null || line.isEmpty() ) break;

        upper = Integer.parseInt(line.split(" ")[0]);
        front = Integer.parseInt(line.split(" ")[1]);

        while(true){
          if( dice2.getFrontSide() == front){
            for (int i=0; i<3; i++)
              if(dice2.getUpperSide() == upper) break;
              dice2.rotate("W");
          }
          else {
            for(int i=0; i < 4; i++)
              if(dice2.getUpperSide() != front) dice2.rotate("N");
            for(int i=0; i < 4; i++)
              if(dice2.getUpperSide() != front) dice2.rotate("W");
            if(dice2.getUpperSide() != upper) dice2.rotate("S");
          }
          if( (dice2.getUpperSide()==upper) && (dice2.getFrontSide()==front)) break;
        }
        System.out.println(dice2.getRightSide());
      }
    }
  }
}

class Dice {
  private int[] side;

  public Dice( int[] ia ) {
    side = Arrays.copyOf(ia, ia.length);
  }
  public Dice( String[] s ) {
    side = new int[s.length];
    for ( int i=0; i < 6; i++)
      side[i] = Integer.parseInt(s[i]);
  }

  public void setDice(int[] ia) {
    side = Arrays.copyOf(ia, ia.length);
  }

  public int getUpperSide() {
    return side[0];
  }
  public int getFrontSide() {
    return side[1];
  }
  public int getRightSide() {
    return side[2];
  }

  public int doRotate(String s) {
    for ( int i=0; i < s.length(); i++ ) {
      rotate(s.substring(i, i+1));
    }
    return side[0];
  }

  public void rotate(String o) {
    switch(o) {
      case "N" :
        rotateN();
        break;
      case "S" :
        rotateS();
        break;
      case "W" :
        rotateW();
        break;
      case "E":
        rotateE();
        break;
      default :
    }
  }

  private void rotateN() {
    int tmp = side[0];
    side[0] = side[1]; side[1] = side[5]; side[5] = side[4];
    side[4] = tmp;
  }
  private void rotateS() {
    int tmp = side[0];
    side[0] = side[4]; side[4] = side[5]; side[5] = side[1];
    side[1] = tmp;
  }
  private void rotateW() {
    int tmp = side[0];
    side[0] = side[2]; side[2] = side[5]; side[5] = side[3];
    side[3] = tmp;
  }
  private void rotateE() {
    int tmp = side[0];
    side[0] = side[3]; side[3] = side[5]; side[5] = side[2];
    side[2] = tmp;
  }
}


Measured memory_bytes: 24368
unittest
{
	assert( [ "1000 8", "1 3 4 5 6 7 8 9" ].parse.expand.solve == 2000 );
	assert( [ "9999 1", "0" ].parse.expand.solve == 9999 );
	
	assert( [ "1112 9", "0 2 3 4 5 6 7 8 9" ].parse.expand.solve == 11111 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto ds = input.front.split.map!( to!char ).array;
	return tuple( nk[ 0 ], ds );
}

auto solve( long n, char[] ds )
{
	for( ;; n++ )
	{
		if( memoize!f( n.to!string, ds ) ) break;
	}
	return n;
}

bool f( string cs, char[] ds )
{
	if( cs.empty ) return true;
	foreach( d; ds )
	{
		if( cs[ 0 ] == d ) return false;
	}
	return memoize!f( cs[ 1 .. $ ], ds );
}


Measured memory_bytes: 10108
#include <stdio.h>
int main(void){
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    if(e-a>k){
        printf(":(\n");
    }else{
        printf("Yay!\n");
    }   
    return 0;
}

Measured memory_bytes: 128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,X=MI()
    print(B//X - (A-1)//X)
if __name__ == '__main__':
    main()

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

int main(){
  int N;
  cin >> N;
  vector<int> digit(3);
  digit.at(0) = N / 100;
  N %= 100;
  digit.at(1) = N / 10;
  digit.at(2) = N % 10;
  if(digit.at(2) == 3){
    cout << "bon" << endl;
  }
  else if(digit.at(2) == 0 || digit.at(2) == 1 || digit.at(2) == 6 || digit.at(2) == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

ll power(ll base, ll exp) {
    ll ans = 1;
    REP(i, exp) ans *= base;
    return ans;
}

int sign(ll a) { return (a > 0) - (a < 0); }

ll n, i;
bool oneput;
vector<int> ans;
int main() {
    cin >> n;
    if (n == 0) {
        cout << 0;
        return 0;
    }
    while(n){
        ans.push_back(abs(n%2));
        if(i&1){
            n+=abs(n%2);
        }
        else n-=abs(n%2);
        n/=2;
        i++;
    }
    for(auto i=ans.end()-1;i!=ans.begin()-1;i--){cout<<*i;}
    return 0;
}


Measured memory_bytes: 256
MP = 999983

sieve = [*0..MP]
2.upto(Math.sqrt(MP).to_i) do |i|
  next if sieve[i].zero?
  2.upto(MP / i) {|j| sieve[i * j] = 0}
end
sieve = sieve[2..-1].reject {|x| x.zero?}

until (n = $<.gets.to_i).zero?
  prize_amount = n.times.map do
    p, m = $<.gets.split.map(&:to_i)
    s = sieve.bsearch_index {|i| i >= p - m}
    e = sieve.bsearch_index {|i| i > p + m} || sieve.size
    prize = e - s
    prize.zero? ? -1 : prize - 1
  end.sum
  puts prize_amount
end


Measured memory_bytes: 23052
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int gcd(int a, int b) {
	if (a > b) {
		swap(a, b);
	}

	if (a == 0) {
		return b;
	}

	return gcd(b % a, a);
}

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

	vector<int> p{ 2 };
	for (int i = 3; i <= 1000; i++) {
		bool isPrime = true;
		for (int pi : p) {
			if (i % pi == 0) {
				isPrime = false;
			}
		}

		if (isPrime) {
			p.emplace_back(i);
		}
	}

	
	bool isPairwise = true;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int num = a[i];
		for (int pi: p) {

			if (num < pi) {
				break;
			}
			if (num % pi != 0) {
				continue;
			}

			if (s.find(pi) != s.end()) {
				isPairwise = false;
			}

			s.insert(pi);

			while (num % pi == 0) {
				num /= pi;

			}

			
		}

		if (num == 1) {
			continue;
		}

		if (s.find(num) != s.end()) {
			isPairwise = false;
		}

		s.insert(num);
	}

	if (isPairwise) {
		cout << "pairwise coprime" << endl;
		return 0;
	}

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);

	}

	if (g == 1) {
		cout << "setwise coprime" << endl; 
	}
	else {
		cout << "not coprime" << endl;
	}

}

Measured memory_bytes: 10628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  
  int cnt = 0;
  for (int i=0;i<N; i++) {
    bool flag = true;
    for (int j=1; flag; j++) {
      if (j*A[i] + 1 <= D) {
        cnt++;
      }
      else flag = false;
    }
  }
  int ans = N+cnt+X;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{

    unsigned long long power,i,n;
    power=1;
    scanf("%llu",&n);
    for(i=1;i<=n;i++){
        power*=i;
        power=power%1000000007;
    }
    printf("%llu\n",power);
    return 0;
}


Measured memory_bytes: 1732
# (c) midandfeed
while(True):
	h, w = [int(x) for x in input().split()]
	
	if (h == 0) and (w==0):
		break
		
	for i in range(1, h+1):
		if (i&1):
			flag = True
		else:
			flag = False
		for j in range(1, w+1):
			if (flag):
				print("#", end='')
			else:
				print(".", end='')
			flag = not(flag)
		print()
	print()
			
	

Measured memory_bytes: 9124
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


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

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

  return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
a = -1
b = -1
c = -1
for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if pow(10, 4)*i + 5000*j + 1000*k == y:
            a = i
            b = j
            c = k
            break

print(a, b, c)

Measured memory_bytes: 3064