akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const ll OO = 1LL << 62;
const double eps = 1e-9;

const int N = 2002;

int n, x;
int a[N];
int f[N];
int mn[N][N];

int get(int st, int en) {
	if (st <= en)
		return mn[st][en];
	return min(mn[st][n - 1], mn[0][en]);
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		mn[i][i] = a[i];
		for (int j = i + 1; j < n; j++) {
			mn[i][j] = min(a[j], mn[i][j - 1]);
		}
	}
	ll res = LLONG_MAX;
	for (int k = 0; k < n; k++) {
		ll cur = k * 1LL * x;
		for (int i = 0; i < n; i++) {
			int st = i - k;
			if (st < 0)
				st += n;
			cur += get(st, i);
		}
		res = min(res, cur);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 15360
mod = 1000000007

balls, blue_balls = gets.split.map(&:to_i)

red_balls = balls - blue_balls

comb1 = red_balls + 1

def modpow (a, n, mod)
  res = 1
  while n > 0
    if n & 1 != 0
      res = res * a % mod
    end
    a = a * a % mod
    n >>= 1
  end
  res
end

p = 1

(1..blue_balls).each do |i|
  
  puts (p * comb1) % mod
  
  comb1 *= (red_balls + 1 - i)
  comb1 *= modpow(i + 1, mod - 2, mod)
  comb1 %= mod
  
  p *= (blue_balls - i)
  p *= modpow(i, mod - 2, mod)
  p %= mod
end

Measured memory_bytes: 1788
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-11 22:11:30
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    string ans = S;
    for (int i = 0; i < S.length(); i++) {
        char c = S[i];
        char d = c + N;

        if (d > 'Z') d -= 26;

        ans[i] = d;
    }

    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
    int x3 = x2+(y1-y2);
    int y3 = y2+(x2-x1);
    int x4 = x1+(y1-y2);
    int y4 = y1+(x2-x1);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}


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

const int MOD = 1e+9 + 7;

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

  int N = L.size(), max_d, l;
  vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(2, vector<ll>(2, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    l = L[i] - '0';
    for (int j = 0; j < 2; j++) {
      max_d = j ? 1 : l;
      for (int d = 0; d <= max_d; d++) {
          dp[i + 1][j || d < l][d] += (dp[i][j][0] + dp[i][j][1]) * (d + 1);
      }
    }
    rep(j, 2) rep(d, 2) {
      dp[i + 1][j][d] %= MOD;
    }
  }
  int ans = 0;
  rep(i, 2) rep(j, 2) {
    ans = (ans + dp[N][i][j]) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18320
#include<bits/stdc++.h> 
#define f(i, a, b) for(int i=a; i<b; i++)
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit));
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	int n, q;
	cin>>n>>q;
	int a[n];
	f(i, 0, n) cin>>a[i];
	Query queries[q];
	f(i, 0, q)
	{
		cin>>queries[i].l>>queries[i].r;
		queries[i].l--, queries[i].r--;
		queries[i].idx = i;
	}
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 

Measured memory_bytes: 19416
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    string t;
    cin>>t;
    ll loop=0,pos=0;
    set<int> eachpos[26];
    int sn=s.size(),tn=t.size();
    rep(i,0,s.size()){
        eachpos[s[i]-'a'].insert(i);
    }
    rep(i,0,t.size()){
        if(eachpos[t[i]-'a'].empty()){
            cout<<-1<<endl;
            return 0;
        }
        auto itr=eachpos[t[i]-'a'].lower_bound(pos);
        if(itr==eachpos[t[i]-'a'].end()){
            loop++;
            pos=0;
            itr=eachpos[t[i]-'a'].lower_bound(pos);
        }
        pos=*itr;
        pos++;
    }
    cout<<loop*sn+pos<<endl;
    return 0;
}




Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



map<int,int> H, W;
int N, M;

