akhauriyash/Code-Regression huggingface dataset:
n = input()
l_lst = map(int, input().split())
# newlst = list(set(l_lst))
# print(set(l_lst))
# print(newlst)
cnt = 0
startnum = 1
secondstartnum = 2
# for i in range(0, len(newlst)):
    
#     for j in range(startnum, len(newlst)):
#         # startnum += 1
#         # print(startnum)
        
#         for k in range(secondstartnum, len(newlst)):
#             print(i, j, k, secondstartnum)
#             # print(newlst[i], newlst[j], newlst[k])
#             # if newlst[i] + newlst[j] > newlst[k] and newlst[j] + newlst[k] > newlst[i] and newlst[k] + newlst[i] > newlst[j]:
#             #     cnt += 1
#             secondstartnum += 1
#         secondstartnum = 2
#     startnum += 1

import itertools
for pair in itertools.combinations(l_lst, 3):
    # print(pair)
    if pair[0] + pair[1] > pair[2] and pair[1] + pair[2] > pair[0] and pair[2] + pair[0] > pair[1]:
        if pair[0] != pair[1] and pair[1] != pair[2] and pair[2] != pair[0]:
            # print(pair[0], pair[1], pair[2])
            cnt += 1

print(cnt)

Measured memory_bytes: 9160
L,R = map(int,input().split())
 
left = L % 2019
c = 2019 - left
if L + c <= R:
    ans = 0
else:
    ans = 2020
    right = R % 2019
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            ans = min((i*j)%2019,ans)
print(ans)
 

Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{   
    ll w,n,a,b;
    cin>>n>>w;
    vector<ll> dp(1000*n+1,pow(10,12));//dp[value]=minimum weight which forms value exactly
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {   
        cin>>a>>b;
        for(ll m=1000*n;m>=b;m--)
        {
            if (dp[m-b]!=pow(10,12))
            {
                dp[m]=min(dp[m],dp[m-b]+a);
            }
        }
    }
    ll ans;
    for(ll i=0;i<=1000*n;i++)
    {
        if (dp[i]!=pow(10,12)&& dp[i]<=w)
           ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4044
import sys

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))


a.sort()
for i, ai in enumerate(a):
    x -= ai
    if x < 0:
        print(i)
        sys.exit()

if x == 0:
    print(N)
else:
    print(N-1)

Measured memory_bytes: 3060
n=int(input())
a=[0]*n
adic={}
amod=[]
for i in range(n):
    aa=int(input())
    a[i]=aa
    if aa in adic:
        adic[aa]+=1
    else:
        adic[aa]=1
    if adic[aa]<3:
        amod.append(aa)    
amod=sorted(amod)
p=len(amod)
for i in range(n):
    m = p - 1
    while a[i] == amod[m] and adic[a[i]]==1 and m > 0:
        m -= 1
    print(amod[m])

Measured memory_bytes: 21872
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = br.readLine()) != null) {
			String[] arr = line.split(" ");
			int a = Integer.parseInt(arr[0]);
			String op = arr[1];
			int b = Integer.parseInt(arr[2]);
			if ("?".equals(op))
				break;

			if ("+".equals(op))
				System.out.println(a + b);
			else if ("-".equals(op))
				System.out.println(a - b);
			else if ("*".equals(op))
				System.out.println(a * b);
			else if ("/".equals(op))
				System.out.println(a / b);
		}
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string s = to_string(N);
    int sum = 0;
    REP(i, s.size())
        sum += s[i] - '0';
    if (N % sum) cout << NO << '\n';
    else cout << YES << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

const bool DEBUG = false;

double A, B;

void input() { cin >> A >> B; }

