akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    ios::sync_with_stdio(false);
    
    int n, x;    
    cin >> n;

    vector<PI> v;
    FOR(i, n){
        cin >> x;
        v.push_back({x, i+1});
    }

    sort(ALL(v));
    for(PI p:v){
        cout << p.second << " ";
    }

    return 0;
}



Measured memory_bytes: 1780
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll L,R;
  cin >> L >> R;
  ll width = R - L + 1;
  ll r_mod = R % 2019;
  ll l_mod = L % 2019;

  if(width >= 2019 || l_mod > r_mod)cout << 0 << endl;
  else{
    ll ans = 2019;
    for(ll i = l_mod;i < r_mod;i++){
      for(ll j = l_mod + 1;j <= r_mod;j++){
        if((i * j) % 2019 < ans)ans = (i * j) % 2019;
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> rode(n);  

  for(int i=0; i<m; i++){
    int t1, t2;
    cin >> t1 >> t2;
    rode.at(t1-1)++;
    rode.at(t2-1)++;
  }
  
  for(int i=0; i<n; i++){
    cout << rode.at(i) << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
  ll a,b;
  cin>>a;
  ll ans =(a/500)*1000+((a%500)/5)*5;
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N,t[100010],x[100010],y[100010];
	cin >> N;
	t[0] = 0; x[0] = 0; y[0] = 0;
	bool flag = true;
	for(int i=1; i<=N; i++){
		cin >> t[i] >> x[i] >> y[i];
		if(t[i] - t[i-1] < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
			flag = false;
		if((t[i] - t[i-1] - abs(x[i] - x[i-1]) - abs(y[i] - y[i-1])) % 2 != 0)
			flag = false;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int N;
string ss;
string x()
{
	string ans;
	int X;
	string y;
	int Z=0;
	while(Z<ss.length()){
		string r;
		X=1;
		y=ss[Z];
		while(Z<ss.length()-1&&ss[Z]==ss[Z+1]){
			X++;
			Z++;
		}
		while(X>0){
			r+=(X%10+'0');
			X/=10;
		}
		for(int i=0;i<r.length();i++)ans+=r[r.length()-1-i];
		ans+=y;
		Z++;
	}
	return ans;
}
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)break;
		cin >> ss;
		for(int i=0;i<N;i++){
			ss=x();
		}
		cout << ss << "\n";
	}
	return 0;
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3];
  FOR(i,3) cin>>a[i];
  sort(a,a+3,greater<int>() );
  cout<<a[0]*10+a[1]+a[2]<<endl;
  return 0;
}



Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
temp=[0]*n
temp[n-2]=abs(arr[n-2]-arr[n-1])
if n>=3:
    i=n-3
    while i>=0:
        temp[i]=min(abs(arr[i+1]-arr[i])+temp[i+1],abs(arr[i+2]-arr[i])+temp[i+2])
        i-=1
print(temp[0])

Measured memory_bytes: 13800
import java.util.Scanner;
public class Main{

	public static void main(String[] args){
		//writeInput();
		solve();
		}

	public static void solve(){
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());

		boolean[] isFrom1 = new boolean[N];
		boolean[] isFromN = new boolean[N];

		for(int i = 0;i<M;i++){
			int ai = Integer.parseInt(sc.next());
			int bi = Integer.parseInt(sc.next());
			if(ai==1){
				isFrom1[bi]=true;
			}
			if(bi==N){
				isFromN[ai]=true;
			}
		}
		//System.out.println(M);
		boolean routeExists =false;for(int i=0;i<N;i++)routeExists|=(isFrom1[i]&&isFromN[i]);
		answer(routeExists);
		sc.close();

	}

	public static void answer(boolean b){
		String yes =new String("POSSIBLE");
		String no =new String("IMPOSSIBLE");
		System.out.println(b?yes:no);
	}


/*	public static void writeInput(){
		try{
			File file = new File("c:\\Users\\jugem\\Documents\\pleiades\\input.dat");
			if (checkBeforeWritefile(file)){
				PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
				pw.println("5 5");
				pw.println("1 3");
				pw.println("2 3");
				pw.println("2 4");
				pw.println("4 5");
				pw.println("1 4");
				pw.close();
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}

	public static boolean checkBeforeWritefile(File f){
		return f.exists()?(f.isFile()&&f.canWrite()):false;
	}
*/
}


Measured memory_bytes: 65472
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long X;
        X = sc.nextLong();
        solve(X);
    }

    static void solve(long X){
        long a = X % 500;
        long ans = X / 500 * 1000;
        ans += a /5 * 5;
        System.out.println(ans);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


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

int main()
{
        int a, b;
        char op;

        do{
                cin >> a >> op >> b;
                if( op == '?' ){break;}

                switch(op){
                case '+' : cout << a+b << endl; break;
                case '-' : cout << a-b << endl; break;
                case '/' : cout << a/b << endl; break;
                case '*' : cout << a*b << endl; break;
                }
        }while(1);

        return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>

#define MAX 10000

int sosu(int [],int);

int main(void){

  int A[MAX];
  int i;
  int count;
  int result;
  
  scanf("%d",&count);
  for(i=0;i<count;i++)
    scanf("%d",&A[i]);
  
  result = sosu(A,count);

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

int sosu(int A[],int count){

  int i,j;
  int flag;
  int n=0;


  for(i=0;i<count;i++){
    flag=0;
    for(j=2;j<=sqrt(A[i]);j++){
      if(A[i] % j == 0){
	flag++;
	break;
      }
    }
    
    if(flag==0)
      n++;
  }
  
  return n;
}

Measured memory_bytes: 628
// t-rex is saying he's better than ever because when he was down south he got a rejuvenating mineral bath and is determined to believe that it was worth it, did you know that all this backstory and more goes into every code only to be ruthlessly cut
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;}
template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;}
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n, 0);
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        a[x]++;
        a[y]++;
    }
    rep(i, 0, n) {
        if (a[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
   
    ll n,k,i,j,ans=0;;
    cin>>n>>k;
    vector<ll> h(n);
    f(i,0,n)
        cin>>h[i];
    sort(rall(h));
    f(i,k,n)
    {
        ans+=h[i];
    }
    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int alice = in.nextInt();
            int bob = in.nextInt();
            if (alice == 1) alice = 14;
            if (bob == 1) bob = 14;

            if (alice == bob) {
                out.println("Draw");
            } else if (alice > bob) {
                out.println("Alice");
            } else {
                out.println("Bob");
            }
        }

    }
}



