akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, L;
  cin>>N>>L;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  bool can = false;
  int index;
  for(int i=0;i<N-1;++i) {
    if(A[i]+A[i+1]>=L) {
      index = i+1;
      can = true;
      break;
    }
  }
  if(!can) {
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  for(int i=1;i<index;++i) {
    cout<<i<<endl;
  }
  for(int i=N-1;i>=index;--i) {
    cout<<i<<endl;
  }
}



Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t; cin >> s >> t;
    ll res = 0;
    rep(i,s.size())if(s[i] != t[i])res++;
    cout << res << endl;
    
}

Measured memory_bytes: 3800
#include <stdio.h>

#define hash(x) (((x) - 160) / 5)

int dist[6];

int main(void)
{
	int n;
	int i, j;
	
	scanf("%d", &n);
	while (n-- > 0){
		int height;
		
		scanf("%d.%*d", &height);
		if (height < 165) dist[0]++;
		else if (height >= 185) dist[5]++;
		else dist[hash(height)]++;
	}
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		for (j = 0; j < dist[i]; j++){
			putchar('*');
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 616
S=list(input())
a=[S[0],S[1]]
b=[S[2],S[3]]
c=int("".join(a))
d=int("".join(b))
if 0<c<13 and 0<d<13:
  print("AMBIGUOUS")
if 0<c<13 and (d<1 or 12<d):
  print("MMYY")
if (c<1 or 12<c) and 0<d<13:
  print("YYMM")
if (c<1 or 12<c) and (d<1 or 12<d):
  print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;

string s, t;
vector<int> a[28];
ll ans;

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        a[s[i]-'a'].push_back(i+1);
    }
    
    int cur = -1;
    int n = s.size();
    for (int i = 0; i < t.size(); i++) {
        int c = t[i]-'a';
        if (a[c].size() == 0) {
            cout << "-1\n";
            return 0;
        }
        
        int x = upper_bound(a[c].begin(), a[c].end(), cur) - a[c].begin();
        if (x == a[c].size()) {
            x = 0;
            ans += n;
        }
        
        cur = a[c][x];
        if (i == t.size()-1) {
            ans += cur;
        }
    }
    
    cout << ans << '\n';
}

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

const int MAX=25;

