akhauriyash/Code-Regression huggingface dataset:
// In the name of God
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <iomanip>
#include <ctime>
#include <queue>
using namespace std;

template <typename T>
T next_int() {  
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if (ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return x * p;
}

const int max_n = (int)2e5 + 227 + 1;
const int max_int = (int)1e9 + 227 + 1;
const int mod = (int)1e9 + 7;

bool used[10];

inline bool f(int n) {
    while(n) {
        if(used[n % 10]) return 0;
        n /= 10;
    }
    return 1;
}

int main() {
//    freopen(".in", "r", stdin);

    int n = next_int<int>();

    int m = next_int<int>();

    for(int i = 0; i < m; i++) used[next_int<int>()] = 1;

    while(!f(n)) n++;

    cout << n << "\n";
}


Measured memory_bytes: 256
N, C = list(map(int, input().split()))
STC = [tuple(map(int, input().split())) for _ in range(N)]
STC.sort()

_l = [[0 for _ in range(2*int(1e5+1))] for _ in range(C+1)]

for s,t,c in STC:
  if _l[c][2*s] == -1:
    _l[c][2*s] = 0
    _l[c][2*t] = -1
  else:
    _l[c][2*s-1] = 1
    _l[c][2*t] -= 1

import numpy as np

_l = np.array(_l)

ac = (_l.sum(axis=0)).cumsum()
print(max(ac))

Measured memory_bytes: 124192
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005],b[100005],c[100005];
long long f[100005]={0};
int main(void)
{
	int i,n;
	long long ans=0LL;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=1;i<=n;++i)scanf("%d",&b[i]);
	for(i=1;i<=n;++i)scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(i=1;i<=n;++i)
	{
//		cout<<*upper_bound(c+1,c+n+1,b[i])<<" ";
		f[i]=(c+n+1)-upper_bound(c+1,c+n+1,b[i]);
//		cout<<f[i]<<endl;
	}
	for(i=n;i>=1;--i)f[i]+=f[i+1];
	for(i=1;i<=n;++i)
	{
//		cout<<*upper_bound(b+1,b+n+1,a[i])<<" ";
		ans+=f[upper_bound(b+1,b+n+1,a[i])-b];
//		cout<<f[upper_bound(b+1,b+n+1,a[i])-b]<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i,j,t;
  string s;
  while(cin>>s)
  {
    if(s=="Sunny")
    {
      printf("Cloudy\n");
    }
    else if(s=="Cloudy")printf("Rainy\n");
    else if(s=="Rainy")printf("Sunny\n");
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a,b,c;
    for(int i=0;i<N;i++){
        cin >> a >> b >> c;
        if(a*a==b*b+c*c) cout << "YES" <<endl;
        else if(b*b==a*a+c*c) cout << "YES" <<endl;
        else if(c*c==a*a+b*b) cout << "YES" <<endl;
        else cout << "NO" <<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define lb lower_bound
using namespace std;
void solve()
{
    db x;
    cin >> x;
    ll ans= 100;
    for(ll i=1;i<=3760;i++)
    {
        ans = (floor)((db)ans*1.01);
        if(ans >= x)
        {
            cout << i;
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3856
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int dist[22][22];
int dp[22][1<<22];
int bfs[1000][1000];
int cnt = 0;

int dec(char c){
    if(c == 's')    return 0;
    if(c == 'e')    return cnt+1;
    return c-'A'+1;
}

int main(){
    memset(dist, 0x3f, sizeof(dist));
    memset(dp, 0x3f, sizeof(dp));
    int h, w, k;
    cin >> h >> w >> k;
    char mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == 'a'){
                mat[i][j] = (char)('A' + cnt++);
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mat[i][j] == '#' || mat[i][j] == '.')    continue;
            int ind = dec(mat[i][j]);
            memset(bfs, 0x3f, sizeof(bfs));
            bfs[i][j] = 0;
            queue<int> q;
            q.push(i*w+j);
            while(!q.empty()){
                int x = q.front();  q.pop();
                int i = x/w, j = x%w;
                if(mat[i][j] != '.'){
                    dist[ind][dec(mat[i][j])] = bfs[i][j];
                }
                for(int k = 0; k < 4; k++){
                    int ni = i+di[k], nj = j+dj[k];
                    if(inRange(ni,0,h)&&inRange(nj,0,w)&&bfs[ni][nj]>bfs[i][j]+1&&mat[ni][nj]!='#'){
                        bfs[ni][nj] = bfs[i][j]+1;
                        q.push(ni*w+nj);
                    }
                }
            }
        }
    }
    dp[0][1] = 0;
    for(int s = 1; s < 1<<(cnt+1); s++){
        for(int i = 0; i < cnt+1; i++){
            if(((s>>i)&1) == 0) continue;
            if(dp[i][s] > 1e9)  continue;
            for(int j = 0; j < cnt+1; j++){
                if((s>>j)&1)   continue;
                if(dist[i][j] > 1e9)    continue;
                dp[j][s|(1<<j)] = min(dp[j][s|(1<<j)], dp[i][s]+dist[i][j]);
            }
        }
    }
    int ret = 2e9;
    for(int s = 1; s < 1<<(cnt+1); s++){
        int pop = -1;
        for(int j = 0; j < cnt+1; j++)  pop += (s>>j)&1;
        if(pop < k) continue;
        for(int j = 1; j <= cnt; j++){
            if(dist[j][cnt+1] < 1e9 && dp[j][s] < 1e9)  ret = min(ret, dp[j][s]+dist[j][cnt+1]);
        }
    }
    cout << (ret >= 2e9 ? -1 : ret) << endl;
    return 0;
}


Measured memory_bytes: 368484
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Paper : IEnumerable<int>
  {
    int[,] paper;

    public Paper(int x, int y)
    {
      paper = new int[y,x];
    }

    public int this[int x, int y]
    {
      get
      {
        if (paper.GetLowerBound(1) <= x && x <= paper.GetUpperBound(1) && paper.GetLowerBound(0) <= y && y <= paper.GetUpperBound(0))
          return paper[x, y];
        return -1;
      }
    }

    public void Drop(int x, int y, int size)
    {
        Drop(x, y);
        Drop(x - 1, y);
        Drop(x + 1, y);
        Drop(x, y - 1);
        Drop(x, y + 1);
        if (2 <= size)
        {
          Drop(x - 1, y - 1);
          Drop(x - 1, y + 1);
          Drop(x + 1, y - 1);
          Drop(x + 1, y + 1);
        }
        if (size == 3)
        {
          Drop(x - 2, y);
          Drop(x + 2, y);
          Drop(x, y - 2);
          Drop(x, y + 2);
        }
    }

    public IEnumerator<int> GetEnumerator()
    {
      foreach (var x in Enumerable.Range(0, paper.GetLength(0)))
        foreach (var y in Enumerable.Range(0, paper.GetLength(1)))
          yield return paper[x, y];
    }

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
      return ((System.Collections.IEnumerable)paper).GetEnumerator();
    }

    void Drop(int x, int y)
    {
      if (paper.GetLowerBound(0) <= x && x <= paper.GetUpperBound(0) && paper.GetLowerBound(0) <= y && y <= paper.GetUpperBound(1))
        ++paper[x, y];
    }
  }

  class Problem0026
  {
    static void Main()
    {
      var paper = new Paper(10, 10);
      foreach (var ink in ReadInkPoint())
      {
        paper.Drop(ink[0], ink[1], ink[2]);
      }
      Console.WriteLine(paper.Count(cell => cell == 0));
      Console.WriteLine(paper.Max());
    }

    static IEnumerable<int[]> ReadInkPoint()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return line.Split(',').Select(s => int.Parse(s)).ToArray();
    }
  }
}

