akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace agc011_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] member = new int[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                member[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(member);
            int bus = 0;
            int zyoukyaku = 0;
            int time = member[0];
            for (int i = 0; i < x[0]; i++)
            {
                zyoukyaku++;
                if (zyoukyaku > x[1] || member[i] - time > x[2])
                {
                    bus++;
                    zyoukyaku = 1;
                    time = member[i];
                }
            }
            Console.WriteLine(zyoukyaku == 0 ? bus : bus + 1);
        }
    }
}

Measured memory_bytes: 15584
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>12){
		cout<<b<<endl;
	}
	if(12>=a&&a>5){
		cout<<b/2<<endl;
	}
	if(5>=a){
		cout<<"0"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a, b, c, d; cin >> a >> b >> c >> d;
    vector<ll>v(4);
    v[0] = a*c;
    v[1] = a*d;
    v[2] = b*c;
    v[3] = b*d;

    ll mx = *max_element(v.begin(), v.end());

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n, a;
    cin >> n >> a;
    if(n < a){
        cout << 0;
    }else{
        cout << 10;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#define LEN 100005
using namespace std;

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN]; //queue
int head, tail, n;

void enqueue(P x);
P dequeue();

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    cin >> n >> q;
    for ( i = 1; i <= n; i++ ) { //queue stock
        cin >> Q[i].name;
        cin >> Q[i].t;
    }
    head = 1; tail = n + 1;
    while (head != tail) {
        u = dequeue(); //P u
        c = min(q, u.t);
        u.t -= c; //rest time
        elaps += c; //past time
        if ( u.t > 0 ) enqueue(u); //if not completed add to queue
        else cout << u.name << " " << elaps << endl;
    }
    return 0;
}

void enqueue(P x) { 
    Q[tail] = x; //input to tail
    tail = (tail + 1) % LEN;
    //if tail > length of queue go back 
}

P dequeue() { 
    P x = Q[head]; //output from queue head
    head = (head + 1) % LEN;
    return x;
}


Measured memory_bytes: 13220
import sys
from itertools import accumulate
f = sys.stdin


while True:
    n = int(f.readline())
    if n == 0:
        break
    p = list(map(int, f.readline().split()))
    j = list(map(int, f.readline().split()))
    j.sort(reverse=True)
    j.insert(0, 0)
    
    total_length = sum(p)
    num_of_pipe = len(p)
    
    print(max((num_of_pipe - i) * (total_length + ji) for i, ji in enumerate(accumulate(j))))

Measured memory_bytes: 9176
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char s[500001];
int l[500001];
int r[500001];

