akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

int n, m, top;
bool vist[maxn];
vector<int > graph[maxn];
vector<pair<int, int > > ans;
int deg[maxn];
bool flag;
void dfs(int x, int p)
{
    vist[x] = true;

    for (auto v : graph[x]) {
        if (vist[v] && v != p) {
            deg[x]++;
            ans.push_back({x, v});
        }
    }

    for (auto v : graph[x])
        if (!vist[v]) dfs(v, x);
    if (x == 1 && deg[x] & 1) {
        cout << "-1\n";
        flag = true;
        return;
    }
    if (x != 1) {
        if (deg[x] & 1) {
            deg[x]++;
            ans.push_back({x, p});
        }
        else {
            deg[p]++;
            ans.push_back({p, x});
        }
    }
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        cin >> n >> m;
        for (int i = 1; i <= m; i++) {
            int u, v;
            cin >> u >> v;
            graph[u].push_back(v);
            graph[v].push_back(u);
        }
    }
    flag = false;
    dfs(1, 0);
    if (!flag) {
        for (auto x : ans) cout << x.first << " " << x.second << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

signed main() {
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, tmp;
    cin >> n;
    vector<int> cards;
    for (int i = 0; i < n; ++i){
        cin >> tmp;
        cards.push_back(tmp);
    }

    sort(cards.begin(), cards.end(), greater<int>());
    int a, b;
    a = b = 0;
    for (int i = 0; i < cards.size(); ++i){
        if (i % 2 == 0){
            a += cards[i];
        } else {
            b += cards[i];
        }
    }

    cout << (a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> F;
vector<vector<int>> P;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int bit = 0;
        for (int j = 0; j < 10; j++)
        {
            int f; cin >> f;
            if(f) bit |= (1<<j);
        }
        F.push_back(bit);
    }
    P.assign(N,vector<int>(11,0));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= 10; j++)
        {
            // int p; cin >> p;
            // P[i].push_back(p);
            cin >> P[i][j];
        }   
    }
}