int main(int argc, char const *argv[]) {
  input();

  double candidate = max(ceil(A / 0.08), ceil(B / 0.1));
  if ((candidate < ((A + 1) / 0.08)) && (candidate < ((B + 1) / 0.1))) {
    cout << static_cast<int>(candidate) << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

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

using namespace std;

struct Task{
  long A,B;
};

bool cmp (const Task& t1, const Task& t2) {
  if (t1.B < t2.B) {
    return true;
  } else if (t1.B > t2.B) {
    return false;
  } else {
    return t1.A > t2.A;
  }
}

int main() {
  int N; cin>>N;
  vector<Task> tsk(N);
  long a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    tsk[i] = Task{a,b};
  }
  sort(tsk.begin(), tsk.end(), cmp);

  long time = 0;
  for (int i = 0; i < N; i++) {
    time += tsk[i].A;
    if (time > tsk[i].B) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3328
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,i,ans=-1000000000000000;
		ll sum=0;
		priority_queue<int> q;
		priority_queue<int,vector<int>,greater<int>>p;

		cin>>n;
		ll arr[3*n+1],g[3*n],s[3*n];
		rep(i,0,3*n)
		cin>>arr[i];
		for(i=0;i<3*n;i++)
		{
			sum+=arr[i];
			p.push(arr[i]);
			if(i>=n)
			{
				sum-=p.top();
				p.pop();
			}
			g[i]=sum;

		}sum=0;
		for(i=3*n-1;i>=0;i--)
		{
			s[i]=sum;
			sum+=arr[i];
			q.push(arr[i]);

			if(i<2*n)
			{
				sum-=q.top();
				q.pop();
			}
			
		}
		for(i=n-1;i<2*n;i++)
		{
			ans=max(ans,g[i]-s[i]);

		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 8184
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" ");
        int h = Integer.parseInt(params[0]);
        int w = Integer.parseInt(params[1]);
        String[][] ss = new String[h][w];
        for (int i = 0; i < h; i++) {
            params = in.nextLine().split("");
            for (int j = 0; j < w; j++) {
                ss[i][j] = params[j];
            }
        }

        // 全ての場所をスタート地点として最長距離を回答とする
        int maxDistance = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                maxDistance = Math.max( maxDistance , getMaxDistanceWithBfs( ss , i , j ) );
            }
        }

        System.out.println(maxDistance);

    }

    /**
     * 幅優先探索で最長距離を返す
     * @param ss 迷路の配列
     * @param startY スタート地点のY座標
     * @param startX スタート地点のX座標
     * @return 最長距離
     */
    private static int getMaxDistanceWithBfs( String[][] ss , int startY , int startX ) {

        int[][] distances = new int[ss.length][ss[0].length];
        Queue<Integer> queue = new ArrayDeque<>();

        // 四方の距離の定義 順に左上右下
        int[] dx = { -1 , 0 , 1 , 0 };
        int[] dy = { 0 , 1 , 0 , -1 };

        int maxDistance = 0;

        // スタート位置をキューに追加しておく
        queue.add( startX );
        queue.add( startY );

        // キューが空になった時 = 探索できる場所がなくなった時
        // ループ回数 = スタート位置からの距離
        while( !queue.isEmpty()  ) {

            int x = queue.remove();
            int y = queue.remove();

            // 今いる場所が壁の場合処理しない
            if( "#".equals( ss[y][x] ) ){
                continue;
            }

            maxDistance = Math.max( maxDistance , distances[y][x] );

            // 四方を確認
            for( int i = 0 ; i < 4 ; i++ ){

                // 確認先の座標
                int xx = x + dx[i];
                int yy = y + dy[i];

                // 確認先の座標が配列外にいないこと
                if( !( 0 <= yy && yy < ss.length && 0 <= xx && xx < ss[0].length ) ) {
                    continue;
                }

                // 確認先の座標が壁でないこと
                if( !".".equals( ss[yy][xx] ) ) {
                    continue;
                }

                // 既に通った道でないこと
                if( distances[yy][xx] != 0 ){
                    continue;
                }

                // スタート地点でないこと
                if( xx == startX && yy == startY ){
                    continue;
                }

                queue.add( xx );
                queue.add( yy );
                distances[yy][xx] = distances[y][x] + 1;

            }

        }

        return maxDistance;

    }

}