Measured memory_bytes: 5988
N = int(input())
L = list(map(int, input().split()))

cnt = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      a, b, c = L[i], L[j], L[k]
      if a != b and b != c and c != a:
        if max(a, b, c) < a + b + c - max(a, b, c):
          cnt += 1

print(cnt)

Measured memory_bytes: 9216
N = gets.to_i
S = gets.chomp

stack = []

S.chars.each do |s|
  stack << s
  next if stack.size == 1

  if stack[-1] == ')' && stack[-2] == '('
    stack.pop(2)
  end
end

rc = stack.count { |x| x == ')' }

stack = []

S.chars.reverse_each do |s|
  stack << s
  next if stack.size == 1

  if stack[-1] == '(' && stack[-2] == ')'
    stack.pop(2)
  end
end

lc = stack.count { |x| x == '(' }

left = '(' * rc
right = ')' * lc

puts [left, S, right].join


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include<string>
#include<vector>
int main() {
	int ining;
	std::cin >> ining;
	std::string s;
	for (int i = 0; i < ining; ++i) {
		int co = 0;
		int ch = 0;
		int c = 0;
		while (std::cin >> s) {
			if (s == "OUT") {
				++co;
			}
			if (co == 3) {
				break;
			}
			if (s == "HIT") {
				++ch;
			}
			if (ch == 4) {
				--ch;
				++c;
			}
			if (s == "HOMERUN") {
				c += ch + 1;
				ch = 0;
			}
		}
		std::cout << c << std::endl;
	}
	}

