akhauriyash/Code-Regression huggingface dataset:
/*******************************
* BASMILLAHHIR RAHMANNIR RAHIM *
* MD SHAHINUR RAHMAN           *
* DATE: 12/sep/2020            *
* DEPT. OF CSE                 *
* LEADING UNIVERSITY, SYLHET   *
*******************************/
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<math.h>
#define shahin std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax=1000*1007;
const int mod = 1e9 + 7;

using namespace std;
char wcz[nax];

bool fu(int a, int b){
    return (a>b);
}
 
void fun(){
   ll a,b,c,d,sum=0,S=-10000000000;
    cin >> a>>b>>c>>d;
    cout << max(a * c, max(a * d, max(b * c, b * d)));
    
                   
}

int main()
{
    shahin
  /*  ll tc,i=1;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/ 
    fun();
   
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int res=0;
    rep(i,n) {
        cin >> a[i];
        res=res^a[i];
    }
    rep(i,n) {
        int ans=res^a[i];
        pt(ans);
    }
    


    return 0;
}


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	a = min(a, 2*b);
	x = 500+(x-1)/500*500;
	cout << a*(x/1000) + min(a,b)*(x/500%2) << endl;
	return 0;
} 



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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int main() {
    string s;
    int k;
    cin >> k >> s;
    if(s.length() <= k) {
        cout << s;
    } else {
        cout << s.substr(0,k) << "...";
    }
    return 0;
}


Measured memory_bytes: 3636
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    N = int(input())
    if N==1:
        print(0)
        return
    factors = factorization(N)
    ans = 0
    for (k,v) in factors:
        count = 1
        tmp = 1
        rest = v
        while True:
            if rest-tmp<tmp+1:
                break
            rest -= tmp
            tmp += 1
            count += 1
        ans += count
    print(ans)

main()


Measured memory_bytes: 9496
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    s[3] = '8';
    cout <<  s << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

int N, M;
int[][] edges;

int root = 0, timer = 1;
int[] prenum, lowest, parent;
bool[] visited, is_kansetsu;

int s;
int end1, end2;
int[] required;

void dfs(int u, int prev) {
    prenum[u] = timer;
    lowest[u] = timer;
    timer++;

    visited[u] = true;

    foreach (v; edges[u]) {
        if (!visited[v]) {
            parent[v] = u;
            dfs(v, u);
            lowest[u] = min(lowest[u], lowest[v]);
        }
        else if (v != prev) {
            lowest[u] = min(lowest[u], prenum[v]);
        }
    }
}


bool dfs2(int n, int prev) {
    parent[n] = prev;

    if (visited[n]) return false;
    visited[n] = true;
    int cnt = 0;

    foreach (m; edges[n]) {
        if (visited[m]) continue;
        auto ret = dfs2(m, n);
        if (ret) return true;
        cnt += 1;
    }

    if (cnt == 0) {
        end1 = n;
        return true;
    }
    visited[n] = false;
    return false;
}

void main() {
    auto S = readln.split.map!(to!int);
    N = S[0];
    M = S[1];
    edges = new int[][](N);
    foreach (i; 0..M) {
        S = readln.split.map!(to!int);
        edges[S[0]-1] ~= S[1] - 1;
        edges[S[1]-1] ~= S[0] - 1;
    }

    prenum = new int[](N);
    lowest = new int[](N);
    parent = new int[](N);
    visited = new bool[](N);
    dfs(root, -1);

    is_kansetsu = new bool[](N);
    int cnt = 0;
    foreach (i; 0..N) {
        if (i == root || parent[i] == root) continue;
        if (prenum[parent[i]] <= lowest[i]) is_kansetsu[parent[i]] = true;
        if (parent[i] == root) cnt += 1;
    }
    if (cnt >= 2) is_kansetsu[root] = true;

    foreach (i; 0..N) {
        if (!is_kansetsu[i]) {
            s = i;
            break;
        }
    }

    parent = new int[](N);
    visited = new bool[](N);
    dfs2(s, -1);
    end2 = end1;
    visited[s] = false;
    dfs2(s, -1);

    int[] ans2;
    int[] ans1;
    while (end2 != -1) {
        ans2 ~= end2;
        end2 = parent[end2];
    }
    while (end1 != s) {
        ans1 ~= end1;
        end1 = parent[end1];
    }

    ans1.reverse();
    int[] ans = ans2 ~ ans1;
    ans.length.writeln;
    ans.map!(a => (a+1).to!string).join(" ").writeln;
}


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

int main(void){
  int N;
  bool result = false;
  cin >> N;
  int vertex[N];
  for(int i=0;i<N;i++){
    cin >> vertex[i];
  }
  sort(vertex,vertex+N);
  int sum = 0;
  for(int i=0;i<N-1;i++) sum += vertex[i];
  if(vertex[N-1] < sum){
    result = true;
  }
  if(result){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

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

int main()
{
  int H, W;
  cin >> H >> W;
  
  string s[50];
  rep(i, H)
  {
    cin >> s[i];
  }
  
  rep(i, H)
  {
    rep(j, W)
    {
      if ('#' == s[i][j])
      {
        continue;
      }
      
      int counter = 0;
      rep(k, 8)
      {
        int tmp_y = i + dy[k];
        int tmp_x = j + dx[k];
        
        if (0 > tmp_y || H <= tmp_y || 0 > tmp_x || W <= tmp_x)
        {
          continue;
        }
        
        if ('#' == s[tmp_y][tmp_x])
        {
          counter++;
        }
      }
      
      s[i][j] = (char)(counter + '0');
    }
  }
  
  rep(i, H)
  {
    cout << s[i] << endl;
  }

  return 0;
}


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

using namespace std;

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
int i, j, ans = numeric_limits<int>::max(), tmp;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> s >> t;
    for (i = 0; i <= s.length() - t.length(); ++i) {
        tmp = 0;
        for (j = 0; j < t.length(); ++j)
            if (s[i + j] != t[j])
                ++tmp;
        ans = min(ans, tmp);
    }
    cout << ans;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x,a,b,z=0;
	cin>>x;
	a=x/11;
	b=x%11;
	if(b!=0){
		if(b<=6) z=1;
		else z=2;
	}
	cout<<a*2+z;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s,t;
signed main()
{
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	if(s[i]!=t[i])
	{
		printf("No");
		return 0;
	}
	printf("Yes");
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,br=0;
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int p;
            cin>>p;
            if(a[p]==0){a[p]=1;br++;}
        }
    }
    cout<<n-br<<endl;
}



Measured memory_bytes: 3664
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define repv(i,k,n) for(i=k; i<n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
int mod = 1e9+7;
int par[100005],siize[100005];
// -----------------------------------------------------------------
//  substr(pos,length);

//  bitset<32> a(n);
//  cout<<a.count();

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

void solve()
{
    int n,i,j,k,m;
    cin>>n>>m>>k;
    cin>>n;
    int flag=0;
    while(n)
    {
        int val = n%10;
        if(val==7)
            flag=1;
        n/=10;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    out_of_reach;
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  
  int X = ceil(N / 1.08);
  int Xmax = ceil((N + 1) / 1.08);
  
  if (X == Xmax) {
    cout << ":(" << endl;
  } else {
    cout << X << endl;
  }
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n;

    cin >> n;

    ll a[n],b[n];

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

        b[i] = a[i];
    }

    sort(a,a+n);




    int count = 0;

    for(int i=0; i<n; i++)
    {
        if(a[i]!=b[i])
        {
            count++;
        }
    }

    //cout << count << endl;

    if(count==2 || count == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;

    }




    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d,e,f,g,h;
map<long long,long long>mp;

cin>>a;
for(long long i=1;i<=a-1;i++)
{
    cin>>b;
    mp[b]++;
}

for(long long i=1;i<=a;i++)
{

    cout<<mp[i]<<endl;
}


}


Measured memory_bytes: 16104
#include <bits/stdc++.h>
using namespace std;
int a[26];

int main()
{
    char s[30];
    scanf("%s",s);
    int len = strlen(s);
    int ok =1;
    for (int i=0;i<len;i++)
        if(a[s[i]-'a'])
            ok=0;
        else
            a[s[i]-'a']=1;
    if (ok)
        printf("yes\n");
    else
        printf("no\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
 
using namespace std;
 
int main (void) {
    string S;
    cin >> S;

    if ( S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(3) ){
        printf("Yes\n");
    }
    else if ( S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1) ){
        printf("Yes\n");
    }
    else if ( S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1) ){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        if (n.charAt(0) == '9' || n.charAt(1) == '9') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int N, a[300000];
ll ans;

int main() {
    cin >> N;
    rep(i, 3 * N) cin >> a[i];
    sort(a, a + 3 * N, greater<int>());
    rep(i, N) ans += a[i*2+1];
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

  // LW[i]:i番目の人よりLeftあってW
  // RE[i]:i番目の人よりRightにあってR
  // 求める答えは、LW[i]+RE[i]のうち最小のもの
  vector<int> LW(n), RE(n);

  // LW の決定。LW[0]=0 としてよい
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'W')
      LW[i] = LW[i - 1] + 1;
    else
      LW[i] = LW[i - 1];
  }
  // RE の決定。RE[n-1]=0
  for (int i = n - 2; i >= 0; i--) {
    if (s[i + 1] == 'R')
      RE[i] = RE[i + 1] + 1;
    else
      RE[i] = RE[i + 1];
  }

  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    ans = min(ans, min(LW[i], RE[i]) + abs(LW[i] - RE[i]));
  }
  cout << ans << '\n';
}

Measured memory_bytes: 5188
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {
	int len, qs, i = 1, l, r, cnt = 0;
	string str;
	cin >> len >> qs >> str;
	vector<int> num(len);
	for (; i < len; i++) {
		if (str[i - 1] == 'A' && str[i] == 'C')
			cnt++;
		num[i] = cnt;
	}
	i = 0;
	for (; i < qs; i++) {
		scanf("%d %d", &l, &r);
		printf("%d\n", num[r-1]-num[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

ll l[200005];
ll pref[200005];

ll getSum(int lhs, int size) {
  return pref[lhs+size] - pref[lhs];
}

pll solve(int lhs, int size) {
  int minS = 1;
  int maxS = size-1;
  ll totalSum = getSum(lhs, size);
  while(minS + 3 < maxS) {
    int low = (2*minS+maxS)/3;
    int high = (2*maxS+minS)/3;
    ll lowSum = getSum(lhs, low);
    ll highSum = getSum(lhs, high);
    if(abs(totalSum - 2 * lowSum) < abs(totalSum - 2 * highSum)) {
      maxS = high;
    }
    else {
      minS = low;
    }
  }
  ll best = totalSum;
  pll ret = pll(best, best);
  for(int i = minS; i <= maxS; i++) {
    ll candSum = getSum(lhs, i);
    if(abs(totalSum - 2 * candSum) < best) {
      best = abs(totalSum - 2 * candSum);
      ret = pll(candSum, totalSum - candSum);
    }
  }
  if(ret.first > ret.second) {
    ret.first ^= ret.second;
    ret.second ^= ret.first;
    ret.first ^= ret.second;
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  ll total = 0;
  for(int i = 0; i < n; i++) {
    scanf("%lld", &l[i]);
    total += l[i];
    pref[i+1] = pref[i] + l[i];
  }
  ll ret = total;
  for(int numMid = 2; numMid <= n-2; numMid++) {
    pll lhs = solve(0, numMid);
    pll rhs = solve(numMid, n-numMid);
    ret = min(ret, max(rhs.second, lhs.second) - min(lhs.first, rhs.first));
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 3328
from scipy.sparse import*;f=csgraph.johnson;n,m,l,*t=map(int,open(0).read().split());m*=3;d=f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l);d[d>n]=0;print(*d[t[m+1::2],t[m+2::2]]-1,sep='\n')

Measured memory_bytes: 40836
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
  int a,len;
  char old[27],nee[27],pri[1111];
  string ans;
  for(int i=0;i<26;i++){
    if(i == 0){
      old[0] = 'A';
      nee[0] = old[0] + 3;
    }else{
      old[i] = old[i-1] + 1;
      if(nee[i-1] == 'Z'){
	nee[i] = 'A';
      }else{
	nee[i] = nee[i-1] + 1;
      }
    }
  }
  cin >> pri;
  len = strlen(pri);
  for(int i=0;i<len;i++){
    for(int j=0;j<26;j++){
      if(pri[i] == nee[j]){
	ans += old[j];
	break;
      }
    }
  }
  cout << ans << endl;
}

  

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

#define LEFT (idx<<1)
#define RIGHT (idx<<1|1)
#define MID ((start+end)>>1)
const int N = 1e6;
set<pair<int, int>> arr[N + 1];
pair<int, int> tree[N + 1 << 4];
pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
	if (a.first > b.first)
		return a;
	return b;
}

void add(int pos, pair<int, int> val, int idx = 1, int start = 0, int end = N) {
	if (start == end) {
		arr[start].insert(val);
		tree[idx] = *arr[start].rbegin();
		return;
	}
	if (pos <= MID)
		add(pos, val, LEFT, start, MID);
	else
		add(pos, val, RIGHT, MID + 1, end);
	tree[idx] = merge(tree[LEFT], tree[RIGHT]);
}

void remove(int pos, pair<int, int> val, int idx = 1, int start = 0,
		int end = N) {
	if (start == end) {
		arr[start].erase(val);
		if (arr[start].size())
			tree[idx] = *arr[start].rbegin();
		else
			tree[idx] = { -1, -1 };
		return;
	}
	if (pos <= MID)
		remove(pos, val, LEFT, start, MID);
	else
		remove(pos, val, RIGHT, MID + 1, end);
	tree[idx] = merge(tree[LEFT], tree[RIGHT]);
}

pair<int, int> query(int from, int to, int idx = 1, int start = 0,
		int end = N) {
	if (from <= start && end <= to)
		return tree[idx];
	if (to <= MID)
		return query(from, to, LEFT, start, MID);
	if (MID < from)
		return query(from, to, RIGHT, MID + 1, end);
	return merge(query(from, to, LEFT, start, MID),
			query(from, to, RIGHT, MID + 1, end));
}
int main() {
	run();
	memset(tree, -1, sizeof tree);
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (char ch : s) {
			if (ch == '(')
				v[i].second++;
			else
				v[i].second--;
			if (v[i].second < 0)
				v[i].second++, v[i].first++;
		}
		add(v[i].first, { v[i].second, i });
	}
	int need_to_close = 0;
	for (int i = 0; i < n; i++) {
		pair<int, int> p = query(0, need_to_close);
		if (p == make_pair(-1, -1))
			return cout << "No\n", 0;
		int j = p.second;
		need_to_close = (need_to_close - v[j].first + v[j].second);
		remove(v[j].first, { v[j].second, j });
	}
	if (need_to_close != 0)
		cout << "No\n";
	else
		cout << "Yes\n";
}


Measured memory_bytes: 229536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  rep(i,n){
    string j;
    cin >> j;
    if(j == "AC") ac++;
    if(j == "WA") wa++;
    if(j == "TLE") tle++;
    if(j == "RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}
    

Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, M;
    cin >> N;
    map<int, int> x, y;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        x[tmp]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> tmp;
        y[tmp]++;
        if (y[tmp] > x[tmp])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 22188
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n') 
s = lines.shift() * 1
a = ~~(s / 100)
b = s % 100 
if (a == 0 || b == 0) {
    if (a == 0 && b > 0 && b <= 12) {
        console.log('YYMM')
    } else if (b == 0 && a > 0 && a <= 12) {
        console.log('MMYY')
    } else {
        console.log('NA')
    }
} else {
    if (a <= 12) {
        if (b <= 12 ) {
            console.log('AMBIGUOUS')
        } else {
            console.log('MMYY')
        } 
    } else if (b <= 12) {
        console.log('YYMM')
    } else {
        console.log('NA')
    }
}


Measured memory_bytes: 7372
#include <stdio.h>

int kuku(int a, int b){

 return a*b;
}

void hyozi(void){

 int i, j;

 for(i=1; i<=9; i++){
   for(j=1; j<=9; j++){
       printf("%dx%d=%d\n",i,j,kuku(i,j));
   }
 }
}

int main(void){

 hyozi();
 return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int ans=1000;
    for(int i=0;i<=s.size()-t.size();i++){
        int x=0;
        for(int j=0;j<t.size();j++)if(s[i+j]!=t[j])x++;
        ans=min(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
//????????????????????????????????£?????????????????????...?????????????????¬?????????????????????????????????????¶?????????????????????°https://kakuseikyu.jp ???600??????????????????????????????????????????
int main()
{
    int n;
    int i,j,k,t,a,b;
    int namenagasa,kanbannagasa;
    int cnt=0;
    char name[26],kanban[201] ;
    scanf("%d",&n);
    scanf("%s",name);
    namenagasa=strlen(name);
    for(i=0;i<n;i++){
        scanf("%s",kanban);
        kanbannagasa=strlen(kanban);
        for(j=0;j<kanbannagasa; j++){
            for(k=1;j+(namenagasa-1)*k<kanbannagasa;k++){
				a=0;
				b=0;
                for( t=0;t<namenagasa;t++){
                    if(kanban[j+t*k]!=name[t]){
						a=1;
						break;
				    }
                }
				if(a==0){
                	cnt++;
					b=1;
					break;
				}
		    }
			if(b==1){
				break;
			}
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 600
// Sorting3Numbers.cs
// ??\????????????3????????°???????°????????????????????????????????????°??????

using System;

class Sorting3Numbers{
    static void Main(){
        var str = Console.ReadLine();
        string[] s = str.Split(' ');
        
        var a = int.Parse(s[0]);
        var b = int.Parse(s[1]);
        var c = int.Parse(s[2]);
        
        var alt = 0;
        
        if (a > b){
            alt = b;
            b = a;
            a = alt;
        }
        
        if (b > c){
            alt = c;
            c  = b;
            b = alt;
        }
        
        if (a > b){
            alt = b;
            b = a;
            a = alt;
        }
        Console.WriteLine("{0} {1} {2}" ,a ,b ,c);
    }
}

Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAX_N 12
double dp[MAX_N][1 << MAX_N], p[MAX_N][MAX_N], x[MAX_N]; int N, M, bit[MAX_N]; string S;
int main() {
	while (S = "", getline(cin, S)) {
		S += ' '; string T; int u = 0;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == ' ') { if (u == 0) { M = stoi(T); } else { x[u - 1] = stoi(T); }u++; T = ""; }
			else { T += S[i]; }
		}
		N = u - 1;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i == j) { continue; }
				p[i][j] = sqrt((x[i] + x[j])*(x[i] + x[j]) - (x[i] - x[j]) * (x[i] - x[j])) - x[i] + x[j];
			}
		}
		for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < (1 << MAX_N); j++) { dp[i][j] = 1e9; } }
		for (int i = 0; i < N; i++) {
			dp[i][1 << i] = x[i] * 2;
		}
		for (int i = 0; i < (1 << N); i++) {
			for (int j = 0; j < N; j++) { bit[j] = (i / (1 << j)) % 2; }
			for (int j = 0; j < N; j++) {
				if (dp[j][i] >= 1e8) { continue; }
				for (int k = 0; k < N; k++) {
					if (bit[k] == 0) {
						dp[k][i + (1 << k)] = min(dp[k][i + (1 << k)], dp[j][i] + p[j][k]);
					}
				}
			}
		}
		double maxn = 1e9;
		for (int i = 0; i < N; i++) { maxn = min(maxn, dp[i][(1 << N) - 1]); }
		if (maxn <= M) { cout << "OK" << endl; }
		else { cout << "NA" << endl; }
	}
	return 0;
}

Measured memory_bytes: 3504
N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

from itertools import permutations

states = list(permutations(list(range(N))))

ans = 0
for state in states:
    dist = 0
    for i,n in enumerate(state):
        if i == 0:
            prev = xy[n]
            continue
        now = xy[n]
        dist += pow(pow(prev[0]-now[0], 2)+pow(prev[1]-now[1],2),.5)
        prev = now
    ans += dist

ans /= len(states)
print(ans)

Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n ; 
    cin >> n;
    bool flag = 1;
    for(int i = 0 ; i < n ; i++){
        int x;cin >> x;
        if(x % 2 == 0 )
            if(x % 3 !=0 && x % 5 != 0)
                flag = 0;
    }
    if(flag)
        cout << "APPROVED";
    else cout <<"DENIED";
    return 0;
}

Measured memory_bytes: 256
s = input()


def main(s):
    if 'C' in s and 'F' in s:
        for i in range(s.count('C')):
            if i != 0:
                s_l = list(s)
                del s_l[c_i]
                s = ''.join(s_l)
            c_i = s.index('C')
        for i in range(s.count('F')):
            if i != 0:
                s_l = list(s)
                del s_l[f_i]
                s = ''.join(s_l)
            f_i = s.index('F')

        if c_i <= f_i:
            return 'Yes'
        else:
            return 'No'
    else:
        return 'No'

print(main(s))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  
  sort(A.begin(),A.end(),greater<int>());
  int alice = 0;
  int bob = 0;
  for(int i=0;i<n;i++) i%2==0? alice += A[i]: bob += A[i];
  
  int ans = alice - bob;
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, a[5];

int main(){
  cin >> N;
  REP(i, 5) {
    cin >> a[i];
  }

  sort(a, a + 5);
  ll min = a[0];
  ll ans = 4;
  if(N % min == 0) ans += N / min;
  else ans += N / min + 1;

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int MOD = 1e9+7;

inline void Add(int& x, int y)
{
    x += y;
    if(x >= MOD) x -= MOD;
}

inline void Sub(int& x, int y)
{
    x -= y;
    if(x < 0) x += MOD;
}


int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    vector<int> dp(k+5);
    dp[0] = 1;
    int maxCandy = 0;
    for(int i = 0; i < n; ++i)
    {
        maxCandy = min(k, maxCandy + a[i]);
        vector<int> prev = dp;

        for(int numCandy = 1; numCandy <= maxCandy; ++numCandy)
        {
            dp[numCandy] = 0;
            Add(dp[numCandy], dp[numCandy-1]);
            if(numCandy - a[i] > 0)
            {
                Sub(dp[numCandy], prev[numCandy-a[i]-1]);
            }          
            Add(dp[numCandy], prev[numCandy]);
        }        
    }
    cout << dp[k] << "\n";
    return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int ct = 0;
    int n; cin>>n;
    For(i, 1, n+1){
        int a; cin>>a;
        if(a%2 && i%2)
            ct++;
    }
    cout<<ct;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int i, j, k, N, L[101], count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(L[i]));
	for (i = 1; i <= N - 2; i++) {
		for (j = i + 1; j <= N - 1; j++) {
			if (L[i] == L[j]) continue;
			for (k = j + 1; k <= N; k++) {
				if (L[k] != L[i] && L[k] != L[j] && L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) count++;
			}
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;
  long Y;
  cin >> N >> Y;
  long A=-1, B=-1, C=-1;
  if(Y > 10000*N || Y < 1000*N){
  	cout << A << ' '<< B << ' '<<C << endl;
  }else{
    for(long i=0; i<=N; i++){
      for(long j=0; j<=N-i; j++){
        long k = N-i-j;
        if(Y -10000*i - 5000*j -1000*k == 0){
          A = i;B=j;C=k;
        }
      }
    }
  	cout << A << ' '<< B << ' '<<C << endl;
  }
}


Measured memory_bytes: 256
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
po=math.pow(P,(1/N))
for i in reversed(range(int(round(po,0))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

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

int n, a[100005], ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];

    for(int i=1; i<=n; i++) {
        if(a[i]==i) {
            swap(a[i], a[i+1]);
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}


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

int main(){
  int N, fl = 0, sl = 0;
  scanf("%d",&N);
  vector<int> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
    if (fl < A[i]){
      sl = fl;
      fl = A[i];
    }
    else if (sl < A[i]){
      sl = A[i];
    }
  }
  for (int i = 0; i < N; i++){
    if (fl == A[i]){
      printf("%d\n", sl);
    }
    else{
      printf("%d\n", fl);
    }
  }
  return 0;
}


Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//後ろから２文字ずつ削って判定してく関数
//配列をポインタで渡す場合長さも渡しておく
int mojikezuri(char* str, int length) {
	int flag = 0;
	int l2=length/2;
	char str1[101];
	char str2[101];
	int i;
	int ans;

	strncpy(str1, str, l2);
	strncpy(str2, str + l2, l2);
	str1[l2] = '\0';
	str2[l2] = '\0';
#ifdef DEBUG
	printf("%s\n", str1);
	printf("%s\n", str2);
#endif

	if (strcmp(str1,str2)) {
		ans = mojikezuri(str, length - 2);
	}
	else {
		ans = length;
	}
	return ans;
}
int main(void) {
#ifdef DEBUG
	printf("");
#endif

	char S[201] = { '\0' };
	int length=0;
	int ans=0;
	int i;
	
	scanf("%s", S);
	length = strlen(S);

#ifdef DEBUG
	printf("%s\n", S);
#endif
	
#ifdef DEBUG
	printf("length=%d\n", length);
#endif

	ans = mojikezuri(S,length-2);

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

	return 0;
}


Measured memory_bytes: 128
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	for (int i = 1; i < S.size(); i++) {
		for (int j = 0; j < i;j++) {
			if (S[i] == S[j]) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");

	return(0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n",(n-a)%b);
}

Measured memory_bytes: 764
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int a[]= new int[n];
		for( int i=0; i<n; i++){
			a[i] = sc.nextInt();
			map.putIfAbsent(a[i],0);
			map.put(a[i],map.get(a[i])+1);
		}
		int count=0;
		for(int i=0; i<n; i++){
		//	System.out.println(count);
			if(!map.containsKey(a[i]))continue;
			if(map.get(a[i])>a[i]){
				count+=map.get(a[i])-a[i];
				map.remove(a[i]);
			}
			else if(map.get(a[i])<a[i]){
				count+=map.get(a[i]);
				map.remove(a[i]);
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 63796
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; ++i){
    cin >> A[i];}
  
  vector<size_t> indicies(N);
  iota(indicies.begin(), indicies.end(), 0);
  
  sort(indicies.begin(), indicies.end(), [&A](size_t i1, size_t i2){
    return A[i1] < A[i2];});

  int max_ind, sec_ind;
  max_ind = indicies[N-1];
  sec_ind = indicies[N-2];
  

  sort(A.begin(), A.end());
  
  int max_val = A[N-1];
  int sec_val = A[N-2];
  
  for (int i = 0; i < N; ++i){
    int res;
    if (i == max_ind){res = sec_val;}
    else{res = max_val;}
    
    cout << res << endl;
  }
  
  
  
  return 0;
}

Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int H,A,B,N,R,M,K,X,Y,Z,C;
  string S,T,U;
  int N_tmp=0;
  cin >> S;

  if(S == "ARC"){
    cout << "ABC" << endl;

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

  }
  return 0;
  


}

Measured memory_bytes: 3596
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-03-28 20:05:00
 * @LastEditTime: 2020-03-28 20:08:00
 * @FilePath: \VSCode\C++\Practice\AC abc160 B.cpp
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int x;
    scanf("%lld",&x);
    printf("%lld\n",x/500*1000+(x%500)/5*5);
    return 0;
}

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

  while(1){
    ans=0;
  scanf("%d",&money);

  if(!money) break;

  money=1000-money;

  while(money){
    if(money / 500 >= 1){
      ans += (money / 500);
      money %= 500;
    }
    else if(money / 100 >= 1){
      ans += (money / 100);
      money %= 100;
    }
    else if(money / 50 >= 1){
      ans += (money / 50);
      money %= 50;
    }
    else if(money / 10 >= 1){
      ans += (money / 10);
      money %= 10;
    }
    else if(money / 5 >= 1){
      ans += (money / 5);
      money %= 5;
    }
    else{
      ans += money;
      money=0;
    }
  }

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

  }

  return 0;

}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(void){
int W,H,x,y,r;
cin >> W >> H >> x >> y >>r;
if(x-r<0 || y-r<0 || W<x+r || H<y+r){
cout <<"No"<<endl;}
else{
    cout<<"Yes"<<endl;
}
return 0;

    
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
	string a,b;
	string res = "EQUAL";
	cin >> a >> b;
	if (a.size() != b.size()){
		res = (a.size() > b.size()) ? "GREATER" : "LESS";
	}else{
		rep(i,a.size()){
			if (a[i] > b[i]){
				res = "GREATER";
				break;
			}else if (a[i] < b[i]){
				res = "LESS";
				break;
			}else{
				continue;
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

long long a[51],p[51];

long long f(long long N,long long X){
    if (N == 0)
        if (X <= 0) return 0;
        else return 1;
    else if (X <= 1 + a[N-1])
        return f(N-1, X-1);
    else 
        return p[N-1] + 1 + f(N-1, X-2-a[N-1]);
}

int main(){
    long long N,X;
    cin >> N >> X;

    a[0] = 1;
    p[0] = 1;
    for(int i=1;i<N;i++){
        a[i] = a[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }

    cout << f(N,X) << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def warshall_floyd(n, d):
    # d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


def main():
    N = int(input())
    S = [list(input()) for _ in range(N)]

    def bfs(start, S):
        visited = [False] * N
        visited[start] = True
        group = [-1] * N
        group[start] = 0
        q = deque([(start, 0)])
        while q:
            n, g = q.popleft()

            for i in range(N):
                if S[n][i] == "1":
                    if visited[i]:
                        if abs(group[i] - g) != 1:
                            return -1
                        else:
                            continue
                    else:
                        group[i] = g + 1
                        visited[i] = True
                        q.append((i, g + 1))
                else:
                    continue
        n_group = 1
        for i in range(N):
            if group[i] == -1:
                return -1
            if n_group < group[i] + 1:
                n_group = group[i] + 1
        return n_group

    answer = -1
    for i in range(N):
        n_group = bfs(i, S)
        if n_group > answer:
            answer = n_group
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3692
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    string sub = s.substr(0, 4);
    int y = atoi(sub.c_str());
    sub = s.substr(5, 2);
    int m = atoi(sub.c_str());
    if (y < 2019) {
        cout << "Heisei" << endl;
    }
    else if (y == 2019) {
        if (m <= 4) {
            cout << "Heisei" << endl;
    }
        else {
            cout << "TBD" << endl;
        }
    }
    else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int h, w;
	cin >> h;
	cin >> w;
	char ch;
	int a[100][100];
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> ch;
			if (ch == '.') {
				a[i][j] = 0;
			}
			else {
				a[i][j] = 1;
			}
		}
	}
	int check = 0;

	for (int i = 0;i < w;i++) {
		for (int j = 0;j < h;j++) {
			if (a[j][i] == 1) {
				check = 1;
				break;
			}
		}
		if (check == 0) {
			for (int j = 0;j < h;j++) {
				a[j][i] = 2;
			}
		}
		check = 0;
	}

	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (a[i][j] == 1) {
				check = 1;
				break;
			}
		}
		if (check == 0) {
			for (int j = 0;j < w;j++) {
				a[i][j] = 3;
			}
		}
		check = 0;
	}
	
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (a[i][j] == 0) {
				cout << ".";
			}
			if (a[i][j] == 1) {
				cout << "#";
			}
		}
		if (a[i][w - 1] != 3) {
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
s = input()
x = 0
y = 1
for e in s:
  if e == 'a':
    if x < a+b:
      print("Yes")
      x += 1
    else:
      print("No")
  elif e == 'b':
    if x < a+b and y <= b:
      print("Yes")
      x += 1
    else:
      print("No")
    y += 1
  else:
    print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <cmath>

using namespace std;

static const double pi=3.141592653589793238;

int main(void){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double thetaL,thetaS;
    
    thetaS=H*30+M*0.5;
    thetaL=M*6;
    
    double COS=cos((thetaS-thetaL)*pi/180);
    
    double square=A*A+B*B-2*A*B*COS;
    double ans=sqrt(square);
    
    printf("%2.15lf",ans);
}


Measured memory_bytes: 4216
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
s, t = read().decode().split()

ans = 0
for i in range(N):
    if i == 0:
        if s == t:
            ans = N
            break
    if s[i:] == t[:-i]:
        ans = i * 2 + N - i
        break
if ans == 0:
    ans = N * 2

print(ans)


Measured memory_bytes: 3188
# your code goes here
n = gets.to_i
v_s = gets.split.map(&:to_i)

v_s.sort!

sum = 0.0

while v_s.length > 1 do
	new_v = (v_s[0] + v_s[1]) / 2.to_f
	v_s[0] = new_v
	v_s.delete_at(1)
end

puts v_s[0]

Measured memory_bytes: 1788