akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

int main(){
    string s; cin >> s;
    set<char> se;
    rep(i, s.size()) se.insert(s[i]);
    if(se.size() == 26) cout << "None" << endl;
    else{
        char c = 'a';
        while(1){
            if(!se.count(c)){
                cout << c << endl;
                return 0;
            }
            c++;
        }
    }
}


Measured memory_bytes: 3732
#include <stdio.h>

int main(){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if((a+b)>=c){
        printf("Yes\n");
    }
    
    else{
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
using namespace std;;
 
int main() {
  int N,M; cin >> N >> M;
  vector<pair<int,int>> pair(M);
  rep(i,0,M) {
    int a,b; cin >> a >> b;
    pair[i] = make_pair(a,b);
  }
   
  map<int,int> secondS;
  vector<int> firstS;
  for(auto x: pair) {
    if(x.first == 1) firstS.push_back(x.second);
    if(x.second == N) secondS[x.first]=1;
  }
  
  int size = secondS.size();
  for(int x: firstS) {
    if (secondS[x] == 1) {
        cout << "POSSIBLE" << endl; return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 14404
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

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

vector<ll> divisor(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) {
				res.push_back(n / i);
			}
		}
	}
	sort(all(res));
	return res;
}

bool is_prime(ll x) {
	for (ll i = 2; i * i <= x; ++i) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}


ll n, a, b, c;
int main() {
	cin >> n;
	vector<pair<ll, pair<ll, ll>>>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second.first >> v[i].second.second;
		if (v[i].second.second > 0) {
			a = v[i].first;
			b = v[i].second.first;
			c = v[i].second.second;
		}
	}


	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			ll height = c + abs(i - a) + abs(j - b), mon = 0;
			for (int k = 0; k < n; ++k) {
				if (max(height - abs(i - v[k].first) - abs(j - v[k].second.first), 0ll) == v[k].second.second) {
					++mon;
				}
				else {
					break;
				}
			}

			if (mon == n) {
				cout << i << " " << j << " " << height << endl;
				return 0;
			}
		}
	}
}

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