Measured memory_bytes: 3136
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize("Ofast,no-stack-protector")
#include <bits/stdc++.h>
#define ll long long
#define res register ll
#define N 200005
#define inf 0x3f3f3f3f
#define mod 1000000007
ll a[N],n,m,sum[N],ans=2e18,total;
using namespace std;
inline ll read(){
	res w=0,X=0;register char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){X=(X<<1)+(X<<3)+(ch^48);ch=getchar();}
	return w?-X:X;
}
int main(){
	n=read(),m=read();
	for(res i=1;i<=n;i++)
	  a[i]=read(),sum[i]=sum[i-1]+a[i];
	for(res i=1;i<=n;i++){
		res tmp=3LL;
		total=0;
		for(res j=n;j>=1;j-=i){
			total+=(sum[j]-sum[max(j-i,0LL)])*max(tmp,5LL);
			tmp+=2;
			if(total>=ans) break;
		}
		ans=min(ans,total+m*(n+i));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <fstream>

using namespace std;

#define ll long long
#define pb push_back
/*void usacosolve(string x){
    ofstream fout(x+".out");
    ifstream fin(x+".in");
}*/
void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    ll dp[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        dp[i]=0;
    }
    dp[0]=0;
    dp[1]=dp[0]+abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}
int main(){
    /*//usaco:
    string x="";
    usacosolve(x);*/
    //codechef and others
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        //cout<<t<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
 
int find_min(int a, int b, int c){
  int min;
  min = a;
  if(min > b){
    min = b;
  }
  if(min > c){
    min = c;
  }
  
  return min;
}
 
int main(void){
  
  int k, a, b, c, sum = 0, min, gcd = 1, i;
  
  scanf("%d", &k);
  
  for(a = 1; a <= k; a++){
    for(b = 1; b <= k; b++){
      for(c = 1; c <= k; c++){
        min = find_min(a, b, c);
        for(i = min; i >= 1; i--){
          if((a%i == 0) && (b%i == 0) && (c%i == 0)){
            gcd = i;
            break;
          }
        }
        sum += gcd;
      }
    }
  }
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a;
    cin>>n;
    int W[105],sum=0,m=10001;
    for(int i=0;i<n;i++){
        cin>>W[i];
        sum+=W[i];
    }
    for(int i=n-1;i>=0;i--){
        sum-=2*W[i];
        m=min(m,abs(sum));
    }
    cout<<m<<endl;
}

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

int main() {

    int k;

    scanf("%d", &k);

    if (k % 2 == 0) {
        printf("%d", (k / 2)*(k / 2));
    } else {
        printf("%d", (1 + (k / 2))*(k / 2));
    }


    return 0;

}


Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let T1= xs[1].trim().split(' ');
   
   let ans =T1[0].substring(xs[0]/2);
   let ans2 =T1[0].substring(0,xs[0]/2);
 
   if(ans==ans2&&xs[0]%2==0){
   console.log('Yes');
   }else{
   console.log('No');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 9420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String word1 = "";
		String word2 = "";
		int n = 0;
		int pointA = 0;
		int pointB = 0;

		// ??????????????°??????????????°
		n = stdIn.nextInt();

		for (int i = 0; i < n; i++) {
			// ???????????\???
			word1 = stdIn.next();
			word2 = stdIn.next();
			int result = word1.compareTo(word2);
			if (result > 0) {
				// ?????????+3???
				pointA = pointA + 3;
			} else if (result == 0) {
				// ????????¨??±??????+1???
				pointA = pointA +1;
				pointB = pointB +1;
			} else {
				// ??±??????+3???
				pointB = pointB +3;
			}
		}

		System.out.println(pointA + " " + pointB);

		stdIn.close();
	}

}

Measured memory_bytes: 29196
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<int,101> a{};
  int d;

  while ( cin >> d )
    ++a[d];

  int mx = 0;

  for ( auto i = 1; i <= 100; ++i )
    if ( mx < a[i] ) mx = a[i];

  for ( auto i = 1; i <= 100; ++i )
    if ( a[i] == mx ) cout << i << endl;

  return 0;
}

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