Measured memory_bytes: 22996
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main()
{
	double  x1,y1,x2,y2;
	cin >> x1>>y1>>x2>>y2;
	printf("%.9lf", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));

	return 0;
}

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


int main(){
  
  
  long long x;
  cin>>x;
  int flag = 0;
  int A,B;
  for(int i=-200 ;i<=200;i++){
   for(int j=-200;j<=200;j++){
    long long a=i,b=j;
	A = a;
	B = b;
     for(int k=1;k<=4;k++){
      a = a*i;
       b = b*j;
     }
	 //A =a;
	 //B = b;
     if(a - b == x){
      cout<<A<<" "<<B<<endl;
       return 0;
     }
   }
  }
  //cout<<A<<" "<<B<<endl;
  
  
  
  
 //return 0; 
  
  
}

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

int main() {
int n,m;
cin >> n >> m;
int likes[n][m];
int k[n];
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        likes[i][j]=40;
    }
}
for(int i=0;i<n;i++){
    cin >> k[i];
    for(int j=0;j<k[i];j++){
        cin >> likes[i][j];
    }
}
int cnt[40];
for(int i=0;i<40;i++){
    cnt[i]=0;
}
for(int i=0;i<n;i++){
    for(int j=0;j<k[i];j++){
        cnt[likes[i][j]-1]++;
    }
}
int ans=0;
for(int i=0;i<m;i++){
    if(cnt[i]==n)ans++;
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, vi, ans = 0;
  bool flg;
  string s, v(3,'0');
  cin >> n >> s;
  for (int i = 0; i < 1000;i++){
    v[0] = i / 100 + '0';
    v[1] = i % 100 / 10 + '0';
    v[2] = i % 10 + '0';
    vi = 0;
    flg = false;
    for (int j = 0; j < n;j++){
      if(s[j]==v[vi]){
        vi++;
        if(vi>=3){
          flg = true;
          break;
        }
      }
    }
    if(flg){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i32>();
  let a = read::<i32>();
  let b = read::<i32>();

  println!("{}", min(b, a * n));
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
         
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        for (h = 2; h < H; h++) {
            putchar('#');
            for (w = 2; w < W; w++) putchar('.');
            putchar('#');
            putchar('\n');
        }
 
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2128
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))

lis = sorted(a)
high_med = lis[int(n/2)]
low_med = lis[int(n/2-1)]
if high_med == low_med:
    for _ in range(n):
        print(high_med)
else:
    for v in a:
        if v < high_med:
            print(high_med)
        else:
            print(low_med)

Measured memory_bytes: 26016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = (A % 2) * B * C;
    ans = min(ans, (B % 2) * A * C);
    ans = min(ans, (C % 2) * A * B);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}


