akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
const int MAX_D = 12810;
bool dp[80][80][2 * MAX_D];
int a[80][80], b[80][80];
int main() {
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> b[i][j];
            a[i][j] -= b[i][j];
            for(int k = 0; k < 2 * MAX_D; k++) {
                dp[i][j][k] = false;
            }
        }
    }
    dp[0][0][a[0][0] + MAX_D] = true;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            for(int k = 0; k < 2 * MAX_D; k++) {
                if(!dp[i][j][k]) continue;
                if(i + 1 < H) {
                    int p = k + a[i + 1][j];
                    int n = k - a[i + 1][j];
                    if (p >= 0 && 2 * MAX_D > p) {
                        dp[i + 1][j][p] = true;
                    }
                    if (n >= 0 && 2 * MAX_D > n) {
                        dp[i + 1][j][n] = true;
                    }
                }
                if (j + 1 < W) {
                    int p = k + a[i][j + 1];
                    int n = k - a[i][j + 1];
                    if (p >= 0 && 2 * MAX_D > p) {
                        dp[i][j + 1][p] = true;
                    }
                    if (n >= 0 && 2 * MAX_D > n) {
                        dp[i][j + 1][n] = true;
                    }
                }
            }
        }
    }
    int ans = 1e8;
    for(int i = 0; i < 2 * MAX_D; i++) {
        if(!dp[H - 1][W - 1][i]) continue;
        ans = min(ans, abs(i - MAX_D));
    }
    cout << ans << endl;
  	return 0;
}



Measured memory_bytes: 160384
s = str(input()[::-1])
n=len(s)
mlist,m,d=[],0,1
  
for ss in s:
  m += int(ss) * d
  m %= 2019
  d *= 10
  d %= 2019
  mlist.append(m)
  
l=sorted(mlist)
l.append(2020)
pre,count,ans=0,0,0
for ll in l:
  if pre==ll:
    count+=1
  else:
    ans+=count*(count+1)//2
    pre=ll
    count=0
print(ans)

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

int main() {
	int N;
    cin >> N;
  	string S, T;
    cin >> S >> T;
  
  	for(int i = 0; i < N; i++) {
    	cout << S[i] << T[i];
    }
    cout << endl;
}

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

vector<int> t;
vector<int> g={3,5,7};
int dfs(int a,int n){
  string s=to_string(a);
  if (s.size()==n and a!=0){
  //
    set <char> m;
    rep(i,s.size()){
      m.insert(s[i]);
    }//cout<<m.size()<<endl;
     if (m.size()==3){

    t.push_back(a);
  }return 0;
  }

  for (int i=0;i<3;i++){
    int ne=a*10+g[i];
    dfs(ne,n);
  }
}

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

  for(int i=3;i<=9;i++){
    dfs(0,i);
  }
  sort(t.begin(),t.end());
auto idx=upper_bound(t.begin(),t.end(),n);
int ans=idx-t.begin();
//rep(i,n)cout<<t[i]<<endl;
  cout<<ans;

}


Measured memory_bytes: 512
//WriteandErase.cpp (C)
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

int main(){
  int N;
  string A;
  int Ans = 0;
  map<string, int> num;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(num[A] == 0) ++num[A];
    else num[A] = 0;
  }
  for(auto ans: num){
    if(ans.second == 1) ++Ans;
  }
  printf("%d\n",Ans);
}


Measured memory_bytes: 12544
#include<stdio.h>
#define MAX 100
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra()
{
  int i,u,v, minv,sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;  
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	  u=i;
	  minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];

	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }

}

int main(){
  int i, j,e;
  int k,c,u,v;
  scanf("%d",&n);
   for(i=0;i<n;i++){
    for(j=0;j<n;j++){

      M[i][j]=INFTY;
    }
  }
   for(i=0;i<n;i++){
     scanf("%d",&u);
     scanf("%d",&k);
     for(j=0;j<k;j++){
       scanf("%d",&v);
       scanf("%d",&c);
       M[u][v]=c;
     }
   }
   dijkstra();


   return 0;
}



Measured memory_bytes: 2036
N = input()
P = input().split()

N = int(N)
P =[int(p) for p in P] 


count = 0

minimum=N

for i in range(N):
    if minimum >= P[i]:
        count+=1
        minimum = P[i]
        if minimum == 1:
            break
        
    
print(count)


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