int main(){
  int n;string s;
  cin >> n >> s;
  for(int i=0;i<s.size();i++){
    int a=s[i]-'A';
    char c='A'+(a+n)%26;
    cout << c;
  }
  cout << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
    //code
 	
 	int h , w;
 	string s;
 	cin >> h >> w;
 	for(int i = 0 ;  i < h ; ++i){
 		cin >> s;
 		cout << s << "\n" << s << "\n";
 	}   
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll sum = 0;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        sum += temp - 1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
abc = list(input())
if abc[k-1] == 'A':
    abc[k-1] = 'a'
if abc[k-1] == 'B':
    abc[k-1] = 'b'
if abc[k-1] == 'C':
    abc[k-1] = 'c'
print(''.join(abc))

Measured memory_bytes: 3060
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=[a,b,c,d,e]
sum=0
for i in range(5):
    if f[i]%10==0:
        sum+=f[i]
    else:sum+=(f[i]//10)*10+10
    f[i]=f[i]%10-1
    if f[i]==-1:f[i]=9
r=min(f)
if r==9:
    print(sum)
else:
    q=9-r
    print(sum-q)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string a;
    cin >> a;
    
    bool n = false, w=false, s=false, e=false;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == 'N') n = true;
        else if (a[i] == 'W') w = true;
        else if (a[i] == 'S') s = true;
        else e = true;
    }

    bool ans = true;
    if (n && s);
    else if (!n && !s);
    else ans = false;

    if (w && e) ;
    else if (!w && !e);
    else ans = false;

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll m=sqrt(n)+1,l=1;
    for(int i=1;i<m;++i){
        if(n%i==0)l=i;
    }
    ll a=l,b=n/l;
    string s=to_string(max(a,b));
    cout<<s.size();
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

// ライブラリを整備しなさ～い！
const int N = 1<<17;
pll dat[2*N];
void qset(int x, pll v){
  x += N-1;
  CHMAX(dat[x], v);
  while(x){
    x=(x-1)/2;
    dat[x] = max(dat[2*x+1], dat[2*x+2]);
  }
}
pll qmax(int l, int r, int a, int b, int k){
  if(r<=a || b<=l)return pll(-1ll<<60,-1ll<<60);
  if(l<=a && b<=r)return dat[k];
  int m = (a+b)/2;
  return max(qmax(l,r,a,m,2*k+1), qmax(l,r,m,b,2*k+2));
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  fill(dat,dat+2*N,pll(0,0));
  pll ans = pll(0,0);
  REP(i,n){
    int v = a[i];
    pll s = pll(0,0);
    if(v==0){
      s = pll(1,0);
    }else{
      pll q = qmax(0,v,0,N,0);
      s = q;
      s.first++;
      s.second+=v;
    }
    CHMAX(ans, s);
    qset(v, s);
  }
  printf("%lld\n",ans.second);
  return 0;
}