int main(){
    ll n,x,t;cin >> n >> x >> t;
    cout << (n+x-1)/x*t <<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> f(26, 50);
	for(int i = 0; i < n; i++){
		string s;
		cin>>s;
		vector<int> g(26, 0);
		for(auto ch : s){
			g[ch - 'a']++;
		}
		for(int i = 0; i < 26; i++){
			f[i] = min(f[i], g[i]);
		}
	}
	for(int i = 0; i < 26; i++){
		for(int j = 0; j < f[i]; j++){
			cout<<char(i + 'a');
		}
	}
	cout<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#define long long long
#define LF '\n'
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

priority_queue<int> pq[1005];


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

  int n, q;
  cin >> n >> q;

  while(q--) {
    int com, t, x;
    cin >> com;

    if (com == 0) {
      cin >> t >> x;
      pq[t].emplace(x);
    }
    else if (com == 1) {
      cin >> t;
      if(pq[t].size()) cout << pq[t].top() << LF;
    }
    else {
      cin >> t;
      if(pq[t].size()) pq[t].pop();
    }
  }

  return 0;
}




Measured memory_bytes: 4088
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
d = { }
s = 0
for i in a:
	if i not in d:
		d[i] = 0
	d[i] += 1
	s += i
while q:
	q -= 1
	b, c = map(int, input().split())
	if b in d:
		if c not in d:
			d[c] = 0
		s += (c - b) * d[b]
		d[c] += d[b]
		del d[b]
	print(s)



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec p(n);
    init(p);
    sort(all(p), greater<int>());
    p[0] /= 2;
    print(sum_(p));

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        String S = scn.next();
        String T = scn.next();

        int countOp = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != T.charAt(i)) {
                countOp++;
            }
        }
        System.out.println(countOp);

    }
}