Measured memory_bytes: 24660
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v) {
    for (lli i=0;i<v.size();i++)
        cout<<v.at(i)<<endl;
}
int main() {
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    vi a;
    rep(i, n) {
        a.push_back(i);
    }
    vec(pii) z(n);
    rep(i, n) {
        lli x, y;
        cin>>x>>y;
        z[i]=pii(x, y);
    }
    long double cnt=1;
    long double ans=0;
    while (true) {
        rep(i, n-1) {
            ans += sqrt(pow(z[a[i]].first-z[a[i+1]].first, 2)+pow(z[a[i]].second-z[a[i+1]].second, 2));
        }
        bool s=next_permutation(all(a));
        if (!s) {
            break;
        }
        cnt++;
    }
    out(ans/(cnt));
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

using num = modnum<int(1e9) + 7>;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	num tot = 0;
	num s = 0;
	for (int i = 0; i+1 < n; i++) {
		s += num(i+1).inv();
		tot += num(x[i+1] - x[i]) * s;
	}
	for (int i = 1; i < n; i++) {
		tot *= i;
	}
	cout << tot << '\n';
}


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

int res(int n){
 int count = 0;
 for(int i=0; i<10; i++)
  for(int j=0; j<10; j++)
   for(int k=0; k<10; k++)
    for(int l=0; l<10; l++)
     if(i + j + k + l == n) count++;

 return count;
}
int main()
{
 int n;
 while(cin >> n)
  cout << res(n) << '\n';

 return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

static const int MAX_N = 1000000;
bool isPrime[MAX_N];

int main(){
	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<int> nums;
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=0;j<5;j++){
				int p;
				scanf("%d",&p);
				sum += p;
			}
			nums.push_back(sum);		
		}
		sort(nums.begin(),nums.end());
		printf("%d %d\n",*(nums.end()-1),*nums.begin());
	}
}

Measured memory_bytes: 1208
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();

		long[] H = new long[(int) N+1];

		for (long i = 1; i <= N; i++) {
			H[(int) i] = sc.nextLong();
		}

		long[] A = new long[(int) M+1];
		long[] B = new long[(int) M+1];
		boolean[] good = new boolean[(int) N+1];
		Arrays.fill(good, true);
		good[0]=false;

		for (long i = 1; i <= M; i++) {
			A[(int) i] = sc.nextLong();
			B[(int) i] = sc.nextLong();

			if (H[(int)A[(int) i]] <= H[(int)B[(int)i]]) {
				good[(int) A[(int) i]] = false;
			}
			if (H[(int)A[(int) i]] >= H[(int)B[(int) i]]) {
				good[(int) B[(int) i]] = false;
			}
		}
		int ans = 0;

		for (boolean goodP : good) {
			if (goodP) {
				ans++;
			}
		}
		System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

}


Measured memory_bytes: 63200
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
//x^n(MOD)
long long power(ll x,long long n,long long MOD){
    long long a = 1;
    long long b = x;
    while(n>0){
        if(n%2==1){
            a*=b;
            a%=MOD;
        }
        n/=2;
        b = b*b;
        b%=MOD;
    }
    return a;
}
int solve(int a){
    if(a==0) return 1;
    int ret = 0;
    while(a!=0){
        int pop_count = 0;
        rep(i,30) if((a&(1<<i))!=0) pop_count++; 
        a = a%pop_count;
        ret++;       
    }
    return ret+1;
}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int pc = 0;
    rep(i,s.size()) if(s[i]=='1') pc++;
    int mi = 0;int pl = 0;
    int now_pl = 1;
    int now_mi = 1;
    bool fl = true;
    if(pc==1){
        fl = false;
    }
    for(int i = n-1;i>=0;i--){
        if(s[i]=='1'){
            pl+=now_pl;
            if(fl) mi+=now_mi;
            pl%=(pc+1);
            if(fl) mi%=(pc-1);
        }
        now_pl*=2;
        if(fl) now_mi*=2;
        now_pl%=(pc+1);
        if(fl) now_mi%=(pc-1);
    }
    vector<int> ans(n);
    //cout << pc << endl;
    //cout << now_pl << " " << now_mi << endl;
    for(int i = n-1;i>=0;i--){
        if(s[i]=='1'){
            if(!fl){
                ans[i]=0;
                continue;
            }
            int now = power(2LL,n-1-i,pc-1);
            now = mi-now;
            now%=(pc-1);
            if(now<0) now+=(pc-1);
            ans[i] = solve(now);
            //cout << now << endl;
        }
        else{
            int now = power(2LL,n-1-i,pc+1);
            now += pl;
            now%=(pc+1);
            if(now<0) now+=(pc+1);
            ans[i] = solve(now);
            //cout << now << endl;
        }
    }
    rep(i,n) cout << ans[i] << endl;

}

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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadStr();
        var ans = "";
        for (int i = 0; i < N.Length; i++)
        {
            if (N[i] == '9') ans += '1';
            else if (N[i] == '1') ans += '9';
        }
        Console.WriteLine(ans);
    }
    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 11092