int main() {
    while(cin >> N >> M) {
        if (N == 0) break;
        H.clear();
        W.clear();
        int sH[2000], sW[2000];
        for (int i = 0; i < N; ++i) {
            int num; cin >> num;
            sH[i+1] = sH[i] + num;
        }
        for (int i = 0; i < M; ++i) {
            int num; cin >> num;
            sW[i+1] = sW[i] + num;
        }
        for (int i = 0; i <= N; ++i) {
            for (int j = i+1; j <= N; ++j) {
                int t = sH[j] - sH[i];
                H[t]++;
            }
        }
        for (int i = 0; i <= M; ++i) {
            for (int j = i+1; j <= M; ++j) {
                int t = sW[j] - sW[i];
                W[t]++;
            }
        }
        
        int res = 0;
        EACH(it,H) {
            res += it->SE * W[it->FI];
        }
        
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 32464
n, x, y = map(int, input().split())
x -= 1
y -= 1

distance = [[0 for _ in range(n)] for _ in range(n)]
ans = [0 for _ in range(n)]
for i in range(n):
    for j in range(i, n):
        d = min(j-i, abs(j-y)+1+abs(x-i))
        distance[i][j] = d
        ans[d] += 1
for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 84076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e9+7;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> key(m);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
        int b;
        cin >> b;
        for(int j = 0; j < b; j++)
        {
            int c;
            cin >> c;
            c--;
            key[i] += (1 << c);
        }
    }
    vector<ll> dp(1<<n);
    for(int i = 0; i < (1<<n); i++)
    {
        dp[i] = -1;
    }
    dp[0] = 0;
    for(int i = 0; i < (1 << n)-1; i++)
    {
        if(dp[i] == -1) continue;
        for(int j = 0; j < m; j++)
        {
            if(dp[i | key[j]] == -1) dp[i | key[j]] = dp[i] + a[j];
            else dp[i | key[j]] = min(dp[i | key[j]], dp[i] + a[j]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszrz[nax];
int jeszkol[nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if (!jeszrz[a])
	{
		szuk(a+1, b, x, y, w);
		return;
	}
	if (!jeszrz[b])
	{
		szuk(a, b-1, x, y, w);
		return;
	}
	if (!jeszkol[x])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if (!jeszkol[y])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszrz[i]--;
				jeszkol[j]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
	{
		//~ jeszrz[i]=pyt(i, i, 0, n-1);
		jeszrz[i]=1e9;
		jeszkol[i]=pyt(0, n-1, i, i);
	}
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int X;
  cin >> X;
  int ans = 1;
  REPI(i, 1, X) {
    REPI(j, 2, X) {
      if (pow(i, j) <= X) {
        ans = max(ans, (int)pow(i, j));
      } else {
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int r, g, b;
    cin >> r >> g >> b;
    int hoe = r*100+g*10+b;
    if (hoe % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
//    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] a){
		StringBuilder buf = new StringBuilder();
		for(int i = 1; i < 10; i++) {
			for(int j = 1; j < 10; j++) {
				buf.append(String.format("%dx%d=%d\n",i,j,i*j));
			}
		}
		System.out.printf(buf.toString());
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) == S.at(i+1)){
      count++;
    }
  }
  cout << N - count << endl;
}
      
 

Measured memory_bytes: 3728
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;

public class Program
{
    public static void Main()
    {
        var watch = new Stopwatch();
        watch.Start();
        var stream = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(stream);
        TextReader reader;
        reader = Console.In;

        // ここから
        var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        Console.WriteLine(6 - A - B);


        Console.Out.Flush();
    }
}

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

int main()
{
	int n;
	cin >> n;
	int i = 1;
	for (int i = 1; i <= n; i++)
	{
		int x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
			continue;
		}
		do
		{
			if (x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}
		while (x);
	}
	cout << endl;
}


Measured memory_bytes: 3068
import itertools

def war(N,d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d

def main():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    d = [[float('inf')] * N for _ in range(N)]

    for i in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        d[A][B] = C
        d[B][A] = C

    for i in range(N):
        d[i][i] = 0

    war(N,d)
    ans = float('inf')

    for a in itertools.permutations(r):
        tmp = 0
        for i in range(len(a)-1):
            tmp += d[a[i]-1][a[i+1]-1]
        ans = min(ans, tmp)

    print(ans)


main()

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, h, w;
	cin >> n >> h >> w;

	cout << (n-h+1) * (n-w+1) << endl;
}


Measured memory_bytes: 256
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}


Measured memory_bytes: 34396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    vector<int> v(5);
    REP(i,5){
        cin>>v[i];
    }
    
    vector<int> w(5);
    REP(i,5){
        w[i] = v[i] % 10;
    }
    int min_lowdigit=4,min_where=4;
    
    
    sort(w.begin(), w.end());
    REP(i,5){
        if(w[i]){
            min_where = i;
            break;
        }
    }
    REP(i,5){
        if(w[min_where]==v[i]%10){
            min_lowdigit = i;
        }
    }
    int result = 0;
    REP(i,5){
        if(i!=min_lowdigit){
            result += v[i];
        }
        if(result%10){
            result += 10 - (result % 10);
        }
    }
    result += v[min_lowdigit];
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>

using namespace std;

const long long MOD = (long long)1e9 + 7;
long long dp[110][10];

long long mod_pow(long long x_, long long y_){
	if(y_ == 0) return 1;
	long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
	if(y_ & 1) res = x_ * res % MOD;
	return res;
}

bool check_yoko(int x){
	for(int i = 2; i <= x; i = i << 1){
		if((x & i) && (x & (i >> 1))){
			return false;
		}
	}
	return true;
}

int main(){
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	vector<int> b;
	for(int i = 0; i < (1 << (w - 1)); i++){
		if(check_yoko(i)){
			b.push_back(i);
		}
	}
	vector<int> c(w + 1);
	for(int i = 0; i < w - 1; i++){
		for(int j = 0; j < b.size(); j++){
			if(b[j] & (1 << i)){
				c[i + 1]++;
			}
		}
	}
	dp[0][1] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 1; j <= w; j++){
			dp[i + 1][j - 1] = (dp[i + 1][j - 1] + (dp[i][j] * c[j - 1]) % MOD) % MOD;
			dp[i + 1][j] = (dp[i + 1][j] + (dp[i][j] * (b.size() - c[j - 1] - c[j])) % MOD) % MOD;
			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + (dp[i][j] * c[j]) % MOD) % MOD;
		}
	}
	cout << dp[h][k] << endl;
	return 0;
}

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

int64_t factorial(int n) {
  int64_t ret = 1;
  for (int i = 1; i <= n; i++) {
    ret = (ret * i) % MOD;
  }
  return ret;
}

int main(void) {
  int N, M;
  cin >> N >> M;

  int64_t ANS = 0;
  if(abs(N-M) <= 1) {
    ANS = (factorial(N) * factorial(M)) % MOD;
    if (N == M) {
        ANS = (ANS * 2) % MOD;
    }
  }
  cout << ANS << endl;
  return 0;
}


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

int N, M;
string S, T;

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

int main() {
    cin >> N >> M;
    cin >> S >> T;
    
    int d = gcd(N, M);   //N, Mの最大公約数
    for (int i = 0; i < d; i++) {
        if(S[i * N / d] != T[i * M / d]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << 1ll * N * M / d << endl;
}

Measured memory_bytes: 512
nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]

name = []
time = []

for i in range(n):
    x = input().split()
    name.append(x[0])
    time.append(int(x[1]))

resultname = []
ms = 0
resulttime = []

while len(resultname) < n:
    result = time[0] - q
    popname = name.pop(0)
    poptime = time.pop(0)
    if result <= 0:
        resultname.append(popname)
        ms += poptime
        resulttime.append(ms)
    else:
        name.append(popname)
        time.append(result)
        ms += q

for i in range(n):
    print(resultname[i], resulttime[i])


Measured memory_bytes: 11104
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#include<climits>
using namespace std;
const int N=2e5+5;
const int M=4e6+5;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const long long inf=LLONG_MAX;
int v[N],w[N],nex[N];
long long deep[N];
int n,now,head[N];

void addedges(int x,int y,int z){
	nex[++now]=head[x],w[now]=z;
	head[x]=now,v[now]=y;
}

long long L,R,mid;
void Dfs(int x){
	for(int i=head[x];i;i=nex[i])
		deep[v[i]]=deep[x]+w[i],Dfs(v[i]);
}

typedef pair<long long,long long>P;
#define se second
#define fi first
vector<P>b[N],tmp;
void merge(int rt){
	int x=0,y;
	long long res=inf;
	for(int i=head[rt];i;i=nex[i])
		x?y=v[i]:x=v[i];

	if(b[x].size()>b[y].size())	swap(x,y);
	int sx=b[x].size(),sy=b[y].size();
	tmp.clear();

	for(int i=sx-1,j=0;~i;i--){
		while(j<sy&&b[y][j].fi+b[x][i].fi-deep[rt]*2<=mid)
			res=min(res,b[y][j++].se);
		if(res==inf)	continue;
		tmp.push_back(P(b[x][i].se,res));
		tmp.push_back(P(res,b[x][i].se));
	}

	sort(tmp.begin(),tmp.end());
	int si=tmp.size();
	res=inf;

	for(int i=0;i<si;i++)
		if(!i||tmp[i].se<res){
			b[rt].push_back(tmp[i]);
			res=tmp[i].se;
		}
}

void dfs(int x){
	if(!head[x]){
		b[x].push_back(P(deep[x],deep[x]));
		return ;
	}
	for(int i=head[x];i;i=nex[i])
		dfs(v[i]);
	merge(x);
}

bool check(){
	for(int i=1;i<=n;i++)	b[i].clear();
	dfs(1);
	return b[1].size();
}

int main(){
	n=read();
	for(int i=2;i<=n;i++){
		int x=read(),z=read();
		addedges(x,i,z),R+=z;
	}	Dfs(1);

	while(L<R){
		mid=(L+R)>>1;
		if(check())	R=mid;
		else	L=++mid;
	}
	printf("%lld\n",L);
	return 0;
}

Measured memory_bytes: 32244
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define mod 1000000007
#define inf 1e17
using namespace std;

int main() 
{ 

   ll n,w;
   cin>>n>>w;
   ll dp[100005];
   vector<ll>wght,val;
   ll sumval=0;
   for(ll i=0;i<n;i++)
   {
      ll a,b;
      cin>>a>>b;
      wght.pb(a);
      val.pb(b);
      sumval = sumval + b;
   }
   dp[0] = 0;
   for(int i=1;i<=sumval;i++)
   {
      dp[i] = INT_MAX;
   }
   for(ll i=0;i<n;i++)
   {
      for(ll j=sumval;j>=0;j--)
      {
         if(val[i]<=j)
         {
            dp[j] = min(dp[j],dp[j-val[i]]+wght[i]);
         }
      }
   }
   int ans=0;
   for(int i=0;i<=sumval;i++)
   {
      if(dp[i]<=w)
      {
         ans = i;
      }
   }
   cout<<ans<<endl;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  ll N;
   cin >> N;

   vector<ll> A(N);
   ll tmp_odd = 0;
   ll tmp_even = 0;
   REP(i, N){
     cin >> A[i];
     if (i == N - 1) continue;
     else if (i % 2 == 0) tmp_even += A[i];
     else tmp_odd += A[i];
   }
   ll tmp1 = tmp_even - tmp_odd + A[N- 1];
   REP(i, N){
     if (i == 0) cout << tmp1;
     else {
       tmp1 = 2 * A[i - 1] - tmp1;
       cout << " " << tmp1;
     }
   }
   cout << endl;

  return 0;
}


Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(10)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

class vec2d {
public:
	double x, y;
	vec2d(double x, double y) :x(x), y(y) {}
	double norm2() const {
		return x * x + y * y;
	}
	vec2d operator*(double k) const {
		return vec2d(x * k, y * k);
	}
	vec2d operator/(double k)const {
		return vec2d(x / k, y / k);
	}
	double operator*(const vec2d&v)const {
		return x * v.x + y * v.y;
	}
	static vec2d projection(const vec2d&a, const vec2d&b) {
		return a * (a * b) / a.norm2();
	}
};
signed main() {
	SETP;
	int xp1 = in(), yp1 = in(), xp2 = in(), yp2 = in();
	vec2d a(xp2 - xp1, yp2 - yp1);
	int q = in();
	REP(i, q) {
		int x = in(), y = in();
		vec2d b(x - xp1, y - yp1);
		vec2d proj = vec2d::projection(a, b);
		cout << proj.x + xp1 << ' ' << proj.y + yp1 << endl;
	}
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_upd>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

const LL MOD = 998244353;
const LD EPS = 0.0000001 ;

LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const LL N = 200000 + 50;
LL cnt[N];

int main(void)
{
	int n; cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++){
		cin >> arr[i];
		cnt[arr[i]]++;
	}

	LL overall = 0;
	for (int i = 1; i < N; i++){
		overall += cnt[i] * (cnt[i] - 1LL) / 2LL;
	}

	for (int i = 0; i < n; i++){
		int who = arr[i];
		LL ans = overall - (cnt[who] * (cnt[who] - 1LL) / 2LL);
		cnt[who]--;
		ans +=  (cnt[who] * (cnt[who] - 1LL) / 2LL);
		cnt[who]++;
		cout << ans << endl;
	}
	
	return 0;
}




Measured memory_bytes: 3968
// 2020/07/20 Tazoe

#include <iostream>
using namespace std;

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

	int c[1001];			// 猫の情報
	for(int i=1; i<=L; i++){
		cin >> c[i];
	}

	int A[101];			// 猫のスタック位置
	for(int i=1; i<=100; i++){
		A[i] = -1;
	}
	int sp = 0;			// スタックポインタ

	for(int i=1; i<=L; i++){
		if(c[i]>0){				// 横穴に入った
			if(A[c[i]]==-1){
				A[c[i]] = sp;
				sp++;
			}
			else{
				cout << i << endl;
				return 0;
			}
		}
		else{					// 横穴から出た
			if(sp>0 && A[-c[i]]==sp-1){
				A[-c[i]] = -1;
				sp--;
			}
			else{
				cout << i << endl;
				return 0;
			}
		}
	}
	
	cout << "OK" << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
int main()
{
    int h, w;

    cin >> h >> w;

    char s[h][w], ans[h][w];

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cin >> s[i][j];

            if (s[i][j] == '#')
            {
                ans[i][j] = '#';
            }
            else
            {
                ans[i][j] = '0';
            }
        }
    }

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            for (size_t k = i - 1; k < i + 1; k++)
            {
                if (k < 0 || h - 1 < k)
                {
                    continue;
                }

                for (size_t l = j - 1; l < j + 1; l++)
                {
                    cout << "i=" << i << " j=" << j << " k=" << k << " l=" << l << endl;
                    if (l < 0 || w - 1 < l || (l == j && k == i))
                    {
                        continue;
                    }

                    if (s[k][l] == '#')
                    {
                        ans[i][j]++;
                    }
                }
            }
        }
    }

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}
*/

