akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int e_mx,e_mx_index,e_mx2,o_mx,o_mx_index,o_mx2;
vector<int> ecnt(100010),ocnt(100010);
int main() {
    int n,y;
    cin >> n >> y;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int c;
            if(i+j > n) continue;
            if(n-i-j >= 0) c = n-i-j;
            if(i+j+c > n) continue;
            int tmp = 1000*i+5000*j+10000*c;
            if(tmp == y){
                cout << c << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


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

int main()
{
  int N,M ;
  cin>>N>>M ;
  vector<int>Food(M,0) ;
  int K,food ;
  for(int i=0;i<N;i++){
    cin>>K ;
    for(int j=0;j<K;j++){
      cin>>food ;
      Food.at(food-1)++ ;
    }
  }
  
  int ans=0 ;
  for(int i=0;i<M;i++) if(Food.at(i)==N) ans++ ;
  
  cout<<ans<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new DirectedGraph(N);
    auto D = new int[](N);
    foreach (_; 0..N-1+M) {
        s = readln.split.map!(to!int);
        G.add_edge(s[0]-1, s[1]-1);
        D[s[1]-1] += 1;
    }


    int root = 0;
    foreach (i; 0..N) if (D[i] == 0) root = i;

    DList!(int) stack;
    auto P = new int[](N);

    stack.insertBack(root);
    P[root] = -1;

    while (!stack.empty) {
        int n = stack.front;
        stack.removeFront;
        foreach (m; G.adj[n]) {
            if (D[m] == 1) {
                P[m] = n;
                stack.insertBack(m);
            } else {
                D[m] -= 1;
            }
        }
    }

    P.each!(i => writeln(i+1));
}




class DirectedGraph {
    int n;
    int[][] adj;
    int[][] inv;

    this(int n) {
        this.n = n;
        adj = new int[][](n);
        inv = new int[][](n);
    }

    void add_edge(int u, int v) {
        adj[u] ~= v;
        inv[v] ~= u;
    }
}


class StronglyConnectedComponent : DirectedGraph {
    int[] index;
    int[][] scc;

    this(DirectedGraph g) {
        int cnt = 0;
        auto ord = new int[](g.n);
        auto used = new bool[](g.n);
        index = new int[](g.n);

        void dfs1(int n) {
            if (used[n]) return;
            used[n] = true;
            foreach (m; g.adj[n]) if (!used[m]) dfs1(m);
            ord[cnt++] = n;
        }

        void dfs2(int n) {
            if (used[n]) return;
            used[n] = true;
            index[n] = cnt;
            scc.back ~= n;
            foreach (m; g.inv[n]) if (!used[m]) dfs2(m);
        }

        foreach (i; 0..g.n) if (!used[i]) dfs1(i);

        cnt = 0;
        fill(used, false);

        foreach_reverse (i; 0..g.n) {
            if (used[ord[i]]) continue;
            scc.length += 1;
            dfs2(ord[i]);
            cnt += 1;
        }

        super(cnt);
        auto edge = new bool[int][](cnt);

        foreach (i; 0..g.n)
            foreach (j; g.adj[i])
                if (index[i] != index[j])
                    edge[index[i]][index[j]] = true;

        foreach (i; 0..cnt)
            foreach (j; edge[i].keys)
                add_edge(i, j);
    }
}


Measured memory_bytes: 15612
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

long long int sum = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] < R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
			sum += n1 - i;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	int A[n];
	for(int i = 0; i < n; i++) scanf("%d",&A[i]);

	mergeSort(A,0,n);

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

}



Measured memory_bytes: 4276
#include<iostream>
using namespace std;
int main() {
	double w;
	while (cin >> w) {
		if (w <= 48)cout << "light fly" << endl;
		else if (w <= 51)cout << "fly" << endl;
		else if (w <= 54)cout << "bantam" << endl;
		else if (w <= 57)cout << "feather" << endl;
		else if (w <= 60)cout << "light" << endl;
		else if (w <= 64)cout << "light welter" << endl;
		else if (w <= 69)cout << "welter" << endl;
		else if (w <= 75)cout << "light middle" << endl;
		else if (w <= 81)cout << "middle" << endl;
		else if (w <= 91)cout << "light heavy" << endl;
		else if (w >91)cout << "heavy" << endl;
	}
	return 0;
}

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