int main() {
    int n, i;
    long long ans = 0;
    
    scanf("%s", s);
    
    n = strlen(s) + 1;
    
    for (i = 1; i < n; i++) {
        if (s[i - 1] == '<') {
            l[i] = l[i - 1] + 1;
        } else {
            l[i] = 0;
        }
    }
    
    for (i = n - 2; i >= 0; i--) {
        if (s[i] == '>') {
            r[i] = r[i + 1] + 1;
        } else {
            r[i] = 0;
        }
    }
    
    for (i = 0; i < n; i++) ans += max(l[i], r[i]);
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
typedef long long ll;

void solve(){
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy\n";
    else if(s == "Cloudy")
        cout << "Rainy\n";
    else if(s == "Rainy")
        cout << "Sunny\n";
    else{}    

}

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

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

int main() {

    int N;
    cin >> N ;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    for (int i = 0; i < N; i++) {
    string op;
    cin >> op ;
    if(op == "AC"){
        ac++;
    }
    else if(op == "WA"){
        wa++;
    }
    else if(op == "TLE"){
        tle++;
    }
    else{
        re++;
    }
    }

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

   return 0;

}





Measured memory_bytes: 3628
import sys
import copy
from itertools import accumulate
input=sys.stdin.readline
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    ans = copy.deepcopy(A)
    for _ in range(K):
        cumsum = [0]*N
        for i,a in enumerate(ans):
            l = max(0,i-a)
            r = min(N-1,i+a)
            cumsum[l] += 1
            if r+1 < N:
                cumsum[r+1] -= 1
        ans = list(accumulate(cumsum))
        if ans[0] == N:
            break
    print(*ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 179900
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct node{
    pair<ll, ll> parent = {-1, -1};
    vector<pair<ll, ll>> child;
};

ll n; 
vector<node> tree;

void bfs(ll node, vector<ll> &dist){
    vector<ll> color(n, 0);
    color[node] = 1;
    dist[node] = 0;
    queue<ll> que;
    que.push(node);

    while(!que.empty()){
        auto p = que.front();
        que.pop();

        if(tree[p].parent.first != -1 && color[tree[p].parent.first] == 0){
            que.push(tree[p].parent.first);
            dist[tree[p].parent.first] = dist[p]+tree[p].parent.second;
            color[tree[p].parent.first] = 1;
        }
        for(auto c: tree[p].child){
            if(color[c.first] == 0){
                que.push(c.first);
                dist[c.first] = dist[p]+c.second;
                color[c.first] = 1;
            }
        }
    }
}

int main(){
    Init();
    cin >> n;
    tree.resize(n);

    // 根
    ll root = -1;
    rep(i, n-1){
        // 入力と0-based-index
        ll a, b, c; cin >> a >> b >> c; a--; b--;
        // 両方親が未定の場合
        if(tree[a].parent.first == -1 && tree[b].parent.first == -1){
            tree[b].parent.first = root = a;
            tree[b].parent.second = c;
            tree[a].child.push_back(make_pair(b, c));
        }
        // Aの親が未定の場合
        else if(tree[a].parent.first == -1){
            tree[a].parent.first = b;
            tree[a].parent.second = c;
            tree[b].child.push_back(make_pair(a, c));
        }
        // Bの親が未定の場合
        else{
            tree[b].parent.first = a;
            tree[b].parent.second = c;
            tree[a].child.push_back(make_pair(b, c));
        }
    }

    // クエリの処理
    ll q, k; cin >> q >> k; k--;
    // ノードkから各ノードへの距離
    vector<ll> dist(n);
    bfs(k, dist);

    rep(i, q){
        ll x, y; cin >> x >> y; x--; y--;
        cout << dist[x]+dist[y] << endl;
    }
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  ll cnt[26];
  rep(i,26){
    cnt[i]=0;
  }
  rep(i,k){
    rep(j,26){
      if(abc[j]==s[i]){
        cnt[j]++;
      }
    }
  }
  bool b=true;
  rep(j,26){
    if(cnt[j]%2!=0){
      b=false;
    }
  }
  if(b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	a.pb(INF);
	sort(all(a));
	ll ng = -INF, ok = INF + 12;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		ll cnt = 0;
		rep(i, n) {
			if (a[i] == 0) {
				if (mid >= 0) cnt += n;
			}
			else if (a[i] >= 0) {
				if (mid >= 0) {
					cnt += upper_bound(all(a), mid / a[i]) - a.begin();
				}
				else {
					ll nmid = -mid;
					cnt += upper_bound(all(a), -((nmid + a[i] - 1) / a[i])) - a.begin();
				}
			}
			else {
				if (mid >= 0) {
					cnt -= lower_bound(all(a), -(mid / -a[i])) - a.begin();
					cnt += n;
				}
				else {
					ll mmid = -mid; ll ma = -a[i];
					cnt -= lower_bound(all(a), (mmid + ma - 1) / ma) - a.begin();
					cnt += n;
				}
			}
		}
		rep(i, n) if (a[i] * a[i] <= mid) cnt--;
		cnt /= 2;
		if (cnt >= k) ok = mid;
		else ng = mid;
	}
	cout << ok << '\n';
}

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

int main() {
	int s;
	int a, b, c;
	cin >> s;
	a = s / 3600;
	s = s % 3600;
	b = s / 60;
	c = s % 60;
	cout << a << ":" << b << ":" << c << endl;
}


Measured memory_bytes: 3096
#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>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	int v[3], k, cnt = 0;
	for(int &i : v)
		cin >> i;
	cin >> k;
	for(int i = 1; i <= 2; i++){
		while(v[i] <= v[i-1])
			v[i] *= 2, cnt++;
	}
	cout << (cnt <= k ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin >> d;
    int n = 26;
    vector<int> c(n);
    for(int i = 0; i < n; i++) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(n));
    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> s[i][j];
        }
    }
    vector<int> last(n, 0);
    for(int i = 0; i < d; i++)
    {
        int tmp = 0;
        int del = 0;
        for(int j = 0; j < 26; j++)
        {
            del += c[j] * (i+1 - last[j]);
        }
        int con = 0;
        for(int j = 0; j < 26; j++)
        {
            //select j
            int tt = s[i][j];
            tt -= del;
            tt += c[j] * (i+1 - last[j]);
            if(tmp < tt)
            {
                tmp = tt;
                con = j;
            }
        }
        last[con] = i+1;
        cout << con+1 << endl;
    }
}