int main()
{
 int n;
  cin>>n;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  
  float avg=0;
  for(int i=0;i<n;i++)
  {
	avg+=arr[i];
  }
  
  avg=(avg/n);
  if(avg-(int)(avg)<=0.5)
  {
    avg=(int)(avg);
  }
  else
  {
    avg=(int)(avg)+1;
  }
  long long int cost=0;
  for(int i=0;i<n;i++)
  {
    cost+=(avg-arr[i])*(avg-arr[i]);
  }
  cout<<cost;
  
  return 0;
}

Measured memory_bytes: 256
// Limit: 32768K / 8000ms
#include <vector>
#include <cstdio>
using namespace std;

class UnionFindTree {
public:
  UnionFindTree(int n) {
    par = vector<int>(n);
    for (int i = 0; i < n; i++) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    int rx = find(x), ry = find(y);
    if (rx != ry) par[ry] = rx;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
private:
  vector<int> par;
};

vector<vector<int> > G;
vector<bool> marked;
UnionFindTree tree(0);

long long solve(int N, int Q, vector<int>& parent, vector<pair<bool, int> >& queries) {
  for (int i = 0; i < Q; i++) {
    if (queries[i].first == false) marked[queries[i].second-1] = true;
  }

  tree = UnionFindTree(N);
  for (int i = 0; i < N; i++) {
    if (!marked[i]) tree.unite(parent[i], i);
  }

  long long res = 0;
  for (int i = Q - 1; i >= 0; i--) {
    int x = queries[i].second - 1;
    if (queries[i].first == false) {
      tree.unite(parent[x], x);
    } else {
      res += tree.find(x) + 1;
    }
  }
  return res;
}

int main() {
  while (true) {
    int N, Q; scanf("%d %d", &N, &Q);
    if (N == 0 && Q == 0) break;

    vector<int> parent(N);
    G = vector<vector<int> >(N);
    for (int i = 1; i < N; i++) {
      int n; scanf("%d", &n);
      G[n-1].push_back(i);
      parent[i] = n-1;
    }

    marked = vector<bool>(N);
    marked[0] = true;
    vector<pair<bool, int> > queries(Q);
    char buf[2];
    int qnum = 0;
    for (int i = 0; i < Q; i++) {
      int n; scanf("%s %d", buf, &n);
      if (buf[0] == 'Q') {
        queries[qnum++] = make_pair(true, n);
      } else if (!marked[n-1]) {
        marked[n-1] = true;
        queries[qnum++] = make_pair(false, n);
      }
    }
    Q = qnum;
    queries.resize(Q);
    long long ans = solve(N, Q, parent, queries);
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
自分にとって最大をとるだけじゃだめ、妨害も考慮
ただ総合値が大きいのをとればいいんじゃ
*/
int main(){
  ll N; cin>>N;
  vector<vector<ll>> S(N,vector<ll>(3,0));
  for(ll i=0; i<N; i++){
    ll a,b; cin>>a>>b;
    S[i][0]=a;
    S[i][1]=b;
    S[i][2]=a+b;
  }
  sort(S.begin(), S.end(), [](auto& x, auto& y){return x[2] > y[2];});
  ll asum=0,bsum=0;
  for(ll i=0; i<N; i++){
    if(i%2==0) asum+=S[i][0];
    else bsum+=S[i][1];
  }
  cout<<asum-bsum<<endl;
}

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

using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;

template<typename C>
i64 Size(const C& c) { return static_cast<i64>(c.size()); }

template<typename C>
void Sort(C &c) { std::sort(c.begin(), c.end()); }

template<typename C>
void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }

template<typename T, typename U, typename Comp=std::less<>>
bool ChMax(T& x_max, const U& x, Comp comp={}) {
  if(comp(x_max, x)) {
    x_max = x;
    return true;
  }
  return false;
}

template<typename T, typename U, typename Comp=std::less<>>
bool ChMin(T& x_min, const U& x, Comp comp={}) {
  if(comp(x, x_min)) {
    x_min = x;
    return true;
  }
  return false;
}

struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;

  ProconInit() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(IOS_PREC);
    if (AUTOFLUSH) std::cout << std::unitbuf;
  }
} PROCON_INIT;

void solve() {
  i64 n; std::cin >> n;

  if (n % 10 == 7) {
    std::cout << "Yes" << "\n";
    return;
  }

  if ((n / 10) % 10 == 7) {
    std::cout << "Yes" << "\n";
    return;
  }

  if ((n / 100) % 10 == 7) {
    std::cout << "Yes" << "\n";
    return;
  }

  std::cout << "No" << "\n";
}