string dir;
int chi,par,t;
vector<int> pars(MAX,1);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i=0;i<MAX-1;++i) pars[i+1]=pars[i]*2;
    while(cin >> dir,dir!="#"){
        reverse(dir.begin(),dir.end());
        chi=(dir[0]=='h'?0:90),par=1,t=(dir[0]=='h'?5:4);
        for (int i=0;t<dir.size();++i){
            if (pars[i]!=par) par*=2,chi*=2;
            if (dir[t]=='h') chi-=45,t+=5;
            else chi+=45,t+=4;
            if (chi<0) chi+=par*360;
        }
        if (par>1) cout << chi << '/' << par << '\n';
        else cout << chi << '\n';
    }
}


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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

	int h , a;
	cin >> h >> a;
	cout << (h/a) + ((h % a != 0)?1:0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int cnt=0,maxv=0;
    for(int i=0;i<n;i++){
        int d1,d2;
        cin>>d1>>d2;
        if(d1==d2)cnt++;
        else cnt=0;
        maxv=max(maxv,cnt);
    }
    if(maxv>=3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		long r = 0;
		long g = 0;
		long b = 0;
		
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (c == 'R') r++;
			if (c == 'G') g++;
			if (c == 'B') b++;
		}
		
		long ans = r * g * b;
		
		for (int st = 0; st < n - 2; st++) {
			for (int dist = 1; st + dist * 2 < n; dist++) {
				char si = s.charAt(st);
				char sj = s.charAt(st + dist);
				char sk = s.charAt(st + dist * 2);
				if (si != sj && sj != sk && sk != si)
					ans--;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 27528
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var A = strShift().split("/");
  A[0] = "2018";
  
  return A.join("/");
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
2017/01/07
`);

Measured memory_bytes: 7372
//***Faithless is he that says farewell when the road darkens***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll mod=1000000007;
ll a[2001];
int main()
{
   ll n,k,an=0;
   cin>>n>>k;

   forn(i,n) cin>>a[i];

   for(ll i=0;i<n;i++){
      ll t=0,b=0;
      for(ll j=0;j<n;j++)
         if(a[j]>a[i]) 
            t++;
      for(ll j=0;j<i;j++)
         if(a[j]>a[i])
            b++;
      ll aa=((k*b)%mod+(((((k-1)*k)/2)%mod)*t)%mod)%mod;
      an=(an+aa)%mod;
   }

   cout<<an;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
 const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll inverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
vll v[100000+1];
ll ans=1;
ll factorial[3*100000+1];
long long binomial_coefficient(int n, int k) 
{
    return (factorial[n] * (inverse(factorial[k]) % mod * inverse(factorial[n - k]) % mod)%mod)%mod;
}
void dfs(int u,int p=-1)
{
    if(ans==0)
    return;
    if(p==-1)
    {
        ans*=k;
        if(v[u].size()>k-1)
     {
        ans=0;
        return ;
     }
     //deb(ans);
    ans*=(binomial_coefficient(k-1,v[u].size())*factorial[v[u].size()])%mod;
    //deb(ans);
    ans%=mod;
    }
    else
    {
          if(v[u].size()>k-1)
     {
        ans=0;
        return ;
     }
    ans*=(binomial_coefficient(k-2,v[u].size()-1)*factorial[v[u].size()-1])%mod;
    ans%=mod;
    }
    //deb(u);
    //deb(ans);
    for(auto x:v[u])
    {
        if(x!=p)
        {
           dfs(x,u); 
           if(ans==0)
           return ;
        }
    }
    
}
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
cin>>k;
m=n-1;
while(m--)
{
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
}
//return ;
int MAXN=100000+23;
factorial[0] = 1;
for (int i = 1; i <= MAXN; i++) {
    factorial[i] = factorial[i - 1] * i % mod;
}
dfs(1);
cout<<ans;
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 12672
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A
// Combinatorial - Coin Changing Problem
// status: []

#define SUBMIT

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_M = 20;
const int MAX_N = 50000;

int c[MAX_M];

// dp[i] i円支払うときの最小枚数
int dp[MAX_N + 1];
int n, m;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(55 4
1 5 10 50
)";
    stringstream stream(program_input_str);
#endif
    memset(dp, 0, sizeof(dp));
    stream >> n >> m;
    for (int i = 0; i < m; ++i) {
        stream >> c[i];
    }

    iota(dp, dp + n + 1, 0);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i + 1 >= c[j]) dp[i + 1] = min<int>({dp[i + 1 - c[j]] + 1, dp[i] + 1, dp[i + 1]});
            else dp[i + 1] = min(dp[i] + 1, dp[i + 1]);
        }
    }

    cout << dp[n] << endl;
    return 0;
}


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

int main () {
  int n, l, ans;
  cin >> n >> l;
  if(l >= 0) {
    for(int i=2;i<=n;i++) {
      ans += l+i-1;
    }
  }
    else {
      for(int i=1;i<n;i++) {  
        if(l+i-1 == 0)
          ans += l+n-1;
        ans += l+i-1;
      }
    }
    cout << ans;
}


Measured memory_bytes: 256
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)

K=int(input())
count=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            count+=gcd(a,b,c)
print(count)

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 1e6 + 1e3, Mod = 1e9 + 7;

int n, f[N], sum = 0;

int main () {

	File();

	n = read();

	f[n] = n; f[n - 1] = 1ll * n * n % Mod;
	Fordown (i, n - 2, 1) {
		(sum += f[i + 3]) %= Mod;
		f[i] = (f[i + 1] + 1ll * (n - 1) * (n - 1) + (i + 1) + sum) % Mod;
	}
	printf ("%d\n", f[1]);

	return 0;

}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    while(a%2==0){
      a/=2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main()
{
    int n; cin >> n;
    int ans = 0;
    int highest = 0;
    vector <ll> H(n, 0);
    for (int i = 0; i < n; i ++){
        cin >> H.at(i);
    }

    for (auto h: H){
        if  (highest<=h) {
            ans += 1;
            highest = h;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
unittest
{
	assert( [ "198 1.10" ].parse.expand.solve == 217 );
	assert( [ "1 0.01" ].parse.expand.solve == 0 );
	assert( [ "1000000000000000 9.99" ].parse.expand.solve == 9990000000000000 );
}



import std.conv;
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 ab = input.front.split;
	return tuple( ab[ 0 ].to!( long ), ab[ 1 ].to!( dchar[] ) );
}

auto solve( long a, dchar[] b )
{
	// 実数による誤差防止のため整数で計算する
	return a * b.replace( ".", "" ).to!( long ) / 100;
}


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

int n, h[200111];
long long a[200111], fen[200111];
pair<int, int> tinggi[200111];

void update(int id, long long val) {
	for (int i = id; i <= n; i += i & -i) fen[i] = max(fen[i], val);
}

long long query(int id) {
	long long res = 0;
	for (int i = id; i >= 1; i -= i & -i) res = max(res, fen[i]);
	return res;
}

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

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		tinggi[i].first = h[i];
		tinggi[i].second = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	sort(tinggi + 1, tinggi + n + 1);

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		long long best = query(tinggi[i].second - 1);
		update(tinggi[i].second, best + a[tinggi[i].second]);

		ans = max(ans, best + a[tinggi[i].second]);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans=1;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	if(ans<k) ans+=ans;
    	else ans+=k;
    }
    cout<<ans;
    return 0;
}



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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(12);
	
	int n;
	cin >> n;
	double p[n];
	for (int i = 0; i < n; i++) cin >> p[i];
	
	double dp[n + 1];
	fill(dp, dp + n + 1, 0);
	dp[0] = 1 - p[0];
	dp[1] = p[0];
	for (int i = 2; i <= n; i++) {
		for (int j = i; j >= 0; j--) {
			dp[j] = dp[j]*(1 - p[i - 1]);
			if (j) dp[j] += dp[j - 1]*p[i - 1];
		}
	}
	
	double ans{};
	for (int i = n/2 + 1; i <= n; i++) ans += dp[i];
	cout << ans;
}

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

int main()
{
	int N; cin >> N;
	vector<char> C(N);
	rep(i, N) cin >> C[i];

	int ans = 0;
	int l = 0;
	int r = N - 1;

	while (l < r) {
		if ((C[l] == 'W') && (C[r] == 'R')) {
			ans++;
			l++;
			r--;
		}
		else if (C[l] == 'W') {
			r--;
		}
		else {
			l++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, k;
    ll a[1110], sum[1110];
    int q[10000][50];
    bool u[1100000];
    vector<ll> v;

    cin >> n >> k;
    sum[0] = 0;
    REP(i, n)
    {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            v.push_back(sum[j + 1] - sum[i]);
            // cout << v[v.size() - 1] << endl;
        }
    }

    SORT(v);

    ll b = 0;
    ll tmp = v[v.size() - 1];
    while (tmp > 0)
    {
        tmp /= 2;
        b++;
    }

    b--;

    //ll b = ceil(log2l(v[v.size() - 1])) - 1;

    ll res = 0;

    while (true)
    {
        if (b < 0)
        {
            cout << 0 << endl;
            return 0;
        }

        ll cnt = 0;
        REP(i, v.size())
        {
            if (v[i] & (1ll << b))
                cnt++;
        }

        if (cnt >= k)
            break;

        b--;
    }

    REP(j, v.size())
    {
        if (!(v[j] & (1ll << b)))
        {
            v[j] = 0;
            //cout << "#" << j << endl;
        }
    }

    res += 1ll << b;

    for (ll i = b - 1; i >= 0; i--)
    {
        ll cnt = 0;
        for (int j = v.size() - 1; j >= 0; j--)
        {
            if (v[j] & (1ll << i))
                cnt++;
        }

        if (cnt >= k)
        {
            res += 1ll << i;

            REP(l, v.size())
            {
                if (!(v[l] & (1ll << i)))
                {
                    v[l] = 0;
                    //cout << "#" << l << endl;
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6256
#include <iostream>

using namespace std;

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

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

  int sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <utility>
#include <queue>

#define ii pair<int, int>
#define iii pair<int, ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, m, l, a, b, c, dist[305][305], sisa[305][305], k, s, t, nxtd, nxts;
	bool done[305];
	iii u;
	ii v;
	vector<ii> adj[305];
	priority_queue<iii> pq;
	scanf("%d %d %d", &n, &m, &l);
	while (m--) {
		scanf("%d %d %d", &a, &b, &c);
		adj[a].pb(mp(b, c));
		adj[b].pb(mp(a, c));
	}
	for (int i = 1; i <= n; i++) {
		done[i] = false;
		for (int j = 1; j <= n; j++)
			dist[i][j] = 1000;
	}
	scanf("%d", &k);
	while (k--) {
		scanf("%d %d", &s, &t);
		if (done[s]) {
			if (dist[s][t] > 500)
				puts("-1");
			else
				printf("%d\n", dist[s][t]);
			continue;
		}
		dist[s][s] = 0;
		sisa[s][s] = l;
		pq.push(mp(0, mp(l, s)));
		while (pq.size()) {
			u = pq.top();
			pq.pop();
			b = -u.fi;
			c = u.se.fi;
			a = u.se.se;
			if (dist[s][a] < b)
				continue;
			if ((dist[s][a] == b) && (sisa[s][a] > c))
				continue;
			for (int i = 0; i < (int) adj[a].size(); i++) {
				v = adj[a][i];
				if (v.se <= c) {
					nxtd = b;
					nxts = c - v.se;
					if (nxtd > dist[s][v.fi])
						continue;
					if ((nxtd == dist[s][v.fi]) && (nxts < sisa[s][v.fi]))
						continue;
					dist[s][v.fi] = nxtd;
					sisa[s][v.fi] = nxts;
					pq.push(mp(-nxtd, mp(nxts, v.fi)));
				}
				else if (v.se <= l) {
					nxtd = b + 1;
					nxts = l - v.se;
					if (nxtd > dist[s][v.fi])
						continue;
					if ((nxtd == dist[s][v.fi]) && (nxts < sisa[s][v.fi]))
						continue;
					dist[s][v.fi] = nxtd;
					sisa[s][v.fi] = nxts;
					pq.push(mp(-nxtd, mp(nxts, v.fi)));
				}
			}
		}
		done[s] = true;
		if (dist[s][t] > 500)
			puts("-1");
		else
			printf("%d\n", dist[s][t]);
	}
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int h,w;
  bool flg,FLG,tmp,TMP;
  while(cin >> h >> w && h||w){
    flg = true,tmp=false;
    for(int i=0;i<h;i++){
      FLG = flg,TMP=tmp;
      for(int j=0;j<w;j++){
	cout << (FLG ? "#" : ".");
	swap(FLG,TMP);
      }
      cout << endl;
      swap(flg,tmp);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc067/tasks/arc067_a
# C - Factors of Factorial
"""
m > n impossible
m = n, possible only when n = 1


"""

H = gi()
W = gi()
cs = [[0 for x in range(10)] for i in range(10)]

for i in range(10):
    for j in range(10):
        cs[i][j] = gi()

for mid in range(10):
    for u in range(10):
        for v in range(10):
            cs[u][v] = min(cs[u][v], cs[u][mid] + cs[mid][v])
            cs[v][u] = min(cs[v][u], cs[v][mid] + cs[mid][u])

ans = 0
for i in range(H):
    for j in range(W):
        a = gi()
        if a >= 0:
            ans += cs[a][1]
print(ans)


Measured memory_bytes: 12268
import java.util.Arrays;
import java.util.Scanner;

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

		final int n = sc.nextInt();
		
		for(int i = 1; i <= n; i++){
			if(i % 3 == 0 || (i + "").contains("3")){
				System.out.print(" " + i);
			}
		}
		System.out.println();
	}

}

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

int res = 0;

void sum(int n)
{
    if(n < 10)
    {
        res+=n;
    }
    else
    {
        res+=n%10;
        sum(n/10);
    }
}

int main()
{
    int n;
    cin>>n;
    sum(n);
    if(n % res == 0)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int n;
vector<int> v;

ll operator+(P<ll,ll> a, P<ll,ll>b){
  return a.first + a.second + b.first + b.second;
}

P<ll,ll> dp(int l, int r){
  static ll mm[401][401];
  static ll sum[401][401];
  static bool used[401][401];
  static const ll inf = (1e+18);

  if(l == r) return {0,v[l]};

  if(used[l][r]) return {mm[l][r],sum[l][r]};
  else used[l][r] = true;

  mm[l][r] = inf;
  sum[l][r] = v[r];

  for(int i = l; i < r; ++i){
    ChangeMin(mm[l][r], dp(l,i) + dp(i+1,r));
    sum[l][r] += v[i];
  }

  return {mm[l][r],sum[l][r]};
}

int main(){
  cin >> n;
  v = vector<int>(n); cin >> v;
  cout << dp(0,n-1).first << endl;
  return 0;
}


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

int n;
int m;
int p[100000];
int y[100000];
vector<pair<int, int> > YtoP;
map<int, int> Ytoi;
int countY[100001];

int main(){
    scanf("%d%d", &n, &m);
    rep(i, m){
        scanf("%d%d", &p[i], &y[i]);
        YtoP.push_back(make_pair(y[i], p[i]));
    }
    sort(YtoP.begin(), YtoP.end());
    for(int i=0; i<YtoP.size(); i++){
        Ytoi[YtoP[i].first] = ++countY[YtoP[i].second];
    }
    
    rep(i, m){
        printf("%06d", p[i]);
        printf("%06d", Ytoi[y[i]]);
        putchar('\n');
    }
    return 0;
    
}


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


int main(){
    long long mod = 1000000007;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<long long> a(n, 0);

    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
        if(i > 0)
        a[i] += a[i-1];
    }

    long long dp[n][n];
    memset(dp, 0, sizeof(dp));

    for(int i = 1 ; i < n ; i++){
        for(int j = 0; j + i < n ; j++){
            dp[j][i + j] = LONG_LONG_MAX;
            for(int k = j ; k < j + i ; k++){
                dp[j][i + j] = min(dp[j][i + j], dp[j][k] + dp[k+1][i+j]);
            }
            long long x = a[i + j];
            if(j > 0)x -= a[j-1];
            dp[j][i+j] += x;
        }
    }
    cout<<dp[0][n-1]<<endl;

    return 0;
}


Measured memory_bytes: 1664
from itertools import accumulate


def main():
    n = int(input())
    array = [int(x) for x in input().split()]
    acc = accumulate(array)
    mod = 10 ** 9 + 7
    ans = 0
    for i, ai in enumerate(acc):
        if i == n - 1:
            continue
        ans += ai * array[i + 1]
        ans %= mod
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 31476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans;
void Main(){
    ll n;cin>>n;
    ans=n;
    vector<pair<ll,ll>> robot(n);
    For(i,0,n) cin>>robot[i].first>>robot[i].second;
    sort(ALL(robot));
    ll init=robot[0].first+robot[0].second;
    For(i,1,n){
        if(init>robot[i].first-robot[i].second){
            ans--;
            init=min(init,robot[i].first+robot[i].second);
        }
        else{
            init=robot[i].first+robot[i].second;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;


int main(){

    char buf[1100],word[1100];
    int length = 0;

    fgets(buf,1100,stdin);
    bool firstFLG = true;

    for(int i=0;buf[i]!='\n' && buf[i] != '\0';i++){
    	if(buf[i] == ' ' || buf[i] == '.' || buf[i] == ','){
    		if(length >= 3 && length <= 6){
    			if(firstFLG){
    				printf("%s",word);
    				firstFLG = false;
    			}else{
    				printf(" %s",word);
    			}
    		}
    		length = 0;
    	}else{
    		word[length] = buf[i];
    		word[length+1] = '\0';
    		length++;
    		if(buf[i+1] == '\n'){
    			if(length >= 3 && length <= 6){
					if(firstFLG){
						printf("%s",word);
						firstFLG = false;
					}else{
						printf(" %s",word);
					}
				}
				length = 0;
    		}
    	}
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

vector<P> p;


int main(){
  int N;
  cin >> N;
  int v[N];
  int c[N];
  int ans = 0;
  rep(i,N){
    cin >> v[i];
  }
  rep(i,N){
    cin >> c[i];
  }
  rep(i,N){
    if(v[i] - c[i] > 0) ans += (v[i] - c[i]);
  }
  cout << ans << endl;
}



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

int main(void){
    char s[200000];
    char *fst, *snd;
    int a = 'A';
    int z = 'Z';
    int i;
    scanf("%s",s);
    fst = strchr(s,a);
    snd = strrchr(s,z);
    printf("%ld\n",(snd - s) - (fst - s) + 1);
    return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
x, y, z = [], [], []

for _ in range(N):
    _x, _y, _z = map(int, input().split())
    x.append(_x)
    y.append(_y)
    z.append(_z)

cand = []

for sgn_x in [-1, 1]:
    for sgn_y in [-1, 1]:
        for sgn_z in [-1, 1]:
            pop_score = list(map(sum,
                                 zip([sgn_x * _x for _x in x],
                                     [sgn_y * _y for _y in y],
                                     [sgn_z * _z for _z in z])))
            pop_score.sort(reverse=True)
            cand.append(sum(pop_score[:M]))
print(max(cand))

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

const int N = 1e5 + 1;

const int maxn = 2510;

void solve() {
    int n, a;
    cin >> n >> a;
    vi x(n);
    vector<vvll> dp(n + 1, vvll(n + 1, vll(maxn)));
    dp[0][0][0] = 1;
    for2(i, 1, n){
        cin >> x[i - 1];
        forn(j, n + 1){
            forn(z, maxn) dp[i][j][z] = dp[i - 1][j][z];
        }
        forn1(j, n + 1){
            for1(z, x[i - 1], maxn){
                dp[i][j][z] += dp[i - 1][j - 1][z - x[i - 1]];
            }
        }
    }
    ll ans = 0;
    forn1(i, n + 1) ans += dp[n][i][i * a];
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 55440
function Main(input) {
	var inputs = input.split(" ");
	var a = inputs[0];
	var b = inputs[1];

	var valid = true;
	if (a > 8 || b > 8) {
		valid = false;
	}

	console.log(valid ? "Yay!" : ":(");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# 写経

N, K = map(int, input().split())
a = list(map(int, input().split()))

s = [0 for _ in range(50)]
# s[j] = aでj桁目のbitが立っている数 -> xにbitを立てないときのf(x)の増加量に関係
# N - s[j] = 〃 bitが立っていない数 -> xにbitを立てたときのf(x)の増加量に関係

dp = [[0 for _ in range(2)] for _ in range(50)]
# dp[桁][K未満未確定==0/確定==1] = 最大値

for aa in a:
    for j in range(50):
        if (aa >> j) & 1:
            s[j] += 1

for j in sorted(range(45 + 1), reverse=True):
    if (K >> j) & 1:
        # xにbit立てられる
        # 元々bit立っていなかった分だけf(x)増加
        dp[j][0] = dp[j + 1][0] + ((N - s[j]) << j)
        if dp[j + 1][1] == 0:
            dp[j][1] = dp[j + 1][0] + (s[j] << j) # 未満確定の最大値候補が計算されたことがない場合、未満->未満の推移は見ない
        else:
            dp[j][1] = max(
                dp[j + 1][1] + (s[j] << j),
                dp[j + 1][1] + ((N - s[j]) << j),
                dp[j + 1][0] + (s[j] << j)
            )
    else:
        # xにbit立てられない
        # 元々bit立っていた分だけf(x)増加
        dp[j][0] = dp[j + 1][0] + (s[j] << j)
        if dp[j + 1][1] == 0:
            dp[j][1] = 0 # 未満確定の最大値候補が計算されたことがない場合、未満->未満の推移は見ない
        else:
            dp[j][1] = max(
                dp[j + 1][1] + (s[j] << j),
                dp[j + 1][1] + ((N - s[j]) << j)
            )
print(max(dp[0][0], dp[0][1]))


Measured memory_bytes: 14588
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  vi a(5);
  rep(i,5) cin >> a[i];

  int min_index = -1;
  int min_time = INF;

  rep(i,5)
  {
    if(min_time > a[i] % 10 && a[i] % 10 != 0)
    {
      min_time = a[i] % 10;
      min_index = i;
    }
  }

  int sum = 0;

  rep(i,5)
  {
    if(i == min_index)
    {
      sum += a[i];
    }
    else
    {
      sum += kiriage(a[i],10) * 10;
    }
  }
  
  cout << sum << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n) for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	/*---- continue Coding ;----*/

	int a, b, c;
	cin >> a >> b >> c;
	double ans = (double) a/c;
	if(ans <= b){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";
	}

	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  string t="abcdefghijklmnopqrstuvwxyz";
  llvec d;
  string S="";
  ll p = 26;
  N=N-1;
  while(N>=0){
    d.push_back(N%p);
    N /=p;
    N-=1;
  }
  reverse(ALL(d));
  for(auto id:d){
    cout << t[id];
  }
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int n, e;

vector<int> graph[100005];
int vis[100005];
int dp[100005];

int solve(int node){
	if(node > n) return -1;
	if(dp[node] != -1) return dp[node];
	
	vis[node] = 1;
	if(graph[node].size() == 0) return 0;
	
	int best = 0;
	for (int i = 0; i < graph[node].size(); ++i)
		best = max(best, solve(graph[node][i]));
	
	dp[node] = max(best + 1, dp[node]);
	return dp[node];
}

int main(){
	cin>>n>>e;
	for (int i = 0; i < e; ++i){
		int a ,b;
		cin>>a>>b;
		graph[a].push_back(b);
	}

	memset(dp , -1, sizeof dp);
	int ans = 0;
	for(int i = 1; i<= n; ++i)
		if(!vis[i])
			ans = max(ans, solve(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8576
def cal(n1, n2, o):
    if o == "+":
        return str(n1 + n2)
    elif o == "-":
        return str(n1 - n2)
    elif o == "*":
        return str(n1 * n2)

S = input().split()
i = 0
while len(S) > i:
    if S[i] == "+" or S[i] == "-" or S[i] == "*":
        r = cal(int(S[i-2]), int(S[i-1]), S[i])
        del S[i-2:i+1]
        S.insert(i-2, r)
        i = 0
    else:
        i += 1

print(S[0])



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)
#define SP(i)           fixed << setprecision(i) 

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741
ll n;
ll arr[405];
ll dp[405][405];
ll presum[405];

ll calc(ll p, ll q){
	if (p>=q)return dp[p][q]=0;
	if (dp[p][q]!=inf)return dp[p][q];
	rep(i,p,q){
		if (p<=0)dp[p][q]=min(dp[p][q],presum[q]+calc(p,i)+calc(i+1,q));
		else dp[p][q]=min(dp[p][q],presum[q]-presum[p-1]+calc(p,i)+calc(i+1,q));
	}
	return dp[p][q];
}

void solve() {
    cin>>n;
    rep(i,0,n){
    	cin>>arr[i];
    	presum[i]=arr[i];
    }
    rep(i,1,n)presum[i]+=presum[i-1];
    rep(i,0,405){
    	rep(j,0,405)dp[i][j]=inf;
    }
    cout<<calc(0,n-1)<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 1536
def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


n = intin()
t, a = intin()
hlist = intina()

minsub = 999999999999999999999999999999999999999
minidx = None
for i, h in enumerate(hlist):
    temp = t - h * 0.006
    if abs(a - temp) < minsub:
        minsub = abs(a - temp)
        minidx = i

print(minidx + 1)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7
#define INF (int) 2e9

int main(){
    int n;
    cin >> n;
    int a[n], b[n] = {};
    rep(i, n){
        cin >> a[i];
    }

    int m = 0;
    for (int i = n; i >=1; i--){
        int ma = n/i * i;
        int s = 0;
        for (int j = ma; j > i; j-=i){
            s += b[j-1];
        }
        if(s%2!=a[i-1]){
            b[i-1] = 1;
            m++;
        }
    }

    cout << m << endl;
    for (int i = 0; i < n; i++){
        if(b[i]==1){
            cout << i+1 << " ";
        }
    }

    cout << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 2432
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    string a;
    cin>>a;
    int cnt=1;
    char c = a[0];
    for(int i=1;i<n;i++){
        if(a[i]==c){
            continue;
        }
        else{
            c = a[i];
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 512
import java.util.*;


class Main {
    public static void main(String[] args) {
   		Scanner sc=new Scanner(System.in);
   		String str=sc.next();
   		int num=0;
   		for(int i=0;i<str.length();i++){
   			if(str.charAt(i)=='+')num++;
   			else num--;
   		}
   		System.out.println(num);
   		sc.close();
    }
}

Measured memory_bytes: 35628
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n,ans=0,t[1000],u[1000];
  bool visited[1000];
  map<int,int> change;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i];
    change[t[i]]=i;
    u[i]=t[i];
    visited[i]=false;
  }
  sort(u,u+n);
  for(int i=0;i<n;i++){   
    int w=i,x=0,y=0,z=10000;
    while(!visited[w]){
      z=min(z,t[w]);
      y+=t[w];
      x++;
      visited[w]=true;
      w=change[u[w]];
    }
    if(x>=2)ans+=min(y+z+u[0]*(x+1),y+z*(x-2));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1264