Measured memory_bytes: 3680
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int h = in.nextInt();
        int w = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();

        out.println((h - a) * (w - b));
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int train[100];
	int temp;
	int i, j;
	
	i = 0;
	while (scanf("%d", &temp) != EOF){
		if (temp != 0){
			train[i] = temp;
			i++;
		}
		else {
			printf("%d\n", train[i - 1]);
			i--;
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		doIt();
	}

	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		while(n + m + l > 0){
			int[][] road = new int[m][4];
			for(int i = 0; i < m; i++){
				for(int j = 0; j < 4; j++){
					road[i][j] = sc.nextInt();
				}
			}
			//宿場nに予算lでたどり着く時の盗賊の最小値
			int[][] place = new int[n][l + 1];
			for(int[] a : place){
				Arrays.fill(a, INF);
			}
			place[0][0] = 0;
			//Arrays.fill(place[0],0);
			boolean bContinue = true;
			while(bContinue){
				bContinue = false;
				for(int i = 0; i < m; i++){
					int from = road[i][0] - 1;
					int to = road[i][1] - 1;
					int dist = road[i][2];
					int enemy = road[i][3];
					for(int j = 0; j <= l; j++){
						//金を払っていく場合
						if(j + dist <= l && place[from][j] != INF && (place[from][j] < place[to][j + dist])){
							place[to][j + dist] = place[from][j];
							bContinue = true;
						}

						//金を払わない場合
						if(place[from][j] != INF && (place[from][j] + enemy <  place[to][j])){
							place[to][j] = place[from][j] + enemy;
							bContinue = true;
						}
					}

					from = road[i][1] - 1;
					to = road[i][0] - 1;

					for(int j = 0; j <= l; j++){
						//金を払っていく場合
						if(j + dist <= l && place[from][j] != INF && (place[from][j] < place[to][j + dist])){
							place[to][j + dist] = place[from][j];
							bContinue = true;
						}

						//金を払わない場合
						if(place[from][j] != INF && (place[from][j] + enemy <  place[to][j])){
							place[to][j] = place[from][j] + enemy;
							bContinue = true;
						}
					}
				}
			}
			int[] dest = place[n - 1];
			Arrays.sort(dest);
			//print(dest);
			System.out.println(dest[0]);
			n = sc.nextInt();
			m = sc.nextInt();
			l = sc.nextInt();
		}
	}

	public static void print(int[] a){
		for(int b : a){
			System.out.print(b + " ");
		}
		System.out.println();
	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int val[101];
int weight[101];
int n, W;

int dp[105][100005];


int main(){
    
    cin >> n >> W;
    
    memset(dp, 0x3f3f3f3f, sizeof(dp));
    
    for(int i=0; i<n;i++){
        cin >> weight[i] >> val[i];
    }
    
    dp[0][0] = 0;
    // we get min weigth possible to every possible value
    for(int i=1; i<=n; i++){
        dp[i][0] = 0;
        
        for(int v=1; v<100001; v++){
            // check if there is a combination of values that equal v            
            dp[i][v] = dp[i-1][v]; 
            
            if(v >= val[i-1]){

                dp[i][v] = min(dp[i][v], dp[i-1][v-val[i-1]] + weight[i-1]);
            }
        }
    }
        
    for(int v=100000; v>=0; v--){
    
        if(dp[n][v] <= W){
            cout << v << endl;
            return 0;
        }
    }

}

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int n, long[] A)
        {
            long sum1 = 0;
            long sum2 = 0;
            long res1 = 0;
            long res2 = 0;
            for (int i = 0; i < n; ++i)
            {
                sum1 += A[i];
                sum2 += A[i];
                if (i % 2 == 0)
                {
                    if (sum1 >= 0)
                    {
                        res1 += sum1 + 1;
                        sum1 = -1;
                    }
                    if (sum2 <= 0)
                    {
                        res2 += -sum2 + 1;
                        sum2 = 1;
                    }
                }
                else
                {
                    if (sum1 <= 0)
                    {
                        res1 += -sum1 + 1;
                        sum1 = 1;
                    }
                    if (sum2 >= 0)
                    {
                        res2 += sum2 + 1;
                        sum2 = -1;
                    }
                }
            }
            return Math.Min(res1, res2);
        }
        static void Main(string[] args)
        {
            int n = ReadInt();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(n, A));
        }
    }
}


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

