akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int a, b, c;

	fgets(str, 100, stdin);
	sscanf(str, "%d %d %d\n", &a, &b, &c);

	int res[6] = {};

	res[0] = (b-a>0 ? b-a : a-b) + (c-b>0 ? c-b : b-c);
	res[1] = (c-a>0 ? c-a : a-c) + (b-c>0 ? b-c : c-b);

	res[2] = (a-b>0 ? a-b : b-a) + (c-a>0 ? c-a : a-c);
	res[3] = (c-b>0 ? c-b : b-c) + (a-c>0 ? a-c : c-a);

	res[4] = (a-c>0 ? a-c : c-a) + (b-a>0 ? b-a : a-b);
	res[5] = (b-c>0 ? b-c : c-b) + (a-b>0 ? a-b : b-a);

	int min=res[0];

	for (int i = 0; i < 6; i++) {
		// printf("%d\n", res[i]);
		min = min < res[i] ? min : res[i];
	}

	printf("%d\n", min);

	return 0;
}


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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int mod = 1e9 + 7;

int n;
string s;
const int MAXN = 3010;

int dp[MAXN][MAXN];


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    cin>> n;
    cin>> s;
    dp[1][1]= 1;
    for(int len= 2; len<=n; ++len){
        int suma = 0;
        for(int i= 1; i<=len; ++i){
            suma+= dp[len-1][i];
            suma%=mod;
            dp[len-1][i] = suma;
        }
        for(int num= 1; num<=len; ++num){
            int l, r;
            if(s[len-2]=='<'){
                l= 1; r= num-1;
            }else{
                l= num; r= len;
            }
//            for(int i= l; i<=r; ++i){
//                dp[len][num]+= dp[len-1][i];
//                (dp[len][num])%=mod;
//            }
            dp[len][num] += (dp[len-1][r]- dp[len-1][l-1] + mod )%mod;

        }
    }
    int ans =0;
    for1(i,n){
        ans+=dp[n][i];
        ans%=mod;
    }
    cout<<ans<<el;
}


Measured memory_bytes: 34304
import sys
N, M, Q = map(int, sys.stdin.readline().split())

LR = [[0 for _ in range(N+2-i)] for i in range(N+2)]
for i in range(M):
  L, R = map(int, sys.stdin.readline().split())
  LR[L][R-L+1] += 1

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

for i in range(Q):
  p, q = map(int, sys.stdin.readline().split())
  print(LR[p][q-p+1])


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