int main(){
    int N;
    long long K;
    cin >> N >> K;
    long long A[100000],B[100000];
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];

    int t;
    for(t=30;t>=0;t--){
        if(K & (1<<t)) break;
    }
    long long vmax[32];
    for(int i=0;i<=t+1;i++) vmax[i]=0;
    for(int i=0;i<=t+1;i++){
        if(i>0 && (K&(1<<(i-1)))==0) continue;
        for(int j=0;j<N;j++){
            if(((K>>i)|(A[j]>>i))==(K>>i) && (i==0 || (A[j]&(1<<(i-1)))==0)) vmax[i]+=B[j];
        }
    }

    long long max=0;
    for(int i=0;i<=t+1;i++){
        if(max<vmax[i]) max=vmax[i];
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 1792
s = input()

rs  = s[::-1]

inds = 0
indrs = 0

for i in range(len(s)):
    if s[i] == "A":
        inds = i
        break
    
for j in range(len(rs)):
    if rs[j] == "Z":
        indrs = j
        break

indrs = len(s) - indrs

print(abs(indrs - inds))


Measured memory_bytes: 9344
N,K,Q=map(int,input().split()) #N人、K点、Q問
A=[int(input())-1 for i in range(Q)] #受験番号とリスト番号のズレを補正
P=[0]*N #持ち点
for j in range(Q):
    P[A[j]]+=1
for k in range(N):
    if P[k]>Q-K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8636
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,sum;
ll num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
string s;

int main(){
	cin >> s;
	const string t = "AKIHABARA";
	for(i=0;i<9;i++){
		if(num < s.length() && s[num] == t[i]){
			num++;
		}else if(t[i] == 'A'){
			continue;
		}else{
			dame = true;
		}
	}
	if(dame || num != s.size()){
		p("NO");
	}else{
		p("YES");
	}
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i + 1 < s.size(); i++)
    {
        if (s[i] != s[i + 1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
const int MAXN = 1e5+5;
#define rep(i,a,b)for(int i=(a);i<=(b);i++)
int n,m,a[MAXN];
int main(){
    cin>>n;
    cout <<(n-2) *180<<'\n';
    return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

string nx[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main(){
    fIO

    string s;
    cin >> s;

    int days = 0;
    string curr = s;
    int i = 0;
    while(nx[i] != s) i++;
    while(true) {
        days++;
        i = (i + 1) % 7;
        curr = nx[i];
        if(curr == "SUN") break;
    }
    cout << days;


}








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

int main() {
  int N, K;
  string S;
  char SelectedChar;
  cin >> N >> S >> K;
  SelectedChar = S.at(K-1);

  for(int i = 0; i < N; i++){
    if (S.at(i) != SelectedChar) {
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
int main() {
	int n;
	ll ans = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
S = input()
if(S == 'SUN'): ans = 7
elif(S == 'MON'): ans = 6
elif(S == 'TUE'): ans = 5
elif(S == 'WED'): ans = 4
elif(S == 'THU'): ans = 3
elif(S == 'FRI'): ans = 2
else: ans = 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int n = int(s.size());
    
    int count = 0;
    for (int i = 1; i < n; i++) if (s[i] != s[i - 1]) count += 1;
    
    cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll T[2];
ll C[2];
ll A[2];
ll B[2];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i <= 1; i++) cin >> T[i];
    for(int i = 0; i <= 1; i++) cin >> A[i];
    for(int i = 0; i <= 1; i++) cin >> B[i];
    for(int i = 0; i <= 1; i++) C[i] = (A[i] - B[i]) * T[i];
    if(C[0] < 0) {
        C[0] *= -1;
        C[1] *= -1;
    }
    if(C[1] > 0) {
        cout << 0 << endl;
        return 0;
    }
    if(-C[1] < C[0]) {
        cout << 0 << endl;
        return 0;
    }
    if(-C[1] == C[0]) {
        cout << "infinity" << endl;
        return 0;
    }
    ll delta = +C[1] + C[0];
    ll ans = 0;
    ans = 2 * (C[1] / delta) - 1;
    if(C[1] % delta == 0) ans--;
    cout << ans << endl;
    cerr << C[0] << " " << C[1] << " " << delta << endl;
    //cout << C[1] / delta << endl;
    return 0;
}


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


int main(){

string c;
cin>>c;
int a=c[0]-48;
int b=c[3]-48;
int d=c[5]-48;
int e=c[6]-48;
if(a<=2&&b<=9){
  if(d==0&&e<=4){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }

}
else{
  cout<<"TBD"<<endl;
}



return 0;}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#define atcoder(x)int TAKAHASIKUN[x] 
#include<bits/stdc++.h>

using namespace std;
int ieei(int x,int y) {
	if (x % y == 0)
		return y;
	else
		return ieei(y, x%y);
}
int main() {
	int n;
	cin >> n;

	if (n < 2)
		cout << n * 2 / ieei(2, n) << endl;
	else
		cout << n * 2 / ieei(n, 2) << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

ll ans = INF;
ll D;
ll pnum[15];
ll bonus[15];
ll G;
bool flag[15];

int main(void) {
	cin >> D>>G;
	FOR(i, 0, D)cin >> pnum[i]>>bonus[i];
	FOR(i, 0, 1025) {
		FOR(k, 0, 15)flag[k] = false;
		ll cur = G,num=i,cnt=0;
		for (int k = 0;k<10;k++) {
			if (num & 1 == 1) {
				cur -= 100 * (k + 1)*pnum[k];
				flag[k] = true;
				cnt += pnum[k];
				cur -= bonus[k];
			}
			num /= 2;
		}
		if (cur > 0) {
			REP(k, D-1,-1) {
				if (flag[k] == false&&pnum[k]>0) {
					int cnt2 = 0;
					while (cur > 0&&cnt2!=(pnum[k]-1)) {
						cur -= 100 * (k + 1);
						cnt++;
						cnt2++;
					}
					break;
				}
			}
		}
		if (cur <= 0)ans = min(ans, cnt);

	}

	ct(ans);
	return 0;
}

Measured memory_bytes: 256
#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 lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    cout << 1 - n << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

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

        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
/*input
25
*/

// Nihesh Anderson - knandy

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

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int x; cin >> x;
	if(x >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




















Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long int ll;
const int N = (int)1e5+5;

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

    int n;
    string s;
    cin>>n>>s;
    unordered_map<char,vector<int>> mp;
    mp['R'].resize(n+1);
    mp['G'].resize(n+1);
    mp['B'].resize(n+1);
    rep(i,1,n) {
        mp['R'][i] = mp['R'][i-1];
        mp['G'][i] = mp['G'][i-1];
        mp['B'][i] = mp['B'][i-1];
        mp[s[i-1]][i]++;
    }
    ll ans = 0;
    rep(i,1,n-2) {
        rep(k,i+2,n) {
            if(s[i-1]!=s[k-1]) {
                int t = 'R' + 'G' + 'B' - (s[i-1] + s[k-1]);
                char ch = (char)t;
                ans += (mp[ch][k-1]-mp[ch][i]);
                if((i+k)%2==0 && ch==s[(i+k)/2 - 1]) {
                    ans--;
                }
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3660
main :: IO()
main = getContents >>= putOut.show.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
   
formatIn :: String -> ([Int], String)
formatIn = (\(x:y:_) -> (map read $words x, y)).lines

solve :: ([Int], String) -> Int
solve (xs,ys) = head $foldl label xs ys 

label (x1:x2:x3:x4:x5:x6:_) c
    | c == 'E' =  [x4,x2,x1,x6,x5,x3]
    | c == 'N' =  [x2,x6,x3,x4,x1,x5]
    | c == 'S' =  [x5,x1,x3,x4,x6,x2]
    | c == 'W' =  [x3,x2,x6,x1,x5,x4]

Measured memory_bytes: 3520
S = [int(i) for i in input()]
K = int(input())
ans = 0
# 最初の2以上の添え字
idx = 101
for s in S:
    if s > 1:
        idx = S.index(s)
        break

# 2以上が無いなら、5000兆日後も変化なし
if idx == 101:
    ans = S[K - 1]

else:
    # 2以上があっても、添え字より前ならK出力
    if K - 1 < idx:
        ans = S[K - 1]
    else:
        ans = s

print(ans)

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

int main()
{
  int L,R,d,c=0;
  cin >> L >> R >> d;
  
  for(int i=L;i<=R;i++)
  {
    if(i%d==0)
      c++;
  }
  
  cout << c << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
ll k[20];
ll p[20];
ll ans;

int main(){
  cin >> n >> m;
  for(ll i = 0;i < m;i++){
    ll s;
    cin >> s;
    for(ll j = 0;j < s;j++){
      ll b;
      cin >> b;
      k[i] |= (1<<(b-1));
    }
  }
  for(ll i = 0;i < m;i++){
    cin >> p[i];
  }
  for(ll i = 0;i < (1 << n);i++){
    ll flag = 1;
    for(ll j = 0;j < m;j++){
      if(__builtin_popcount(k[j]&i)%2 != p[j]){
        flag = 0;
        break;
      }
    }
    ans += flag;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[100001];
ll  sum=0;
int main(){

	ll n;	cin>>n;
	
	for(int i=0; i<n; i++){
		int a;	cin>>a;
		sum+=a;
		arr[a]++;
	}
	ll q;
	cin>>q;
	while(q--){
		int a, b;
		cin>>a>>b;
		ll d = a*arr[a];
		sum-=d;
		sum+=(b*arr[a]);
		arr[b]+=arr[a];
		arr[a] = 0;
		cout<<sum<<endl;
	}


return 0;
}

Measured memory_bytes: 4404
s = gets.chomp
K = gets.to_i
#s = 5000.times.map{('a'..'z').to_a[rand(26)]}.join
#t=Time.now
#K = 5
l = s.length
sorted = l.times.map{|i|[i, s[i]]}.sort_by{|arr|arr[1]}.map{|arr|arr[0]}
ss = Array.new(K, nil)
sorted.each do |i|
    next if ss[K-1] && ss[K-1][0] < s[i]
    cnt = -1
    right = [l, i+K].min
    (i...right).each do |j|
        str = s[i..j]
        next if cnt == K - 1
        next if ss.include?(str)
        next if ss[K-1] && ss[K-1] < str
        ((cnt+1)...K).each do |k|
            if !ss[k] || ss[k] > str
                (K-2).downto(k) do |kk|
                    ss[kk+1] = ss[kk]
                end
                ss[k] = str
                cnt = k
                break
            end
        end
    end
end

puts ss[K-1]
#p Time.now- t

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


int  main() {
	int n, i = 0 , j = 0;
	string s, t;
	cin >> n;
	n = n * 2;
	bool whichOne = true;
	cin >> s >> t; 
	
	while(n--){
	    if(whichOne)
	        cout << s[i++];
	    if(!whichOne)
	        cout << t[j++];
	    
	    whichOne = !whichOne;
	}
	         
   return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, m, l;
    cin >> n >> m >> l;
    if (n >= l) {
        cout << 0 << endl;
    } else {
        if (n+m < l) {
            cout << "NA" << endl; 
        } else {
            cout << l - n << endl;
        }
    }
}


Measured memory_bytes: 3112
import java.util.*;

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

    ArrayList<Integer> a = new ArrayList<Integer>(n);

    for (int i=0 ; i<n ; i++){
      a.add(sc.nextInt());
    }

    int cnt=0;
    int ans=0;

    for (int i=0 ; i<n ; i++){
      if (i+1==n){break;}
      if(a.get(i)>=a.get(i+1)){
          cnt++;
          ans = (ans<cnt) ? cnt:ans;
      }else{
          ans = (ans<cnt) ? cnt:ans;
          cnt=0;
      }
    }


    System.out.println(ans);
  }
}

Measured memory_bytes: 65476
use std::io;


fn main() {
    let n = read_one::<usize>();
    if n > 999 {
        println!("ABD");
    } else {
        println!("ABC");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(readline())
a = [int(readline()) for _ in range(n)]
ans = 0
for v in Counter(a).values():
    ans += 1 if v % 2 == 1 else 0
print(ans)


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

int main() {

    string s;
    map<string, int> dias;
    dias["SUN"] = 7;
    dias["MON"] = 6;
    dias["TUE"] = 5;
    dias["WED"] = 4;
    dias["THU"] = 3;
    dias["FRI"] = 2;
    dias["SAT"] = 1;

    cin >> s;
    cout << dias[s];

    return 0;
}


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

int main(){
  //小数点以下12桁を表示させるためのおまじない。
  cout << fixed << setprecision(12);
  
  int s;
  cin>>s;
  
  int h = s / (60 * 60);
  s %= 60 * 60;
  int m = s / 60;
  s %= 60; 

  cout<<h<<":"<<m<<":"<<s<<endl;
  
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main() {
	int a[3];
	int i, j;
	int s;
	int m = 300;
	
	for (i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (i != j) {
				s = a[i] + a[j];
				if (s < m) {
					m = s;
				}
			}
		}
	}
	printf("%d\n", m);
	return 0;
}

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

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    // p[i][0]...市, p[i][1]...県, p[i][2]...誕生年, p[i][3]...県内の順番
    int[][] p = new int[M][4];

    for (int i = 0; i < M; i++) {
      p[i][0] = i; 
      p[i][1] = Integer.parseInt(sc.next());
      p[i][2] = Integer.parseInt(sc.next());
    }

    sc.close();

    Arrays.sort(p, (o1, o2) -> o1[1] == o2[1] ? o1[2] - o2[2] : o1[1] - o2[1]);

    int k = 1;

    p[0][3] = k;
    
    for (int i = 1; i <= M - 1; i++) {
      if (p[i-1][1] == p[i][1]) {
        k++;
        p[i][3] = k;
      } else {
        k = 1;
        p[i][3] = k;
      }
    }

    Arrays.sort(p, (o1, o2) -> o1[0] - o2[0]);

    PrintWriter out = new PrintWriter(System.out);

    for (int i = 0; i < M; i++) {
      out.println(String.format("%06d", p[i][1]) + String.format("%06d", p[i][3]));
    }

    out.flush();

  }

}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    cout << (A+B)%24 << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;

void SelectionSort(vector<string> &A, int n) {
  for(int i = 0; i < n; i++) {
    int minj = i;
    for(int j = i; j < n; j++) {
      if(A[j][1] < A[minj][1]) {
        minj = j;
      }
    }
    if(minj != i) {
      string tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    }
  }
}

void BubbleSort(vector<string> &A, int n) {
  bool flg = true;
  int sw = 0;
  while(flg) {
    flg = false;
    for(int i = n-1; i > sw; i--) {
      if(A[i-1][1] > A[i][1]) {
        string tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;

        flg = true;
      }
    }
    sw++;
  }
}

int main(){
  int n;
  cin >> n;
  vector<string> c(n); // selection sort
  for(int i = 0; i < n; i++) cin >> c[i];

  vector<string> b(n); // bubble sort
  for(int i = 0; i<n; i++) b[i] = c[i];

  SelectionSort(b, n);
  BubbleSort(c, n);

  for(int i = 0; i < n; i++) {
    cout << c[i];
    if(i != n-1) {
      cout << " ";
    } else {
      cout << endl << "Stable" << endl;
    }
  }
 
  bool same = true; 
  for(int i = 0; i < n; i++) {
    if(c[i] != b[i]) same = false;

    cout << b[i];
    if(i != n-1) cout << " ";
    else {
      cout << endl;
      if(same) cout << "Stable" << endl;
      else cout << "Not stable" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3236
program Colorful_Subsequence
    implicit none
    integer(8):: cnt(ichar('z') - ichar('a') + 1), ans
    character(:), allocatable:: s
    integer(4):: n, i
    integer(8),parameter:: md = 1000000007

    read*, n
    allocate(character(n):: s)
    read*, s

    cnt(:) = 1_8
    block
        integer(4):: index
        do i=1, n
            index = ichar(s(i:i)) - ichar('a')+1
            cnt(index)=cnt(index)+1_8
        end do
    end block

    ans=1
    
    do i=1,ichar('z') - ichar('a') + 1
        ans = mod(ans*cnt(i), md)
    end do

    print*, ans - 1
end program Colorful_Subsequence

Measured memory_bytes: 768
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

#t=1
t=ii()
lol=[] 
ans=0
for _ in range(t):
    a,b=ml()    
    lol.append([b,a])
lol.sort()
f=0
for i in range(t):
    if(lol[i][1]+ans<=lol[i][0]):
        ans+=lol[i][1]
    else:
        f=1
        break
if f:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 104388
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end

function main()
	n,m = readline() |> split |> parseMap
	i = 1
	a = Int[]
	while i<sqrt(m)
		if m%i==0
			push!(a,i)
			push!(a,div(m,i))
		end
		i+=1
	end
	if i*i==m
		push!(a,i)
	end
	a = sort(a)
	k = bsearch(a,n)+1
	println(div(m,a[k]))
end

main()

Measured memory_bytes: 114060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>

using namespace std;
int main() {
	int n, m,x;
	cin >> n >> m;
	vector<int> v(2 * n);
	vector<int> vv(2 * n);
	for (int i = 0; i < 2 * n; i++) v[i] = i+1;

	for (int i = 0; i < m; i++) {
		cin >>x;
		int countv = 0,countvv=0;
		if (x == 0) {
			while (countv < n) {
				vv[countvv] = v[countv];
				vv[countvv + 1] = v[n+countv];
				countvv += 2;
				countv++;
			}
		}
		else {
			for (int j = x; j < 2 * n; j++) {
				vv[j - x ] = v[j];
			}
			for (int j = 0; j < x ; j++) {
				vv[j + (2*n)-(x)] = v[j];
			}
		}

		for (int j = 0; j < 2 * n; j++) v[j] = vv[j];
	}

	for (int i = 0; i < 2 * n; i++) {
		cout << v[i] << endl;
	}
	return 0;
}

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

public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %0.5f\n",d,r,f);
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

#define f first
#define s second
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define forn(i, n) for(register int i=0; i<n; i++)
#define Forn(i, n) for(register int i=1; i<=n; i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=2e5+5;

ll dp1[MAX], dp2[MAX], dp3[MAX], sum[MAX], ret;
int N, a[MAX];

inline ll Sum(int l, int r)// (l, r]
{
    return sum[r]-sum[l];
}

inline int f1(int x)
{
    return !x?2:(x&1);
}

inline int f2(int x)
{
    return !x?1:1-(x&1);
}

int main()
{
    ret=1e18;
    N=in();
    Forn(i, N)
    {
        a[i]=in();
        sum[i]=a[i]+sum[i-1];
    }
    
    Forn(i, N)// [1, i]
        dp1[i]=min(Sum(0, i), dp1[i-1]+f1(a[i]));/*
    Forn(i, N)
        cout<<dp1[i]<<" ";
    puts("");*/
    for(int i=N; i>0; i--)
        dp2[i]=min(Sum(i-1, N), dp2[i+1]+f1(a[i]));/*
    Forn(i, N)
        cout<<dp2[i]<<" ";
    puts("");*/
    for(int i=N; i>0; i--)// [i, x]
        dp3[i]=min(dp2[i+1]+f2(a[i]), dp3[i+1]+f2(a[i]));/*
    Forn(i, N)
        cout<<dp3[i]<<" ";
    puts("");*/
    forn(i, N)
        ret=min(ret, dp1[i]+min(dp3[i+1], dp2[i+1]));
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	ll a, b;
	cin >> a >> b;
	ll res = abs(abs(a)-abs(b));
	if((a < 0 && b > 0) || (a >= 0 && b < 0)){
		cout << res+1 << endl;
		return 0;
	}
	if((a >= 0 && b > 0 && a > b) || (a < 0 && b < 0 && b < a)){
		cout << res+2 << endl;
		return 0;
	}
	if(b == 0){
		if(a <= 0){
			cout << res << endl;
			return 0;
		}else{
			cout << res + 1 << endl;
			return 0;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
readline = sys.stdin.readline

H, W, K = map(int, readline().split())

G = [[2]*(W+2)]

st = (None, None)
for h in range(H):
    g = readline().strip()
    if 'S' in g:
        st = (1+h, 1+g.index('S'))
    
    G.append([2] + [1 if s == '#' else 0 for s in g] + [2])

G.append([2]*(W+2))

DIREC = [(0, -1), (0, 1), (1, 0), (-1, 0)]

Q = deque([st])
INF = 10**9+7
dist = [[INF]*(W+2) for _ in range(H+2)]
for h, w in Q:
    dist[h][w] = 0


Q2 = deque([st])
ans = INF
while Q:
    nh, nw = Q.pop()
    for dh, dw in DIREC:
        fh, fw = nh+dh, nw+dw
        if G[fh][fw]:
            continue
        if dist[fh][fw] > 1 + dist[nh][nw]:
            dist[fh][fw] = 1 + dist[nh][nw]
            if dist[fh][fw] <= K:
                Q2.append((fh, fw))
                if fh == 1 or fh == H or fw == 1 or fw == W:
                    ans = 1
            Q.appendleft((fh, fw))

if ans == INF:
    dist = [[INF]*(W+2) for _ in range(H+2)]
    for h, w in Q2:
        dist[h][w] = 0
    while Q2:
        nh, nw = Q2.pop()
        for dh, dw in DIREC:
            fh, fw = nh+dh, nw+dw
            if G[fh][fw] == 2:
                continue
            if dist[fh][fw] > 1 + dist[nh][nw]:
                dist[fh][fw] = 1 + dist[nh][nw]
                if fh == 1 or fh == H or fw == 1 or fw == W:
                    ans = min(ans, 2+(dist[fh][fw]-1)//K)
                Q2.appendleft((fh, fw))

print(ans)
            


Measured memory_bytes: 82652
#include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<map>
    using namespace std;
    typedef long long ll;
    int n;
    struct node{int col[4];
        node nxt(){ return node{col[1],col[2],col[3],col[0]};}
        friend bool operator <(node a,node b)
        {
            for (int i=0;i<4;i++)
                if (a.col[i]!=b.col[i]) return a.col[i]<b.col[i];
            return 0;
        }
    }a[410],a1,a2,a3,a4;
    map<node,int>mp;
    void insert(node x,int v)
    {for (int i=0;i<4;i++,x=x.nxt()) mp[x]+=v;}
     
     
    node xx,yy;
    int id1;
    ll ans,re;
    int main()
    {
        scanf("%d",&n);
        for (int i=1;i<=n;i++)
        {
            scanf("%d%d%d%d",&a[i].col[0],&a[i].col[1],&a[i].col[2],&a[i].col[3]);    
            insert(a[i],1);    
        }
        for (int i=1;i<=n;i++)
        {
            insert(a[i],-1);
            for (int j=i+1;j<=n;j++)
            {
                insert(a[j],-1);
                for (int t=0;t<4;t++)
                {
                    a1=node{a[j].col[1],a[i].col[0],a[i].col[3],a[j].col[2]};
                    a2=node{a[i].col[1],a[j].col[0],a[j].col[3],a[i].col[2]};
                    a3=node{a[j].col[1],a[j].col[0],a[i].col[1],a[i].col[0]};
                    a4=node{a[i].col[3],a[i].col[2],a[j].col[3],a[j].col[2]};
                    a[j]=a[j].nxt();                
                    if (mp[a1]==0||mp[a2]==0||mp[a3]==0||mp[a4]==0) continue;
                    re=1;
                    re*=mp[a1];insert(a1,-1);
                    re*=mp[a2];insert(a2,-1);
                    re*=mp[a3];insert(a3,-1);
                    re*=mp[a4];
                    insert(a1,1);insert(a2,1);insert(a3,1);
                    ans+=re;
     
                }
                insert(a[j],1);
            }
        }
        cout<<ans;
    }

Measured memory_bytes: 20352
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005];
int main(){
	int ans,num,i;
	while(scanf("%d",&n)!=EOF){
		ans=0;
		num=0;
		for( i=1;i<=n;++i){
			scanf("%d",&a[i]);
			b[i]=a[i];
			if(ans<a[i]){
				ans=a[i];
				num=0;
			}
			else if(ans==a[i]){
				num++;
			}
		}
		if(num>0) {
			for( i=1;i<=n;++i) 
				printf("%d\n",ans);
		}
		if(num==0){
			sort(b+1,b+1+n);
			b[0]=b[1];
			for(i=1;i<=n;++i){
				if(ans==a[i]) printf("%d\n",b[n-1]);
				else printf("%d\n",ans);
			}
			
		}
		
	}
	
	
	
	return 0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define vecadd emplace_back

typedef long long ll;

int main(){
  int n,a[110],b[110];
  cin>>n;
  rep(i,n){
    a[i]=1000000;
    cin>>b[i];
  }
  
  rep(i,n-1){
    a[i]=min(a[i],b[i]);
    a[i+1]=b[i];
  }
  
  int ans=0;
  rep(i,n){
    ans+=a[i];
  }
  
  cout<<ans;
  
  return 0;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    set<ll> st;
    REP(i, 3) {
        ll x; cin >> x;
        st.insert(x);
    }
    cout << SZ(st) << endl;
    
    return 0;
}

Measured memory_bytes: 256
s, e = [int(_) for _ in raw_input().split(" ")]
if s < 0 and 0 < e:
  print "Zero "
  exit()

if 0 < s:
  print "Positive"
  exit()

if (e - s + 1) % 2 == 0:
  print "Positive"
else:
  print "Negative"
  



Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
     ll n;
     cin>>n;
     ll mi=mm;
     rep1(i,sqrt(n)){
        if(n%i==0){
            mi=min(mi,i+n/i-2);
        }
     }
     cout<<mi;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
      //  nextl;
    }
    return 0;
}


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


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

int main()
{
    IOS();
    ll Q;
    cin>>Q;
    while(Q--)
    {
      ll n,m,l,r;
      cin>>n>>m>>l>>r;
      ll k = (max(n,m)-1) / (min(n,m) + 1) + 1;
      debug(k);
      //ll mx = 0;
      // ki +  j + p = n
      //  i + kj + q = m
      ll bl = 0, br = min((n-1) / k + 1,m+1);
      while(bl != br - 1)
      {
        ll i = (bl+br)/2;
        ll j = (m - i) / k;
        ll p = n - k * i - j;
        ll q = m - i - k * j;
        if(p >= 0 && q >= 0)bl = i;
        else br = i;
      }
      ll i = bl;
      ll j = (m - i) / k;
      ll p = n - k * i - j;
      ll q = m - i - k * j;
      if(p == -1)
      {
        p = 0;
        q += k;
        j--;
      }

      string s = "";
      for(int x = l;x <= r;x ++)
      {
        if(x <= (k+1) * i)
        {
          if((x-1) % (k+1) == k)s.pb('B');
          else s.pb('A');
        }
        else if(x <= (k+1) * i + p)s.pb('A');
        else if(x <= (k+1) * i + p + q)s.pb('B');
        else
        {
          ll tmpx = x - ( (k+1) * i + p + q );
          if((tmpx - 1) % (k+1) == 0)s.pb('A');
          else s.pb('B');
        }
      }
      cout<<s<<endl;
      //debug(mx,i,j,p,q);
      /*REP(x,i)
      {
        REP(y,k)s.pb('A');
        s.pb('B');
      }
      REP(x,p)s.pb('A');
      REP(x,q)s.pb('B');
      REP(x,j)
      {
        s.pb('A');
        REP(y,k)s.pb('B');
      }
      debug(s);
      cout<<s.substr(l-1,r-l+1)<<endl;*/
    }
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        StringTokenizer st=new StringTokenizer(in.readLine()," ");
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());
        for(int i=1;i<n;i++){
            st=new StringTokenizer(in.readLine(), " ");
            int a1=Integer.parseInt(st.nextToken());
            int b1=Integer.parseInt(st.nextToken());
            int c1=Integer.parseInt(st.nextToken());
            int x=a1+Math.max(b,c);
            int y=b1+Math.max(a,c);
            int z=c1+Math.max(b,a);
            a=x; b=y; c=z;
        }
        System.out.println(Math.max(a,Math.max(b,c)));
    }
}


Measured memory_bytes: 40936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M=1e5+5;
 
int main(){
	ll n,a[M],b[M];
	cin>>n;
	for(int i=0;i<=n;i++)
		cin>>a[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(b[i]<=a[i]) ans+=b[i];
		else if(b[i]<=a[i]+a[i+1]){
			ans+=b[i];
			a[i+1]-=b[i]-a[i];
		}
		else{
			ans+=a[i]+a[i+1];
			a[i+1]=0;
		}
	}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007LL                                              
# define MAX 100005                                                                                //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	ld w,h,x,y;int ans2;
	cin>>w>>h>>x>>y;
	ld ans1=(w*h)/2;
	ld x1=(ld)w/2,y1=(ld)h/2;
	if(x==x1&&y==y1)
	ans2=1;
	else
	ans2=0;
	cout<<fixed<<setprecision(9)<<ans1<<" "<<ans2;
	return 0;
}

Measured memory_bytes: 256