// Contest: DISCO Presents Discovery Channel Code Contest 2020 Qual (https://atcoder.jp/contests/ddcc2020-qual)
// Problem: C: Strawberry Cakes (https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_c)

using namespace std;

template <class T, size_t... Is> struct arr_helper;
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<arr<T, Is...>, I>; };

using ll = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using vpi = vector<pi>;

arr<char, 300, 300> g;
arr<int, 300, 300> c;

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

    int h, w, k; cin >> h >> w >> k;
    vi row(h);
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> g[i][j], row[i] += g[i][j] == '#';

    int last_row = h - 1;
    while (row[last_row] == 0) --last_row;
    int last_occ_row = -1;
    int col = 0;
    for (int i = 0; i < h; ++i) {
        if (row[i] == 0)
            continue;
        int rem = row[i];
        int last_occ_col = -1;
        int max_row = i == last_row ? h : i + 1;
        for (int j = 0; j < w; ++j) {
            if (g[i][j] == '.')
                continue;
            --rem;
            ++col;
            int max_col = rem > 0 ? j + 1 : w;
            for (int ci = last_occ_row + 1; ci < max_row; ++ci)
                for (int cj = last_occ_col + 1; cj < max_col; ++cj)
                    c[ci][cj] = col;
            last_occ_col = max_col - 1;
        }
        last_occ_row = i;
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            cout << c[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 1280
N = int(input())
s = []
for i in range(N):
   s.append(input())
M = int(input())
t = []
for i in range(M):
   t.append(input())

def point(x):
   result = 0
   result += s.count(x)
   result -= t.count(x)
   return result

ans = 0

for word in set(s):
   if ans < point(word):
      ans = point(word)

print(ans)

Measured memory_bytes: 9028
hex_to_dig = {"0":"0000", "1":"0001", "2":"0010", "3":"0011",
              "4":"0100", "5":"0101", "6":"0110", "7":"0111",
              "8":"1000", "9":"1001", "a":"1010", "b":"1011",
              "c":"1100", "d":"1101", "e":"1110", "f":"1111"}
def dig_to_dec(digit):
  tf = digit[0]
  x = digit[1:25][::-1]
  y = digit[25:32]
  
  sumx = 0
  acc = 1
  for i, c in enumerate(x):
    if c == "1":
      sumx += acc
    acc *= 2
  
  sumy = 0
  acc = 0.5
  for i, c in enumerate(y):
    if c == "1":
      sumy += acc
    acc /= 2
  
  tf = "-" if int(tf) == 1 else ""
  if sumy == 0:
    print(tf + str(sumx) + "." + "0")
  else:
    print(tf + str(sumx + sumy))

n = int(input())
for _ in range(n):
  h = input()
  d = ""
  for c in h:
    d += hex_to_dig[c]
  dig_to_dec(d)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, p;
  cin >> n >> p;
  if (n==1) {
    cout << p << endl;
    return 0;
  }
  ul ans = 1;
  for (ul i=2; i*i<=p; ++i) {
    ul cnt = 0;
    while (p%i==0) {
      cnt++;
      p /= i;
    }
    for (ul j=0; j<cnt/n; ++j) ans*=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int cnt = 0;
		while (n != 0) {
			cnt += n/5;
			n /= 5;
		}
		out.println(cnt);
		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 1e5 + 20;

vi g[N];
int dp[N][2];

void dfs(int v, int par = 0) {
	dp[v][0] = dp[v][1] = 1;
	for(int u : g[v]) if (u != par) {
		dfs(u, v);
		dp[v][0] = (dp[v][0] * ((dp[u][0] + dp[u][1]) % MOD)) % MOD;
		dp[v][1] = (dp[v][1] * dp[u][0]) % MOD;
	}
}

int32_t main(){

    sync;

    int n; cin >> n;
    for(int i = 1; i < n; i++) {
    	int v, u; cin >> v >> u;
    	g[v].push_back(u);
    	g[u].push_back(v);
    }

    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;

    return 0;
}

Measured memory_bytes: 14208
_ = $stdin.gets
a = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
N = a.size

ma = a.max
mi = a.min

ops = []
i0 = (ma > -mi) ? a.index(ma) : a.index(mi)
#p a
(0...N).map { |i|
  a[i] += a[i0]
  ops << [i0,i]
}

#p a

if a[0] >= 0
  (1...N).map { |j|
    i = j - 1
    if a[i] > a[j]
      a[j] += a[i]
      ops << [i,j]
    end
  }
else
  (1...N).map { |jj|
    j = N - jj - 1
    i = j + 1
    if a[i] < a[j]
      a[j] += a[i]
      ops << [i,j]
    end
  }
end

#p a
p ops.size
ops.each{ |i,j| puts "#{i+1} #{j+1}" }


Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
	int a, b, c, n;
	scanf("%d %d %d", &a, &b, &c);
	n = 0;
	while(n < c) {
	       if (b >= a) {
			n++;
			b = b - a;
	       }
		else {
	 		break;
		}
	}		
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min( b/a,c) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0) {
        cout << a - b << endl;
    }
    else {
        cout << b - a << endl;
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] iarray = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int N = iarray[0];
            int K = iarray[1];
            int[] x = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            int min = int.MaxValue;
            for(int i = 0;i <= N- K; i++)
            {
                int L = Math.Abs(x[i]) + Math.Abs(x[i + K - 1] - x[i]);
                int R = Math.Abs(x[i + K - 1]) + Math.Abs(x[i + K - 1] - x[i]);

                min = Math.Min(min, Math.Min(L, R));
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 23520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    float adt,bdt,t;
    adt=360.0/12.0/60.0;
    bdt=360.0/60.0;
    t=h*60.0+m;
    float ad,bd;
    ad=t*adt;
    bd=m*bdt;
    float d,l;
    d=min(abs(ad-bd),360-abs(ad-bd));
    //l=sqrt(a*a+b*b-2*a*b*cos(d*M_PI/180.0));
    cout << fixed << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(d*M_PI/180.0)) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 55;
ll N, A[MAX];

ll solve() {
    ll res = 0;
    REP (q, 5e6) {
        REP (i, N) if (A[i] >= N) {
            ll temp = A[i]/N;
            res += temp;
            A[i] -= temp*(N+1);
            REP (j, N) A[j] += temp;
        }
    }
    return res;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 384
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;
const ALL_L: std::ops::RangeInclusive<usize> = 0..=MAX_L;

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        ul: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for (u, l) in ul {
        println!("{}", calc(&dp, &vw, u - 1, l));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push({
        let w = vw[0].1 as usize;
        ALL_L
        .map(|i| if i < w { 0 } else { vw[0].0 })
        .collect()
    });

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push({
            let w = vw[c].1 as usize;
            let v = vw[c].0;
            ALL_L
            .map(|i| {
                max(dp[p][i], if i < w { 0 } else { dp[p][i - w] + v })
            })
            .collect()
        });
    }

    dp
}

fn calc(
    dp: &Vec<Vec<u32>>,
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: usize,
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1 as usize;
        let sum1 = calc(dp, vw, p, l);
        let sum2 = if l < w { 0 } else { calc(dp, vw, p, l - w) + vw[u].0 };
        max(sum1, sum2)
    }
}


Measured memory_bytes: 410960
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

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

		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long K = Long.parseLong(tokens[1]);
		tokens = in.readLine().split(" ");
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < N; ++i) {
			sum += A[i];
		}
		List<Long> yakusuu = getYakusuu(sum);
		long result = 1;
		for (int i = 0; i < yakusuu.size(); ++i) {
			if (isEnable(A, K, yakusuu.get(i))) {
				result = yakusuu.get(i);
				break;
			}
		}
		System.out.println(result);
	}

	static boolean isEnable(long[] A, long K, long target) {
		List<Long> a = new ArrayList<>();
		for (int i = 0; i < A.length; ++i) {
			a.add(A[i] % target);
		}
		Collections.sort(a);
		
		Deque<Long> deque= new ArrayDeque<>(a.size());
		deque.addAll(a);

		long count = 0;
		long diff = 0;
		while(!deque.isEmpty()) {
			if(deque.getLast()+diff >= target) {
				diff -= target - deque.pollLast();
			}else {
				long val = deque.pollFirst();
				count += val;
				diff += val;
			}
			if(count>K) {
				return false;
			}
		}
		return true;
	}

	static List<Long> getYakusuu(long value) {
		Deque<Long> small = new ArrayDeque<>();
		Deque<Long> large = new ArrayDeque<>();
		for (long v = 1; v <= 1 + (long) Math.floor(Math.sqrt((double) value)); ++v) {
			if (value % v == 0) {
				small.addFirst(v);
				large.addLast(value / v);
			}
		}
		List<Long> result = new ArrayList<>(small.size() + large.size());
		result.addAll(large);
		result.addAll(small);
		return result;
	}
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        long K= long.Parse(input[1]);

        input = Console.ReadLine().Split(' ');
        int[] move = new int[N];
        for(int i=0;i<N;i++){
            move[i]=int.Parse(input[i]);
        }
        int[] route = Enumerable.Repeat<int>(0,move.Length).ToArray();

        int[] loop = LoopFinder(move,ref route);
        Console.WriteLine(final_position(K,loop,move,route));
    }

    static int[] LoopFinder(int[] move, ref int[] route){
        int i=1;
        while(true){
            int next = move[i-1];
            if(route[next-1]>0||next == 1){
                return new int[2]{next, i};
            }else{
                route[next-1]=route[i-1]+1;
                i=next;
            }
        }
    }

    static int final_position(long step, int[] loop, int[] move, int[] route){
        //ループより前パターン
        if(step<route[loop[0]-1]){
            int res =1;
            for(int i=0;i<step;i++){
                res = move[res-1];
            }
            return res;
        }else{
            //ループの中
            step -= route[loop[0]-1];
            int len_loop = route[loop[1]-1]-route[loop[0]-1]+1;
            step = step % len_loop;
            int res = loop[0];
            for(int i=0;i<step;i++){
                res = move[res-1];
            }
            return res;
        }

    }
}