const int DIM = 5e3 + 5;
const int MOD = 1e9 + 7;

string str;
int dp[2][DIM];

int main( void ) {
    
    int n, k;
    cin >> n >> str;
    k = (int) str.length();
    
    dp[0][0] = 1;
    for( int i = 1; i <= n; i ++ )
        for( int j = 0; j <= n; j ++ )
            dp[i & 1][j] = ( dp[(i - 1) & 1][j + 1] * 2LL +
                             dp[(i - 1) & 1][max( 0, j - 1 )] ) % MOD;
    
    cout << dp[n & 1][k] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
in_counts = [0] * n
for line in sys.stdin.readlines():
    a, b = list(map(int, line.split()))
    a -= 1
    b -= 1
    links[a].add(b)
    in_counts[b] += 1

root = 0
for v, ic in enumerate(in_counts):
    if ic == 0:
        root = v
        break

parents = [-1] * n
q = deque([(c, root) for c in links[root]])

while q:
    v, p = q.popleft()
    in_counts[v] -= 1
    if in_counts[v] == 0:
        parents[v] = p
        q.extend((c, v) for c in links[v])

print('\n'.join(str(p + 1) for p in parents))


Measured memory_bytes: 43336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1,0)
int main()
{
   int m,n;
   cin>>m>>n;
   string s;
   for(int i=1;i<=m;i++)
   {
       cin>>s;
       cout<<s<<endl;
       cout<<s<<endl;
   }
   return 0;
   // 2 2 4 1 3
   //
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;


int main() {
	string s;
	cin >> s;

	if (s == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}
}

Measured memory_bytes: 3568
# codefestival_2016_qualA_b_bacha.py
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i,v in enumerate(A):
    # print(i ,v, A[v-1])
    if i+1 == A[v-1]:
        ans += 1
print(ans//2)

Measured memory_bytes: 14004
from math import sqrt
pf={}
m=int(input())
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
#print(pf)

cnt = 0
calc = lambda n: (sqrt(8 * n + 1) - 1) // 2
for i in pf:
    cnt += calc(pf[i])
print(int(cnt))



Measured memory_bytes: 9448
import java.util.Scanner;

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

        final int A = sc.nextInt();
        final int B = sc.nextInt();

        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= 1000; i++) {
            if (Math.floor(i * 0.08) == A && Math.floor(i * 0.1) == B) {
                min = Math.min(min, i);
            }
        }

        System.out.println(min == Integer.MAX_VALUE ? -1 : min);
    }
}


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