int main() {
    ll N; cin >> N;
    ll W[110];
    ll sum = 0;
    for(int i = 0; i < N; i++){ 
        cin >> W[i];
        sum += W[i];
    }

    ll S_1 = 0;
    ll S_2 = sum;
    ll min = 1000;
    for(int t = 0; t < N; t++){
        S_1 += W[t];
        S_2 -= W[t];
        if(abs(S_1 - S_2) < min) min = abs(S_1 - S_2);
    }
    cout << min << endl;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int H,N;
    cin >> H >> N;
    int dp[H+1][N];
    vector<pair<int,int>> magic(N);
    REP(i,0,H+1){
        REP(j,0,N){
            dp[i][j]=0;
        }
    }
    REP(i,0,N)
        cin >> magic[i].first >> magic[i].second;
    
    REP(i,1,H+1)
        dp[i][0] = magic[0].second+((i-1)/magic[0].first)*magic[0].second;

    REP(h,0,H){
        REP(m,1,N){
            if(h+1-magic[m].first>0){
                dp[h+1][m] = min(dp[h+1][m-1], dp[h+1-magic[m].first][m]+magic[m].second);
            }else{
                dp[h+1][m] = min(dp[h+1][m-1], magic[m].second);
            }
        }
    }
    // REP(i,1,H+1){
    //     REP(j,0,N){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    P(dp[H][N-1]);
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n, m, a;
	while(cin >> n >> m >> a, n){
		vector<vector<int>> amida(n+1, vector<int>(1001,0));
		//To create amida
		for(int i=0; i<m; i++){
			int h, p, q;
			cin >> h >> p >> q;
			amida[p][h] = q;
			amida[q][h] = p;
		}

		for(int hi=1000; hi>0; hi--){
			//cout << amida[a][hi] << endl;
			if(amida[a][hi] != 0) a = amida[a][hi];
			//else if(a > 1 && amida[a-1][hi] != 0) a = amida[a-1][hi];
		}

		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 3312
#include <string.h>
#include <stdio.h>
int main(void){
	int H,A;
	scanf("%d %d",&H,&A);
    if(H%A==0){
        printf("%d",H/A);
    }
    else{
        printf("%d",H/A+1);
    }
	return 0;
	}

Measured memory_bytes: 256
using System;

namespace A___One_Card_Poker
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            if (a == 1) { a += 13; }
            if (b == 1) { b += 13; }
            if (a > b)
            {
                Console.WriteLine("Alice");
            }
            else if (a < b)
            {
                Console.WriteLine("Bob");
            }
            else
            {
                Console.WriteLine("Draw");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>


using namespace std;


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


int main()
{
	string s = "CODEFESTIVAL2016";
	
	string t;
	cin>>t;
	
	int cnt = 0;
	rep(i,s.size())if(s[i] != t[i])cnt++;
	
	cout<<cnt<<endl;
}




Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/abc105/tasks/abc105_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(TOTALSUM):
    result = "No"
    totalsum4max = TOTALSUM // 4 + 1
    totalsum7max = TOTALSUM // 7 + 1
    for j in range(0,totalsum4max):
        for k in range(0,totalsum7max):
            nowtotal = j * 4 + k * 7
            if nowtotal == TOTALSUM :
                result = "Yes"
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))


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


int main() {
    int n;
    string s,t;
    cin>>n>>s>>t;
    
    rep(i,n) printf("%c%c",s[i],t[i]);

    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
l = [[]for i in range(26)]

for i, c in enumerate(s * 2):
    l[ord(c) - ord('a')].append(i)


from bisect import *

shukai = 0
now = 0

t = input()
for c in t:
    x = ord(c) - ord('a')
    if len(l[x]) == 0:
        print(-1)
        exit()
    i = bisect_left(l[x], now)
    now = l[x][i] + 1

    if now >= n:
        now -= n
        shukai += 1


print(shukai * n + now)


Measured memory_bytes: 11896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main() {
    std::string s;

    std::cin >> s;

    if (s[0] == s.back()) {
        std::cout << ((s.length() - 2 - 1) % 2 ? "First" : "Second") << std::endl;
        return 0;
    } else {
        std::cout << ((s.length() - 2) % 2 ? "First" : "Second") << std::endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std ;
int main()
{
  int numK , numX ;
  
  cin >> numK >> numX ;
  
  for(int i = numX - numK +1 ; i <= numX + numK - 1 ;i++){
    
    cout << i << endl ;
  }
  return 0 ;
  
}

Measured memory_bytes: 384
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> result;
  while (n) {
    vector<int> temp;
    int pos = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == i + 1) {
        pos = i;
        break;
      }
      temp.push_back(a[i]);
    }
    if (pos == -1) {
      cout << -1 << '\n';
      return 0;
    }
    for (int i = pos - 1; i >= 0; i--) {
      temp.push_back(a[i]);
    }
    reverse(all(temp));
    a = temp;
    n--;
    result.push_back(pos + 1);
  }
  reverse(all(result));
  for (auto x : result) {
    cout << x << '\n';
  } 
  return 0;
}

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

int main()
{
	int N, K;
	int x = 1;
  
	cin >> N >> K;

	for(int i=0;i<N;i++){
      if(x*2 < x + K) x *= 2;
      else x += K;
	}
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
char n;
int main() {
  rep(i,12){
    cin >> n;
    cout << n;
    if(i==3) cout << ' ';
  }
  cout << endl;
  return 0;
}














Measured memory_bytes: 256
void main()
{
    long n = rdElem;

    if (n == 0) 0.writeln;
    else
    {
        string s;
        long b = 1;
        while (n)
        {
            long d = abs(n%(-2*b)/b);
            s ~= (d + '0').to!dchar;
            n -= d * b;
            b *= -2;
        }

        foreach_reverse (x; s)
        {
            x.write;
        }
        writeln;
    }
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


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

	int a, b;
	cin >> a >> b;
	int res = max(a + b, max(a - b, a * b));
	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

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

	public static void ALDS1_4_B() {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int n = sc.nextInt();
		int[] S = new int[n];
		for(int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] T = new int[n];
		for(int i = 0; i < q; i++) {
			T[i] = sc.nextInt();
			if(Arrays.binarySearch(S, T[i]) >= 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 68084
y = {
  'r' => %w[q w e r t a s d f g z x c v b],
  'l' => %w[y u i o p h j k l n m]
}
while (n = gets.chomp) != '#'
  f, *s = n.split('')
  h = y['r'].include?(f) ? 'r' : 'l'
  c = 0
  s.each do |k|
    unless y[h].include?(k)
      h = h == 'r' ? 'l' : 'r'
      c += 1
    end
  end
  p c
end

Measured memory_bytes: 8856
"use strict";
function Main(input) {
    let S = input.split("\n")[0];
    let s = S.split('').map((v) => +v);
    let ans = 0, f = true;
    while (f) {
        f = false;
        for (let n = 0; n < s.length - 1; n++) {
            if (s[n] + s[n+1] == 1) {
                ans += 2;
                s.splice(n, 2);
                n -= 2;
            }
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15052
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 1e6+7;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

bool flag;
string s, t, res;
vector<string> ans;
int main()
{
    cin >> s >> t;
    res = s;
    flag = false;
    for(int i = 0; i < s.size(); ++i)   //  st
    {
        flag = true;
        for(int j = 0, k = i; j < t.size(); ++j, ++k)
        {
            if(s[k] != t[j] && s[k] != '?')
            {
                flag = false;
                break;
            }
            if(s[k] == '?') res[k] = t[j];
        }
        if(flag)
        {
            for(int i = 0; i < res.size(); ++i)
                if(res[i] == '?')   res[i] = 'a';
            ans.push_back(res);
        }
        res = s;
    }
    if(ans.size())
    {
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    }
    else    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
 
int32_t main()
{
 // c_p_c();
  int n,k,pos = -1;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
  }
  if(k >= n)
  {
    cout<<1<<endl;
  }
  else
  {
    n--,k--;
    cout<<ceil(n/(k*1.0))<<endl;
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;

void chmax(ll &x, ll y) { x = max(x, y); }

int main() {
    int r, c, n;
    cin >> r >> c >> n;

    vector<vector<int>> value(r, vector<int>(c));
    for (int i = 0; i < n; i++) {
        int x, y, v;
        cin >> x >> y >> v, x--, y--;
        value[x][y] = v;
    }

    vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4)));
    dp[0][0][1] = value[0][0];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            for (int k = 0; k <= 3; k++) {
                if (i > 0) {
                    chmax(dp[i][j][0], dp[i - 1][j][k]);
                    chmax(dp[i][j][1], dp[i - 1][j][k] + value[i][j]);
                }
                if (j > 0) {
                    chmax(dp[i][j][k], dp[i][j - 1][k]);
                    if (k > 0) {
                        chmax(dp[i][j][k], dp[i][j - 1][k - 1] + value[i][j]);
                    }
                }
            }
        }
    }

    cout << max({dp[r - 1][c - 1][0], dp[r - 1][c - 1][1], dp[r - 1][c - 1][2], dp[r - 1][c - 1][3]}) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    int n;

    cin >> n;

    int ans = 0;
    int c;

    int i, j;

    for (i = 1; i <= n; i += 2) {
        c = 0;

        repiin(j, i, 1) if (i % j == 0) c++;

        if (c == 8) ans++;
    }

    Out(ans);

    return 0;
}


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


 int main() {

  int H, s;
  cin >> H>>s;

  for(int i=0; i<s; i++)
  { int A;
    cin>>A;
     H-=A;


}
if(H<=0){cout<<"Yes";} else cout<<"No";
 }


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long x = getLong(sc);
		long y = getLong(sc);

		List<Long> array = new ArrayList<>();
		array.add(x);

		while (true) {
			long next = array.get(array.size() - 1) * 2;
			if (next <= y) {
				array.add(next);
			} else {
				break;
			}
		}
		System.out.println(array.size());

	}

	private static boolean checkSumRange(int i, int a, int b) {
		String[] digits = String.valueOf(i).split("");
		int sum = 0;
		for (String digit : digits) {
			sum += Integer.parseInt(digit);
		}

		if (sum < a || sum > b) {
			return false;
		} else {
			return true;
		}

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int main(void)
{
    int L,A,B,C,D;
    cin>>L>>A>>B>>C>>D;
    if(A/C>=B/D&&A%C!=0)cout<<L-(A/C+1)<<"\n";
    else if(A/C<B/D&&B%D!=0)cout<<L-(B/D+1)<<"\n";
    else if(A/C>=B/D)cout<<L-A/C<<"\n";
    else cout<<L-B/D<<"\n";
}

Measured memory_bytes: 1164
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::{i32, i64, i128, u32, u64, u128, f64};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};
use core::f64::consts::PI;

#[proconio::fastout]
fn main() {
    proconio::input!{
        a: i32,
        b: i32,
        h: i32,
        m: i32,
    }
    let (a, b, h, m) = (a as f64, b as f64, h as f64, m as f64);
    let h = h + m / 60.0;
    let (xh, yh) = (a * (2.0 * PI * h / 12.0).cos(), a * (2.0 * PI * h / 12.0).sin());
    let (xm, ym) = (b * (2.0 * PI * m / 60.0).cos(), b * (2.0 * PI * m / 60.0).sin());
    println!("{}", (xh - xm).hypot(yh - ym));
}


Measured memory_bytes: 2928
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll A,B;
	double H,M,HH,MM,deg,ANS;
	cin>>A>>B>>H>>M;
	if(H>=12)H=H-12;
	HH=H*30+(M*0.5);
	MM=M*6;
	deg=deg2rad(min(max(HH,MM)-min(HH,MM),360-(max(HH,MM)-min(HH,MM))));
	cout << fixed << setprecision(20);
	//cout<<deg<<endl;
	ANS=(A*A+B*B)-(2*A*B*cos(deg));
	cout << fixed << setprecision(20);
	cout<<sqrt(ANS)<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 1e8;
    rep(i, n) {
        if (i == n - 1) {
            ans = min(ans, k-(a[0]+k - a[i]));
        }
        else {
            ans = min(ans, k-(a[i+1] - a[i]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=4091001001001001001;
  //           3999999996000000001


int main() {
  ll n,k;
  cin>>n>>k;
  vector<P>v(n);//圧縮前座標
  vector<P>V(n);//圧縮前座標
  vector<ll>Vrev(n);//圧縮前座標


  vector<P>x(n);//x座標、id
  vector<P>y(n);//y座標、id


  rep(i,n){
    ll x1,y1;
    cin>>x1;
    cin>>y1;
    x[i]=make_pair(x1,i);
    y[i]=make_pair(y1,i);
    v[i]=make_pair(x1,y1);

  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  rep(i,n){
    ll idx=x[i].second;
    ll idy=y[i].second;
    V[idx].first=i;
    V[idy].second=i;//V[i番目頂点]=(圧縮ごx座標、圧縮ごy座標)
  }
  vector<vector<ll>> Vnew(n+1, vector<ll>(n+1,0));//1index
rep(i,n){
  ll xnow=V[i].first;
  ll ynow=V[i].second;
  Vnew[xnow][ynow]++;
}


  vector<vector<ll>> g(n+1, vector<ll>(n+1,0));//1index
  vector<vector<ll>> G(n+1, vector<ll>(n+1,0));//1index

  rep(i,n)rep(j,n){
    g[i+1][j+1]=g[i][j+1]+Vnew[i][j];
  }
  rep(j,n)rep(i,n){
    G[i+1][j+1]=G[i+1][j]+g[i+1][j+1];
  }
  /*
  rep(i,n+1)rep(j,n+1){
      cout<<G[i][j]<<'i'<<i<<'j'<<j<<endl;
}
*/
ll ans=INF;
rep(xl,n)rep(yl,n){
  for(ll xr=xl;xr<n;xr++){
    for(ll yr=yl;yr<n;yr++){
      ll area=G[xr+1][yr+1]-G[xl][yr+1]-G[xr+1][yl]+G[xl][yl];
    //  cout<<area<<"area "<<xr<<"xr "<<xl<<"xl "<<yr<<"yr "<<yl<<"yl"<<endl;
      if(area>=k){
        ll areas=(x[xr].first-x[xl].first)*(y[yr].first-y[yl].first);
      //  cout<<x[xr].first<<"xr "<<x[xl].first<<"xl "<<y[yr].first<<"yr "<<y[yl].first<<"yl"<<endl;

        ans=min(ans,areas);
      }
    }
  }
}
cout<<ans;



}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    
    ll N; cin >> N;
    vector <ll> a(N); rep(i,N) cin >> a[i];
    Sort(a);
    ll ans = 0;
    rep(i,N) {
        ll d = a[i] - 1;
        ll u = a[i] + 1;
        ll sum = upper_bound(a.begin(), a.end(), u) - lower_bound(a.begin(), a.end(), d);
        ans = max(ans, sum);
    }
    out(ans);

    
    
    return 0;
}











Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  VVI ans(H, VI(W));
  REP(i, H)
  {
    REP(j, W)
    {
      if (i < B && j < A) cout << 1;
      else if (i >= B && j < A) cout << 0;
      else if (i < B && j >= A) cout << 0;
      else if (i >= B && j >= A) cout << 1;
    }
    ENDL
  }
  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#include <vector>
#include <limits>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

const int N_MAX = 20;

int n;
int p[N_MAX] = {};
void solve() {
    cin >> n;
    REP(i,n) { cin >> p[i];}
    int cnt = 0;
    REP (i, n-2) {
        bool cnd1 = p[i] < p[i+1] && p[i+1] < p[i+2];
        bool cnd2 = p[i] > p[i+1] && p[i+1] > p[i+2];
        if (cnd1 || cnd2) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 256
def solve():
    diff = Y - N
    if diff < 0:
        return -1, -1, -1
    for y in range(diff // 4 + 1):
        tmp = diff - 4 * y
        if tmp < 0:
            break
        if tmp % 9 == 0:
            x = tmp // 9
            if x >= 0 and N - x - y >= 0:
                return x, y, N - x - y
    return -1, -1, -1


N, Y = map(int, input().split())
Y //= 1000
ans = solve()
print(*ans)

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

int f(int x){
    int cnt = 0;
    for(int i = 1; i <= x; i++){
        if(x % i == 0) cnt++;
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    int ans = 0;

    for(int i = 105; i <= n; i+=2){
        if(f(i) == 8){
            ans++;
        }
    }
    put(ans);
}

Measured memory_bytes: 256
use proconio::input;

const MOD: usize = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    m: usize,
    breaks: [usize;m]
  }

  let breaks = breaks
                .into_iter()
                .collect::<std::collections::HashSet<usize>>();
  let mut dp: Vec<usize> = vec![0;n+1];
  dp[0] = 1;
  if !breaks.contains(&1) {
    dp[1] = 1;
  }

  for i in 2..=n {
    if !breaks.contains(&i) {
      dp[i] = (dp[i-1] + dp[i-2]) % MOD;
    }
  }
  println!("{}", dp[n]);
}

Measured memory_bytes: 4520
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n, k;
	vector<int> as;

	scanf("%d%d", &n, &k);
	as.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &as[i]);

	vector<i64> subseqs(n * n);

	for(int i = 0; i < n; ++i) {
		i64 s = 0;
		for(int j = i; j < n; ++j) {
			s += as[j];
			subseqs.push_back(s);
		}
	}

	i64 ans = 0;

	for(int bit = 50; bit >= 0; --bit) {

		i64 val = ans | (1LL << bit);
		int count = 0;

		for(auto s : subseqs) {
			if((s & val) == val) {
				count += 1;
			}
		}

		if(count >= k) {
			ans = val;
		}
	}

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 17408
/*
 * 長さ N の配列 A が与えられます。 A を何箇所かで切って、A の連続した部分であるようないくつかの数列に分けます。
 * この時、分けられたあとの数列は全て、単調非減少または単調非増加な列になっている必要があります。 最小で何個の数列に分ければ良いかを求めて下さい。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int temp1, temp2, index = 0, count = 0;
            
            temp2 = Integer.parseInt(sc.next());
            
            while(index<n-1){
            	temp1 = temp2;
            	temp2 = Integer.parseInt(sc.next());
            	index++;
            	
            	while(index<n-1 && temp2 == temp1){
            		temp2 = Integer.parseInt(sc.next());
            		index++;
            	}
            	
            	if(temp1 < temp2){
            		while(index<n-1 && temp1 <= temp2){
            			temp1 = temp2;
            			temp2 = Integer.parseInt(sc.next());
            			index++;
            		}
            		if(index==n-1 && temp1 > temp2){
            			count++;
            		}
            	}else{
            		while(index<n-1 && temp1 >= temp2){
            			temp1 = temp2;
            			temp2 = Integer.parseInt(sc.next());
            			index++;
            		}
            		if(index==n-1 && temp1 < temp2){
            			count++;
            		}
            	}
            	count++;
            }
            
            //出力
            System.out.println(Math.max(count, 1));
            sc.close();
        }
    }
	

Measured memory_bytes: 46588
#include <iostream>
using namespace std;
int main(void){
  int* x = new int[5];
  int* y = new int[5];
  cin >> x[1] >> y[1] >> x[2] >> y[2];
  int vdx, vdy;
  vdx = x[2] - x[1];
  vdy = y[2] - y[1];
  x[3] = x[2] - vdy;
  y[3] = y[2] + vdx;
  x[4] = x[3] - vdx;
  y[4] = y[3] - vdy;
  cout << x[3] << ' ' << y[3] << ' ' << x[4] << ' ' << y[4] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
	int n; std::cin >> n;
	std::vector<int> a(n);
	for (int i = 0; i < n; i++) std::cin >> a[i];
	std::sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += std::lower_bound(a.begin() + j + 1, a.end(), a[i] + a[j])
				- (a.begin() + j + 1);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N, T, A;
  	cin >> N >> T >> A;
  	int s[N];
  	int l =100000000, re;
  	for(int i = 0; i < N; i++){
    	cin >> s[i];
      	s[i] =fabs((T * 1000 - s[i] * 6) - A * 1000);
      	if(l > s[i]){
        l = s[i];
        re = i + 1;
        }
    }
  	cout << re << endl;
  	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int q = sc.NextInt();
        string s = sc.Next();

        int[] sum = new int[s.Length];
        for (int i = 0; i < s.Length; i++)
        {
            if (i == 0)
            {
                sum[i] = 0;
                continue;
            }
            if (s[i - 1] == 'A' && s[i] == 'C')
            {
                sum[i] = sum[i - 1] + 1;
            }
            else
            {
                sum[i] = sum[i - 1];
            }
        }

        for (int i = 0; i < q; i++)
        {
            int l = sc.NextInt() - 1;
            int r = sc.NextInt() - 1;

            int answer = sum[r] - sum[l];

            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };



int main() {
	fastIO;
	string s, t, u;
	cin >> s >> t;
	map<string, int> m;
	cin >> m[s];
	cin >> m[t];
	cin >> u;
	m[u]--;
	cout << m[s] << " " << m[t];



}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
//saw editional

class states{
    public:
    unsigned int state;
    unsigned int len;
    unsigned int numBar;
    states(unsigned int state,unsigned int len,unsigned int numBar){
        this->state=state;
        this->len=len;
        this->numBar=numBar;
    }
};

int main(){
    int N,M,Q;
    std::cin>>N>>M>>Q;
    std::vector<std::vector<int> >q(Q,std::vector<int>(4));
    for(int i=0;i<Q;++i){
        for(int j=0;j<4;++j){
            std::cin>>q[i][j];
        }
        q[i][0]-=1;
        q[i][1]-=1;
    }
    std::stack<states> st;
    std::vector<unsigned int> searchStates;
    st.push(states(0,0,0));
    while (st.size()>0){
        states calcState=st.top();
        st.pop();
        unsigned int state=calcState.state;
        unsigned int len=calcState.len;
        unsigned int numBar=calcState.numBar;
        if(numBar<N){
            states buf=states(state | 0x00001 << len,len+1,numBar+1);
            if(buf.len==N+M-1){
                searchStates.push_back(buf.state);
            }else{
                st.push(buf);
            }
        }
        if(len-numBar<M-1){
            states buf=states(state,len+1,numBar);
            if(buf.len==N+M-1){
                searchStates.push_back(buf.state);
            }else{
                st.push(buf);
            }
        }
    }
    int maxScore=-1;
    for(auto searchState:searchStates){
        std::vector<int> buf;
        int scorebuf;
        int cnt=0;
        for(int i=0;i<N+M-1;++i){
            if(searchState & 0x0001<<i){
                buf.push_back(cnt+1);
            }else{
                cnt++;
            }
        }
        scorebuf=0;
        for(int i=0;i<Q;++i){
            if(buf[q[i][1]]-buf[q[i][0]]==q[i][2]){
                scorebuf+=q[i][3];
            }
        }
        if(maxScore<scorebuf){
            maxScore=scorebuf;
        }
    }
    std::cout<<maxScore<<std::endl;
}


Measured memory_bytes: 3804
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
a = [[i+1, II()] for i in range(n)]
a = sorted(a, key=lambda x: x[1])
maxi = a[-1][1]
for i in range(1, n+1):
    print(maxi if i != a[-1][0] else a[-2][1])


Measured memory_bytes: 111948
#include<cstdio>
#include<queue>
#define NIL (-1)

using namespace std;

struct node{
    int parent;
    int left;
    int right;
    int key;
};

node tree[500001];
int treesize;
int root = NIL;

void pre(int id){
    if(id == -1)
        return;
    printf(" %d",tree[id].key);
    if(tree[id].left >= 0)
        pre(tree[id].left);
    if(tree[id].right >= 0)
        pre(tree[id].right);
}

void in(int id){
    if(id == -1)
        return;
    if(tree[id].left >= 0)
        in(tree[id].left);
    printf(" %d",tree[id].key);
    if(tree[id].right >= 0)
        in(tree[id].right);
    
}


void insert(int key){
    int y = NIL;
    int x = root;
    while(x != NIL){
        y = x;
        if(key < tree[x].key)
            x = tree[x].left;
        else
            x = tree[x].right;
    }
    tree[treesize].parent = y;

    if(y == NIL)
        root = treesize;
    else if(key < tree[y].key)
        tree[y].left = treesize;
    else
        tree[y].right = treesize;
    tree[treesize].left = NIL;tree[treesize].right = NIL;tree[treesize].key = key;

    treesize++;
        
}


int main(void){
    int n;
    scanf("%d",&n);

    for(int i = 0;i < n;i++){
        char s[20];
        scanf("%s",s);

        if(s[0] == 'i'){
            int key;
            scanf("%d",&key);
            insert(key);
        }else{
            in(root);
            printf("\n");
            pre(root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 10384
#include <stdio.h>

int main(){
    int N;

    scanf("%d", &N);

    int X = (int) (N / 1.08);

    if((int) (X * 1.08) == N){
        printf("%d\n", X);
    }else if((int) ((X + 1) * 1.08) == N){
        printf("%d\n", X + 1);
    }else{
        printf(":(\n");
    }
}

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

class UnionFind {
  vector<int> parent;
public:
  UnionFind(int n) : parent(n, -1) {}
  int root(int n) {
    return parent.at(n) < 0 ? n : parent.at(n) = root(parent.at(n));
  }
  bool same(int a, int b) {
    return root(a) == root(b);
  }
  int size(int n) {
    return -1 * parent.at(root(n));
  }
  void unite(int a, int b) {
    if (!same(a, b)) {
      if (size(a) < size(b)) swap(a, b);
      int ra = root(a);
      int rb = root(b);
      parent.at(ra) += parent.at(rb);
      parent.at(rb) = ra;
    }
  }
};

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

  vector<pair<int, int>> road(k);
  vector<pair<int, int>> railway(l);

  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    road.at(i).first = --x;
    road.at(i).second = --y;
  }
  for (int i = 0; i < l; i++) {
    int x, y;
    cin >> x >> y;
    railway.at(i).first = --x;
    railway.at(i).second = --y;
  }

  UnionFind a(n);
  UnionFind b(n);

  for (const auto& e : road) {
    a.unite(e.first, e.second);
  }
  for (const auto& e : railway) {
    b.unite(e.first, e.second);
  }

  map<pair<int, int>, int> ans;

  for (int i = 0; i < n; i++) {
    ans[make_pair(a.root(i), b.root(i))]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(make_pair(a.root(i), b.root(i))) << endl;
  }
}


Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>

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

using namespace std;

typedef unsigned long long ll;

const int N = 1000;
const ll MOD = 1000000007;


int V, cmp[N];
vector<int> G[N], rG[N], vs;
bool used[N];
void init(){
  rep(i, N){
    G[i].clear();
    rG[i].clear();
  }
  vs.clear();
}

void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v] = true;
  rep(i, G[v].size()){
    if(!used[G[v][i]])dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  rep(i, rG[v].size()){
    if(!used[rG[v][i]])rdfs(rG[v][i], k);
  }
}

int scc(){
  rep(i, N)used[i] = false;
  vs.clear();
  rep(v, V){
    if(!used[v])dfs(v);
  }
  rep(i, N)used[i] = false;
  int k = 0;
  for(int i = vs.size() -1; i>=0; i--){
    if(!used[vs[i]])rdfs(vs[i], k++);
  }
  return k;
}


pair<ll, ll> dp[N];
vector<int> edge[N];


pair<ll, ll> solve(int id){
  if(dp[id].first > 0 )return dp[id];
  pair<ll, ll> ret = make_pair(1, 1);
  rep(i, edge[id].size()){
    ll next = edge[id][i];
    pair<ll, ll> result = solve(next);
    ret.first *= (result.first + result.second)%MOD;
    ret.second *= result.second;
    ret.first %= MOD;
    ret.second %= MOD;
  }
  return ret;
}

int main(){
  int n, m;
  bool first = true;
  while(cin >> n >> m){
    assert(first);
    first = false;
    if(n == 0 && m == 0)break;
    V = n;
    init();
    vector<pair<int, int> > INPUT;
    rep(i, m){
      int from, to;
      cin >> from >> to;
      INPUT.push_back(make_pair(to-1,from-1));
      add_edge(to-1, from-1);
    }
    int cnt = scc();
    bool root[N];
    rep(i, N)root[i] = true;
    rep(i, N)edge[i].clear();
    rep(i, INPUT.size()){
      if(cmp[INPUT[i].first] == cmp[INPUT[i].second])continue;
      edge[cmp[INPUT[i].first]]	.push_back(cmp[INPUT[i].second]);
      root[cmp[INPUT[i].second]] = false;
    }
    
    rep(i, N)dp[i] = make_pair(0, 0);
    
    ll ans = 1;
    rep(i, cnt){
      if(root[i] == true){
	pair<ll, ll> ret = solve(i);
	ans *= (ret.first + ret.second)%MOD;
	ans %= MOD;
      }
    }
    cout << ans << endl;
  }
}
/*0 1 1
1 1 1
4 1 1
3 4 1
2 10 1
176*/

Measured memory_bytes: 0