Measured memory_bytes: 41224
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 510, M = N * N;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int n, p[M], dis[N][N], vis[N][N];
ll ans;
deque<pii> que;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n * n; ++i) read(p[i]);
	for (R int i = 1; i <= n; ++i)
		for (R int j = 1; j <= n; ++j)
			dis[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
	for (R int i = 1; i <= n * n; ++i) {
		int y = (p[i] - 1) / n + 1, x = (p[i] - 1) % n + 1;
		ans += dis[y][x], vis[y][x] = 1;
		que.emplace_back(y, x);
		while (que.size()) {
			y = que.front().first, x = que.front().second;
			que.pop_front();
			for (R int j = 0; j <= 3; ++j) {
				int ny = y + dy[j], nx = x + dx[j], w = !vis[y][x];
				if (dis[ny][nx] > dis[y][x] + w) {
					dis[ny][nx] = dis[y][x] + w;
					w ? que.emplace_back(ny, nx) : que.emplace_front(ny, nx);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7616
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	string s; cin >> s;
	int mi = sqrt(INF),cnt=0;
	rep(i, 0, s.size()) {
		if (i % 2) {
			if (s[i] == '0') cnt++;
		}
		else {
			if (s[i] == '1') cnt++;
		}
	}
	mi = min({ mi, cnt,(int)s.size() - cnt });
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
const ll mod =1e18 + 7;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
int main(){
	fast;
	int n;
	cin >> n;
	map< int , int > mp;
	ll ans = 0;
	for(int i = 1, x ; i <= n ; i++){
		cin >> x;
		ans += mp[i - x];
		mp[x+i]++;
	}			
	cout << ans << endl;																																																							
	return 0;
}


Measured memory_bytes: 20664
#include<iostream>

using namespace std;

const int MAX = 7368793;

int sieve[MAX];

int n, m;

int main () {
    for (int i = 0; i < MAX; ++i) {
        sieve[i] = -1;
    }
    for (int i = 2; i < MAX; ++i) {
        if(sieve[i] == -1) {
            sieve[i] = i;
            for(int k = i + i; k < MAX; k += i) {
                if (sieve[k] == -1) sieve[k] = i;
            }
        } else {
            sieve[i] = i / sieve[i];
        }
        //for(int k = i + i; k < MAX; k += i) {
        //    sieve[k] = i;
        //}
    }

    //for (int i = 0; i < MAX; ++i) {
    //    cout << sieve[i] << " ";
    //}
    //cout << endl;

    while (1) {
        cin >> m >> n;
        if (m * n == 0) break;
        int i;
        for (i = m; i < MAX && n > 0; ++i) {
            if (!(m <= sieve[i] && sieve[i] < i)) {
                n--;
            }
        }
        while (m <= sieve[i] && sieve[i] < i) i++;
        cout << i << endl;
    }
}

Measured memory_bytes: 31864
#include <iostream>
#include <string>

int main()
{
    std::size_t N;
    std::string S;
    std::cin >> N;
    std::cin >> S;

    std::size_t nR = 0;
    std::size_t nG = 0;
    std::size_t nB = 0;
    for(const char c: S)
    {
        switch(c)
        {
            case 'R': {nR += 1; break;}
            case 'G': {nG += 1; break;}
            case 'B': {nB += 1; break;}
            default: {break;}
        }
    }

    if(N < 3) {std::cout << 0 << std::endl; return 0;}

    std::size_t A = 0;

    for(std::size_t i=0; i<N-3; ++i)
    {
        bool is_R = true;
        bool is_G = true;
        bool is_B = true;

        if     (S[i] == 'R') {nR -= 1; is_R = false;}
        else if(S[i] == 'G') {nG -= 1; is_G = false;}
        else if(S[i] == 'B') {nB -= 1; is_B = false;}

        std::size_t mR = nR;
        std::size_t mG = nG;
        std::size_t mB = nB;
        for(std::size_t j=i+1; j<N-1; ++j)
        {
            bool is_R_ = is_R;
            bool is_G_ = is_G;
            bool is_B_ = is_B;

            if     (S[j] == 'R') {mR -= 1; is_R_ = false;}
            else if(S[j] == 'G') {mG -= 1; is_G_ = false;}
            else if(S[j] == 'B') {mB -= 1; is_B_ = false;}

            if(S[i] == S[j]) {continue;}

            if     (is_R_) {A += mR; if(S[j+j-i] == 'R'){A -= 1;}}
            else if(is_G_) {A += mG; if(S[j+j-i] == 'G'){A -= 1;}}
            else if(is_B_) {A += mB; if(S[j+j-i] == 'B'){A -= 1;}}
        }
    }

    std::cout << A << std::endl;

    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
	  Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] rank = new int[n+1];
      int[] parent = new int[n+1];
      
      for(int i= 0; i<=n; i++){
        rank[i] = 1;
        parent[i] = i;
      }
      
      int res = 0;
      for(int i=0; i<m; i++){
          int u = sc.nextInt();
          int v = sc.nextInt();	
          union(u, v, rank, parent);
      }
      for(int curRank : rank) res = Math.max(res, curRank);
      System.out.println(res);
	}
  public static int find(int u, int[] parent){
    if(u != parent[u]){
      parent[u] = find(parent[u], parent);
    }
    return parent[u];
  }
  
  public static void union(int u, int v, int[] rank, int[] parent){
    int parU = find(u, parent);
    int parV = find(v, parent);
    if(parV == parU) return;
    if(rank[parV] > rank[parU]){
      rank[parV] += rank[parU];
      parent[parU] = parV;
      return;
    }
    rank[parU] += rank[parV];
    parent[parV] = parU;
    return;
  }
}

Measured memory_bytes: 61696
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1000010;
const long long mod = 1e9 + 7;
ll A[maxn];	//A[i]表示i的阶乘
ll B[maxn];	//B[i]表示i的阶乘关于mod的逆元
using namespace std;

ll pow_mod(ll a, ll b)
{
	ll ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a%mod;
		b >>= 1;
		a = a * a%mod;
	}
	return ret;
}

void Init()
{
	A[0] = 1;
	for (int i = 1; i <= maxn; i++)
		A[i] = (A[i - 1] * i) % mod;
	for (int i = maxn; i >= 0; i--)
		B[i] = pow_mod(A[i], mod - 2);
}

ll C(ll n, ll m) {
	if (n < m)
		return 0;
	return (A[n] * B[m] % mod)*B[n - m] % mod;
}

ll count_ways(ll a, ll b, ll c, ll d) {
	ll tot = (c - a) + (d - b);
	ll down = (c - a);
	ll ret = C(tot, down);
	return ret;
}

int main()
{
	Init();
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	ll tot = count_ways(1, 1, h, w);
	for (ll i = 1; i <= b; i++) {
		ll tmp = count_ways(1, 1, h - a, i)*count_ways(h - a + 1, i, h, w) % mod;
		while (tot < tmp) tot += mod;//防止出现负数
		tot = (tot - tmp) % mod;
	}
	cout << tot;
	return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i <= 32; i++) {
		if (pow(k, i) > n) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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;
}

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    vector<vector<int>> dist(N, vector<int>(N, -1));
    for (int s = 0; s < N; ++s)
    {
        queue<int> que;
        que.push(s);
        dist[s][s] = 0;
        while (!que.empty())
        {
            auto v = que.front();
            que.pop();
            vector<int> nvs;
            if (v > 0) nvs.push_back(v - 1);
            if (v < N - 1) nvs.push_back(v + 1);
            if (v == X) nvs.push_back(Y);
            if (v == Y) nvs.push_back(X);
            for (auto nv : nvs)
            {
                if (dist[s][nv] == -1)
                {
                    dist[s][nv] = dist[s][v] + 1;
                    que.push(nv);
                }
            }
        }
    }
    vector<int> res(N, 0);
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j) res[dist[i][j]]++;
    }
    for (int d = 1; d < N; ++d) cout << res[d] << endl;

    return 0;
}


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

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