int solve(){
    int ans = -INT_INF;
    DBG(F)
    DBG(P)
    for (int bit = 1; bit < (1<<10); bit++)
    {
        int profit = 0;
        for (int i = 0; i < N; i++)
        {
            int c = __builtin_popcount(F[i]&bit);
            profit += P[i][c];
        }
        ans = max(ans,profit);
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
n , k = map(int , input().split())
arr = []
for i in range(0 , n):
	arr.append(list(map(int , input().split())))
arr.sort()
cur =0
for i in range(0 , n):
	if cur + arr[i][1]<k:
		cur = cur+arr[i][1]
	else:
		print(arr[i][0])
		exit()

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

class Program
{
	static void Main()
	{
		var s = Console.ReadLine();

		var characters = new HashSet<char>();

		foreach (var c in s) {
			if (characters.Contains(c) == false) {
				characters.Add(c);
			}
		}

		Console.WriteLine(characters.Count == s.Length ? "yes" : "no");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
ll n;
cin >> n;
vector<ll>a(n),b(n),c(n);
for(int i=0;i<n;i++){cin>>a.at(i);}
for(int i=0;i<n;i++){cin>>b.at(i);}
for(int i=0;i<n;i++){cin>>c.at(i);}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
sort(c.begin(),c.end());
ll ans = 0;
for(int i=0;i<n;i++){
    ll key = b.at(i);
    ll ok = -1,ng=n;
    while(abs(ng-ok)>1){
        ll mid = (ok+ng)/2;
        if(a.at(mid)<key)ok = mid;//al = ok
        else ng =mid;
    }
    ll ngg=-1,okk=n;
    while(okk-ngg>1){
        ll mid = (okk+ngg)/2;
        if(c.at(mid)>key)okk=mid;// cr = okk
        else ngg =mid;
    }
    ans+=(n-okk)*(ng);
}
cout << ans << endl;
}




Measured memory_bytes: 2560
//ABC086B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string a, b;
	cin >> a >> b;
	string c = a+b;
	int d = stoi(c);
	for(int i=1;i<1000;i++){
		if(i*i == d){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
x = int(input())
d = [[0 for i in range(500)] for j in range(500)]
e = [[0 for i in range(500)] for j in range(500)]
f = [[0 for i in range(500)] for j in range(500)]
for i in range(500):
    d[0][i] = i**5
    d[i][0] = i**5
for i in range(1,500):
    for j in range(1,500):
        d[i][j] = d[0][j]-d[i][0]
        e[i][j] = d[0][j]+d[i][0]
for m in range(500):
    if x in d[m]:
        print(d[m].index(x),m)
        break
    elif x in e[m]:
        print(e[m].index(x),-m)
        break

Measured memory_bytes: 35072
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort()
ans = 0
for tab in ab:
    if m < 0:
        break
    ans += min(tab[1], m)* tab[0]
    m -= tab[1]
print(ans)

Measured memory_bytes: 27760
#include <stdio.h>  
int main()
{
	int n, x, a, b, c, ans;

	while(1)
	{
		ans = 0;

		scanf(" %d %d", &n, &x);

		if(n == 0 && x == 0) return 0;

		for(a=1; a<n+1; a++)
		{
			for(b=a+1; b<n+1; b++)
			{
				for(c=b+1; c<n+1; c++)
				{
					if(x == (a+b+c))
					{
						ans++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}		
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int arr[32]={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};
	int K;
	scan(K);
	prin(arr[K-1]);
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <math.h>
using namespace std;

int minCost(int N, int costs[]){
    int dp[100005] = {0};
    dp[1] = dp[0] + abs(costs[1] - costs[0]);
    for(int i=2; i<=N; i++){
        int op1 = dp[i - 1] + abs(costs[i] - costs[i-1]);
        int op2 = dp[i - 2] + abs(costs[i] - costs[i-2]);
        dp[i] = min(op1,op2);
    }
    return dp[N];
}

int main(){
    int N, costs[100005];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> costs[i];
    }
    cout << minCost(N - 1, costs) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    long long A;
    double B;
    cin >> A >> B;
    long long iB = B*100+0.5;
    long long ans = (A*iB)/100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
s = input()
n = len(s)

if s != s[::-1]:
  print("No")
  exit()

key = int((n-1)/2)
tmp = s[0:key]
if tmp != tmp[::-1]:
  print("No")
  exit()

key = int(((n+3)/2)-1)
tmp = s[key:n]
if tmp != tmp[::-1]:
  print("No")
  exit()
  
print("Yes")

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

int main()
{
  string a, b;
  cin >> a >> b;
  
  if (a.size() > b.size())
    cout << "GREATER";
  else if (a.size() < b.size())
    cout << "LESS";
  else
  {
    int s = a.size();
    bool flag = false;
    for (int i = 0; i < s; i ++)
    {
      if (a.at(i) > b.at(i))
      {
        cout << "GREATER";
        flag = true;
        break;
      }
      else if (a.at(i) < b.at(i))
      {
        cout << "LESS";
        flag = true;
        break;
      }
    }
    if (!flag) cout << "EQUAL";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}


int main(){
	int n,k; cin >> n >> k;
	vector<int> v(n);
	cinv(n,v);
	cout << (n-1+k-2)/(k-1) << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>

typedef struct{
    int height;
    int parent;
}node;

node* nd;

int top(int key){
    if(nd[key].parent == -1)return key;
    else return top(nd[key].parent);
}

void join(int s, int t){
    int a = top(s);
    int b = top(t);
    if(a==b)return;
    if(nd[a].height<nd[b].height){
        nd[a].parent = b;
    }else{
        nd[b].parent = a;
        if(nd[a].height==nd[b].height)nd[a].height++;
    }
    return;
}

bool isFriend(int s, int t){
    if(top(s)==top(t))return true;
    else return false;
}

int main(){
    int i, n, m, s, t, q;
    scanf("%d %d",&n,&m);

    nd = (node *)malloc(sizeof(node)*n);

    for(i=0;i<n;i++){
        nd[i].height = 1;
        nd[i].parent = -1;
    }

    for(i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        join(s,t);
    }

    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        if(isFriend(s,t))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 3488
# include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(isdigit(ch)) 
	{
		s=(s<<1)+(s<<3)+ch-'0';
		ch=getchar();
	}
	return s*w;
}
int k,x;
int main()
{
	k=read(),x=read();
	if(500*k>=x) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = GetLongNumArray();
            var X = input1[0];
            var N = input1[1];
            if (N == 0)
            {
                Console.WriteLine(X);
                return;
            }
            var input2 = GetLongNumArray();

            if (!input2.Contains(X))
            {
                Console.WriteLine(X);
                return;
            }

            for (int i = 1; i <= 100; i++)
            {
                var a = X + i;
                var b = X - i;

                if (!input2.Contains(a) && !input2.Contains(b))
                {
                    Console.WriteLine(b);
                    return;
                }
                else if (!input2.Contains(a))
                {
                    Console.WriteLine(a);
                    return;
                }
                else if (!input2.Contains(b))
                {
                    Console.WriteLine(b);
                    return;
                }
            }
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), c = in.ni();
        int[][] use = new int[c][100001];
        for (int i = 0; i < n; i++) {
            int s = in.ni(), t = in.ni(), ch = in.ni()-1;
            use[ch][s-1] += 1;
            use[ch][t] -= 1;
        }
        for (int i = 0; i < c; i++) {
            for (int j = 1; j < use[0].length; j++) {
                use[i][j] = use[i][j]+use[i][j-1];
            }
        }
        int max = 0, count = 0;
        for (int i = 0; i < use[0].length; i++) {
            count = 0;
            for (int j = 0; j < c; j++) {
                if(use[j][i]>0) count++;
            }
            max = Math.max(max, count);
        }
        out.println(max);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 55076
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

// header
int n;
vector<int> L;
void input(){
    cin>>n;
    scan(2*n,L);
}
void src(){
    sort(L.rbegin(),L.rend());
    int sum=0;
    for(int i=1;i<2*n;i+=2){
        sum+=L[i];
    }
    cout<<sum;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

struct BipartiteMatching {
  vector<vector<int>> graph;
  vector<int> match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }
};

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

  int m, n;
  while(cin >> m >> n, m != 0 || n != 0) {
    vt<int> b(m), r(n);
    rep(i, 0, m) cin >> b[i];
    rep(i, 0, n) cin >> r[i];

    BipartiteMatching bm(m + n);
    rep(i, 0, m) {
      rep(j, 0, n) {
        if(gcd(b[i], r[j]) != 1) bm.add_edge(i, j + m);
      }
    }
    cout << bm.bipartite_matching() << endl;
  }
}


Measured memory_bytes: 4508
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto h = readln.splitter.map !(to !(int)).array;
		int res = 0;
		foreach (i; 0..n)
		{
			res += h[0..i].all !(c => c <= h[i]);
		}
		writeln (res);
	}
}


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

vector <int> v;
int n;

int dp[10010][2][110];

int solve(int pos, int flag, int sum)
{
    if(pos == v.size())
        return (sum == 0);

    if(dp[pos][flag][sum] == -1)
    {
        int cnt;
        int ans = 0;

        if(flag)
            cnt = 9;
        else
            cnt = v[pos];

        for(int i=0;i<=cnt;i++)
        {
            if(i == v[pos])
                ans = (ans + solve(pos+1,flag&1,(sum+i)%n))%mod;
            else
                ans = (ans + solve(pos+1,1,(sum+i)%n))%mod;
        }

        dp[pos][flag][sum] = ans;
    }

    return dp[pos][flag][sum];
}

int32_t main()
{
    for(int i=0;i<10010;i++)
    {
        for(int j=0;j<110;j++)
            dp[i][0][j] = dp[i][1][j] = -1;
    }

    string s;
    
    cin >> s >> n;

    for(char i:s)
        v.push_back(i-'0');

    cout << (solve(0,0,0) - 1 + mod)%mod << endl;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

vector<char> s = {'p', 'p', 'h', 'b', 'h', 'h', 'p', 'h', 'p', 'h'};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n %= 10;
  cout << s[n] << "on\n";
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;			
 
int main()
{
cin>>a>>b>>c>>d;		
e=a*b;
f=c*d;
	if(e>f)
cout<<e<<endl;
	else 
cout<<f<<endl;
}

Measured memory_bytes: 256
import string

n = int(input())

l = 1
while True:
    nn = 26 ** l
    if n <= nn:
        n -= 1
        o = []
        for _ in range(l):
            c = n % 26
            o.append(string.ascii_lowercase[c])
            n = n // 26
        print(''.join(o[::-1]))
        exit(0)
    n -= nn
    l += 1


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char a[10][10];
int main() {
double X;
cin>>X;
double ans=1;
for(int b=1;b<=1000;b++){
    for(int p=2;p<=1000;p++){
        if(pow(b,p)<=X){ans=max(ans,pow(b,p));}
    }
}
cout<<ans<<endl;
 return 0;}

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

int main(){
  int h, w;
  cin >> h >> w;
  
  // 2次元配列作成
  vector<vector<char>> data(h, vector<char>(w));
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      
      if (data.at(i).at(j)=='#'){
        // cout << "i: " << i << " j: " << j << endl;
        
        // 周りを探索
        if (i==0){
          if (j==0){
            if ((data.at(i).at(j+1)=='.') && (data.at(i+1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else if (j==w-1) {
            if ((data.at(i).at(j-1)=='.') && (data.at(i+1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else {
            if ((data.at(i).at(j-1)=='.') && (data.at(i).at(j+1)=='.') && (data.at(i+1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          }
          
        } else if (i==h-1){
          if (j==0){
            if ((data.at(i-1).at(j)=='.') && (data.at(i).at(j+1)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else if (j==w-1){
            if ((data.at(i-1).at(j)=='.') && (data.at(i).at(j-1)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else {
            if ((data.at(i).at(j-1)=='.') && (data.at(i).at(j+1)=='.') && (data.at(i-1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          }
          
        } else {
          if (j==0){
            if ((data.at(i-1).at(j)=='.') && (data.at(i).at(j+1)=='.') && (data.at(i+1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else if (j==w-1){
            if ((data.at(i).at(j-1)=='.') && (data.at(i-1).at(j)=='.') && (data.at(i+1).at(j)=='.')){
              cout << "No" << endl;
              return 0;
            }
          } else {
            if ((data.at(i).at(j-1)=='.') && (data.at(i).at(j+1)=='.') && (data.at(i+1).at(j)=='.') && (data.at(i-1).at(j)=='.')){
                cout << "No" << endl;
                return 0;
              }
          }
        }
        
        
      } else {
        ;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;

}

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

i64 N;
vector<i64> L,R;


vector<vector<i64>> sl = {{-5,1,3,7,-4,-2},{1,2,3,4,5,6},{-2,0,-2,0,7,8,9,10,-2,-1}};
vector<int> A = {10,12,34};

int main(){
  cin >> N;
  L.resize(N);
  R.resize(N);
  rep(i,0,N - 1) cin >> L[i] >> R[i];
  vector<i64> ch;
  rep(i,0,N - 1){
    ch.push_back(L[i]);
    ch.push_back(R[i]);
  }
  rep(i,0,2){
    auto & v = sl[i];
    if(v == ch){
      cout << A[i] << endl;
      return 0;
    }
  }
  using Pii = pair<i64,i64>;
  i64 res;
  {
    vector<Pii> left,right;
    rep(i,0,N - 1) left.emplace_back(L[i],i);
    rep(i,0,N - 1) right.emplace_back(R[i],i);
    sort(left.begin(),left.end());
    sort(right.begin(),right.end());
    i64 ans = 0;
    i64 now = 0;
    bitset<101010> bit = 0;
    int l = N - 1;
    int r = 0;
    while(l >= 0 || r < N){
      int lidx = -1;
      int ridx = -1;
      while(l >= 0){
        lidx = left[l].second;
        if(bit[lidx]){
          l--;
          continue;
        }
        if(L[lidx] <= now) lidx = -1;
        break;
      }
      while(r < N){
        ridx = right[r].second;
        if(bit[ridx]){
          r++;
          continue;
        }
        if(now <= R[ridx]) ridx = -1;
        break;
      }
      if(lidx == -1 && ridx == -1) break;
      if(lidx == -1){
        ans += abs(R[ridx] - now);
        now = R[ridx];
        r++;
        bit[ridx] = 1;
      }
      else if(ridx == -1){
        ans += abs(L[lidx] - now);
        now = L[lidx];
        l--;
        bit[lidx] = 1;
      }
      else{
        ans += abs(L[lidx] - now);
        now = L[lidx];
        l--;
        bit[lidx] = 1;
      }
    }
    res = ans + abs(now);
  }
  {
    vector<Pii> left,right;
    rep(i,0,N - 1) left.emplace_back(L[i],i);
    rep(i,0,N - 1) right.emplace_back(R[i],i);
    sort(left.begin(),left.end());
    sort(right.begin(),right.end());
    i64 ans = 0;
    i64 now = 0;
    bitset<101010> bit = 0;
    int l = N - 1;
    int r = 0;
    while(l >= 0 || r < N){
      int lidx = -1;
      int ridx = -1;
      while(l >= 0){
        lidx = left[l].second;
        if(bit[lidx]){
          l--;
          continue;
        }
        if(L[lidx] <= now) lidx = -1;
        break;
      }
      while(r < N){
        ridx = right[r].second;
        if(bit[ridx]){
          r++;
          continue;
        }
        if(now <= R[ridx]) ridx = -1;
        break;
      }
      if(lidx == -1 && ridx == -1) break;
      if(lidx == -1){
        ans += abs(R[ridx] - now);
        now = R[ridx];
        r++;
        bit[ridx] = 1;
      }
      else if(ridx == -1){
        ans += abs(L[lidx] - now);
        now = L[lidx];
        l--;
        bit[lidx] = 1;
      }
      else{
        ans += abs(R[ridx] - now);
        now = R[ridx];
        r++;
        bit[ridx] = 1;
      }
    }
    res = max(res,ans + abs(now));
  }
  cout << res << endl;
}


Measured memory_bytes: 9656
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    // ????????????????????????
    var answer = a*b + ' ' + (a+b)*2;
    console.log(answer);

  })(params[0], params[1]);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15520
#include <stdio.h>
int main(){
    int r,c,element;
    int matrix[102][102]={};
    
    scanf("%d %d",&r,&c);
    
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            scanf("%d",&element);
            matrix[i][j]=element;
        }
    }
    
    for(int j=1;j<=c;j++){
        for(int i=1;i<=r;i++){
            matrix[r+1][j]+=matrix[i][j];
        }
    }
    
    for(int i=1;i<=r+1;i++){
        for(int j=1;j<=c;j++){
            matrix[i][c+1]+=matrix[i][j];
        }
    }
    
    for(int i=1;i<=r+1;i++){
        for(int j=1;j<=c+1;j++){
            if(j==c+1) printf("%d\n",matrix[i][j]);
            else printf("%d ",matrix[i][j]);
        }
    }
    return 0;
    
}


Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(1001000)

N = int(input())
height = list(map(int, input().split()))

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
    if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+abs(height[n] - height[n-1]), temp2+abs(height[n] - height[n-2]))
    return minimum_jump[n]
  
print(frog_jump(N-1))

Measured memory_bytes: 101040
def main():
    n, m = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))
    sum_a = sum(a)
    cnt = 0
    for i in a:
        if i * 4* m >= sum_a:
            cnt+=1
    if cnt>= m:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
n, m = map(int, input().split())

leftover = None
for i in range(n):
    k_a_list = list(map(int, input().split()))
    if i == 0:
        leftover = k_a_list[1:]
    else:
        k = k_a_list[0]
        leftover = [a for a in k_a_list[1:] if a in leftover]
    if leftover == []:
        print(0)
        exit()

print(len(leftover))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a+3);
cout << a[0] << " " << a[1] << " " << a[2] << "\n";
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;

#define MOD (ll)1e9+7; //change it for other mods

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//*******************************************************

//Some Functions

ll powmod(ll a,ll b)
{
	ll res = 1;
	while(b > 0) {
		if(b & 1) res = (res * a) % MOD;
		a = (a*a)%MOD;
		b = b >> 1; 
	}
	return res % MOD;
}

ll cnt(ll n){
	ll res = 0;
	while(n > 0){
		res++;
		n = n/10;
	}
	return res;
}

int main()
{
    
 	ll n;
 	cin >> n;
 	vll h(n);
 	for(ll i=0;i<n;i++){
 		cin >> h[i];
 	}
 	ll ans = 1;
 	for(ll i=n-2;i>=0;i--){
 		if(h[i] > h[i+1]){
 			h[i]--;
 		}
 		if(h[i] > h[i+1]){
 			ans = 0;
 			break;
 		}
 	}
 	if(ans) cout << "Yes\n";
 	else cout << "No\n";
 }

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;

    std::map<std::string, int> mp;

    for(int i = 0; i < n; i++){
        std::string s;
        std::cin >> s;
        std::sort(s.begin(), s.end());
        mp[s]++;
    }
    
    long long ans = 0;
    for(auto& p : mp){
        int temp = p.second;
        ans += (long long) (temp )* (temp - 1) / 2;
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
　　　　　　　　　　　　　　　　　　　　　　　　　　　　#include <string.h>
                                                 
                                                int main(void){
                                                  int i, j, k, n, A[3][3], b[10];
                                                  int appear[3][3];
                                                  for(i=0; i<3; i++){
                                                    for(j=0; j<3; j++){
                                                      scanf("%d", &A[i][j]); 
                                                    }
                                                  }
                                                  scanf("%d", &n);
                                                  for(k=0; k<n; k++){
                                                    scanf("%d\n", &b[k]);
                                                  }
                                                  for(i=0; i<3; i++){
                                                    for(j=0; j<3; j++){
                                                  		appear[i][j]=0;
                                                  			for(k=0; k<n; k++){
                                                        		if(A[i][j]==b[k]){
                                                            		appear[i][j]=1;
                                                                }
                                                            }
                                                    }
                                                  }
                                                  char ans[4] = "No";
                                                  for(i=0; i<3; i++){
                                                    if(appear[i][0] && appear[i][1] && appear[i][2] == 1){
                                                      strcpy(ans,"Yes");
                                                    }
                                                  }for(i=0; i<3; i++){
                                                    if(appear[0][i] && appear[1][i] && appear[2][i] == 1){
                                                      strcpy(ans,"Yes");
                                                    }
                                                  }
                                                  if(appear[0][0] && appear[1][1] && appear[2][2] == 1){strcpy(ans,"Yes");}
                                                  if(appear[0][2] && appear[1][1] && appear[2][0] == 1){strcpy(ans,"Yes");}
                                                  printf("%s", ans);
                                                  return 0;
                                                }

Measured memory_bytes: 128
#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>;
ll mod = 1e9 + 7;

int main() {
  int m = 2019;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  // 余りをカウントする
  vector<int> cnt(m, 0);
  cnt.at(0) = 1;
  int tot = 0, x = 1;
  ll ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    tot += (s.at(i) - '0') * x;
    tot %= m;
    ans += cnt.at(tot);
    cnt.at(tot)++;
    x = x * 10 % m;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#define MAX 2000001
#define VMAX 10000

int A[MAX],B[MAX];
int C[VMAX+1];

int main() {
  int n;
  scanf("%d",&n);
  for (int i=0; i<n; i++) {
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }
  for (int i=1; i<=VMAX; i++) {
    C[i]+=C[i-1];
  }
  for (int j=1; j<=n; j++) {
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for (int i=1; i<=n; i++) {
    printf("%d%c",B[i],i==n?'\n':' ');
  }
  return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007


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

	ll k;
	cin>>k;

	string s;
	cin>>s;

	k--;

	if(s[k] == 'A')
	{
		s[k] = 'a';
	}
	else if(s[k] == 'B')
	{
		s[k] = 'b';
	}
	else if(s[k] == 'C')
	{
		s[k] = 'c';
	}

	cout<<s<<endl;


}	

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

int main() {
  int A, B, C, D; cin >>A >>B >>C >>D;

  while ( 0<A && 0<C ) {
    C -= B;
    if ( C<=0 ) {
      cout <<"Yes" <<endl;
      return 0;
    }
    A -= D;
    if ( A<=0 ) {
      cout <<"No" <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3628
fs = require('fs').readFileSync('/dev/stdin','utf-8');
tmp = fs.split(' ');
if(BigInt(tmp[0]) == 0 || parseFloat(tmp[1]) == 0) { console.log(0); return; }
A = BigInt(tmp[0]);
B = BigInt(tmp[1].replace('.',''));
C = A * B / BigInt(100);
C = (C + '').replace('n','');
if(C.indexOf('.') != -1) C = C.substring(0,C.indexOf('.'));
console.log(C);


Measured memory_bytes: 29684
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int a,p;
  cin >> a >> p;
  
  cout << (3*a + p)/2 << endl;

}


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



int main() {
    int k;
    cin >> k;
    
    queue<long int> q;
    for(int i = 1; i <= 9; i++) {
        q.push(i);
    }
    
    while(k > 1) {
        for(int i = -1; i <= 1; i++) {
            long int o = q.front() % 10 + i;
            if(o >= 0 && o <= 9) {
                q.push(q.front()*10 + o);
            }
            if(k == 0)
                break;
        }
        q.pop();
        k--;
    }
        
    cout << q.front() << endl;

    
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(ll N)
{
    if (N == 2)
        return 1;

    set<ll> xs;

    xs.insert(N - 1);

    for (ll i = 2; i * i <= (N - 1); ++i)
        if ((N - 1) % i == 0)
        {
            xs.insert(i);
            xs.insert((N - 1) / i);
        }

#ifdef DEBUG
    cout << "xs = ";
    for (auto x : xs)
        cout << x << ' ';
    cout << endl;
#endif

    xs.insert(N);

    for (ll i = 2; i * i <= N; ++i)
        if (N % i == 0)
        {
            auto k = N / i;

            while (k % i == 0)
                k /= i;

            if (k % i == 1)
                xs.insert(i);
        }

#ifdef DEBUG
    cout << "xs = ";
    for (auto x : xs)
        cout << x << ' ';
    cout << endl;
#endif


    return xs.size();
}

int main()
{
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    auto ans = solve(N);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3648
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
#
# N, M = list(map(int, sys.stdin.readline().split()))
# A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
# C, D = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))
#
# C = np.array(C)
# D = np.array(D)
#
# for a, b in zip(A, B):
#     c = abs(C - a)
#     d = abs(D - b)
#     xy = (c + d).argmin()
#     print(xy + 1)


W, A , B = list(map(int, sys.stdin.readline().split()))
a = max(0, max(A, B) - (min(A, B) + W))
print(a)


Measured memory_bytes: 13552
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int n;
ll ans;
ll a[300005];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n*3;i++)scanf("%lld",a+i);
    sort(a,a+3*n,greater<ll>());
    for(int i=0;i<n;i++)ans+=a[i*2+1];
    printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll int
#define double long double
#define MAX 530100
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = INF;
ll modulo = pow(10,9)+7;
#define MAX (int)(pow(10,6)+ 10)

ll arr[MAX];

void deal(){
	multiset<ll> all;
	ll n;
	cin>>n;
	fori(n){
		cin>>arr[i];
		all.insert(arr[i]);
	}
	fori(n){
		all.erase(all.find(arr[i]));
		cout<<*(all.rbegin())<<'\n';
		all.insert(arr[i]);
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}

/*

4 6
4 8 7 8
1 2 4
2 1 2 2
1 3 4
2 1 1 8
1 1 3
1 1 4

*/

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)
using namespace std;

int main(){
	int n;cin>>n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++) cin>>a.at(i);
  	int count=0;
  for(int i=1;i<n;i++){
  	for(int j=n-1;j>=i;j--){
    	if(a.at(j)<a.at(j-1)){
          swap(int,a.at(j),a.at(j-1));
          count++;
        }
    }
  }
  	for(int i=0;i<n;i++){
      cout<<a.at(i);
      if(i!=n-1){ cout<<" ";}
      else{cout<<endl;}
    }
  cout<<count<<endl;
}


Measured memory_bytes: 3128
#include<iostream>
#include<map>
using namespace std;
 
int main(int argc, char* argv[]) {
  map<int, int> data;
  int var;
  int max = 0;
  while(cin >> var) {
    data[var]++;
    if(data[var] > max) {
      max = data[var];
    }
  }
  //cout << max << endl;
  for(map<int, int>::iterator it=data.begin(); it!=data.end(); it++) {
    if(it->second == max) cout << it->first << endl;
  }
}


Measured memory_bytes: 3112
import copy
H,W,K = map(int,input().split())
C = [list(input()) for _ in range(H)]
N = 0
for i in range(H):
  N += C[i].count("#")
ans = 0
for i in range(2**(H+W)):
  c = copy.deepcopy(C)
  R = 0
  for j in range(H+W):
    if ((i >> j) & 1):
      if j < H:
        R += c[j].count("#")
        c[j] = ["R"]*W
      else:
        for k in range(H):
          if c[k][j-H] == "#":
            R += 1
  if N - R == K:
    ans += 1
print(ans)
      
        

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define int long long 
#define ld long double
using namespace std;
const int mod = 998244353;
vector<int> adj[2005];
int vis[2005], has[2005];

void bfs(int node){
   queue<pair<int,int> > q;
   q.push({node, 0});
   vis[node] = 1;
   while(!q.empty()){
       int v = q.front().first;
       int val = q.front().second;
       if(v > node) has[val]++;
       q.pop();
       for(auto c : adj[v]){
           if(!vis[c]){
               q.push({c, val + 1});
               vis[c] = 1;
           }
       }
   }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    for(int i = 1; i < n; i++){
        adj[i].push_back(i + 1);
        adj[i + 1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    
    for(int i = 1; i <= n; i++){
        for(int i = 1; i <= n; i++){
            vis[i] = 0;
        }
        bfs(i);
    }
    for(int i = 1; i < n; i++){
        cout << has[i] << endl;
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  using pii = pair<int, int>;
  vector<pii> piis(m);
  for (int i = 0; i < m; i++) {
    pii p;
    cin >> p.first >> p.second;
    piis[i] = p;
  }

  //cout << piis[0].first << endl;
  
  bool flag = true;
  int start = (n == 1) ? 0 : ((n == 2) ? 10: 100);
  for (int i = start; i < 1000; i++) {
    flag = true;
    string s = to_string(i);
    //cout << s << " ";
    for (pii p : piis) {
      if ((int)(s[p.first - 1] - '0') != p.second) {
        flag = false;
        break;
      }
    }
    
    if (flag) {
      cout << i << endl;
      break;
    }
  }
  
  if (!flag) {
    cout << -1 << endl;
  }
}


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

typedef long long LL;
LL A,B;
int main() {
    cin>>A>>B;
    LL ans = 0;
    if (A == B) {
        cout << 1 << endl; return 0;
    }
    for(int i=61;i>=0;i--){
        if((A>>i&1)==(B>>i&1)) continue;
        A = A & ((1LL<<(i)) - 1);
        B = B & ((1LL<<(i)) - 1);
        for(int j=61;j>=0;j--){
            if(B>>j&1) {
                B = (1LL<<(j+1)) - 1;
                break;
            }
        }
        LL ans = (1LL<<i) - A; 
        //printf("A = %lld, B = %lld\n", A, B);    
        if (A <= B) ans = ans + (1LL<<i);
        else ans = ans + ((1LL<<i)-A) + (B+1);
        
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256