Measured memory_bytes: 7700
from collections import deque


def main():

    N, M = map(int, input().split())
    E = [list(map(int, input().split())) for _ in range(M)]

    # make graph
    G = [set() for _ in range(N)]
    for i in range(M):
        E[i][0], E[i][1] = E[i][0] - 1, E[i][1] - 1
        G[E[i][0]].add(E[i][1])

    def bfs(s):
        # find connected vertex by bfs
        vis_loc = [False] * N
        vis_loc[s] = True
        q = deque([s])
        while len(q):
            v = q.popleft()
            for n in G[v]:
                if vis_loc[n]:
                    continue
                q.append(n)
                vis_loc[n] = True
        return vis_loc
    vis = bfs(0)
    C = []
    for i in range(M):
        if vis[E[i][0]]:
            C.append(i)

    # Bellman-Ford
    N_con = sum(vis)
    ans = [float('inf')] * N
    ans[0] = 0
    for i in range(N_con):
        ud = -1
        for j in C:
            a, b, c = E[j]
            if ans[b] > ans[a] - c:
                ans[b] = ans[a] - c
                ud = a
        if ud == -1:
            break
        else:
            if i == N_con - 1:
                if bfs(ud)[N - 1]:
                    print('inf')
                    exit()
    print(-ans[N - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 46440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int result = 1;
		for (int i = 0; i < n; i++) {
			int tmp = Math.min(result * 2, result + k);
			result = tmp;
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	int[] A;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		A = new int[N];
		Arrays.fill(A, 0);
		for (int i = 1; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i - 1]) - 1;
		}
		int[] sums = new int[N];
		Arrays.fill(sums, 0);
		for (int i = 1; i < N; ++i) {
			sums[A[i]]++;
		}
		for (int i = 0; i < N; ++i) {
			System.out.println(sums[i]);
		}
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 66260
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define INT_MAX INF
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
int main() {
	string S;
	cin>>S;
	ll N=S.length();
	ll A=0,ans=0;
	for(int i=0;i<N-1;i++){
		if(S[i]=='A')
			A++;
		else if(S[i]=='B' && S[i+1]=='C'){
			ans+=A;
			i++;
		}
		else
			A=0;
		//cout<<i<<" "<<A<<" "<<ans<<endl;
	}
	cout<<ans<<endl;
    return 0;
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double ans = 0.0;
    if (a * a * b * 0.5 <= x) {
        ans = atan(2 * (b / a - x / (a * a * a))) * 180 / M_PI;
    } else {
        ans = atan((a * b * b) / (2 * x)) * 180.0 / M_PI;
    }

    cout << fixed << setprecision(7) << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  int ans_min, ans_max;
  ans_max = min(A, B);
  ans_min = max(A + B - N, 0);
  cout << ans_max << " " << ans_min << endl;
  return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
c = a + b
d = a - b
e = a * b
if c>=d>=e:
    print(c)
elif c>=e>=d:
    print(c)
elif d>=c>=e:
    print(d)
elif d>=e>=c:
    print(d)
else:
    print(e)

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

int main(){
  int n, q;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> q;
  int k[q];
  for(int i = 0; i < q; i++){
    cin >> k[i];
  }
  for(int i : k){
    if(binary_search(a.begin(), a.end(), i)){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3880
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 500000 + 9;
int n,a[N];
 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        int x;
        cin>>x;
        cout<<!x<<endl;



return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n;
	cin >> n;
	long long heights[n];
	for(long long i = 0; i<n; i++)
	{
		cin >> heights[i];
	}
	long long dp[n];
	dp[0] = 0;
	for(long long i = 1; i<n; i++)
	{
		dp[i] = min(dp[i-1] + abs(heights[i] - heights[i-1]), dp[i-2] + abs(heights[i] - heights[i-2]));
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a,b;
    vector<int>ans(n,0);
    REP(i,m*2){
        int tmp;
        cin>>tmp;
        ans.at(tmp-1)+=1;
    }
    REP(i,n) cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



Int n,m,_,x,y,q,key;
string s,sb;
bool ok;



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

  cin>>n; V(Int)a(n),b(n),c(n),bs(n+1);
  rep(i,n)cin>>a[i]; rep(i,n)cin>>b[i]; rep(i,n)cin>>c[i];
  sort(ALL(a)); sort(ALL(b)); sort(ALL(c)); bs[n]=0;
  Int ans=0; V(Int)::iterator it;
  rep(i,n)bs[i]=n-distance(c.begin(),upper_bound(ALL(c),b[i]));
  gnr(i,0,n)bs[i]+=bs[i+1];
  rep(i,n)ans+=bs[distance(b.begin(),upper_bound(ALL(b),a[i]))];
  END
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n,i;
	char c;
	cin>>c;
	if(c>='a' and c<='z') cout<<"a";
	else cout<<"A";
	
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  ll n,W,ans=0;cin>>n>>W;
  vll v(n),w(n);
  vvll dp(n+1,vll(W+1,0));
  rep(i,0,n){
    cin>>v[i]>>w[i];
  }
  rep(i,0,n){
    rep(j,0,W+1){
      if(j>=w[i]){dp[i+1][j]=dp[i][j-w[i]]+v[i];}
      dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
    }
  }
  
  cout<<dp[n][W]<<endl;
}



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

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

    int maxcnt=0;
    for (int i=1; i<s.size(); i++) {
        //文字列分割
        string s1, s2;
        s1=s.substr(0,i);
        s2=s.substr(i,s.size());

        //sortしておく
        sort(s1.begin(), s1.end());
        sort(s2.begin(), s2.end());

        //文字をカウント
        char cbuff=' ';
        int cnt=0;
        rep(i,s1.size()) {
            if (cbuff==s1.at(i)) continue;
            if (s2.find(s1.at(i))!=string::npos) cnt++;
            cbuff=s1.at(i);
        }

        //最大カウント数
        maxcnt=max(maxcnt, cnt);
    }

    cout << maxcnt << endl;
    return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  if(x <= k*500) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int a, b;
  cin >> a >> b;
  int ans = a + b / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	string s,t;
	cin>>s>>t;
	int n=size(s);
	bool ok=true;
	rep(i,n){
		if(s[i]==t[i]){

		}else{
			ok=false;
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;
            string[] vals = Console.ReadLine().Split(' ');
            A = int.Parse(vals[0]);
            B = int.Parse(vals[1]);
            C = int.Parse(vals[2]);

            if(C >= A && C <= B)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
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;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   set<int> a;

   rep(i,n){
      int s;
      cin>>s;
      a.insert(s);
   }
   cout<<a.size();

   


   


   
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,z,i,mi=0,ma;
  vector<int> x(9);
  cin>>n;
  for(i=0;i<n;i++){
    cin>>z;
    x.at(min(z/400,8))++;
  }
  for(i=0;i<8;i++) if(x.at(i)>0) mi++;
  ma=mi+x.at(8);
  if(mi==0) mi++;
  cout<<mi<<' '<<ma<<endl;
}

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

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

	string A = S.substr(2, S.size() - 3);

	if (S[0] == 'A') {
		if (count(A.begin(), A.end(), 'C') == 1) {
			sort(S.begin(), S.end());
			int Q = 0;
			for (int i = 0; i < S.size(); i++) {
				if (islower(S[i])) Q++;
			}

			if (S.size() - Q == 2) {
				cout << "AC" << endl;
				return 0;
			}
			else {
				cout << "WA" << endl;
				return 0;
			}
		}
		else {
			cout << "WA" << endl;
			return 0;
		}
	}
	else cout << "WA" << endl;

}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = Counter(list(map(int,input().split())))
res = 0
#print(A)
for item in A.items():
    k = item[0]
    v = item[1]
    if k > v:
        res += v
    elif k < v:
        res += v-k
print(res)

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			if(i *j == n) {
				cout << "Yes";
				return;
			}
		}
	}
	cout << "No";
	

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}


Measured memory_bytes: 3656
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr, foldl')
import Control.Monad (forM_)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

main = do
  n <- readLn
  xs <- U.map fromIntegral . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let ys :: U.Vector Int64
      ys = U.scanl (+) 0 xs
  let arr :: UArray (Int,Int) Int64
      arr = runSTUArray $ do
        arr <- newArray ((0,0),(n,n)) 0
        -- arr ! (i,j) : 半開区間 [i,j) にいるやつを全部合体させるために必要な最小のコスト
        -- 1個のスライムから1個のスライムを得るのに合体は必要ないので arr ! (i,i+1) == 0
        forM_ [2..n] $ \d -> do
          forM_ [0..n-d] $ \i -> do
            let !j = i + d -- 0 <= i < j <= d
            -- c1: これまでの合体で払うコストの最小値
            c1 <- foldl' min maxBound <$> sequence [(+) <$> readArray arr (i,k) <*> readArray arr (k,j) | k <- [i+1..j-1]]
            let c2 = ys U.! j - ys U.! i -- 今回の合体の際に払うコスト
            writeArray arr (i,j) $! c1 + c2
        return arr
  print $ arr ! (0,n)


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>l(n);
  for(int i=0;i<n;++i){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<k;++i){
    ans+=l[n-1-i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int k, x;
	cin >> k >> x;
	if (500*k>=x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())

max_1 = 0
max_2 = 0
max_index = 0

for i in range(n):
    item = int(input())
    if item >= max_1:
        max_1, max_2 = item, max_1
        max_index = i
    elif item > max_2:
        max_2 = item

for i in range(n):
    ans = max_2 if i == max_index else max_1
    print(ans)



Measured memory_bytes: 9252
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;

vector<int> G[100003];
int main(){
    int n, m;
    vector<int> fa(100003), rudu(100003);
    cin >> n >> m;
    queue<int> qq;
    rep(i, n + m){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        rudu[y]++;
    }
    rep(i,n) if(rudu[i+1] == 0){
        qq.push(i+1);
        break;
    }
    while(!qq.empty()){
        int x = qq.front();
        qq.pop();
        for(int y:G[x]){
            rudu[y]--;
                if(rudu[y] == 0){
                    qq.push(y);
                    fa[y] = x;
                }
        }
    }
    rep(i, n) cout << fa[i+1] << endl;
    return 0;
}


Measured memory_bytes: 7040
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
for i in range(1,10**5):
    tmp = i*(i+1)//2
    if n == tmp:
        k = i+1
        break
    elif n < tmp:
        print('No'); quit()
res = [[0 for j in range(k-1)]for i in range(k)]
cnt = 1
for i in range(k):
    for j in range(k-1-i):
        res[i][j] = cnt
        cnt += 1
# print(res)
cnt = 1
for j in range(k-1)[::-1]:
    for i in range(k):
        if res[i][j]: continue
        res[i][j] = cnt
        cnt += 1

print('Yes')
print(k)
for i in range(k):
    print(k-1,*res[i])


Measured memory_bytes: 72536
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n,k;cin >> n >> k;
    int w[n],v[n];rep{
        cin >> w[i] >> v[i];
    }
    long long dp[n+1][k+1] = {};
    
    for(int i = 0;i<n;i++){
        for(int j = 1;j<=k;j++){
            if(j - w[i] >= 0){
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
            //cout << dp[i+1][j] << " ";
        }
        //cout << endl;
    }
    cout << dp[n][k] << endl;
}

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

lli mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a[26];
  rep(i, n) { a[s[i] - 'a'].push_back(i); }
  lli ans = 1;
  rep(i, 26) { ans = (ans * (a[i].size() + 1)) % mod; }
  ans = (ans + mod - 1) % mod;
  cout << ans << endl;
}


Measured memory_bytes: 1152
H, W = map( int, input().split())
A = []
for _ in range(H):
    a = list( map( int, input().split()))
    A.append(a)
N = 0
ANS = []
for i in range(H):
    for j in range(W):
        if A[i][j]%2 == 0:
            pass
        else:
            if j == W-1:
                if i == H-1:
                    pass
                else:
                    A[i][j] -= 1
                    A[i+1][j] += 1
                    N += 1
                    ANS.append([i+1, j+1, i+2, j+1])
            else:
                A[i][j] -= 1
                A[i][j+1] += 1
                ANS.append([i+1,j+1,i+1,j+2])
                N += 1
print(N)
for a in ANS:
    a = map( str, a)
    print(' '.join(a))

Measured memory_bytes: 29808
h,w=map(int,input().split())

L=[]
for i in range(h):
  a=list(input())
  if "#" in a:
    L.append(a)
import numpy as np
A=[]
tenti=np.array(L).T
for i in range(w):
  if "#" in tenti[i]:
    A.append(tenti[i])
tenti=np.array(A).T 
ans=""

for i in range(len(tenti)):
  for j in range(len(tenti[i])):
    ans+=tenti[i][j]
  print(ans)
  ans=""



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

signed main(){

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

  function< int(vector<int>) > rec =
  [&](vector<int> a){
    int ans = a[0];
    int res = a[0];
    for(int i = 0; i < n; i++){
      if(__gcd(ans,a[i]) < ans){
        if(__gcd(ans,a[i]) <= __gcd(ans,res)){
          ans = __gcd(ans,res);
          res = a[i];
        }
        else {
          ans = __gcd(ans,a[i]);
        }
      }
      else {
        ans = __gcd(ans,a[i]);
      }
    }
    return ans;
  };

  int ans = 1;
  ans = max(ans,rec(a));
  reverse(a.begin(),a.end());
  ans = max(ans,rec(a));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Between a and b ...
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  if (a == 0) printf("%lld\n", b / x + 1);
  else printf("%lld\n", b / x - (a - 1) / x);
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, a, b;
	cin >> n >> a >> b;

	string s;
	cin >> s;

	int passed = 0, overseas_passed = 0;
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] == 'a') {
			if (passed < a + b) {
				cout << "Yes\n";
				++passed;
			} else {
				cout << "No\n";
			}
		} 
		else if (s[i] == 'b') {
			if (passed < a + b && overseas_passed < b) {
				++passed;
				++overseas_passed;
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else {
			cout << "No\n";
		}
	}

	return 0;

}

Measured memory_bytes: 848
def main():
    n,m = map(int,input().split())
    answer = -1
    num = [-1] * n
    mujun = False
    for _ in range(m):
        s,c = map(int,input().split())
        s = s-1
        if num[s] == -1 or num[s] == c:
            num[s] = c
        else:
            mujun = True
            break
    if mujun or (num[0] == 0 and len(num) != 1) :
        print(-1)
    else:
        if num[0] == -1:
            num[0] = 1 if len(num) != 1 else 0
        num = [0 if i==-1 else i for i in num]
        print(int("".join(map(str,num))))



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;

bool cmp(int a,int b)
{
    return a>b;
}
ll a[maxn];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    for(int i=1;i<=1111;i++)
		a[i]=(i*i*i);
	int n;
	while(cin>>n&&n){
		ll t=n*n*n;
		ll Max=-1;
		for(int i=n;i>=1;i--)
		for(int j=n;j>=1;j--){
			if(a[i]+a[j]<=t){Max=max(a[i]+a[j],Max);}
		}
		cout<<t-Max<<endl;
	}
    return 0;
}

Measured memory_bytes: 1164