Measured memory_bytes: 43804
import qualified Data.ByteString.Char8 as C
import Data.List

mdl = 10^9 + 7

t a b = a * b `mod` mdl

positivize x = if x < 0 then x + mdl else x

main :: IO ()
main = do
    [n,a,b] <- unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    let al = powMod 2 n - 1
    let na = chooseOpt n a
    let nb = chooseOpt n b
    print $ positivize $ (al - na - nb) `mod` mdl

powMod :: Int -> Int -> Int
powMod cur 0 = 1
powMod cur n
    | even n = powMod (t cur cur) (div n 2)
    | odd n  = (t cur) $! powMod (t cur cur) (div n 2)

chooseOpt n i = choose n (min (n-i) i)
    where
    choose n i = t (prod' [n-i+1..n] ) $ modInv $ (prod' [1..i])
    prod' = foldr t 1

modInv :: Int -> Int
modInv a =
    let (x,_,1) = eEA a mdl
    in  positivize x

eEA :: Int -> Int -> (Int, Int, Int)
eEA a 0 = (1, 0, a)
eEA a b =   let (q, r) = a `quotRem` b
                (s, t, g) = eEA b r
            in  (t, s-q*t, g)


Measured memory_bytes: 8204
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	//freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	int arr[n];
	for(int i = 0; i<n; i++) cin>>arr[i];

	int land = 0, move = 0, max_move = 0;
	
	for(int i = 1; i<n; i++){
		if(arr[land]>=arr[i]){
		//	cout<<arr[land]<<" "<<arr[i]<<endl;
			move++;
			land++;
		}
		else if(arr[land]<arr[i]){
			land=i;
		//	cout<<move<<endl;
			if(max_move<move){
				
				max_move=move;
				
			}
			move=0;
			
		}
	}
	cout<<max(move,max_move)<<endl;
 
	return 0;
}