import sys
S = list(input())
T = list(input())
s = len(S)
t = len(T)
if s < t:
    print('UNRESTORABLE')
    sys.exit()
OK = False
P = 0
for i in range(s - t + 1):
    if S[i] != T[0] and S[i] != '?':
        continue
    for j in range(1, t + 1):
        if j == t:
            OK = True
            P = i
            break
        if S[i + j] != T[j] and S[i + j] != '?':
            break
for k in range(t):
    S[P + k] = T[k]
for i in range(s):
    if S[i] == '?':
        S[i] = 'a'
if OK:
    [print(S[i], end='') for i in range(s)]
    print('')
else:
    print('UNRESTORABLE')

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

int main() {
  int n;
  long long d;
  cin>>n>>d;
  vector<long long> x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i);
    cin>>y.at(i);
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if((x.at(i)*x.at(i) + y.at(i)*y.at(i))<= d*d)
      ans++;
  }
  cout<<ans<<endl;
}


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

int main(){
    int x,y,s;
    while(1){
        cin>>x>>y>>s;
        if(x ==0 && y== 0 && s==0)break;
        int ans = 0;

        for(int i=1; i<s; i++){
            double pre1 = i*(double)(100+x)/100;
            for(int j=i; j<s; j++){
                if(i+j > s)continue;
                double pre2 = j*(double)(100+x)/100;
                if((int)pre1 + (int)pre2 == s){
                    double itax = (double)(i*(y+100))/100;
                    double jtax = (double)(j*(y+100))/100;

                    ans = max(ans,(int)(jtax)+(int)(itax));  
                }
            }
        } 
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3080
# coding: utf-8


def is_mm(format_2_char):
    n = int(format_2_char)
    if 1 <= n <= 12:
        return True
    return False


def judge(cand):
    if is_mm(cand[0:2]):
        if is_mm(cand[2:]):
            return('AMBIGUOUS')
        else:
            return('MMYY')
    if is_mm(cand[2:]):
        return 'YYMM'
    return 'NA'


candidate = input()
print(judge(candidate))


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b)
        cout<<c<<endl;
    else if(a==c)
        cout<<b<<endl;
    else
        cout<<a<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 102

using namespace std;

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

int main() {
    int N;
    double x[MAX_N], y[MAX_N];
    double min_arg[MAX_N], max_arg[MAX_N], arg[MAX_N];
    
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }
    fill(min_arg, min_arg + N, 0);
    fill(max_arg, max_arg + N, 2 * M_PI);
    
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            double theta;
            if (x[i] != x[j]) {
                double tan = (y[j] - y[i]) / (x[j] - x[i]);
                theta = atan(tan);
                if (x[i] > x[j]) theta += M_PI;
                
            } else {
                theta = M_PI / 2;
                if (y[i] > y[j]) theta += M_PI;
            }
    
            if (theta < 0) theta += 2 * M_PI;  // theta: [0, 2pi)
            
            double min_ = M_PI / 2 + theta, max_ = - M_PI / 2 + theta;
            if (max_ < 0) max_ += 2 * M_PI;
            if (min_ >= 2 * M_PI) min_ -= 2 * M_PI;
            
            if (min_arg[i] == 0 && max_arg[i] == 2 * M_PI) {
                min_arg[i] = min_; max_arg[i] = max_;
                continue;
            }
            
            double a = min_arg[i] - max_, b = max_arg[i] - min_;
            if (a >= M_PI) a -= 2 * M_PI;
            if (a < -M_PI) a += 2 * M_PI;
            if (b > M_PI) b -= 2 * M_PI;
            if (b <= -M_PI) b += 2 * M_PI;
            
            if (a >= 0 && b <= 0) {
                min_arg[i] = max_arg[i] = 0;
                break;
            } else if (a >= 0 && b > 0) {
                min_arg[i] = min_;
            } else if (a < 0 && b <= 0) {
                max_arg[i] = max_;
            }
        }
        
        arg[i] = max_arg[i] - min_arg[i];
        if (arg[i] < 0) arg[i] += 2 * M_PI;
        
    }
    
    for (int i = 0; i < N; ++i) {
        printf("%.6f\n", arg[i] / (2 * M_PI));
    }
    
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n + 1), b(n + 1), c(n + 1);
  vector<vector<int>> dp(n + 2, vector<int>(4, 0));

  rep(i, 1, n + 1) cin >> a[i] >> b[i] >> c[i];
  rep(i, 1, n + 1) {
    dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
    dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
    dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
  return 0;
}

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