signed main() {
  solve();

  return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())

def main(N, M):

    if N <= M // 2: # Sが足りない
        print(int(N + (M - (N*2))//4))
    else:# cが足りない
        print(int(M//2))

if __name__ == '__main__':
    main(N, M)


Measured memory_bytes: 2940
while True:
    m,f,r = map(int, input().split())
    if (m==-1)&(f==-1)&(r==-1): break
    if (m==-1)|(f==-1):
        ans = 'F'
    elif m+f>=80:
        ans = 'A'
    elif m+f>=65:
        ans = 'B'
    elif m+f>=50:
        ans = 'C'
    elif m+f>=30:
        ans = 'D'
        if r>=50:
            ans = 'C'
    else:
        ans = 'F'
    print(ans)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<char>> vec;
int main(){
  ll H,W,ans=0;
  cin>>H>>W;
  ll dp[111][111];
  vec.resize(H,vector<char>(W));
  vector<vector<ll>> answer(H,vector<ll>(W));
  for(ll i=0;i<H;i++){
    for(ll j=0;j<W;j++){
      cin>>vec.at(i).at(j);
    }
  }
  if(vec.at(0).at(0)=='#'){ans++;}
  for(ll i=1;i<=H;i++){
    for(ll j=1;j<=W;j++){
      if(i==1&&j==1){
        dp[i][j]=0;
      }else if(i==1&&j!=1){
        dp[i][j]=dp[i][j-1];
        if(vec.at(i-1).at(j-1)=='#'&&vec.at(i-1).at(j-2)=='.'){dp[i][j]++;}
      }else if(i!=1&&j==1){
        dp[i][j]=dp[i-1][j];
        if(vec.at(i-1).at(j-1)=='#'&&vec.at(i-2).at(j-1)=='.'){dp[i][j]++;}
      }else{
        ll a;
        a=dp[i][j-1];
        if(vec.at(i-1).at(j-1)=='#'&&vec.at(i-1).at(j-2)=='.'){a++;}
        ll b;
        b=dp[i-1][j];
        if(vec.at(i-1).at(j-1)=='#'&&vec.at(i-2).at(j-1)=='.'){b++;}
        dp[i][j]=min(a,b);
      }
    }
  }
  cout<<dp[H][W]+ans<<endl;
}

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();

        Map<Integer, List<Integer>> map = new HashMap<>();

        for (int i = 0; i < N; i++) {
            int A = nextInt();
            int B = nextInt();
            List<Integer> list = new ArrayList<>();
            if (map.containsKey(B)) {
                list = new ArrayList<>(map.get(B));
            }
            list.add(A);
            map.put(B, list);
        }

        List<Integer> keys = new ArrayList<>(map.keySet());
        Collections.sort(keys);

        int time = 0;
        boolean flag = false;
        for (int i = 0; i < keys.size(); i++) {
            for (int j = 0; j < map.get(keys.get(i)).size(); j++) {
                int A = map.get(keys.get(i)).get(j);
                int B = keys.get(i);
                time += A;
                if (time > B) {
                    flag = true;
                    break;
                }
            }
        }

        println(flag ? "No" : "Yes");
    }

    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 128568
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    string s;
    int ans;
    cin >> s;
    if(s=="SUN"){
        ans = 7;
    }else if(s=="MON"){
        ans = 6;
    }else if(s=="TUE"){
        ans = 5;
    }else if(s=="WED"){
        ans = 4;
    }else if(s=="THU"){
        ans = 3;
    }else if(s=="FRI"){
        ans = 2;
    }else{
        ans = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>

using namespace std;

double EPS = 1e-10;

int main() {
	double ax, ay, bx, by, cx, cy, dx, dy;

	while( cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy ) {
		bx -= ax; by -= ay;
		dx -= cx; dy -= cy;

		if( abs((bx * dx) + (by * dy)) < EPS ) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_H 1000
#define MAX_W 1000


int main(void) {

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

    int n, m;
    M d_mp;
    bool ans = true;
    cin >> n;
    for(int i = 0 ; i < n ; i++){  int d;  cin >> d;  d_mp[d]++;  }
    cin >> m;
    for(int i = 0 ; i < m ; i++){
      int t;  cin >> t;
      if(d_mp[t] - 1 < 0){  ans = false;  break;  }
      else                  d_mp[t]--;
    }

    if(ans)  cout << "YES" << endl;
    else     cout << "NO"  << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);


void solve(long long N){
    ll ans=0;
    for(long long i = 1; i*(i+2) <= N; i++){
        if(N%i==0&&N/(N/i-1)==N%(N/i-1)){
            ans+=N/i-1;
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w;
    int a;
    char field[110][110];
    rep(i,110){
        rep(j,110){
            field[i][j]='#';
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> field[i+1][j+1];
        }
    }
    rep(i,h+2){
        rep(j,w+2){
            cout << field[i][j];
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {

    input = input.split("\n");
    
    const n = parseInt(input[0]);
    var zoro = 0;

    for (var i=0 ; i<n ; i++){
        d = input[i+1].split(" ");
        var d1 = d[0];
        var d2 = d[1];
        
        if(d1 === d2) {
            zoro++;
        } else if(zoro>=3) {
            break;
        } else {
            zoro = 0;
        }

    }

  if (zoro >= 3) {
        console.log('Yes');
    } else {
        console.log('No');
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 29668
a, b, c, x, y = map(int, input().split())
ab = c * 2

res = float("inf")
if a + b <= ab:
    res = x * a + y * b
else:
    if x == y:
        res = x * ab
    elif x > y:
        for i in range(y, x + 1):
            cost = i * ab + (x - i) * a
            res = min(res, cost)
    else:
        for i in range(x, y + 1):
            cost = i * ab + (y - i) * b
            res = min(res, cost)
print(res)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std ; 
#define MOD 1000000007
char grid[2001][2001] ; 
long long int dp[2001][2001] ; //ab karoong mai bottom up build o f this arrya . 
int paths(int h,int w ,int i,int j){
    dp[h-1][w-1] = 1 ;
    for(int i = h-1; i>=0 ; i--){
         for(int j = w-1 ; j>=0 ; j--){
             //dp[i][j] represents the number of ways to go to n,m from i,j .
             if(i==h-1 && j==w-1){
                 continue ; 
             }
             if(grid[i][j]=='#'){
                 dp[i][j] = 0 ; 
             }else{
                 dp[i][j] = (((i==h-1) ? 0 : dp[i+1][j])+ ( (j==w-1) ? 0 : dp[i][j+1] ) )%MOD;
             }


         }

    }
    return dp[0][0] ; 
}
int main(){
    int h,w ; cin>>h>>w ; 
    for(int i = 0 ; i<h ; i++ ){
        for(int j =0 ; j<w ; j++){
            cin>>grid[i][j] ; 
        }
    }
    cout<<paths(h,w,0,0) ;
}

Measured memory_bytes: 20224
def resolve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    sortedA = sorted(A)
    for a in A:
        if a == sortedA[-1]:
            print(sortedA[-2])
        else:
            print(sortedA[-1])

    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 18948
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

fn main() {
    input! {
        q: usize,
        ab: [(i64, i64); q]
    }
    for &(a, b) in ab.iter() {
        if (a - b).abs() <= 1 {
            println!("{}", 2 * (min(a, b) - 1));
            continue;
        }
        let mut c = 0;
        let mut high = max(a, b);
        while high - c > 1 {
            let m = (c + high) / 2;
            if m * m < a * b {
                c = m;
            } else {
                high = m;
            }
        }
        if c * (c + 1) >= a * b {
            println!("{}", 2 * c - 2);
        } else {
            println!("{}", 2 * c - 1);
        }
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> c;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    c.emplace_back(a, b);
  }

  sort(ALL(c));
  int ans = 0;
  int last = 0;
  for (auto& p : c) {
    if (p.second >= last) {
      ans++;
      last = p.first;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  VI a(n);
  REP(i,n)cin >> a[i];

  vector<ll> csum(n+1);
  csum[0]=a[0];
  REP(i,n-1)csum[i+1] = csum[i]+a[i+1];

  ll ans=INF;
  int l=0,r=2;
  REP(i,n-3){
    int y=i+1;

    while(l < y-1 && (abs(2*csum[l]-csum[y]) > abs(2*csum[l+1]-csum[y]))){
      l++;
    }

    ll mi=min(csum[l], csum[y]-csum[l]);
    ll ma=max(csum[l], csum[y]-csum[l]);

    while(r < n-2 && (abs(2*csum[r]-csum[y]-csum[n-1]) > abs(2*csum[r+1]-csum[y]-csum[n-1]))){
      r++;
    }

    ll mii=min(csum[r]-csum[y], csum[n-1]-csum[r]);
    ll maa=max(csum[r]-csum[y], csum[n-1]-csum[r]);

    ans=min(ans, max(ma,maa)-min(mi,mii));

  }
  cout << ans << endl;
}



Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N; cin >> N;
    int x=-1;
    rep(i,1000){
        if(i*(i+1)==2*N){
            x=i;
            break;
        }
    }
    if(x==-1) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        cout << x+1 << endl;
        vector<vector<int>> ans(x+1,vector<int>(x));
        rep(i,x+1){
            rep(j,x){
                if(i<=j){
                    if(i>0) ans[i][j]=ans[i-1][x-1]+(j-i)+1;
                    else ans[i][j]=(j-i)+1;
                }
                else{
                    ans[i][j]=ans[j][j]+(i-j)-1;
                }
            }
        }
        rep(i,x+1){
            cout << ans[i].size() << " ";
            for(int u:ans[i]) cout << u << " ";
            cout << endl;
        }
    }
    
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s, t;  cin >> s >> t;
  vector<char> s1, t1;
  for(auto x: s) s1.push_back(x);
  for(auto x: t) t1.push_back(x);
  sort(s1.begin(), s1.end());
  sort(t1.begin(), t1.end(), greater<char>());
  string ans="Yes";
  if(t1<=s1) ans = "No";
  cout <<ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	cout << ((s[0] == '1') +( s[1] == '1') + (s[2] == '1')) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int N;
    cin >> N;    
    vector <int> A(N), B(N);
    rep(i, N)
        cin >> A[i];
    rep(i, N)
        B[A[i]-1] = i + 1;
    rep(i, N)
        cout << B[i]<<" ";
}

Measured memory_bytes: 2432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LI()
    for i in range(b*10,(b+1)*10):
        if math.floor(i*0.08) == a:
            return i

    return -1


print(main())





Measured memory_bytes: 6228
#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;


int main()
{
	//freopen("in.txt","r",stdin);
	string s;
	cin >> s;
	int k;
	cin >> k;
	FOR(i, 0, SZ(s))
	{
		if (s[i] == 'a') continue;
		int cnt = 'z' - s[i] + 1;

		if (k >= cnt)
		{
			s[i] = 'a';
			k -= cnt;
		}
	}

	if (k != 0)
	{
		int c = s[SZ(s) - 1] - 'a';
		c += k;
		c %= 26;
		s[SZ(s) - 1] = c + 'a';
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512
n = int(input())
cou = 0
for i in range(1,n+1):
  i = str(i)
  if i[0]!="0" and i[-1]!="0":
    if int(i[0])>int(i[-1]):
      cou +=  (10**(len(i)-1)-1)//9
    elif int(i[0])<int(i[-1]):
      cou += (10**(len(i)-2)-1)//9
  #print(i,cou)

cou *= 2
    
l = [0 for i in range(9)]
for i in range(1,n+1):
  i = str(i)
  if i[0]==i[-1]:
    l[int(i[0])-1] += 1
l1 = [i*i for i in l]
print(sum(l1)+cou)

Measured memory_bytes: 9168
// I LOVE MY FAMILY
#include<bits/stdc++.h>
using namespace std;
#define satyendra long long int
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   satyendra a, b ;
   cin >> a >> b ;
   satyendra ans = max( max ( a+b, a-b ) , a*b) ;
   cout << ans ;
}

Measured memory_bytes: 256
from collections import deque


N,M = (int(x) for x in input().split())
connected = [[] for _ in range(N+1)]
searched = [0] * (N+1)
signs = [0] * (N+1)
for i in range(M):
    A,B = (int(x) for x in input().split())
    connected[A].append(B)
    connected[B].append(A)
d = deque()
for edge in connected[1]:
    d.append(edge)
    signs[edge] = 1
    searched[edge] = 1
searched[1] = 1
while d:
    temp = d.popleft()
    for edge in connected[temp]:
        if searched[edge] == 0:
            d.append(edge)
            signs[edge] = temp
            searched[edge] = 1
    searched[temp] = 1
print('Yes')
for x in signs[2:]:
    print(x)

Measured memory_bytes: 35836
n=int(input())
l=list(map(int,input().split()))
c=0
t=-1
j=0
for i in range(n):
    if l[i]>t:
        t=l[i]
        c=0
    else:
        t=l[i]
        c+=1
    if c>=j:
        j=c
print(j)
    

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
int main(){
	ll sum=0;
	ll n=0;
	cin>>n;
	for(register int i=1;i<=n;++i)
	for(register int j=1;j<=n;++j)
	for(register int k=1;k<=n;++k)
	sum+=__gcd(__gcd(i,j),k);
	cout<<sum;
}


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

int main(){
    int N, i, j;
    cin >> N;
    int *A;
    A = new int[N];
    for(i=0; i < N; i++){
        cin >> A[i];
    }
    for(j = 0; j < N; j++){
        if(A[j] % 2 == 0){
            if(A[j] % 3 != 0 && A[j] % 5 != 0){
                cout << "DENIED" << endl;
                break;
            }
        }
    }
    if(j == N){cout << "APPROVED" << endl;}
    system("pause");
    return 0;
}

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

int main() {
	string O, E; cin >> O >> E;
	for(int i=0; i<O.size(); ++i){
	    if(i!=E.size()) cout << O[i] << E[i];
	    else cout << O[i];
	}
	cout << endl;
	return 0;
}


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

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

  map<string, ll> m;
  for (int i = 0; i < n; i++) {
    if (a[i] >= 3200) {
      m["other"]++;
    } else if (a[i] >= 2800) {
      m["red"]++;
    } else if (a[i] >= 2400) {
      m["daidai"]++;
    } else if (a[i] >= 2000) {
      m["yellow"]++;
    } else if (a[i] >= 1600) {
      m["blue"]++;
    } else if (a[i] >= 1200) {
      m["sky"]++;
    } else if (a[i] >= 800) {
      m["green"]++;
    } else if (a[i] >= 400) {
      m["cha"]++;
    } else if (a[i] >= 1) {
      m["gray"]++;
    }
  }
  ll cnt = 0;
  for (auto v : m) {
    if (v.first != "other") { cnt++; }
  }
  // ll mx = min(cnt + m["other"], 8LL);
  // ll mx = min(cnt + m["other"], 8LL);
  ll mx = cnt + m["other"];
  cnt   = max(cnt, 1LL);
  cout << cnt << " " << mx << endl;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = gets.to_i

fac = [1]
1.upto(n+1) {|i| fac << fac.last * i % mod}

x = fac.last
r_fac = [1]
"111011100110101100101000000101".reverse!.each_char do |c|
    r_fac[0] = r_fac[0] * x % mod if c == "1"
    x = x ** 2 % mod
end

n.times {|i| r_fac.unshift(r_fac.first * (n - i + 1) % mod)}
r_fac.unshift(1)

s = 0
jud = Array.new(n+1,-1)
gets.split.map(&:to_i).each_with_index do |e,i|
    if jud[e] == -1
        jud[e] = i
    else
        s = jud[e] + n - i
    end
end

1.upto(n+1) do |i|
    ans = fac[n+1] * r_fac[i] % mod * r_fac[n-i+1] % mod

    if s >= i - 1
        x = fac[s] * r_fac[i-1] % mod * r_fac[s-i+1] % mod
        ans = (ans - x) % mod
    end

    puts ans
end

Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,e;
int main(){
  cin >> n;
  ll mi = 1e15;
  for(int i=0 ; i<5 ; i++){
    ll x;
    cin >> x;
    mi = min(mi, x);
  }
  ll k = n/mi;
  if(n%mi != 0)  k++;
  cout << k + 4 << endl;
  
  return 0;
}


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

import collections
a = list(map(int,input().split()))
A = [] * 3 * N
for i in range(len(a)):
    A.append(a[i] - 1)
    A.append(a[i])
    A.append(a[i] + 1)

c = collections.Counter(A)
ans = c.most_common()[0][1]
print(ans)


Measured memory_bytes: 30940
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
g = []
for i in range(n+1): g.append([])

for i in range(n-1):
    a, b, c = na()
    g[a].append((b,c))
    g[b].append((a,c))

q,k = na()

def dfs(cur, pre, g, par, dw, w):
    dw[cur] = w
    par[cur] = pre
    for e in g[cur]:
        if e[0] != pre:
            dfs(e[0], cur, g, par, dw, w + e[1])

par = [-1] * (n+2)
dw = [-1] * (n+2)
from asyncio import Queue
qs = Queue()
qs.put_nowait(k)
dw[k] = 0

while not qs.empty():
    cur = qs.get_nowait()
    for e in g[cur]:
        if e[0] != par[cur]:
            par[e[0]] = cur
            dw[e[0]] = dw[cur] + e[1]
            qs.put_nowait(e[0])


# dfs(k, -1, g, par, dw, 0)

for z in range(q):
    x, y = na()
    print(dw[x] + dw[y])

Measured memory_bytes: 54588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> ans(N,-2);
    vector<vector<int>> memo(N,vector<int>(0));
    vector<bool> seen(N,false);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        memo[a].push_back(b);
        memo[b].push_back(a);
    }

    queue<int> q;
    q.push(0);
    while(q.size()>0){
        int num = q.front();
        q.pop();
        
        for(int i=0;i<memo[num].size();i++){
            if(seen[memo[num][i]]!=true){
                //cout << "push" << num << "-" << memo[num][i] << endl;
                q.push(memo[num][i]);
                ans[memo[num][i]]=num;
                seen[memo[num][i]] = true;
            }
        }
    }
    for(int i=1;i<N;i++){
        if(ans[i]<0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10216
#include<stdio.h>

int main(void){

  int a, b;

  scanf("%d",&a);
  scanf("%d",&b);

  if (a < b){
    printf("a < b\n");
  }
  else if (a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 1780
N,K=map(int,input().split())
A=list(map(int,input().split()))
now=1
count=0
a=0
l=[1]
b=0
c=0
q=[False]*N
while a==0and count<K:
    now=A[now-1]
    count+=1
    if q[now-1]:
        a=1
    else:
        l.append(now)
        q[now-1]=True
        
b=l.index(now)
c=count-b
if count==K:
    print(now)
else:
    n= ((K-b)%c)
    print(l[b+n])



Measured memory_bytes: 32372
using System;

namespace GCDandLCM
{
    class Program
    {
        static void Main(string[] args)
        {
            string buf;
            while (!string.IsNullOrEmpty(buf = Console.ReadLine()))
            {
                string[] str = buf.Split(' ');
                int a = int.Parse(str[0]), b = int.Parse(str[1]);
                int gcd = (a > b) ? Myfunc(a, b) : Myfunc(b, a);
                Console.WriteLine("{0} {1}", gcd, a / gcd * b);
            }
        }


        public static int Myfunc(int a, int b)
        {
            if (b == 0)
            {
                return a;
            }
            return Myfunc(b, a % b);
        }
    }
}



Measured memory_bytes: 9032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int n, m;
	cin >> n >> m;
	int c[26] = {};

	REP(i,n){
		string s;
		cin >> s;
		for (char x : s) c[x - 'a']++;
	}

	REP(i,26) c[i] %= 4;
	int x[4] = {};
	REP(i,26) x[c[i]]++;

	bool ok = false;

	// REP(i,4) cout << x[i] << " ";
	// cout << endl;

	if (n % 2 == 0 && m % 2 == 0){
		if (x[0] == 26) ok = true;
	}else if (n % 2 == 0 && m % 2 == 1){
		if (x[0] + x[2] == 26 && x[2] <= n/2) ok = true;
	}else if (n % 2 == 1 && m % 2 == 0){
		if (x[0] + x[2] == 26 && x[2] <= m/2) ok = true;
	}else{
		if (x[1] == 1 && x[3] == 0){
			if (x[2] <= n/2 + m/2) ok = true;
		}
		if (x[3] == 1 && x[1] == 0){
			if (x[2] < n/2 + m/2) ok = true;
		}
	}

	cout << (ok ? "Yes" : "No") << endl;

    return 0;
}





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

using namespace std;

int main()
{
	int n = 0, tmp = 1;
	int max = 0;
	
	while (cin >> n) {
		while (1) {
			tmp *= 2;
			if (n < tmp) {
				max = tmp/2;
				break;
			}
		}
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 256
// Created by PRATEEK RANJAN
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long 

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n{};
    cin>>n;
    int freq[n][26]{};
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=0;j<s.length();j++){
            freq[i][s[j]-'a']++;
        }
    }
    string ans;
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<26;j++){
    //         cout<<freq[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    for(int j=0;j<26;j++){
        int m = INT_MAX;
        for(int i=0;i<n;i++){
            m = min(m,freq[i][j]);
        }
        if(m==0)
            continue;
        while(m--){
            ans+= ('a'+j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;//*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
	while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
#define y1 yy11
#define pi acos(-1)
vector<pii> v;
const int N=200011;
int n,x1,x2,y1,y2,b[N];
inline bool In(int x,int y){return x1<=x&&x<=x2&&y1<=y&&y<=y2;}
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif
	x1=rd(),y1=rd(),x2=rd(),y2=rd(),n=rd();
	int fx=1,fy=1;
	if(x1>x2)swap(x1,x2),fx=-1;
	if(y1>y2)swap(y1,y2),fy=-1;
//	if(fx==fy)fx=fy=1;
	rep(i,1,n){
		int x=rd(),y=rd();
		if(In(x,y))v.pb(mp(x*fx,y*fy));
	}
	sort(v.begin(),v.end());
	rep(i,0,n+1)b[i]=inf;
	for(auto x:v){
		*lower_bound(b,b+n+1,x.y)=x.y;
	}
//	cout<<b[0]<<endl;
	int m=lower_bound(b,b+n+1,inf)-b;
//	cout<<m<<endl;
	double ans=100.0*(x2-x1+y2-y1)-20.0*m+5*pi*m;
//	printf("%lf\n",ans);
	if(m>min(x2-x1,y2-y1))ans+=5*pi;
	printf("%.10f\n",ans);
}

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

int n, k;
int snuke[101];

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

	for (int i = 0; i < k; i++)
	{
		int num; 
		cin >> num;
		for (int j = 0; j < num; j++)
		{
			int x;
			cin >> x;
			snuke[x] = 1;
		}
	}

	int count = 0;
	for (int ii = 1; ii <= n; ii++)
	{
		if (snuke[ii] == 0)
		{
			count++;
		}
	}

	cout << count << endl;
}

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

namespace ABC170B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);
            int hantei = -1;
            for (int i = 0; i < X + 1; i++)
            {
                int y = 2 * i + 4 * (X - i);
                if (y == Y)
                {
                    hantei = 0;
                }
            }
            if (hantei == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27532
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double num = sc.nextInt();
      	double power1 = Math.pow(num, 2);
        double power2 = Math.pow(num, 3);
      	double answer = num + power1 + power2;
   
      	System.out.println((int)answer);
    }
}

Measured memory_bytes: 35764
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
using ll = long long;
static const ll MAX = 10000000000;
ll solve(ll H, ll W) {
    ll m = MAX;
    for (ll ah = 1; ah < H; ah++) {
        ll bw = W / 2;
        array<ll, 3> S1 = {ah * W, (H - ah) * bw, (H - ah) * (W - bw)};
        sort(S1.begin(), S1.end());

        ll bh = (H - ah) / 2;
        array<ll, 3> S2 = {ah * W, bh * W, (H - ah - bh) * W};
        sort(S2.begin(), S2.end());

        ll t = min(S1[2] - S1[0], S2[2] - S2[0]);
        if (t < m) m = t;
    }
    return m;
}
int main() {
    ll H, W;
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int n;
	cin >> n;

	int a[n];
	rep(i, n) 
		cin >> a[i];

	int tmp;
	int cut = 0;
	rep (i, n - 1) {
		for (int j = 0; j < n - i - 1; j++) {
			if (a[j] > a[j + 1]) {
				tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
				cut++;
			}
		}
	}

	rep(i, n) {
		if (i > 0) cout << ' ';
		cout << a[i];
	}
	cout << endl;

	cout << cut << endl;

}



Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    int64_t res = k;
    for(int i=1; i<n; i++) res*=(k-1);
    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int a , b , c , d ;
    cin>>a>>b>>c>>d;
    int x = c-a , y = d-b ;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n+2];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	priority_queue <pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > pq;
	for(int i=1;i<=n;i++)
	{
		pq.push({arr[i],i});
	}
	while(pq.size()>0)
	{
		cout<<pq.top().second<<" ";
		pq.pop();
	}
	return 0;
}

Measured memory_bytes: 2164
s = input()
l = len(s)
res = 0
if l % 2 == 0:
    for i in range(l // 2):
        if s[i] != s[l - i - 1]:
            res += 1
else:
    for i in range((l - 1) // 2):
        if s[i] != s[l - i - 1]:
            res += 1
print(res)

Measured memory_bytes: 3060
K = int(input())
row_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(row_list[K - 1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; ++i){
    cin >> P[i];
  }
  int ans = 1e9;
  for(int i = 0; i <= P[0]; ++i){
    vector<int> P_ = P;
    P_[0] -= i;
    int t = i;
    for(int j = 0; j < N-1; ++j){
      t += 2*P_[j];
      P_[j+1] -= P_[j];
      P_[j+1] = max(P_[j+1],0);
    }
    t += P_.back();
    ans = min(ans,t);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3144