akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

 class Main {
	static Integer[] F = new Integer[44];

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(fibonacci(scanner.nextInt()));
	}
	
	static int fibonacci(int n) {
		int a[]=new int[n+1];
	    a[0]=1;
	    a[1]=1;
	    if(n<2){
	        return a[n];
	    }
	    for(int i=2;i<=n;i++){
	        a[i]=a[i-1]+a[i-2];
	    }
	            return a[n];
	    }
}

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

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

  if ( (a%2 ==0 ) || (b%2 ==0 )) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}


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

int main()
{
	int N, K;
	int S[200];
	
	while (scanf("%d %d", &N, &K), N + K){
		for (int i = 0; i < K; i++){
			scanf("%d", &S[i]);
		}
		
		bool f = true;
		for (int i = 0; i < N; i++){
			for (int j = 0; j < K; j++){
				int B;
				scanf("%d", &B);
				
				S[j] -= B;
				
				if (S[j] < 0){
					f = false;
				}
			}
		}
		
		printf(f ? "Yes\n" : "No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1012
#include <iostream>
using namespace std;
 
int main(){

    int m, d;

	cin >> m >> d;

    int sekiDate = 0;

    int i, j;   // iが月，jが日付
    int j1, j2;

    for(i=1; i<=m; i++){
        for(j=1; j<=d; j++){

            if(j >= 10){
                j1 = j/10;
                j2 = j%10;
            }
            else{
                continue;
            }

            if(j1 >= 2 && j2 >= 2 && i == (j1*j2))
                sekiDate += 1;
        }
    }

    cout << sekiDate << endl;

    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = ni();
        }
        long ans = 0;
        long count = 0;
        for (int i = 0; i < N; i++) {
            if(a[i] == 0 || i==N-1){
                count += a[i];
                ans += count/2;
                count = 0;
            }else{
                count += a[i];
            }
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 47288
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

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

const int INF = 1000000000;

double adj[1005][1005];
int x[1005], y[1005],id[1005];
int path[1005];
double d[1005];
int n;
bool visit[1005];

// ノード:s からの最短距離を求める
bool dijkstra (int s, int t )
{
	memset (path, -1, sizeof (d ) );
	memset (visit, false, sizeof (visit ) );
	// greater<P> を指定することでfirstが小さい順に取り出せるようにする
	priority_queue<pdi> que;

	fill (d,  d + n, INF );
	d[s] = 0.0;
	que.push (P (0.0, s ) );
	while (!que.empty() ){
		pdi p = que.top(); que.pop();
		double dis=-p.first;
		int u = p.second;
		if (u == t ) return true;
		visit[u] = true;
		rep (v, n ){
			if (visit[v] ) continue;
			if (d[v] > dis + adj[u][v] ){
				d[v] = dis + adj[u][v];
				que.push (pdi (-d[v], v ) );
				path[v] = u;
			} // end if
		} // end rep
	} // end while

	return false; 
}

void disp_path (int s, int t )
{
	vector<int> res;
	res.push_back (t );
	int curr = t;
	while (path[curr] != -1 ){
		curr = path[curr];
		res.push_back (curr );
	} // end while

	reverse (ALL (res ) );
	rep (i, res.size() ){
		cout << id[res[i]] << (i != res.size() - 1 ? ' ' : '\n' );
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.spiderjin", "r", stdin );

	while (scanf ("%d", &n ) && n != 0 ){
		memset (x, 0, sizeof (x ) );
		memset (y, 0, sizeof (y ) );
		memset (id, 0, sizeof (id ) );
		rep (i, n ) rep (j, n ) adj[i][j] = INF;
		rep (i, n ){
			scanf ("%d %d %d", &id[i], &x[i], &y[i] );
		} // end rep

		rep (i, n ){
			rep (j, n ){
				int xx = x[i] - x[j];
				int yy = y[i] - y[j];
				int dis = xx*xx + yy*yy;
				if (dis <= 50*50 ){
					adj[i][j] = sqrt (dis );
					adj[j][i] = sqrt (dis );
				} // end if
			} // end rep
		} // end rep

		int m;
		scanf ("%d", &m );
		rep (i, m ){
			int ids, idt, s, t;
			scanf ("%d %d", &ids, &idt );
			rep (i, n ){
				if (id[i] == ids ) s = i;
				if (id[i] == idt ) t = i;
			} // end rep

			if (dijkstra (s, t ) ){
				disp_path (s, t );
			}else{
				printf ("NA\n" );
			} // end if
		} // end rep
	} // end while
	
	return 0;
}

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

using namespace std;

int l;
string f(string s){
    while(s.size() < l){
        s = "0" + s;
    }
    return s;
}

string g(string s, string t){
    int n = 0, m = 0;
    for(int i = 0; i < l; i++){
        n *= 10;
        m *= 10;
        n += s[i]-'0';
        m += t[i]-'0';
    }
    return f(to_string(n-m));
}


int main(){
    string s;
    while(cin >> s >> l, s != "0" || l){
        vector<string> v;
        v.push_back(f(s));
        for(int i = 0; i < 25; i++){
            string in = v[v.size()-1];
            sort(in.begin(),in.end());
            string in1,in2;
            in1 = in2 = in;
            reverse(in1.begin(),in1.end());
            string out = g(in1,in2);
            //cout << i << " " << in1 << " " << in2 << " " << out << endl;
            bool c = false;
            for(int j = 0; j < v.size(); j++)if(v[j] == out){
                while(out.size() > 1){
                    if(out[0] == '0')out = out.substr(1);
                    else break;
                }
                cout << j << " " << out << " " << i-j+1 << endl;
                c = true;
                break;
            }
            if(c)break;
            v.push_back(out);
        }
    }
}



Measured memory_bytes: 3244
#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char *argv[])
{
  long long n, k;
  cin >> n >> k;
  vector<long> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  sort(h.begin(), h.end(), greater<long long>());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= k) {
      ans += h[i];
    }
  }

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

Measured memory_bytes: 1792
#include <stdio.h>

int stack1[ 50 ], stack2[ 49 ], stack3[ 50 ];
int sp1, sp2 = 0, sp3 = 0;

int main( void ) {
	int n, r, p, c;

	for ( ; scanf( "%d %d", &n, &r ), n; printf( "%d\n", stack1[ sp1 - 1 ] ) ) {
		for ( sp1 = 0; n--; sp1++ )
			stack1[ sp1 ] = sp1 + 1;

		while ( r-- ) {
			scanf( "%d %d", &p, &c );

			while ( p-- - 1 )
				stack2[ sp2++ ] = stack1[ --sp1 ];
			while ( c-- )
				stack3[ sp3++ ] = stack1[ --sp1 ];

			while ( sp2 )
				stack1[ sp1++ ] = stack2[ --sp2 ];
			while ( sp3 )
				stack1[ sp1++ ] = stack3[ --sp3 ];
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  long long A, V;
  cin >> A >> V;
  long long B, W;
  cin >> B >> W;
  long long T;
  cin >> T;

  long long dist = abs(A - B);
  long long speed = (V - W);
  if (speed * T - dist >= 0) cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, H: int, M: int):
    x = abs((H*60+M)/2 - 6*M)
    ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(x))) ** 0.5
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9588
N = int(input())
A = [int(a) for a in input().split()]
if N % 2 == 0:
    x, y, px, py = 0, 0, 0, -1<<100
    for a in A:
        x, y, px, py = px+a, max(x, py+a), x, y
    print(max(x, y))
else:
    x, y, z, px, py, pz = 0, 0, 0, 0, -1<<100, -1<<100
    for a in A:
        x, y, z, px, py, pz = px+a, max(x, py+a), max(y, pz+a), x, y, z
    print(max(y, z))

Measured memory_bytes: 30948
n,m,x=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
INF=99999999999
ans=INF
for i in range(2**n):
    tans=0
    c=[0]*m
    for j in range(n):
        if (i>>j)&1:
            tans+=a[j][0]
            for k in range(m):
                c[k]+=a[j][k+1]
    
    if min(c)>=x:
        ans=min(tans,ans)
if ans==INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define ll long long
#define N 310
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int n,c,mo;
ll da[N][N],dp[N][N],C[N][N];
int main(){
	cin>>n>>c>>mo;
	C[0][0]=1;
	for (int i=1;i<=300;i++)
		for (int j=0;j<=i;j++){C[i][j]=C[i-1][j];if (j)C[i][j]=(C[i][j]+C[i-1][j-1])%mo;}
	for (int i=0;i<=c;i++)dp[1][i]=1,da[1][i]=c-i+1;
	for (int i=2;i<=n+1;i++){
		for (int j=c;j>=0;j--)
			for (int k=1;k<i;k++)
				dp[i][j]=(dp[i][j]+(dp[i-k][j]*da[k][j+1]%mo)*C[i-2][k-1])%mo;
		for (int j=c;j>=0;j--)da[i][j]=(dp[i][j]+da[i][j+1])%mo;
	}
	cout<<dp[n+1][0]<<endl;
	return 0;
}

Measured memory_bytes: 2432
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

ll f0(ll x, ll y) {
    return x - y;
}

ll f1(ll x, ll y) {
    return x + y;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    rep(i, 0, N) {
        cin >> X[i] >> Y[i];
    }
    vector<ll> F0, F1;
    rep(i, 0, N) {
        F0.push_back(f0(X[i], Y[i]));
        F1.push_back(f1(X[i], Y[i]));
    }
    cout << max(*max_element(all(F0)) - *min_element(all(F0)), *max_element(all(F1)) - *min_element(all(F1))) << endl;
    return 0;
}

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

#　Xの格桁の和を求める
def f(X):
  return sum(list(map(int, str(X))))

summedDigit = 0
sumArray = []
for A in range(N+1):
  if A > 0:
    B = N - A
    if A != N:
      summedDigit = f(A) + f(B)
      sumArray.append(summedDigit)

print(min(sumArray))





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

int main() {
  string n;
  cin >> n;
  long long res = 0;
  int x;
  rep (i, n.size()) {
    x = n.at(i) - '0';
    res += x;
    //cout << res << endl;
  }
  if (res % 9) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3716
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner();
        try (final FastWriter writer = new FastWriter()) {
            String S = scanner.next();
            for (int i = 0; i < S.length(); i++) writer.print('x');
            writer.println();
        }
    }
}

class FastWriter extends PrintWriter {
    public FastWriter() {
        super(new BufferedOutputStream(System.out));
    }

    public static void main(final String[] args) {
        try (final FastWriter w = new FastWriter()) {
            w.println(32);
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (final IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

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

	vector<int> up(n, 1e9);
	vector<int> down(n, 1e9);
	up[0] = 1;
	down[0] = 1;

	for (int i = 1; i < n; i++) {
		if (a[i - 1] <= a[i]) {
			up[i] = up[i - 1];
		}
		if (a[i - 1] >= a[i]) {
			down[i] = down[i - 1];
		}
		up[i] = min(up[i], min(up[i - 1], down[i - 1]) + 1);
		down[i] = min(down[i], min(up[i - 1], down[i - 1]) + 1);
	}

	cout << min(up[n - 1], down[n - 1]) << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
// char s[N_MAX + 1];
// char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;

	return 0;
}
 
int main(void){
	int i, j;
	int x;

	scanf("%d", &x);

	// solve();

	if (x / 100 == x % 10) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 128
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut s=read::<String>();
    println!("{}",s.replace(","," "))
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    if(a+b>=c)cout<<b+c<<endl;
    else cout<<2*b+a+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S;
  cin >> S;
  string ans = "WA";
  int length = S.size();
  int big_count = 0;
  int C_index = 0;

  rep(i, S.size())
  {
    if (S[i] == 'C')
      C_index = i + 1;
    if (isupper(S[i]))
    {
      big_count++;
    }
  }
  if (S[0] == 'A' && big_count == 2 && 3 <= C_index && C_index <= length - 1)
    ans = "AC";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN = 500005;
struct Edge{
	int to,next;
}e[MAXN<<1];
int p[MAXN],q[MAXN],n,head[MAXN],in[MAXN],ord[MAXN],val[MAXN],k;
set<int>ele;
typedef set<int>::iterator SI;
priority_queue<int>pq;
int mx[MAXN<<2];
int ql,qr,qval,qpos;
void update(int i,int l,int r)
{
	if(l==r)return void(mx[i]=qval);
	int mid=(l+r)>>1,lc=i<<1,rc=lc|1;
	if(qpos<=mid)update(lc,l,mid);
	else update(rc,mid+1,r);
	mx[i]=max(mx[lc],mx[rc]);
}
int query(int i,int l,int r)
{
//	cout<<i<<" "<<l<<" "<<r<<endl;
	if(l>=ql&&r<=qr)return mx[i];
	int mid=(l+r)>>1,lc=i<<1,rc=lc|1;
	if(qr<=mid)return query(lc,l,mid);
	else if(ql>mid)return query(rc,mid+1,r);
	else return max(query(lc,l,mid),query(rc,mid+1,r));
}
int cnt;
inline void insert(int u,int v)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",p+i),q[p[i]]=i;
	for(int i=1;i<=n;++i){
		ql=max(q[i]-k+1,1),qr=q[i];
//		cout<<ql<<" "<<qr<<endl;
		int x=query(1,1,n);
		if(x)insert(q[i],q[x]),++in[q[x]];
		ql=q[i],qr=min(q[i]+k-1,n);
//		cout<<ql<<" "<<qr<<endl;
		x=query(1,1,n);
		if(x)insert(q[i],q[x]),++in[q[x]];
		qpos=q[i],qval=i;
//		cout<<qpos<<" "<<qval<<endl;
		update(1,1,n);
	}
	for(int i=1;i<=n;++i)
		if(!in[i])pq.push(i);
	for(int i=n;i;--i){
		ord[i]=pq.top();
		pq.pop();
		for(int j=head[ord[i]];j;j=e[j].next){
			int v=e[j].to;
			if(!--in[v]){
				pq.push(v);				
			}
		}
	}
	for(int i=1;i<=n;++i)val[ord[i]]=i;
	for(int i=1;i<=n;++i)printf("%d\n",val[i]);
	return 0;
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  cout << n * n * n << en;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
import pdb

def main():
    N = int(raw_input())
    dslist = []
    for k in range(N):
        kthvalue = int(raw_input())
        dslist += [kthvalue]
    dslist = np.array(dslist)
    print tallestKagami(dslist)

def tallestKagami(ds):
    N = len(ds)
    ds = np.sort(ds)[::-1]
    stacksize = 0
    while(len(ds) > 0):
        largest = ds[0]
        ds = np.delete(ds, np.where(ds == largest)[0])
        stacksize += 1

    return stacksize


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	int sum = 0;
	vector<int>num(N);
	reps(i,1, N) {
		if (S[i - 1] == 'E')sum++;
		num[i] = sum;
	}
	sum = 0;
	reps(i,1, N) {
		if (S[N - i] == 'W')sum++;
		num[N - 1 - i] += sum;
	}
	int max_num = 0;
	rep(i, N) {
		max_num = max(num[i], max_num);
	}
	cout << N - 1 - max_num << endl;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int a = (s[0] - '0') * 10 + s[1] - '0';
    int b = (s[2] - '0') * 10 + s[3] - '0';
    bool mmyy = a <= 12 && a >= 1;
    bool yymm = b <= 12 && b >= 1;

    if (mmyy){
        if (yymm){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else if (yymm){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int r, g, b;
  cin >> r >> g >> b;

  if ((g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

switches = []
for index in range(m):
    switch = input().split()
    switches.append(list(map(int, switch[1:])))
passes = list(map(int, input().split()))

output = 0
for index in range(2 ** n):

    light = 0
    for mm in range(m):
        count = 0
        for shift in switches[mm]:
            if (index >> shift - 1) & 1:
                count += 1
        if count % 2 == passes[mm]:
            light += 1
    
    if light == m:
        output += 1

print(output)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int H, W; cin >> H >> W;
    vector<string> C(H); REP(i, H) cin >> C[i];

    vector<string> ne;

    REP(i, H) {
        // 2倍にするため、操作を2回実施する
        ne.push_back(C[i]);
        ne.push_back(C[i]);
    }

    REP(i, H * 2) {
        cout << ne[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int max_p = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        ans += p;
        max_p = max(max_p, p);
    }
    ans -= max_p / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		@SuppressWarnings("unchecked")
		ArrayList<Integer> index[] = new ArrayList[26];

		for(int i = 0; i < 26; i++){
			index[i] = new ArrayList<Integer>();
		}

		for(int i = 0; i < str.length(); i++){
			index[str.charAt(i) - 'a'].add(i);
		}

		for(int i = 0; i < 26; i++){
			if(index[i].size() < 2){
				continue;
			}

			for(int j = 0; j < index[i].size(); j++){
				for(int k = j + 1; k < index[i].size(); k++){
					if(index[i].get(k) - index[i].get(j) >= 4){
						break;
					}

					int len = index[i].get(k) - index[i].get(j) + 1;
					int num = k - j + 1;

					if(num > len/2){
						System.out.println((index[i].get(j) + 1) + " " + (index[i].get(k) + 1));
						return;
					}
				}
			}
		}

		System.out.println("-1 -1");
	}
}


Measured memory_bytes: 33404
k,s = map(int, input().split())
a = (s+2)*(s+1)/2
b = (s-k+1)*(s-k)/2
c = (s-2*k)*(s-2*k-1)/2
 
if s <= k:
    print(int(a))
elif s <= 2*k:
    print(int(a-3*b))
elif s <= 3*k:
    print(int(a-3*b+3*c))
#なんこ保持しておくかの計算

Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
    int n, cng;
    scanf("%d", &n);
    if(n % 1000 == 0){
        cng = 0;
    }
    else{
        cng = 1000 - (n % 1000);
    }
    printf("%d", cng);

    return 0;
}


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


int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans[N];

  for(int i=0; i<N; i++){
    ans[i] = 0;
  }

  int p=0,l=0;
  for(int i=0; i<N-1; i++){ 
    if(S[i]=='R' && S[i+1]=='L'){
      l = i - p;
      if(l==0){
        ans[i] += 1;
      }else if(l%2==0){
        ans[i] += l / 2 + 1;
        ans[i+1] += l / 2;
      }else{
        ans[i] += l / 2 + 1;
        ans[i+1] += l / 2 + 1;
      }
      p = i;
    }else if(S[i]=='L'){
      p = i + 1;
    }
  }

  p = N-1;
  for(int i=N-1; i>0; i--){ 
    if(S[i]=='L' && S[i-1]=='R'){
      l = p - i;
      if(l==0){
        ans[i] += 1;
      }else if(l%2==0){
        ans[i] += l / 2 + 1;
        ans[i-1] += l / 2;
      }else{
        ans[i] += l / 2 + 1;
        ans[i-1] += l / 2 + 1;
      }
      p = i;
    }else if(S[i]=='R'){
      p = i - 1;
    }
  }

  for(int i=0; i<N; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 4156
#include <cassert>
#include <iostream>
#include <string>

char solve(char b)
{
  const std::string s = "ATCG";
  assert(s.size() % 2 == 0);
  for (auto i = 0u; i < s.size(); ++i) {
    if (s[i] == b) return i % 2 == 0 ? s[i + 1] : s[i - 1];
  }
  return 'X';
}

int main()
{
  char b;
  std::cin >> b;

  std::cout << solve(b) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  long int sum = 0;
  int nMinus = 0;
  //int nPlus = 0;
  int nZero = 0;
  int absMin = 2000000000;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += abs(A[i]);

    if (abs(A[i]) < absMin && A[i]!=0) {
      absMin = abs(A[i]);
    }
    
    if (A[i] < 0) {
      nMinus++;
    } else if (A[i] == 0) {
      nZero++;
    }
  }

  if (nZero > 0 || nMinus%2 == 0) {
    sum = sum;
  } else {
    sum = sum - 2*absMin;
  }

  cout<<sum<<endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back

string nextStr(string str){
    bool flag = str[0] == '7';
    if(str[0] == '3')str[0] = '5';
    else if(str[0] == '5')str[0] = '7';
    else str[0] = '3';
    for(int i = 1; flag; i ++){
        if(i == str.size()){
            str.pb('3');
            break;
        }
        if(str[i] == '3'){
            flag = false;
            str[i] = '5';
        }
        else if(str[i] == '5'){
            flag = false;
            str[i] = '7';
        }
        else str[i] = '3';
    }
    return str;
}
bool check(string str){
    bool f3 = false, f5 = false, f7 = false;
    for(int i = 0; i < str.size(); i ++){
        if(str[i] == '3')f3 = true;
        if(str[i] == '5')f5 = true;
        if(str[i] == '7')f7 = true;
    }
    return f3 && f5 && f7;
}
int main(){

    int N;
    cin >> N;
    string S = "753";
    int ans = 0;
    reverse(S.begin(), S.end());
    while(stoll(S) <= N){
        //cout << stoi(S) << endl;
        if(check(S)){
            ans ++;
            //cout << "!!!!!!!!" << endl;
        }
        reverse(S.begin(), S.end());
        S = nextStr(S);
        reverse(S.begin(), S.end());
    }
    cout << ans << endl;

    /*string S = "357";
    if(check(S))cout << "Y" << endl;
    else cout << "N" << endl;*/

    return 0;
}

Measured memory_bytes: 256
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  s = input()
  s_time = dt.strptime(s, '%Y/%m/%d')
  dt1 = dt(2019, 4, 30)
  if s_time<=dt1:
    print('Heisei')
  else:
    print('TBD')
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 6112
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	plus, minus := false, false
	for i := 0; i < n; i++ {
		if as[i] > 0 {
			plus = true
		}
		if as[i] < 0 {
			minus = true
		}
	}

	if !plus && !minus {
		fmt.Println(0)
		return
	}

	if plus && !minus {
		fmt.Println(n - 1)
		for i := 1; i < n; i++ {
			fmt.Println(i, i+1)
		}
		return
	}

	if !plus && minus {
		fmt.Println(n - 1)
		for i := n; i > 1; i-- {
			fmt.Println(i, i-1)
		}
		return
	}

	mx, mn := 0, 0
	mxi, mni := -1, -1
	for i := 0; i < n; i++ {
		if as[i] <= mn {
			mn = as[i]
			mni = i + 1
		}
		if as[i] >= mx {
			mx = as[i]
			mxi = i + 1
		}
	}

	fmt.Println(n + n - 1)
	if abs(mn) < abs(mx) {
		for i := 1; i <= n; i++ {
			fmt.Println(mxi, i)
		}
		for i := 1; i < n; i++ {
			fmt.Println(i, i+1)
		}
	} else {
		for i := 1; i <= n; i++ {
			fmt.Println(mni, i)
		}
		for i := n; i > 1; i-- {
			fmt.Println(i, i-1)
		}
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1840
N=int(input())
tl=[]
xl=[]
yl=[]
al=[]
bl=[]
cl=[]
dl=[]

for i in range(N):
 t,x,y=map(int,input().split())
 tl.append(t)
 xl.append(x)
 yl.append(y)
 al.append((x+y)%2)
 bl.append(t%2)

for i in range(N):
 c=abs((xl[i]+yl[i])-(xl[i-1]+yl[i-1]))
 d=abs(tl[i]-tl[i-1])
 cl.append(c)
 dl.append(d)

count=0
for i in range(N):
 if al[i]==bl[i] and (xl[i]+yl[i])<=tl[i] and cl[i]<=dl[i]:
  count+=1
if count==N:
  print("Yes")
else :
  print("No")

Measured memory_bytes: 89688
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int a,b;
    cin >> a >>b;
    rep(i,100000){
        int c = (i*2)/25;
        int d = i/10;
        if(c==a && b==d){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	string s , t;
	cin >> s >> t;
	sort(s.begin() , s.end());
	sort(t.rbegin() , t.rend());
	if(s < t)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 100005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}

int n, m, ans;
char s[maxn]; 
int main(){
	int i, j, x, u, v;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(i = 1;i <= n;i += 2) ans -= s[i] == 'p';
	for(i = 2;i <= n;i += 2) ans += s[i] == 'g';
	printf("%d\n",ans);
	return 0;
}


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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

int main() {
  // freopen("1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ll N;
  cin >> N;
  int X, M;
  cin >> X >> M;

  int h = 0;
  {
    vector<int> H(M, -1);
    int pos = X;
    while (H[pos] == -1) {
      H[pos] = h;
      pos = (1LL * pos * pos) % M;
      ++h;
    }
  }

  ll result = 0;
  int head = min((ll)h, N);
  int pos = X;
  rep(i, head) {
    result += pos;
    pos = (1LL * pos * pos) % M;
  }

  ll cycle_sum = 0;
  int cycle_len = 0;
  vector<bool> H(M);
  do {
    ++cycle_len;
    cycle_sum += pos;
    H[pos] = true;
    pos = (1LL * pos * pos) % M;
  } while (!H[pos]);

  N -= head;
  result += cycle_sum * (N / cycle_len);
  N %= cycle_len;
  rep(i, N) {
    result += pos;
    pos = (1LL * pos * pos) % M;
  }

  cout << result << '\n';
  
  return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var N=Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var ans = A[0];
        for (int i=1;i<N;++i)
        {
            var a = ans < A[i] ? A[i] : ans;
            var b = a == ans ? A[i] : ans;
            ans = GetGcd(a,b);
        }
        Console.WriteLine(ans);
    }
    static long GetGcd(long a,long b)
    {
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}

Measured memory_bytes: 22880
#!/usr/bin/env python
"""AtCoder Beginner Contest 086: C - Traveling
https://atcoder.jp/contests/abc086/tasks/arc089_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    position = {'t': 0, 'x': 0, 'y': 0}

    answer = 'Yes'
    for _ in range(N):
        t, x, y = map(int, input().split())
        # print('x:' + str(abs(x-position['x'])))
        # print('y:' + str(abs(y-position['y'])))
        # print('t:' + str(t - position['t']))
        # print(abs(x-position['x']) + abs(y-position['y']))
        length = abs(x-position['x']) + abs(y-position['y'])
        t_d = t - position['t']
        if length <= t_d and length % 2 == t_d % 2:
            position = {'t': t, 'x': x, 'y': y}
        else:
            answer = 'No'
            break

    print(answer)


if __name__ == '__main__':
    main()


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

int n;
string s[14];
vector<string> t;
int cost[14][14];
int memo[1 << 14][14];

int rec(int S, int cur) {
  if (memo[S][cur] <= 0) return memo[S][cur];
  if ((S | (1 << cur)) == (1 << n) - 1) return 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (S >> i & 1) continue;
    res = min(res, rec(S | (1 << cur), i) + cost[cur][i]);
  }
  return memo[S][cur] = res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    t.clear();
    fill_n((int*)memo, (1 << 14)*14, 1);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    bool contained[14] = {};
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j || s[i].find(s[j]) == string::npos) continue;
        contained[j] = true;
      }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (contained[i]) continue;
      t.emplace_back(s[i]);
      sum += s[i].size();
    }
    n = t.size();

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        int n = t[i].size(), m = t[j].size();
        int len = 0;
        for (int k = 1; k <= min(n, k); k++) {
          if (t[i].substr(n-k) == t[j].substr(0, k)) len = k;
        }
        cost[i][j] = -len;
      }
    }
    int minCost = 0;
    for (int i = 0; i < n; i++) {
      minCost = min(minCost, rec(0, i));
    }
    cout << sum + minCost << endl;
  }

  return 0;
}


Measured memory_bytes: 3916
import java.util.ArrayList;
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int max = Integer.MIN_VALUE;
		int minNum = Integer.MAX_VALUE;
		int temp;
		int num = scan.nextInt();
		for(int i = 0; i < num; i++) {
			list.add(scan.nextInt());
		}

		for(int i = 0; i < num - 1; i++) {
			temp = list.get(i);
			if(i == 0) {
				minNum = temp;
			} else if (temp > minNum) {
				continue;
			} else {
				minNum = temp;
			}
			for(int j = i + 1; j < num; j++) {
				if(list.get(j) - temp > max) {
					max = list.get(j) - temp;
				}
			}
		}

		System.out.println(max);
	}
}


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

using ll = long long;

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

    vector<ll> A(N);

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

    if ((2 * sum) % (N * (N + 1)) != 0) {
        cout << "NO" << endl;
        return 0;
    }

    ll k = (2 * sum) / (N * (N + 1)),
       life = k; // 操作回数

    for (int cur = 0; cur < N; cur++) {
        int next = (cur + 1) % N;

        ll diff = k - (A[next] - A[cur]);

        if (diff % N != 0 || diff / N < 0) {
            cout << "NO" << endl;
            return 0;
        }

        life -= diff / N;
    }

    if (life == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <map>
using namespace std;
int H,W;
char C[105][105];
char t[105][105];
int main()
{
	cin >> H >> W;
	for(int i = 1; i <= H;i++)
		for(int j = 1; j <= W; j++){
			cin >> C[i][j];
		}
	for(int i = 1;i <= H;i++){
		for(int k = 1; k <= 2;k++){
			for(int j = 1;j < W;j++){
				cout << C[i][j];
			}cout << C[i][W] << endl;
		}
	}
	return 0;
}

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

int main() {
	
	int a, b, c;
	cin >> a >> b;
	
	c = max(max(a+b, a-b), a*b);
	cout << c;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001;
#define LLINF 1001001001001001001001;
#define LL long long

int main(){
    int N,M,X;int A[102];
    scanf("%d %d %d",&N,&M,&X);
    int zero_ans=0;int N_ans=0;
    rep(i,M){
        scanf("%d",&A[i]);
        if(A[i]<X)zero_ans++;
        if(A[i]>X)N_ans++;
    }
    printf("%d\n",min(zero_ans,N_ans));
    
}

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

int main() {
    int N,X,D = 0;
    cin >> N >> X;
    int count = 1;
    for (int i = 0; i < N;i = i + 1) {
        int L;
        cin >> L;
        D = D + L;
        if (D > X) {
            break;
        }
        count = count + 1;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    vector <ll> A(T);
    for (int t=0; t<T; t++)
    {
	cin>>A[t];
    }
    sort(A.begin(),A.end(),greater<int>());
    int i=1;
    int kiek=T-2;
    ll ats=A[0];
    while (kiek>0) {
		if (kiek==1) {ats+=A[i];kiek--;}
		else {
			ats+=2*A[i];i++;kiek-=2;
			}
		}
	cout<<ats<<endl;
    return 0;
}


Measured memory_bytes: 4776
use proconio::{input, marker::Chars};
use std::collections::HashMap;

const MOD: usize = 1_000_000_007;

fn main() {
    input! {
        _n: usize,
        s: Chars,
    }

    let mut ans = 1;

    let mut map = HashMap::new();
    for c in s {
        *map.entry(c).or_insert(0) += 1;
    }

    for (_, val) in map {
        
        ans *= val+1;
        ans %= MOD;
    }

    ans += MOD;
    ans -= 1;
    ans %= MOD;

    println!("{}", ans);
}


Measured memory_bytes: 2492
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

#define MOD 1000000007LL

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

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

    int n,m;
    cin>>n>>m;
    vector<int> s(n+1),t(m+1);
    vector<vector<ll>> dp(n+1,vector<ll>(m+1));
    for(int i=1; i<=n; i++) cin>>s[i];
    for(int i=1; i<=m; i++) cin>>t[i];

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
            if(s[i]==t[j]) dp[i][j]=(dp[i][j]+1)%MOD;
            else dp[i][j]=(dp[i][j]-dp[i-1][j-1]+MOD)%MOD;
        }
    }
    cout<<(dp[n][m]+1)%MOD;

    return 0;
}


Measured memory_bytes: 31616
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll n, q; cin >> n >> q;
    string s; cin >> s;
    vc ts(q), ds(q); REP(i, q) cin >> ts[i] >> ds[i];
    s = "0" + s + "0";
    ll l = 1, r = n;
    for(ll i = q-1; i>=0; i--){
        if(ts[i] == s[l] && ds[i] == 'L'){
            l = min(l+1, n+1);
        }
        else if(ts[i] == s[l-1] && ds[i] == 'R'){
            l = max(l-1, 1ll);
        }
        if(ts[i] == s[r] && ds[i] == 'R'){
            r = max(r-1, 0ll);
        }
        if(ts[i] == s[r+1] && ds[i] == 'L'){
            r = min(r+1, n);
        }
    }
    
    ll ans = n - (l - 1 + (n - r));
    cout << max(min(n,  ans), 0ll) << endstr;
    return 0;
}


Measured memory_bytes: 1156