int main(){
    int n,m;
    cin>>n>>m;
    vector<int> seen(n);
    cout<<1<<" "<<2<<endl;
    int a = 3,b = n;
    rep(i,(m-1)/2){
        cout<<a<<" "<<b<<endl;
        a++;b--;
    }
    if((b-a)%2) b--;
    rep(i,m/2){
        cout<<a<<" "<<b<<endl;
        a++;b--;
    }
    return 0;
}

Measured memory_bytes: 3832
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();
	        char[] c = S.toCharArray();	        
	        int cntp=0;
	        int cntg=0;
	        for(int i=0;i<c.length;i++) {
	        	if(c[i]=='p') {
	        		cntp++;
	        	} else {
	        		cntg++;
	        	}
	        }
	        int ans=cntg-cntp;
	        System.out.println(ans/2);
	    }
	}

Measured memory_bytes: 27860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1000000007;

int main() {
  char a, b;
  cin >> a >> b;
  char ans;
  if(a == 'H') {
    ans = b == 'H' ? 'H' : 'D' ;
  } else {
    ans = b == 'H' ? 'D' : 'H' ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string W = Console.ReadLine().ToUpper();
        int count = 0;
        while (true)
        {
            string[] data = Console.ReadLine().Split(' ');
            if (data[0] == "END_OF_TEXT") break;
            for (int i = 0, datacount = data.Length; i < datacount; i++)
            {
                if (data[i].ToUpper() == W)
                {
                    count++;
                }
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 5580
class WeightedUnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.diff_weight = [0 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        root = self.find(self.par[x])
        self.diff_weight[x] += self.diff_weight[self.par[x]]
        self.par[x] = root
        return self.par[x]

    def weight(self, x):
        self.find(x)
        return self.diff_weight[x]

    def diff(self, x, y):
        return self.weight(y)-self.weight(x)

    def unite(self, x, y, w):
        # y の root をくっつけるので。
        w += self.weight(x); w -= self.weight(y)
        x = self.find(x); y = self.find(y)
        if x == y:
            return False
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            w = -w
            self.diff_weight[x] = w
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
            self.diff_weight[y] = w
        else:
            self.par[y] = x
            self.diff_weight[y] = w
            self.rank[x] += 1
        return True

N, M = map(int, input().split())
wuf = WeightedUnionFind(N)
for i in range(M):
    l, r, d = map(int, input().split())
    l-=1;r-=1
    if wuf.find(l) == wuf.find(r):
        if wuf.diff(l, r) != d:
            print('No')
            break
    wuf.unite(l, r, d)
else:
    print('Yes')


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

int main()
{
	int d, n, x, k;
	cin >> d >> n;
	x = 1;
	if (n <= 99) {
		for (int i = 0; i < d; i++)
			x *= 100;
		k = x;
		for (int i = 1; i < n; i++)
			x += k;
	}
	else {
		for (int i = 0; i < d; i++)
			x *= 100;
		k = x;
		for (int i = 1; i <= n; i++)
			x += k;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n;
  long int p = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    p *= i;
    p %= long(1e9 + 7);
  }
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var minC, maxC int
	var ans int64
	parts := make([][]int, 3)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	for i := range parts {
		parts[i] = make([]int, n)
		for j := range parts[i] {
			sc.Scan()
			parts[i][j], _ = strconv.Atoi(sc.Text())
		}
		sort.Ints(parts[i])
	}
	for _, p := range parts[1] {
		minC = sort.SearchInts(parts[0], p)
		maxC = n - sort.SearchInts(parts[2], p+1)
		ans += int64(minC * maxC)
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int a,b;
    cin >> a >> b;
    if(a>=0) {
        cout << "Positive" << endl;
        return 0;
    }
    if(b<0) {
        int ans = abs(a)-abs(b)+1;
        if(ans%2==0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
        return 0;
    }
    cout << "Zero" << endl;
  return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ctype.h>
#include <string>
using namespace std;
 
 
int main(){
    int N,S=0,a;
    cin>>N;
    a=N;
    while(a>0){
        S+=a%10;
        a/=10;
    }
    if(N%S==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,p;
    cin>>n>>a>>b;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>p;
        deq.emplace_back(p);
    }
    sort(deq.begin(),deq.end());
    int count1=0,count2=0,count3=0;
    for (int i=0;i<n;i++) {
        if (deq[i]<=a) {
            count1++;
        }
    }
    for (int i=0;i<n;i++) {
        if (deq[i]>=a+1&&deq[i]<=b) {
            count2++;
        }
    }
    for (int i=0;i<n;i++) {
        if (deq[i]>=b+1) {
            count3++;
        }
    }
    cout<<min(count1,min(count2,count3))<<endl;
}

Measured memory_bytes: 3612
def main():
    n = int(input())
    h = list(map(int,input().split()))
    dp = [0] * (n + 1)
    dp[1] = abs(h[1]-h[0])
    for i in range(2,n):
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))
    print(dp[n-1])

if __name__=='__main__':
    main()


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

int N; string S;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin>> N >> S;
    for (int i = 0; i < S.size(); i++) {
        S[i] = ((S[i]-'A')+N)%('Z'-'A'+1)+'A';
    }
    cout << S << '\n';
    return 0;
}

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

using namespace std;

char initials[] = { 'M','A','R','C','H' };
int pattern[3] = { -1,-1,-1 };
map<char, int> list;
long long ans = 0;

void calc(int now, int remain) {
	if (remain < 0) {
		ans += (long long)list[initials[pattern[0]]] * list[initials[pattern[1]]] * list[initials[pattern[2]]];
	}
	
	else if(now >= 0){
		//now番目を入れる
		pattern[remain] = now;
		calc(now - 1, remain - 1);
		//now番目を入れない
		calc(now - 1, remain);
	}
}

int main() {
	int N;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		string str;
		cin >> str;
		list[str[0]]++;
	}

	calc(4, 2);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <set>
#include <map>
#include <queue>
//#include <priority_queue>
#define N 500005
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m, cnt;
vector<pair<int, int>> edges[N];
int dis[N];
bool vis[N];
int solve(int s, int t) {
  for (int i = 1; i <= cnt; ++i) {
    dis[i] = 1000000000;
  }
  memset(vis, false, sizeof(vis));
  dis[s] = 0;
  vis[s] = true;
  priority_queue<pii, vector<pii>, greater<pii>> q;
  q.push(make_pair(0, s));
  while(!q.empty()) {
    auto top = q.top();
    q.pop();
    int u = top.second;
    int d = top.first;
    if (dis[u]<d) continue;
    if (u == t) continue;
    for (int i = 0; i < edges[u].size(); ++i) {
      int v = edges[u][i].first;
      int d2 = edges[u][i].second;
      if (dis[v] > dis[u]+d2) {
        dis[v] = dis[u]+d2;
        q.push(make_pair(dis[v], v));
      }
    }
  }
  return (dis[t] >= 1000000000 ? -1 : dis[t]/2);
}
int main() {
  scanf("%d%d", &n, &m);
  cnt=n;
  map<pair<int, int>, int> mp;
  mp.clear();
  for (int i = 0; i < m; ++i) {
    int p,q,c;
    scanf("%d%d%d", &p, &q, &c);
    int p1 = ((mp.find(make_pair(p, c)) == mp.end()) ? ++cnt : mp[make_pair(p, c)]);
    int q1 = ((mp.find(make_pair(q, c)) == mp.end()) ? ++cnt : mp[make_pair(q, c)]);
    mp[make_pair(p, c)] = p1;
    mp[make_pair(q, c)] = q1;
    edges[p].push_back(make_pair(p1, 1));
    edges[p1].push_back(make_pair(p, 1));
    edges[p1].push_back(make_pair(q1, 0));
    edges[q1].push_back(make_pair(p1, 0));
    edges[q].push_back(make_pair(q1, 1));
    edges[q1].push_back(make_pair(q, 1));
  }
  cout<<solve(1, n)<<endl;
  return 0;
}


Measured memory_bytes: 58620
from bisect import bisect_right as br
from itertools import accumulate as ac
n,m,k=map(int,input().split())
a=list(ac([0]+list(map(int,input().split()))))
b=list(ac([0]+list(map(int,input().split()))))
l=0
for i in range(n+1):
    if k<a[i]:
        break
    else:
        l=max(l,i+br(b,k-a[i])-1)
print(l)

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

int a[5][4][11];
int main()
{
    ios::sync_with_stdio(false);
    int a1,a2,a3,a4,n;
    cin>>n;
    memset(a,0,sizeof a);
    for(int i=0;i<n;i++){
        cin>>a1>>a2>>a3>>a4;
        a[a1][a2][a3]+=a4;
    }
    for(int i=1;i<5;i++){
        for(int j=1;j<4;j++){
            for(int k=1;k<11;k++)
                cout<<" "<<a[i][j][k];
            cout<<endl;
        }
        if(i!=4) cout<<"####################"<<endl;
    }
    return 0;
}



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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();


        ll n;
        cin>> n;

        ll a[n], mx[n], mn[n];

        for(ll i=0; i<n; i++)
            cin>> a[i];

            if(n==2)
            {
                cout<< max(a[0], a[1]);
                nl;
                return 0;

            }


        ll c=0;

        mx[0] = a[0];
        mn[n- 1] = a[n- 1];

        for (ll i = 1; i< n; i++)
            mx[i] = __gcd (mx[i- 1], a[i]);


        for (ll i = n- 2; i>= 0; i--)
            mn[i] = __gcd(mn[i + 1], a[i]);

            ll t, res= 1;
            res= max(mx[n-2], mn[1]);


        for(ll i=1; i<n; i++)
        {

            t= __gcd(mn[i], mx[i-2]);
            //t= max(t, __gcd(t, a[i]));
            res= max(t, res);
        }

        cout<< res;
        nl;


    return 0;
}




Measured memory_bytes: 5968
using System;
using System.Linq;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());

        int[] houses = AIU(Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));

        Array.Sort(houses);

        Console.WriteLine(houses[houses.Length - 1] - houses[0]);
    }

    static int[] AIU(string[] str)
    {
        int[] temp = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            temp[i] = int.Parse(str[i]);
        }

        return temp;
    }

}