import math
sqrtN = int(math.sqrt(N))

def F(a, b):
    return max(len(str(a)), len(str(b)))

best = 10*9
for n in range(1, sqrtN+1):
    q, mod = divmod(N, n)
    if n * q != N:
        continue
    v = F(n, q)
    if v < best:
        best = v

print(best)


Measured memory_bytes: 3060
/*
    to amy
    https://atcoder.jp/contests/abc135/tasks/abc135_b
*/

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define F first
#define S second
#define MAX 2005

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

int main() {
    IOS
    int n;
    while(cin>>n){
        int x, count = 0;
        for(int i=1;i<=n;i++){
            cin>>x;
            if(i!=x)count++;
        }
        if(count>2) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], b[200009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	int ans = 0;
	if (n % 2) {
		ans = b[n / 2] - a[n / 2] + 1;
	}
	else {
		ans = b[n / 2] + b[n / 2 - 1] - (a[n / 2] + a[n / 2 - 1]) + 1;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define all(x)	x.begin(),x.end()
#define fileopen freopen("input.txt", "rt", stdin);
#define fileclose freopen("output.txt", "wt", stdout);
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hash visited.max_load_factor(0.25);visited.reserve(512)

using namespace std;

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

  ll wa=0;
  ll ac=0;
  ll tle=0;
  ll re=0;

    string str;
  while(n--)
  {
      cin>>str;
      if(str=="AC")
        ac++;
        else if(str=="WA")
            wa++;
        else if(str=="TLE")
            tle++;
        else
        {
            re++;
        }
        
  }

  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;

   
   
}



    
   
   



    
   
   
    
  


    


Measured memory_bytes: 3636
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,X,M=mint()
ans=X
se={X:1}
l=[0,X]
tmp=X
for k in range(2,N+1):
    tmp=(tmp*tmp)%M
    if tmp in se:
        i=se[tmp]
        ans=sum(l[:i])
        N-=(i-1)
        ans+=(N//(k-i))*sum(l[i:k])
        N-=(N//(k-i))*(k-i)
        for t in range(N):
            ans+=l[i+t]
        break
    se[tmp]=k
    l.append(tmp)
    ans+=tmp
print(ans)

Measured memory_bytes: 78628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		in1 := sc.Text()
		sc.Scan()
		in2 := sc.Text()
		countMax(in1, in2)
	}
}

func countMax(in1 string, in2 string) {
	counta := make([][]int, len(in2)+1)
	for i := 0; i < len(in2)+1; i++ {
		for j := 0; j < len(in1)+1; j++ {
			counta[i] = append(counta[i], 0)
		}
	}

	// fmt.Println(counta)
	for a1, v1 := range in1 {
		i1 := a1 + 1
		for a2, v2 := range in2 {
			i2 := a2 + 1
			// fmt.Printf("1:%v 2:%v\n", i1, i2)
			if v1 == v2 {
				counta[i2][i1] = counta[i2-1][i1-1] + 1
				continue
			}
			val := counta[i2-1][i1]
			if val < counta[i2][i1-1] {
				val = counta[i2][i1-1]
			}

			counta[i2][i1] = val
		}
	}
	fmt.Println(counta[len(in2)][len(in1)])
}



Measured memory_bytes: 19008
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>


using namespace std;
typedef long long ll;

int N = 0;
int W = 0;

int main(){
    //ナップサック問題　荷物の価値を最大化
    cin >> N;
    cin >> W;

    vector<pair<ll, ll> > T;
    //価値：重量 
    //T = vector<vector<ll> >(N + 1, vector<ll>(2, 0));
    //初期化
    //T[0][0] = 0;
    //T[0][1] = 0;

    ll value = 0;
    ll weight = 0;

    for(int i = 0; i < N; i++){
         cin >> weight >> value;
         T.push_back(make_pair(value, weight));
    }

    //価値が大きい順にソート
    sort(T.rbegin(), T.rend());
    //余白
    T.insert(T.begin(), make_pair(value, weight));

    //dp
    vector<vector<ll> > dp;
    dp = vector<vector<ll> >(N + 1, vector<ll>(W + 1, -1));
    dp[0][0] = 0;

    //答え
    ll ans = 0;

    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            if(dp[i - 1][j] > -1){
                //直下を更新
                if(dp[i][j] <= dp[i - 1][j]){
                    dp[i][j] = dp[i - 1][j];
                }
                //荷物を足し合わせたところを更新
                if(dp[i][j + T[i].second] <= dp[i - 1][j] + T[i].first && j + T[i].second <= W){
                    dp[i][j +T[i].second] = dp[i - 1][j] + T[i].first;
                    //ans確認
                    if(ans < dp[i - 1][j] + T[i].first) ans = dp[i - 1][j] + T[i].first;
                }
            }          
        }

    }

    cout << ans << endl;

    //確認
    
    /*
    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < W + 1; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    

}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll N, Q;

int main(){
	cin >> N >> Q;
	string S;
	cin >> S;
	int len = S.size();
	
	vector<int> acc(len); // acc[i] : 0..i の間にACがいくつあるか
	acc[0] = 0;
	
	int ct = 0;
	for ( int i = 1; i < len; i++ ){
		if ( S[i-1] == 'A' && S[i] == 'C' )
			ct++;
		acc[i] = ct;
	}
	
	
	for ( int i = 0; i < Q; i++ ){
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		
		cout << acc[r]-acc[l] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 1408
N, K = map(int, input().split())
MOD = 10**9+7
cmb = [[1] if i == -1 else [1] + [0]*i + [1] for i in range(-1,N)]

for i in range(2, N+1):
    for j in range(1, i):
        cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j]

for i in range(1, K+1):
    try:
        ans = cmb[N-K+1][i]
    except IndexError:
        ans = 0
    if ans:
        ans *= cmb[K-1][i-1]
    print(ans % MOD)

Measured memory_bytes: 488460
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

uint32_t gcd(int32_t a, int32_t b) {
  if (b > a) return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int32_t main() {
  while (true) {
    string str;
    cin >> str;
    if (str[0] == '#') break;

    vector<int32_t> dirs;
    uint32_t i = 0;
    while (i < str.size()) {
      if (str[i] == 'n') {
        dirs.push_back(-1);
        i += 5;
      } else if (str[i] == 'w') {
        dirs.push_back(+1);
        i += 4;
      }
    }

    reverse(dirs.begin(), dirs.end());

    pair<int32_t, int32_t> degree;
    degree.second = 1;
    if (dirs[0] == -1) {
      degree.first = 0;
    } else {
      degree.first = 90;
    }

    for (uint32_t i = 1; i < dirs.size(); i++) {
      degree.first *= 2;
      degree.second *= 2;
      degree.first += dirs[i] * 90;
    }

    if (degree.first == 0) {
      cout << 0 << endl;
    } else {
      uint32_t div = gcd(degree.first, degree.second);
      degree.first /= div;
      degree.second /= div;
      if (degree.second == 1) {
        cout << degree.first << endl;
      } else {
        cout << degree.first << "/" << degree.second << endl;
      }
    }
  }
  return 0;
}

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

const int MAX = 1000000;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

	long long x, y; cin >> x >> y;

	if ((x + y) % 3 != 0 ) {
		cout << 0 << endl;
		return 0;
	}
	
	long long m = (2 * x - y) / 3;
	long long n = (-1 * x + 2 * y) / 3;

	if (m < 0 || n < 0) {
		cout << 0 << endl;
	}
	else {
		COMinit();
		cout << COM(m + n, n) << endl;
	}

	return 0;

}

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

int main() {
  int N; cin >> N;
  cout << (N % 2 == 0 ? N : N * 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> cnt(N);
  while (K-- > 0) {
    int d;
    cin >> d;
    while (d-- > 0) {
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }

  int ans = 0;
  rep(i, N) {
    if (cnt[i] == 0)
      ans++;
  }
  cout << ans << endl;
}

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

int main() {

  long long int n, m;
  cin >> n >> m;

  vector< string > a, b;

  for ( long long int i = 0; i < n; i++ ) {

    string in;
    cin >> in;
    a.push_back( in );

  }

  for ( long long int i = 0; i < m; i++ ) {

    string in;
    cin >> in;
    b.push_back( in );

  }

  for ( long long int y = 0; y < n - m + 1; y++ ) {

    for ( long long int x = 0; x < n - m + 1; x++ ) {

      bool f = true;
      for ( long long int yy = 0; yy < m; yy++ ) {

	for ( long long int xx = 0; xx < m; xx++ ) {

	  if ( a[y+yy][x+xx] != b[yy][xx] ) {
	    f = false;
	    break;
	  }

	}

      }

      if ( f == true ) {
	cout << "Yes" << endl;
	return 0;
      }

    }

  }

  cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 1e9
long double PI =3.14159265358979323846;
 
const ll M=1e12;
const ll inf=1e18;
const ll ms=10000000;
fast;
ll ans,n,m;
void solve()
{
    cin>>n;ll ar[n],arr[n],maxi=INT_MIN,maxi1=INT_MIN;
    for(int i=0;i<n;i++)
    {cin>>ar[i];arr[i]=ar[i];}
    sort(ar,ar+n);
    maxi=ar[n-1];maxi1=ar[n-2];
    //cout<<maxi<<" "<<maxi1<<endl;
    for(int i=0;i<n;i++)
    {
        if(maxi==arr[i]) 
            cout<<maxi1<<endl;
        else
            cout<<maxi<<endl;
    }
    
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 200000 + 9, M = 20 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(0);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

int n, k, x, arr[N];

int main() {
//	INPUT();
	OUTPUT();
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		arr[x]++;
	}
	vector<int> v;
	for (int i = 1; i < N; i++) {
		if (arr[i])
			v.push_back(arr[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	int m = max(0, sz(v) - k);
	for (int i = 0; i < m; i++) {
		ans += v[i];
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int	a[10005];
int main()
{
	ll n,k,d;
	scl(n);scl(k);scl(d);
	n=abs(n);
	if(n%d==0){
		if(n/d<=k){
			k-=n/d;
			if(k%2==0)pf("0\n");
			else pf("%lld\n",d);
		}else {
			pf("%lld\n",n-k*d);
		}
	}else {
		if(n/d<=k){
			k-=n/d;
			n=n%d;
			if(k%2==0)pf("%lld\n",n);
			else pf("%lld\n",d-n);
		}else {
			pf("%lld\n",n-k*d);
		}
	}
}

Measured memory_bytes: 3824
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(), k = in.ni();
        if(n%k==0) out.println(0);
        else out.println(1);
    }

    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: 22612
#include <bits/stdc++.h>
using namespace std;

struct UnionFind
{
  vector<int> par;
  vector<int> rank;

  UnionFind(int n = 1)
  {
    init(n);
  }

  void init(int n = 1)
  {
    par.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; ++i)
      par[i] = i, rank[i] = 0;
  }

  int root(int x)
  {
    if (par[x] == x)
      return x;
    int r = root(par[x]);
    return par[x] = r;
  }

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

  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    return true;
  }
};

int main()
{
  int64_t N, M, x, y, z;
  cin >> N >> M;
  UnionFind uf(N);
  for (int i = 0; i < M; i++)
  {
    cin >> x >> y >> z;
    uf.unite(x - 1, y - 1);
  }
  map<int, int> mp;
  for (auto p : uf.par)
    mp[uf.root(p)]++;
  cout << mp.size() << endl;
}


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

int n, k;
long long int a[101010];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  
  //rep(i, n) cerr <<a[i] << " "; cerr << endl;
  
  
  long long sum = 0;
  int hiku = 0;
  for(int i = 0; i < n - 1; i++){
    sum += a[i];
    if(a[i + 1] > sum * 2){
      hiku = i + 1;
      //cerr << "aaa";
    }
    //cerr << sum << " ";
  }
  //cout << hiku << endl;
  cout << n - hiku << endl;
  return 0;
}


Measured memory_bytes: 1024