int main(int argc, char const *argv[])
{
    int h, w, pass = 0, ij = 0;

    cin >> h >> w;

    char s[h][w], ans[h][w];

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cin >> s[i][j];

            if (s[i][j] == '#')
            {
                ans[i][j] = '#';
            }
            else
            {
                ans[i][j] = '0';
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            for (int k = i - 1; k < i + 2; k++)
            {
                for (int l = j - 1; l < j + 2; l++)
                {
                    if ((k < 0 || h - 1 < k) || (l < 0 || w - 1 < l))
                    {
                        continue;
                    }
                    if (s[k][l] == '#' && s[i][j] != '#')
                    {
                        ans[i][j]++;
                    }
                }
            }
        }
    }

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	if (2 * k >= b - a + 1) {
		rep(i, b - a + 1) cout << i + a << endl;
	}
	else {
		rep(i, k) cout << a + i << endl;
		for (int i = k - 1; i >= 0; i--) cout << b - i << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;

struct UnionFind{
    vector<int> d;
    UnionFind(int n):d(n,-1) {}
    int root(int x){
        if(d[x] < 0) return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x, int y){
        x=root(x); y=root(y);
        if(x==y){return false;}
        if(d[x]>d[y])swap(x,y);
        d[x]+= d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){
        return root(x)==root(y);
        }
    int size(int x){
        return -d[root(x)];
    }
};
//直接友達な数
int deg[100001]={0};
//to[i]がもつブロック関係な人
vector<int> to[100005];

int main(void){
  int n,m,k;
  cin >> n >> m >> k;
  //m--;k--;
  UnionFind node(n);
  for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      a--;b--;
      deg[a]++;
      deg[b]++;
      node.unite(a,b);
  }
  for(int i=0;i<k;i++){
      int c,d;
      cin >> c >> d;
      c--;d--;
      to[c].push_back(d);
      to[d].push_back(c);
  }
  for(int i=0;i<n;i++){
      int ans=node.size(i)-1-deg[i];
      for(int u:to[i]){
          //iがブロック関係の人数分引く
          if(node.same(i,u))--ans;
      }
      printf("%d%c",ans,i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  int inp;
  cin >> n;
  inp = n%1000;
  if(inp==0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000-inp << endl;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main(void){
    int N;
    int bar_len[100],count=0;
    int i,j,k;
    //入力
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&bar_len[i]);
    }
    //処理
    for(i=0;i<N-2;i++){
        for(j=i;j<N-1;j++){
            for(k=j;k<N;k++){
                //全て異なる棒か
                if(bar_len[i] == bar_len[j])    continue;
                if(bar_len[j] == bar_len[k])    continue;
                if(bar_len[k] == bar_len[i])    continue;
                //三角形ができるか
                if(bar_len[i] >= (bar_len[j] + bar_len[k])) continue;
                if(bar_len[j] >= (bar_len[i] + bar_len[k])) continue;
                if(bar_len[k] >= (bar_len[i] + bar_len[j])) continue;
                count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
	    int length = scanner.nextInt();
		int A[] = new int[length];
        for(int i = 0; i < length; i++)
        	A[i] = scanner.nextInt();
        
        int key = 1000;
		int j = 1000;
		int count = 0;
		for (int i = 0; i < length; i++) {
			for (j = length-1; j>i; j--) {
				if (A[j] < A[j-1]){
					key = A[j-1];
					A[j-1] = A[j];
					count++;
					A[j] = key;
				}		
			}
		}
		out_put(A);
		System.out.println(count);	
	}
	
	private static void out_put(int A[]){
        System.out.printf("%d", A[0]);
        for(int i = 1; i < A.length; i++){
            System.out.printf(" %d", A[i]);
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 26580
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

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

    sort(v.begin(), v.end());

    double ans = v[0];
    for (int i = 1; i < n; i++) {
        ans += v[i];
        ans /= 2.0;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int MOD = 1000000007;
const int INF = 2000000000;
const long double PI = acosl(-1);
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
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; }

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int H, W, N;
    cin >> H >> W >> N;
    if (H >= W) {
        int ans = N/H + (N%H!=0);
        pa;
    }
    else {
        int ans = N/W +(N%W!=0);
        pa;
    }
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_a && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_a && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_a && sh submit.sh
*/


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int a,x[3000],y[3000];
	for(a=0;a<3000;a++) {
	scanf("%d %d",&x[a],&y[a]);
	if(x[a]==0&&y[a]==0){
		break;
	}
}
	for(a=0;a<3000;a++) {
	if(y[a]<x[a])
		printf("%d %d\n",y[a],x[a]);
	else if(x[a]==0&&y[a]==0) {
		break;
	}
	else
		printf("%d %d\n",x[a],y[a]);
	}
	return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,k,x;cin>>n>>k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>x;vec[i]=x;
    }
    sort(all(vec),greater<int>());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=vec[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580
#include <stdio.h>


int main()
{
  int i = 3, n, ext, tmp;
  scanf("%d", &n);
  while(i <= n) {
    if(0 == (i % 3)) {
      printf(" %d", i);
      i++;
    } else {
      tmp = i;
      while(ext != tmp) {
        ext = tmp % 10;
        tmp = tmp / 10;
        if(ext == 3) {
          printf(" %d", i);
          break;
        }
      }
      i++;
    }
  }
  printf("\n");
  return 0;
}

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

int a[105];

signed main(){
  
  int n;
  cin>>n;
  
  int sum = 0;
  
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum += a[i];
  }
  
  int ans = 1e9;
  int S = 0;
  
  for(int i=0;i<n-1;i++){
    S += a[i];
    int S2 = sum - S;
    ans = min( ans, abs( S - S2 ) );
  }  

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
	char s[100000];
	scanf("%s",s);
	int i,ans=0;

	for(i=1;i<strlen(s);i++){
		if(s[i]!=s[i-1])
			ans++;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int A,B;
    cin>>A>>B;
    int cur=1;
    int num=0;
    while(cur<B)
    {
        cur--;
        num++;
        cur+=A;
    }
    cout<<num<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

using namespace std;
typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

int N, A, B;

void solve() {
	cin >> N >> A >> B;
	int a = B - A;
	if (a % 2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;
}

int main() {
	solve();
	return 0;
}

//数値を文字列に
string tostring(int num) {
	string str;
	while (num) {
		char x = '0' + num % 10;
		str.push_back(x);
		num /= 10;
	}
	reverse(str.begin(), str.end());
	return str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int D; cin >> D;
    if(D == 25) cout << "Christmas";
    else if(D == 24) cout << "Christmas Eve";
    else if(D == 23) cout << "Christmas Eve Eve";
    else if(D == 22) cout << "Christmas Eve Eve Eve";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(i % 2 == 0 && a[i] % 2 == 1)ans++;
	}
	cout << ans << endl;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  vector<vector<int>> ans(H+2,vector<int>(W+2,0));
  for(int i=0;i<H;i++){
    cin>>S.at(i);
  }
  for(int x=1;x<=H;x++){
    for(int y=1;y<=W;y++){
      if(S[x-1][y-1]=='#'){
        ans[x-1][y-1]++;
        ans[x][y-1]++;
        ans[x+1][y-1]++;
        ans[x-1][y]++;
        ans[x+1][y]++;
        ans[x-1][y+1]++;
        ans[x][y+1]++;
        ans[x+1][y+1]++;
      }
    }
  }
  for(int x=1;x<=H;x++){
    for(int y=1;y<=W;y++){
      if(S[x-1][y-1]=='#'){
        cout<<'#';
      }else{
        cout<<ans[x][y];
      }
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
    int n,q;cin>>n>>q;
    list<int > a[n];
    while(q--){
        int i;cin>>i;
        if(i==0){
            int t,x;cin>>t>>x;
            a[t].push_back(x);
        }
        if(i==1){
            int t;cin>>t;
            if(a[t].empty()){
                cout<<endl;
                continue;
            }
            for(auto it=a[t].begin();it != a[t].end();){
                cout<<*it;
                it++;
                if(it==a[t].end())
                    continue;
                cout<<" ";
            }
            cout<<endl;
        }
        if(i==2){
            int t,s;cin>>s>>t;
            a[t].splice(a[t].end(),a[s]);
        }
    }
    return 0;
}



Measured memory_bytes: 18636