Measured memory_bytes: 27328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,x,y,r;
  cin>>a>>b;
  x=a;
  y=b;
  if(x>y) swap(x,y);
  r=y%x;
  while(r>0){
    y=x;
    x=r;
    r=y%x;
  }
  cout<<a*b/x;
}

Measured memory_bytes: 3584
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

N,X=MI()
L=LI()
ans = 1
a=0
for i in range(N):
    a+=L[i]
    if a<=X:
        ans+=1
print(ans)

Measured memory_bytes: 3316
from collections import deque
K = int(input())

Current = [1, 2, 3, 4, 5, 6, 7, 8, 9]
while 1:
    Next = deque([])
    cnt = len(Current) 
    if K <= cnt:
        #現在の桁の中で考える
        ans = Current[K - 1]
        break
    else:   #K > cnt
        #次の桁を考える
        for i in Current:
            key = i % 10
            for j in [key - 1, key, key + 1]:
                if 0 <= j and j <= 9:
                    Next.append(i * 10 + j)
                else: #j < 0 or 9 < j
                    pass
        K -= cnt
        Current = Next


print(ans)


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

int N;
vector<int> M, L;
vector<int> dating;

int main () {
    while (true) {
        cin >> N;
        if (N == 0) {
            break;
        }

        M.resize(N);
        L.resize(N);
        dating.resize(N);

        for (int j = 0; j < N; ++j) {
            cin >> M[j] >> L[j];
            dating[j] = 0;
            for (int k = 0; k < M[j]; ++k) {
                int a, b;
                cin >> a >> b;
                for (int t = a-6; t < b-6; ++t) {
                    dating[j] |= (1 << t);
                }
            }
        }

        vector<long long> dp = vector<long long>(1 << 16, 0LL);
        int ret = 0;

        for (int b = 1; b <= 16; ++b) {
            for (int j = 0; j < (1 << 16); ++j) {
                int bit_count = 0, t = j;
                while (t > 0) {
                    bit_count += t % 2;
                    t >>= 1;
                }
                if (bit_count != b) continue;

                for (int k = 0; k < 16; ++k) {
                    if (j & (1 << k)) {
                        dp[j] = max(dp[j], dp[j ^ (1 << k)]);
                    }
                }

                for (int k = 0; k < N; ++k) {
                    if ((j | dating[k]) == j) {
                        dp[j] = max(dp[j], dp[j ^ dating[k]] + L[k]);
                    }
                }

            }
        }

        cout << dp[(1 << 16) - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{int n;
 double a,m;
	cin>>n;
	if(n%2==0&&n>=1&&n<=100)
{	
	cout<<setiosflags(ios::fixed)<<setprecision(10);
	cout<<(n-(n/2.0))/n<<endl;
	}
	else if(n>=1&&n<=100)
{
	m=(n/2)+1;
	cout<<setiosflags(ios::fixed)<<setprecision(10);
	a=m*1.0/n;
	cout<<a<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  ll ans = 0;
  ll mx = 0;
  rep(i, n) {
    ans += max(mx-A[i], 0LL);
    chmax(mx, A[i]);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 4780