Measured memory_bytes: 640
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x; map<int, int> d;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x, d[x]++;
	vector<int> v;
	for (pair<int, int> i : d) {
		for (int j = 0; j < i.second / 2; j++) v.push_back(i.first);
	}
	sort(v.begin(), v.end());
	cout << (v.size() < 2 ? 0 : 1LL * v[v.size() - 1] * v[v.size() - 2]) << endl;
	return 0;
}

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

typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M) {
    ullong res = 1;
    if (n > 0) {
        res = power(x, n / 2, M);
        if (n % 2 == 0)
            res = (res * res) % M;
        else
            res = (((res * res) % M) * x) % M;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, n;
    cin >> m >> n;

    cout << power(m, n, 1000000007) << endl;

    return 0;
}


Measured memory_bytes: 3224
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N = I()
    A = LI()
    ans = 0
    for i in range(N-1):
        if A[i] == i+1:
            ans += 1
            A[i],A[i+1] = A[i+1],A[i]

    if A[N-1] == N:
        ans += 1

    return(ans)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 53340
//
//M-SOLUTIONS 2020
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    FOR(i, 1, n-k){
        if (a[i-1]<a[i+k-1]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 4836
#include <stdio.h>
int digit(int x)
{
	int i;
	for(i=1;x/=10;i++)
		;
	return i;
}
int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b) != EOF)
		printf("%d\n",digit(a+b));
	return 0;
}

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