int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i){
    for (int j = 1; j <= 9; ++j){
      if (i*j == n) {cout << "Yes" << endl;
      return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define INFINITY 2147483647

void update(int,int);
int findMin(int,int);
int query(int,int,int,int,int);
int min(int,int);
void initRMQ(int);

int n; // the size of target array
int D[20000000];

int main()
{
    int rn,l,i;
    int a;
    int m;

    scanf("%d %d", &rn, &l);
    
    initRMQ(rn);
    
    for(i=0;i<rn;i++){
        scanf("%d", &a);
        update(i,a);
    }

    for(i=0;i<=rn-l;i++){
        m=findMin(i,i+l-1);
        if(i!=0) printf(" ");
        printf("%d",m);
    }

    printf("\n");

    return 0;
}

// input the required array size
void initRMQ(int rn){
    int i;

    n=1;

    // the size of array is power of 2
    while(n<=rn){
        n *= 2;
    }

    // initialize all node in segment tree
    for(i=0;i<(2*n-1-1);i++){
        D[i] = INFINITY;
    }
}

void update(int k, int a){
    k+=n-1;
    D[k]=a;
    while(k>0){
        k=(k-1)/2;
        D[k] = min(D[k*2+1],D[k*2+2]);
    }
}

// [a,b]
int findMin(int a,int b){
    return query(a,b+1,0,0,n);
}

// [a,b)
int query(int a,int b,int k,int l,int r){
    int vl,vr;
    //case1
    if(r<=a || b<=l) return INFINITY;

    //case2
    if(a<=l&&r<=b) return D[k];

    //case3
    vl = query(a,b,k*2+1,l,(l+r)/2);
    vr = query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
}

int min(int x,int y){
    if(x<=y) return x;
    else return y;
}


Measured memory_bytes: 9964
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        for (int i = 1; i <= 5; i++) {
            var x = scan.NextInt();
            if (x == 0) return i;
        }
        return -1;
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
}

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

using namespace std;

int main()
{
	int N;
	vector<int> A,B;
	cin >> N;
	A.resize(N);
	B.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	B = A;
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++)
	{
		if (A[N-1]==B[i]) 
		{
			cout << A[N - 2] << endl;
		}
		else
		{
			cout << A[N - 1] << endl;
		}
	}

	return 0;
}


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

using namespace std;

int main(){
        int n,m;
        cin >> n >> m;
        vector<int> h(n);
        vector<int> a(m),b(m);
        for(int i=0; i<n; i++) cin >> h.at(i);
        vector<int> ans(n);
        ans=h;
        for(int i=0; i<m; i++) {
                cin >> a.at(i);
                cin >> b.at(i);
        }
        for(int i=0; i<m; i++) {
                //cout << "a: " << h.at(a.at(i)-1) << " b:" << h.at(b.at(i)-1) << endl;
                if(h.at(a.at(i)-1)==h.at(b.at(i)-1)) {
                        ans.at(a.at(i)-1) = 0;
                        ans.at(b.at(i)-1) = 0;
                }
                else if(h.at(a.at(i)-1)<h.at(b.at(i)-1)) ans.at(a.at(i)-1) = 0;
                else if(h.at(a.at(i)-1)>h.at(b.at(i)-1)) ans.at(b.at(i)-1) = 0;
        }
        //for(int i=0; i<ans.size(); i++) cout << ans.at(i) << endl;
        cout << ans.size()-count(ans.begin(),ans.end(),0);
        return 0;
}


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

int main()
{
    int n, i, j, flag, count = 0;
    cin>>n;

    int arr[n];

    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    flag = arr[0];

    for(i=0; i<n; i++)
    {
        if(flag <= arr[i])
            count++;
        if(flag < arr[i])
            flag = arr[i];

    }

    cout<<count;

}


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

ll INF = 1LL << 60;

int 
main() {

  int N, Q; cin >> N >> Q;
  vector<vector<ll>> tree(N + 1);
  rep(i, 0, N - 1){
    ll a, b; cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  vector<ll> imos(N + 1, 0);
  rep(i, 0, Q){
    int p, q; cin >> p >> q;
    imos[p] += q;
  }

  queue<ll> q;
  vector<bool> seen(N + 1, false);
  seen[1] = true;
  q.push(1);
  while(! q.empty()){
    ll nodes = q.front();
    q.pop();
    for(auto node: tree[nodes]){
      if(seen[node])continue;
      imos[node] += imos[nodes];
      seen[node] = true;
      q.push(node);
    }
  }

  rep(i, 1, N + 1){
    cout << imos[i] << endl;
  }
}


Measured memory_bytes: 18904
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    H = list( map( int, input().split()))
    ans = 0
    now = 0
    height = 10**9+1
    for h in H:
        if height >= h:
            now += 1
            height = h
        else:
            if now > ans:
                ans = now
            now = 1
            height = h
    if now > ans:
        ans = now
    print(ans-1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

ll f[2000010];

ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
ll binpow(ll a, ll b) {
     ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
 
ll find_ncr(ll n, ll r)
{
    ll m1=max(r,n-r);
    ll i,j,s,d=1,k;
    s=1;
 
    for(i=m1+1;i<=n;i++)
    {
        s=((s%m)*(i%m))%m;
    }
 
    m1=min(r,n-r);
 
    for(i=1;i<=m1;i++)
    {
        k=binpow(i,m-2);
        d=((d%m)*(k%m))%m;
    }
 
    k=(s%m*(d%m))%m;
 
    return k;
}

int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  int c = 0,t= 1;
  vector<int>v(2019,0);
  for (int i = s.length()-1; i >= 0; i--)
  {
    int a = (c+(s[i]-'0')*t)%2019;
    v[a]++;
    t = (t*10)%2019;
    c = a;
  }
  int ans = 0;
  v[0]++;
  for (int i = 0; i < 2019; ++i)
  {
    if(v[i])
    {
      ans += (v[i]*(v[i]-1))/2;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	bool a, b, c, d;
	a = b = c = d = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		switch (str[i])
		{
		case 'N':
			a = true;
			break;
		case 'S':
			b = true;
			break;
		case 'W':
			c = true;
			break;
		case 'E':
			d = true;
			break;
		}
	}
	if (a ^ b) {
		cout << "No" << endl;
	}
	else if (c ^ d) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    char str[10] = {0},ringstr[30] = {0};
    int n,ans = 0,longth;
    scanf("%s",str);
    longth = strlen(str);
    scanf("%d",&n);
    for(int j = 0; j < n; j++)
    {
        scanf("%s",ringstr);
        for(int i = 0; i < 10; i++)
        {
            ringstr[i + 10] = ringstr[i];
        }
        for(int i = 0; i < 20; i++)
        {
            int cou = 0;
            if(str[0] == ringstr[i])
            {
                for(int k = 0; k < longth; k++)
                {
                    if(str[k] != ringstr[k + i])break;
                    cou++;
                }
            }
            if(cou == longth)
            {
                ans++;
                break;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWalkingTakahashi solver = new CWalkingTakahashi();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWalkingTakahashi {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();
            long k = in.nextLong();
            long d = in.nextLong();

            out.println(f(Math.abs(x), k, d));
        }

        private long f(long x, long k, long d) {
            long p = x / d; // moves while remaining non-negative

            if (p >= k) {
                return x - k * d;
            }

            x -= p * d;
            k -= p;

            if (k % 2 == 0)
                return x;
            return Math.abs(x - d);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 25600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    stack<char> st;
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='B'){
            if(st.size())st.pop();
        }
        else st.push(s[i]);
    }
    string ans="";
    while(st.size()){
        ans=st.top()+ans;
        st.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int fib(int n){
  int i;
  int A[45];
  A[0]=1;
  A[1]=1;
  for(i=2;i<=n;i++){
    A[i]=A[i-1]+A[i-2];
  }

  return A[n];
}


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

  printf("%d\n",fib(n));
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,w;
    cin>>n>>w;
    ll dp[n][w+1];
    ll wt[n],val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<=w;j++)
            dp[i][j]=0;
    for(int j=1;j<=w;j++)
        if(wt[0]<=j)
            dp[0][j]=val[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=w;j++){
            if(wt[i]>j)
                dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(val[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
            }
        }
    }
    cout<<dp[n-1][w];
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<vector<int>> score(n + 1, vector<int>(3));
    for(int i = 1; i <= n; i++) cin >> score[i][0] >> score[i][1] >> score[i][2];
    vector<vector<int>> dp(n + 1, vector<int>(3));
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++){
            int mx = 0;
            for(int k = 0; k < 3; k++){
                if(k != j){
                    mx = max(mx, dp[i - 1][k] + score[i][j]);
                }
            }
            dp[i][j] = mx;
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int k;
int x;
int y;
int c;
vector<int> g[N];
vector<int> num(N, 0);
vector<int> comp(N, -1);
void dfs(int v, int c){
    if(comp[v] != -1){
        return;
    }
    comp[v] = c;
    for(auto to: g[v]){
        dfs(to, c);
    }
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> m >> k;
    for(int i = 1; i <= m; i ++){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i ++){
        if(comp[i] == -1){
            dfs(i, ++ c);
        }
    }
    for(int i = 1; i <= n; i ++){
        num[comp[i]] ++;
    }
    vector<int> res(n + 1, 0);
    for(int i = 1; i <= n; i ++){
        res[i] = num[comp[i]] - 1 - (int)g[i].size();
    }
    for(int i = 1; i <= k; i ++){
        cin >> x >> y;
        if(comp[x] == comp[y]){
            res[x] --, res[y] --;
        }
    }
    for(int i = 1; i <= n; i ++){
        cout << res[i] << " ";
    }
    cout << "\n";
}


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

int main() {
  int N, D;
  cin >> N >> D;
  
  if(N%(2*D + 1) == 0){
    cout << N/(2*D + 1) << endl;
  }else{
    cout << N/(2*D + 1) +1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

string dp[10010];
int cost[]={0,2,5,5,4,5,6,3,7,6};

int main() {
    int n,m;
    cin>>n>>m;
    dp[0]="";
    int a[10];
    for(int i=0;i<m;++i)cin>>a[i];
    for(int i=1;i<=n;++i){
        string cur="-1";
        for(int j=0;j<m;++j){
            int prev=i-cost[a[j]];
            if(prev>=0&&dp[prev]!="-1"){
                string cdd=dp[prev];
                cdd.insert(0,1,(char)('0'+a[j]));
                if(cur=="-1"||cdd.size()>cur.size()||cdd.size()==cur.size()&&cdd>cur)cur=cdd;
            }
        }
        dp[i]=cur;
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 43136
//abc166_f.cpp
//Sun May 10 11:49:42 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll abc[3];
	abc[0] = a;
	abc[1] = b;
	abc[2] = c;

	char ABC[3];
	ABC[0] = 'A';
	ABC[1] = 'B';
	ABC[2] = 'C';


	P letter[n];
	string tmp[n];
	for (int i=0;i<n;i++){
		cin >> tmp[i];
		if (tmp[i]=="AB"){
			letter[i].first = 0;
			letter[i].second = 1;
		}else if (tmp[i]=="AC"){
			letter[i].first = 0;
			letter[i].second = 2;
		}else {
			letter[i].first = 1;
			letter[i].second = 2;
		}
	}

	vector<char> ans;
	for (int i=0;i<n;i++){
		if (abc[letter[i].first]==0 && 
			abc[letter[i].second]==0){
			cout << "No" << endl;
			return 0;
		}else if (abc[letter[i].first]==0){
			ans.push_back(ABC[letter[i].first]);
			abc[letter[i].first]++;
			abc[letter[i].second]--;
		}else if (abc[letter[i].second]==0){
			ans.push_back(ABC[letter[i].second]);
			abc[letter[i].first]--;
			abc[letter[i].second]++;
		}else if (i<n-1 && tmp[i]!=tmp[i+1]){
			int other = -1;
			int nonchange = -1;
			int change = -1;
			if (letter[i].first==letter[i+1].first){
				other = letter[i+1].second;
				nonchange = letter[i+1].first;
				change = letter[i].second;
			}else if (letter[i].second == letter[i+1].second){
				other = letter[i+1].first;
				nonchange = letter[i+1].second;
				change = letter[i].first;
			}else if (letter[i].first == letter[i+1].second){
				other = letter[i+1].first;
				nonchange = letter[i+1].second;
				change = letter[i].second;
			}else {
				other = letter[i+1].second;
				nonchange = letter[i+1].first;
				change = letter[i].first;
			}
			if (abc[other]==0){
				ans.push_back(ABC[nonchange]);
				abc[nonchange]++;
				abc[change]--;
			}else {
				ans.push_back(ABC[change]);
				abc[change]++;
				abc[nonchange]--;
			}
		}else {
			ans.push_back(ABC[letter[i].first]);
			abc[letter[i].first]++;
			abc[letter[i].second]--;
		}
	}

	cout << "Yes" << endl;
	for (int i=0;i<n;i++){
		cout << ans[i] << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 7648
package main

import (
	"fmt"
)

func main() {
	var n, k int
	var marks []int

	fmt.Scan(&n, &k)

	marks = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&marks[i])
	}

	for i := k; i < n; i++ {
		if marks[i-k] < marks[i] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 6488
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

int getrandom(int min,int max);

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

int n,k,count = 0;
int h[100010]={};

cin >> n >> k;

rep(i,n){
    cin >> h[i];
}

rep(i,n){
    if (h[i] >= k)
    {
        count++;
    }
    
}
    cout << count << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

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

    sort(d.begin(), d.end());
    ll ans = 0;
    for(ll i = d[n / 2 - 1] + 1; i <= d[n / 2]; i++){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		int n = sc.nextInt()-1;
      	int cs[] = new int[n];
      	int ss[] = new int[n];
      	int fs[] = new int[n];
      	int time;
      
      	int istack;
      	boolean judge = true;
      	
      	for(int i = 0;i < n; i++){
        	cs[i] = sc.nextInt();
          	ss[i] = sc.nextInt();
          	fs[i] = sc.nextInt();
        }
      	
        for(int i = 0; i < n; i++){
         time=0;
         for(int j = i; j < n;j++){
           if(time <= ss[j]) time = ss[j];
           else{
           	 istack = time - ss[j];
             if(istack % fs[j] != 0) time = ss[j] + (istack/fs[j]+ 1)*fs[j];
           }
           time+=cs[j];
         }
         System.out.println(time);
        }
      System.out.println(0);
	}
}


Measured memory_bytes: 39732
s = input()
lst = ["A", "C", "G", "T"]
flag = 0
cnt = 0
cnt_lst = []

for i in s:
    if flag:
        if i not in lst:
            cnt_lst.append(cnt)
            flag = 0
            cnt = 0
        else:
            cnt += 1
    else:
        if i in lst:
            flag = 1
            cnt += 1
if flag:
    cnt_lst.append(cnt)

print(max(cnt_lst)) if cnt_lst else print(0)

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

Measured memory_bytes: 2948
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    string s;

    while(n)
    {
        if(n%26 == 0)
        {
            s += 'z';
            n = n/26;
            n--;
            // if(n == 1) break;
        }
        else
        {
            // test1(n%26)
            s += 'a'-1 + n%26;
            // n -= (n%26);
            n = n/26;
        }
        // test1(n)
    }

    reverse(all(s));
    // test1(s)
    cout<<s;



    return 0;
}       

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

int main() {
  int n, s;
  int v[110];

  while (cin >> n && n > 0) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      sum += s;
      v[i] = s;
    }
    sort(v, v + n);
    sum -= v[0];
    sum -= v[n-1];
    cout << sum/(n-2) << endl;
  }

  return 0;
}


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

int main()
{
	int n0;
	long long t=0; 
	cin>>n0;
	const int n=n0;
	int arr[n];
	
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		//cout<<arr[i];
	}
		
	
	for(int i=0;i<n-1;i++)
		if(arr[i+1]<arr[i])
		{
			t = t + arr[i]-arr[i+1];
			arr[i+1]=arr[i];
		}
		else
		{
			NULL;
		}
	cout<<t;
	return 0;
}

Measured memory_bytes: 4336
#include <stdio.h>

int main() {
	int n, x, t,ans=1;
	scanf("%d %d %d", &n,&x,&t);

	if (n%x==0){
		ans =t*n/x ;
	}else{
		ans = t *( n / x+1);
	}

	printf("%d",ans);
}

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

#define pii pair<int,int>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N=3e5+9;

map<int,int>mp;
int a[N];
int32_t main()
{
    int n=in(),k=in();
    mp[0]++;
    ll ans=0;
    for(int i=1;i<=n;i++){
        a[i]=in();
        a[i]--;
        a[i]+=a[i-1];
        a[i]%=k;
        if(i-k>=0) mp[a[i-k]]--;
        ans+=mp[a[i]];
        mp[a[i]]++;
    }
    cout<<ans<<nl;
    return 0;
}


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

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

}

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

int main() {
  int N;
  cin >> N;
  getchar();
  vector<char> S(N);
  int r = 0, g = 0, b = 0, cnt = N;
  while (cnt--) {
    char c = getchar();
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
    S.at(cnt) = c;
  }

  long ans = (long) r * g * b;

  for (int i = 0; i < N; i++) {
    for (int j = 1; i + j + j < N; j++) {
      if ((S.at(i) ^ S.at(i + j) ^ S.at(i + j + j)) == 87) ans--;
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 3632
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll lcm = (c * d) / __gcd(c, d);
	auto sub_mul = [&](ll den) {
		return max(0ll, b / den - (a + den - 1) / den + 1);
	};
	ll res = (b - a + 1) - (sub_mul(c) + sub_mul(d) - sub_mul(lcm));
	cout << res << "\n";
}

Measured memory_bytes: 256
long d['~~'];A,x,i=5e3,j;main(n){for(scanf("%d%d",&n,&A),d[n*=A]=1;!j--?i=5e3-i,j=-~scanf("%d",&x)*n,x-=A,j:1;d[5000-i+j]=d[i+j]+d[j<x?:i+j-x]);printf("%ld",d[i+n]-1);}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  cin >> n;
  vector<string> s(10);
  s[0] = "pon";
  s[1] = "pon";
  s[2] = "hon";
  s[3] = "bon";
  s[4] = "hon";
  s[5] = "hon";
  s[6] = "pon";
  s[7] = "hon";
  s[8] = "pon";
  s[9] = "hon";
  cout << s[n%10] << endl;
  return 0;
}

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

int main(){
  int n, k;
  cin>>n >>k;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  
  sort(h.rbegin(), h.rend());
  
  long long ans=0;
  for(int i=k;i<n;i++)ans+=h[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val numbers = readLine()!!.split(" ").map { it.toLong() }
    val lcm = numbers.reduce { acc, l -> getLcm(acc, l) }
    val bunsi = numbers.map { lcm / it }.sum()
    println(lcm.toDouble()/bunsi)
}

fun getGcd(num1:Long, num2:Long):Long {
    if(num1 % num2 == 0L) {
        return num2
    }
    return getGcd(num2, num1%num2)
}

fun getLcm(num1:Long, num2:Long):Long {
    return num1/getGcd(num1,num2)*num2
}


Measured memory_bytes: 37864
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
RES = [list("0" * W) for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            RES[i][j] = "#"
            for n in range(-1, 2):
                for m in range(-1, 2):
                    if not(n == 0 and m == 0) and 0 <= i + n and i + n < H and 0 <= j + m and j + m < W:
                        if RES[i + n][j + m] != "#":
                            RES[i + n][j + m] = str(int(RES[i + n][j + m]) + 1)

for i in range(H):
    print("".join(RES[i]))


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

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		int []tmpArray = array.clone();
		Arrays.sort(array);
		if(array[n-1] == array[n-2]) {
			for(int i = 0; i < n;i++) {
				System.out.println(array[n-1]);
			}
		}else {
			int index = 0;
			for(int i = 0; i < n;i++) {
				if(tmpArray[i] == array[n-1]) {
					index = i;
				}
			}
			for(int i = 0; i < n;i++) {
				if(i != index) {
					System.out.println(array[n-1]);
				}else {
					System.out.println(array[n-2]);
				}
			}
		}
	}

}

Measured memory_bytes: 91964
a = gets.to_i
b = gets.split.map(&:to_i)
c = 1
d = 0
for num in 0..a-1
  c = c.lcm(b[num])
end
for num in 0..a-1 
  d += c/b[num]
end
p d % (10**9 +7)

Measured memory_bytes: 58632
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a[310][310];
signed main() {
	cin>>n;
	int sum=0;
	rep(i,n){
		rep(j,n){
			cin>>a[i][j];
			sum+=a[i][j];
		}
	}
	rep(i,n){
		rep(j,n){
			if(i==j)continue;
			rep(k,n){
				if(i==k)continue;
				if(j==k)continue;
				if(a[i][j]==a[i][k]+a[k][j]){
					sum-=a[i][j];
					break;
				}
				if(a[i][j]>a[i][k]+a[k][j]){
					cout<<-1<<endl;
					return 0;
				}
			}
		}
	}
	cout<<sum/2<<endl;
	return 0;
}

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

const int M = 1000010;
const int N = 1010;

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

bool isprime[M];
int number[N][N];
int DP[N][N];

int n, m;

int startx, starty;

int ansnum, ansmax;

void initprime() {
  fill(isprime, isprime+M, true);
  isprime[0] = isprime[1] = false;
  isprime[2] = true;
  for (int i=2; i<M; i++) {
    if (isprime[i]) {
      // cerr << "prime " << i << endl; 
      int j=2;
      while (j * i < M) {
	isprime[j * i] = false;
	j++;
      }
    }
  }
}

void init() {
  fill(&number[0][0], &number[0][0]+N*N, 0);
  fill(&DP[0][0], &DP[0][0]+N*N, -1);
  int d = 0;
  int len = 1;
  int curn = 1;
  int curx = N/2;
  int cury = N/2;
  
  while (true) {
    for (int i=0; i<len; i++) {
      number[curx][cury] = curn;
      // cerr << "x " << curx -N/2 << ", y " << cury -N/2 << ", curn " << curn << endl;
      if (curn == n) {
	startx = curx;
	starty = cury;
	if (isprime[n]) {
	  DP[startx][starty] = 1;
	} else {
	  DP[startx][starty] = 0;
	}
      }
      curn++;
      curx += dx[d];
      cury += dy[d];
      if (curn > m) return;
    }
    d = (d+1)%4;
    if (d%2 == 0) len++;
  }
}

void dynamic(int x, int y) {
  for (int i=-1; i<=1; i++) {
    if (number[x+i][y+1] != 0) {
      if (isprime[number[x+i][y+1]]) {
	if (DP[x+i][y+1] < DP[x][y] + 1) { 
	  DP[x+i][y+1] = DP[x][y] + 1;
	  dynamic(x+i, y+1);
	}
      } else {
	if (DP[x+i][y+1] < DP[x][y]) {
	  DP[x+i][y+1] = DP[x][y];
	  dynamic(x+i, y+1);
	}
      }
    }
  }
}

void solve() {
  ansnum = ansmax = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (DP[i][j] > 0 && ansnum <= DP[i][j]) {
	// if (DP[i][j] > 0) cerr << "ansnum " << ansnum << ", number " << number[i][j] << endl;
	if (ansnum < DP[i][j]) ansmax = 0;
	ansnum = DP[i][j];
	if (ansmax < number[i][j] && isprime[number[i][j]]) {
	  ansmax = number[i][j];
	}
      }
    }
  }
  printf("%d %d\n", ansnum, ansmax);
}

int main() {
  initprime();
  while (scanf("%d%d", &m, &n) != EOF && n && m) {
    init();
    dynamic(startx, starty);
    solve();
  }
}

Measured memory_bytes: 10160
using namespace std;
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>
#include <iterator>
#include <set> 
#include <unordered_set>
#include <string>
#include <functional>
#include <limits.h>
//#include <bits/stdc++.h> 
//#include <list>
#include <stack>
#include <stdio.h>
typedef signed long long ll; //watch out ll= int*int will not become ll, rather (ll)ini*int casting will work
#include <queue>
#include <math.h>
#include <deque>
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
//typedef long float lf;
#include <cmath>
#include <iomanip>
#include <numeric>
#include <stdio.h>
const long double PI = 3.141592653589793238L;
/*struct CustomCompare
{
	bool operator()(pii& p1, pii& p2)
	{
		if (p1.second - p1.first == p2.second - p2.first)
			return p1.first > p2.first;

		return p1.second - p1.first < p2.second - p2.first;
	}
};*/
int tt, n, k, inp, a, b, x,m;
void pv(vector<int> a) {
	for (auto i : a)
		cout << i<< ' ';
	cout << '\n';
}
void pp (vector<pair<int, int>> a) {
	for (auto i : a)
		cout << i.first << ' ' << i.second<<'\n';
}
double solve(tuple<int, int, int> s,
	map <tuple <int, int, int>, double> &memo) {
	//cout << get<0>(s) << ' '<< get<1>(s) << ' '<< get<2>(s);
	//cout << endl;
	if (memo.find(s) == memo.end()) {
		int i = get<0>(s);
		int j = get<1>(s);
		int k = get<2>(s);
		
		//cout << "FIRST";
		double ans = 0;
		if (k>0)
		ans +=(double) k / n * (1 + solve({ i,j + 1,k-1 }, memo));
		
		
		//cout << "SECOND";
		if (j>0)
		ans += (double)  j / n * (1 + solve({ i + 1,j-1,k }, memo));
		
		
		//cout << "THIRD";
		if (i>0)
		ans += (double)     i / n * (1 + solve({ i-1,j,k }, memo));
		
		//cout << "FOURTH";
		ans = (double) n / ((double)i + j + k) * (ans + (double)((double)n - i - j - k) / n);
		
		//cout << "ANS " << ans << '\n';
		memo.insert({ s, ans });
		return ans;
	}
	else
		return memo.find(s)->second;

}
int main() {
	//vector<int> x = { 2,1,0 };
	cin >> n; 
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	//cout << minn;
	vector<vector<long long>> dp(n, vector<long long> (n));
	for (int i = 0; i < n; i++)
		dp[i][i] = (long long)a[i];
	for (int k = 1; k < n + 1; k++) {
		//cout << k<<'\n';
		for (int start = 0; start < n - k; start++) {
			int end = start + k;
			dp[start][end] = max(
				a[start] - dp[start + 1][end],
				a[end] - dp[start][end - 1]);
		}
	
	}
	//for (auto i : dp)
	//	pv(i);
		cout << dp[0][n - 1];
}


/*
tuple <int, int, int> s = {0,0,0};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 1)
			get<0>(s)++;
		else if (a[i]==2)
			get<1>(s)++;
		else if (a[i] == 3)
			get<2>(s)++;

	}
	map <tuple <int, int, int>, double> memo;
	memo.insert({ {0,0,0},0.0 });
	cout << std::setprecision(11)<<solve(s, memo);
}*/

Measured memory_bytes: 73716