using namespace std;

int main(){
    string s;
    int counter=0,ans=0;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C'){
            counter+=1;
        }
        else{
            ans=max(ans,counter);
            counter=0;
        }
    }
    ans=max(ans,counter);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(input())for _ in range(N)]

B=sorted(A)
count=B[-1]==B[-2]
M=B[-1]
M2=B[-2]
for a in A:
    if count:
        print(M)
    elif a==M:
        print(M2)
    else:
        print(M)

Measured memory_bytes: 19004
s = input()

s_list = list(s)
s_len = len(s)

s_pattern1 = ""
is_zero = False
for _ in range(s_len):
    if is_zero:
        s_pattern1 += "0"
    else:
        s_pattern1 += "1"
    is_zero = not is_zero
    
s_pattern2 = ""
is_zero = True
for _ in range(s_len):
    if is_zero:
        s_pattern2 += "0"
    else:
        s_pattern2 += "1"
    is_zero = not is_zero

count1 = 0
count2 = 0
for i, c in enumerate(s_list):
    if c != s_pattern1[i]:
        count1 += 1
    if c != s_pattern2[i]:
        count2 += 1
        
print(min(count1,count2))

Measured memory_bytes: 4084
use text_io::*;
use std::process::exit;

fn main(){
    let mut n:usize = read!();
    let mut k:usize = read!();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        v.push(1);
    }
    for i in 0..k {
        let mut d:usize = read!();
        for j in 0..d {
            let mut x:usize = read!();
            v[x-1] = 0;
        }
    }
    let mut y:usize = 0;
    for i in 0..n {
        y+=v[i];
    }
    println!("{}",y);
}

Measured memory_bytes: 2148
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int H, N;
	cin >> H >> N;

	vector<int> A(N);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum >= H) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
int cnt[40000][20];
int N;
string str;
int func(int x){
	int ans = 0;
	int pos = -1;
	for(int i = 1; i <= N; ++i){
		if(str[i - 1] == x + '0'){
			pos = i;		
			break;
		}	
	}
	if(pos == -1) return 0;
	for(int i = 0; i <= 9; ++i){
		int pp = -1;
		for(int j = N; j >= 1; --j){
			if(str[j - 1] == i + '0'){
				pp = j;	
				break;
			}	
		}	
		if(pp == -1) continue;
		int ll = 0;;
		for(int j = 0; j <= 9; ++j){
			if(cnt[pp - 1][j] - cnt[pos][j] > 0){
				++ll;	
			}
		}
		ans += ll;
	}
	return ans;
}
int main(){
	//freopen("test", "r", stdin);
	cin >> N;
	cin >> str;
	for(int i = 1; i <= N; ++i){
		for(int j = 0; j <= 9; ++j){
			cnt[i][j] = cnt[i - 1][j];
		}
		cnt[i][str[i - 1] - '0']++;
	}
	int ans = 0;
	for(int i = 0; i <= 9; ++i){
		ans += func(i);	
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main(){
	int A=0,B=0,N;
	scanf("%d",&N);
	int C[N];
	for(int i=0;i<N;i++){
		scanf("%d",&C[i]);
	}
	
	char turn = 'A'; 
	int max = 0;
	int num = 0;
	for(int j=0;j<N;j++){
		for(int i=0;i<N;i++){
			if(C[i] > max){
				max = C[i];
				num = i;
			}
		}
		if(turn == 'A'){
			A += max;
			turn = 'B';
		}else if(turn == 'B'){
			B += max;
			turn = 'A';
		}
		C[num] = 0;
		max = 0;
	}
	printf("%d",A-B);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)


class DisjointSets {
  vi rank, p;

public:
  DisjointSets() {}
  DisjointSets(int s) {
    rank.resize(s, 0);
    p.resize(s, 0);

    rep(i, s) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }
  
  bool is_same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  int findSet(int x) {
    if (x != p[x]) p[x] = findSet(p[x]);
    return p[x];
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }
};

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

  auto ds = DisjointSets(n);

  rep(i, q) {
    int c, x, y;
    cin >> c >> x >> y;

    if (c) cout << (ds.is_same(x, y) ? 1 : 0) << endl;
    else ds.unite(x, y);
  }
}



Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define FASTIO() cin.tie(0),ios::sync_with_stdio(0);
#define dbg(x) cout<<#x<<": "<<x<<endl

bool is_prime(int x) {
    for (int i = 2; i*i <= x; i++) if (x%i == 0) return false;
    return x != 1;
}

int main() {
    FASTIO();
    int q; cin >> q;
    static int a[100010] = {0};
    rep(i, 100000) a[i] = (is_prime(i) & is_prime((i + 1) / 2));
    rep(i, 100000) a[i + 1] += a[i];

    while (q--) {
        int l, r; cin >> l >> r;
        int cnt = a[r] - a[l - 1];
        cout << cnt << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024