akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 2e5 + 5;
int n,a[MAXN],ans,t;

inline bool cmp(int x,int y){
    return x > y;
}

int main(){
    scanf("%d",&n);
    FOR(i,1,n) scanf("%d",a+i);
    std::sort(a+1,a+n+1,cmp);
    for(;a[t]>=t;t++);t--;
    if(!((a[t]-t)%2)){
        int j = 0;
        for(;a[t+j]>=t;j++);
        if(j & 1){
            puts("Second");return 0;
        }
    }
    puts("First");
    return 0;
}

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

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int sum = 0, tmp1 = 0, tmp2 = 0;

    if (a > b){
        tmp1 = b;
    } else {
        tmp1 = a;
    }

    if (c > d){
        tmp2 = d;
    } else {
        tmp2 = c;
    }

    if (tmp1 > tmp2){
        tmp1 = tmp2;
    } else {
    }
    
    sum += a + b + c + d;
    sum -= tmp1;

    if(e > f){
        sum += e;
    } else {
        sum += f;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a==b){
		if(c==d){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}else if(a==c){
		if(b==d){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}else if(a==d){
		if(b==c){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}else{
		cout << "no" << endl;
	}
}
		


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int l[105];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	sort(l,l+n);
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(l[i]==l[j])continue;
			for(int k=j+1;k<n;k++){
				if(l[j]==l[k])continue;
				if(l[i]+l[j]>l[k]){
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i += 2) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}


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

using namespace std;

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

	// bool strong = true;
	for (int i = 1; i < S.size(); i++)
		if (S[i - 1] == S[i]) { cout << "Bad"; return 0;}
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  string S;
  IN(S);
  if(S =="SUN") OUT(7);
  else if(S =="MON") OUT(6);
  else if(S =="TUE") OUT(5);
  else if(S =="WED") OUT(4);
  else if(S =="THU") OUT(3);
  else if(S =="FRI") OUT(2);
  else if(S =="SAT") OUT(1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 256
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const int INF = 2e9 ;
int n, m, u, v;
vector<int > g[N];
vector<int > topo;
int vis[N];

void dfs(int x){
    vis[x] = 1;
    for(int u : g[x]){
        if(!vis[u]) dfs(u);
    }
    topo.pb(x);
}

int main(){
    cin >> n >> m;
    for(int i=1;i<=m;i++) {
        cin >> u >> v ;
        g[u].pb(v);
    }
    memset(vis, 0, sizeof(vis));
    for(int i=1;i<=n;i++){
        if(!vis[i]) {
            dfs(i);
        }
    }
    reverse(topo.begin(), topo.end());
    int d[n + 4] = {0}, par[n + 4] = {0};
    for(int i=1;i<=n;i++) d[i] = -INF; 
    d[topo[0]] = 0;
    for(int x : topo){
        if(d[x] == -INF) d[x] = 0;
        for(int u : g[x]) {
            if(d[u] < d[x] + 1) {
                d[u] = d[x] + 1;
                par[u] = x ;
            }
        }
    }
    int mx = 0, end = 0;
    for(int i=1;i<=n;i++){
        // mx = max(mx, d[i]);
        if(mx < d[i]){
            mx = d[i];
            end = i;
        }
    }
    cout << mx << '\n';
    // cout << "Longest Path = " ;
    // do{
    //     cout << end << ", ";
    //     end = par[end]; 
    // }while(par[end]);
    // cout << end << '\n';
    return 0;
}
 

// https://atcoder.jp/contests/dp/tasks






// // // // https://codeforces.com/problemset/problem/474/E
// // // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // // https://codeforces.com/contest/475/problem/D


// // https://www.spoj.com/problems/INS17M/
// // https://www.codechef.com/SEPT18B/problems/ANDSQR
// // 


// int d[] = {1, 2, 2, 4, 5, 10, 15, 28, 45, 79, 129, 218, 356, 589, 959, 1569, 2548, 4145, 6720, 10901, 17656, 28602, 46302, 74959};

// ll C[100][100];

// void pre(){
//   for(int i=0;i<=99;i++) C[i][0] = 1;
//   for(int i=1;i<=99;i++) {
//     for(int j=0;j<=min(99,i);j++){
//       C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod ;
//     }
//   }
// }

// int main() {
//     pre();
//   int x =0, y = 1,z ;
//   for(int i=0;i<=23;i++) {
//     z = x + y ;
//     int p = i;
//     cout << z << ' ' ;
//     x = y ;
//     y = z ;
//   }
//   cout << "\n\n";
//     for(int i=2;i<=24;i++){
//       ll res = 0;
//       for(int j=0;j<=i;j++)
//       {
//         res += C[i][j]*C[i][j];
//         res %= mod;
//         if(j < i) {
//           res += C[i-j-1][j];
//           res %= mod;
//         }
//         res -= C[i+j-1][j];
//         res += mod;
//         res %= mod;
//         if(j < i-1) {
//           res += C[i-j-2][i];
//           res %= mod;
//         }
//       }
//       cout << res<< ' ' ;
//     }
//     cout << '\n';
//   return 0 ;
// }

Measured memory_bytes: 8828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a,b,k;
int ans;
int main(void){
    cin>>a>>b>>k;
    for(int i=100;i>=0;i--){
        if(a%i==0&&b%i==0){
            k--;
        }
        if(k==0){
            cout<<i<<endl;
            return 0;
        }
    }

}



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

int main() {
  int N , M , o = 0, p = 0;
  cin >> N >> M;
  vector<int> a(N);
  for (int i = 0; i < M; i++){
    cin >> o >> p;
    a.at(o - 1) ++;
    a.at(p - 1) ++;
  }
  for (int i = 0; i < N; i++){
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 3624
import java.util.Scanner;

/*
 * @author Tanzim Ibn Patowary
 * Created  Apr 25, 2020 3:55:23 AM
 */
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner mScanner = new Scanner(System.in);
		int number = mScanner.nextInt();
		double pi = 2*Math.PI*number;
		System.out.println(pi);
	}

}


Measured memory_bytes: 27168
#include <stdio.h>

int a[100*1000];
int ans_x[100*1000];
int ans_y[100*1000];
int ans_n = 0;

int main( int argc , char *argv[] )
{
	int n;
	int sum = 0;
	int min = 10001;
	int max = -10001;
	int min_n;
	int max_n;
	int tmp;
	int tmp2;

	int i;

	scanf( "%d\n" , &n );

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

	scanf( "%d\n" , &(a[n-1]) );

	for( i = 0 ; i < n ; i++ ) {
		if( max < a[i] ) {
			max = a[i];
			max_n = i;
		}

		if( min > a[i] ) {
			min = a[i];
			min_n = i;
		}
	}

	if( max_n == min_n ) {
		min = 10001;

		for( i = 0 ; i < n ; i++ ) {
			if( min > a[i] && i != max_n ) {
				min = a[i];
				min_n = i;
			}
		}
	}

	sum = max;
	tmp = max;

	for( i = 0 ; i < n ; i++ ) {
		if( i != max_n && i != min_n && a[i] < 0 ) {
			ans_x[ans_n] = tmp;
			ans_y[ans_n] = a[i];
			ans_n++;
			tmp = tmp - a[i];

			sum -= a[i];
		}
	}

	sum += -min;
	tmp2 = min;

	for( i = 0 ; i < n ; i++ ) {
		if( i != max_n && i != min_n && a[i] >= 0 ) {
			ans_x[ans_n] = tmp2;
			ans_y[ans_n] = a[i];
			ans_n++;
			tmp2 = tmp2 - a[i];

			sum += a[i];
		}
	}

	ans_x[ans_n] = tmp;
	ans_y[ans_n] = tmp2;
	ans_n++;

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

	for( i = 0 ; i < ans_n ; i++ ) {
		printf( "%d %d\n" , ans_x[i] , ans_y[i] );
	}

	return 0;
}


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

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;  //セグ木の幅
  F f;  //モノイドの作用
  T ti;  //初期値
  vector<T> dat;  //セグ木で使う配列 一番上に使われるのがdat[1] 一番下の段の左端がdat[n]
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}  //fがモノイドとしての作用、tiが単位元

  void init(int n_){  //ただの初期化
    n=1;
    while(n<n_) n<<=1;  //nが実際にとる２べきの幅
    dat.assign(n<<1,ti);  //dat配列は幅の２倍あってその全てにtiを代入
  }

  void build(const vector<T> &v){  //vector vに合わせた初期化
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];  //v[i]を一番子の所に代入
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);  //iの子供は2*i、2*i+1
  }

  void set_val(int k,T x){  //（0-indexedで）kにxを代入
    dat[k+=n]=x;
    while(k>>=1)  //kがどんどん自分の親になっていく、0になったらおしまい
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){  //[a,b)の範囲のモノイドの作用を返す
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);  //左端を使いたくなるのはブロックが奇数の時
      if(r&1) vr=f(dat[--r],vr);  //右端〃偶数の時（開区間なのでr:奇数で反応）
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){  //dat[k]:[l,r)の間にいるenを返す
    //下のfind用なので先にそっち読むべき
    //accはst~lとかで確定している値
    if(l+1==r){  //答えがちゃんと存在するならこのlが答え
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1; //入るならk-n(==l)を、入らないなら-1を返す
    }
    int m=(l+r)>>1;  //にぶたんのそれ
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);  //mがstより後ろなら明らかにl=m;
    if(st<=l&&!check(f(acc,dat[k]))){  //今見てるk全部でもダメ(mだと足りないのでl=mにする）
      acc=f(acc,dat[k]);  //kは全部accに加えた上で-1を返す
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);  //まず[l,m)の中にenがいるか探す
    if(~vl) return vl;  //いたならそれを返す(if(~vl)は-1以外にのみ反応する)
    return find(st,check,acc,(k<<1)|1,m,r);  //いなかったら[m,r)の中にenがいるのでそれを返す
    //acc=f(acc,dat[k]);がここで効いてる
  }

  template<typename C>
  int find(int st,C &check){
    //check(f(dat[st]~dat[en-1]))=false,check(f(dat[st]~dat[en]))＝trueとなるenを返す
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  auto f=[](int a,int b){return __gcd(a,b);};
  SegmentTree<int> seg(f,0);
  seg.build(v);
  int ans=0;
  for(int i=0;i<n;i++)chmax(ans,__gcd(seg.query(0,i),seg.query(i+1,n)));
  cout<<ans<<endl;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");

		PriorityQueue<Pair> pq = new PriorityQueue<>(Collections.reverseOrder());

		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(str[i]);
			pq.add(new Pair(1, a));
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			int b = Integer.parseInt(str[0]);
			long c = Long.parseLong(str[1]);

			pq.add(new Pair(b, c));
		}

		long ans = 0;
		long count = 0;

		for (int i = 0; i < n; i++) {
			Pair p = pq.poll();
			if (count + p.size <= n) {
				ans += p.size * p.value;
				count += p.size;
			} else {
				ans += (n - count) * p.value;
				count = n;
				break;
			}
		}

		System.out.println(ans);
	}
}

class Pair implements Comparable<Pair> {
	int size;
	long value;

	public Pair(int size, long value) {
		this.size = size;
		this.value = value;
	}

	@Override
	public int compareTo(Pair p) {
		return Long.compare(this.value, p.value);
	}
}

Measured memory_bytes: 61300
#include<stdio.h>


int main(){
  int n, m, i, j, card[200], card2[200];
  scanf("%d%d", &n, &m);
  for(i = 0;i < 2 * n;i++)card[i] = i + 1;
  for(j = 0;j < m;j++){
    int cut;
    scanf("%d", &cut);
    if(cut == 0){
      for(i = 0;i < n;i ++){
	card2[i * 2] = card[i];
	card2[i * 2 + 1] = card[i + n];
      }
    }
    else{
      for(i = 0;i + cut < 2 * n;i++){
	card2[i] = card[i + cut];
      }
      for(i = 0;i < cut;i++){
	card2[2 * n - cut + i] = card[i];
      }
    }
    for(i = 0;i < 2 * n;i++){
      card[i] = card2[i];
    }
  }
  for(i = 0;i < 2 * n;i++){
    printf("%d\n", card[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int N, L;
    cin >> N >> L;
    vector<int> aji(N);
    vector<int> aji_abs(N);
    for(int i = 0; i < N; ++i)
    {
        aji[i] = L + i - 1 + 1;
        aji_abs[i] = abs(aji[i]);
    }
    auto p_min = min_element(aji_abs.begin(), aji_abs.end());
    aji.erase(aji.begin()+distance(aji_abs.begin(), p_min));

    cout << accumulate(aji.begin(), aji.end(), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  ll ans=0;
  int n=s.size()+1;
  vector<int> left(n);
  vector<int> right(n);
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='<'){
      cnt++;
    }else{
      cnt=0;
    }
    left[i+1]=cnt;
    cerr<<cnt<<" \n"[i==n-2?1:0];
  }
  cnt=0;
  for(int i=0;i<n-1;i++){
    if(s[s.size()-1-i]=='>'){
      cnt++;
    }else{
      cnt=0;
    }
    right[i+1]=cnt;
    cerr<<cnt<<" \n"[i==n-2?1:0];
  }
  reverse(all(right));
  for(int i=0;i<n;i++){
    cerr<<left[i]<<" : "<<right[i]<<endl;
    ans+=max(left[i],right[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    ll N, M, ans = 0 ;
    cin >> N >> M;
    vector<ll> H(N);
    vector<ll> good(N, 1);

    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 0; i < M; i++){
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--;
        tmp2--;
        if(H[tmp1] <= H[tmp2]){
            good[tmp1] = 0;
        }
        if(H[tmp2] <= H[tmp1]){
            good[tmp2] = 0;
        }
    }

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

}



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

using namespace std;
char X,N;
int A[2000010]{};
bool B[2000010]{};
vector <int> C;
int main()
{
  cin>>N;
  if(N>='a')cout<<"a";
  else cout<<"A";
  
  return 0;
}





Measured memory_bytes: 3592
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <map>

using namespace std;

typedef multimap<string, int>::iterator map_it;

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

    multimap<string, int> S;
    int cmd, x;
    string key;
    while (q--)
    {
        cin >> cmd;
        if (cmd == 0)
        {
            cin >> key >> x;
            S.insert(pair<string, int>(key, x));
            // cout << S.size() << endl;
        }
        else if (cmd == 1)
        {
            cin >> key;
            // cout << (S.find(x) != S.end()) << endl;
            // pair<map_it, map_it> pr = S.equal_range(key);
            // map_it it = pr.first;
            // while (it != pr.second)
            // {
            //     cout << it->second << endl;
            //     it++;
            // }

            //法2
            map_it it = S.find(key);
            int i = S.count(key);
            while (i--)
            {
                cout << it->second << endl;
                it++;
            }

            
        }
        else if (cmd == 2)
        {
            cin >> key;
            S.erase(key);
            // remove(S.begin(), S.end(), x);
        }
        else
        {
            string L, R;
            cin >> L >> R;

            map<string ,int>::iterator it1 = S.lower_bound(L), it2 = S.upper_bound(R);
            while (it1 != it2)
            {
                cout << it1->first << ' ' << it1->second << endl;
                it1++;
            }

        }

    }
}


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

class Hello
{
    
    static void Main()
    {
        int a=int.Parse(Console.ReadLine());
        
        for(int i=1;i<=a;i++)
        {
            if(i%3==0||i.ToString().IndexOf("3")>=0)Console.Write(" "+i);
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 18368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+5;
void solve(){
    int n;
    cin>>n;
    vector<int>st,en;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        st.pb(x);
        en.pb(y);
    }
    sort(st.begin(),st.end());
    sort(en.begin(),en.end());
    if(n%2){
        int x = st[n/2];
        int y = en[n/2];
        cout<<(y-x+1)<<endl;
    }
    else{
        int x = st[n/2-1]+st[n/2];
        int y = en[n/2-1]+en[n/2];
        cout<<(y-x+1)<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    scanf("%d",&t);
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 5144
# ABC072 C - Together
from collections import Counter
N = int(input())
A = list(map(str,input().split()))
L = [0]*100001
C = Counter(A)
C = C.items()

if N == 1:
    ans = 1
else:
    for c in C:
        idx,v = c
        idx = int(idx)
        L[idx] = v

    ans = 0
    for i in range(N-1):
        if i == 0:
            ans = L[0] + L[1]
            continue
        ans = max(ans,L[i-1]+L[i]+L[i+1])

print(ans)

Measured memory_bytes: 16740
a,b = map(int, input().split())

s =input()

intlist = ["0","1","2","3","4","5","6","7","8","9"]

for i in range(a):
    if s[i] in intlist:
        pass
    else:
        print("No")
        exit()

if s[a] != "-":
    print("No")
    exit()
    
for j in range(a+1,a+1+b):
    if s[j] in intlist:
        pass
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var n, h, w int
	fmt.Scan(&n, &h, &w)

	var cnt int
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if h <= a && w <= b {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
function Main(input){
  input = input.split("\n")[0];
  
  let answer;
  if(input.substr(-1)==="s"){
    answer = input + "es";
  }else{
    answer = input + "s";
  }
  console.log('%s',answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29680
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	string ans;
	ans="APPROVED";
	rep(i,0,N){
		int A;
		cin>>A;
		if(A%2) continue;
		if(A%3&&A%5) ans="DENIED";
		DBG("A=",A,"ans",ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    string s;
    cin >> s;
    const string ss = "AC";
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (ss == s.substr(i, 2))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main()
{
        ll A, B, C; cin >> A >> B >> C;
        if (A == B) cout << C << endl;
        else if (A == C) cout << B << endl;
        else cout << A << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define li unsigned long long
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
const ll M = 1e9 + 7;
using namespace std; 
int main() 
{
	FAST
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(ll i=2;i<n;i++)
		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;





signed main() {
	speed;
	int n;
	cin >> n;
	string a = "AC", w = "WA", t = "TLE", r = "RE";
	vector<int> ans(4);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if (s == a) {
			ans[0]++;
		}
		if (s == w) {
			ans[1]++;
		}
		if (s == t) {
			ans[2]++;
		}
		if (s == r) {
			ans[3]++;
		}
	}
	cout << "AC x " << ans[0] << '\n';
	cout << "WA x " << ans[1] << '\n';
	cout << "TLE x " << ans[2] << '\n';
	cout << "RE x " << ans[3] << '\n';
	return 0;
}

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

  //   String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu[3]);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/
int cou=0;
for(String tem:nyu){
if(tem.equals("o"))cou++;
}

System.out.println(700+cou*100);






	}
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N,0));
    vector<vector<int>> v(N*N);
    vector<int> cnt(N*N, 0);

    auto id = [&](int x, int y){
        return x*N+y;
    };
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> A[i][j];
            A[i][j]--;
            if(j == 0) continue;
            
            int a = (i < A[i][j-1] ? id(i, A[i][j-1]) : id(A[i][j-1], i));
            int b = (i < A[i][j]? id (i, A[i][j]) : id(A[i][j], i));
            v[a].push_back(b);
            cnt[b]++;
        }
    }

    vector<int> vis(N*N);
    function<bool(int)> dfs = [&](int n){
        bool ok = true;
        vis[n] = -1;
        for(auto x:v[n]){
            //未訪問　=> 再帰
            if(vis[x] == 0) ok &= dfs(x);
            //閉路検出 => false
            else if(vis[x] == -1) return false;
        }
        vis[n] = 1;
        return ok;
    };

    for(int i=0;i<N*N;i++){
        if(!vis[i] && !dfs(i)){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=0;i<N*N;i++) vis[i] = 0;
    vector<int> u;
    function<void(int)> dfs2 = [&](int n){
        vis[n] = 1;
        for(auto x:v[n]) if(vis[x] == 0) dfs2(x);
        u.push_back(n);
    };
    for(int i=0;i<N*N;i++) if(cnt[i] == 0 && vis[i] == 0) dfs2(i);
    reverse(u.begin(), u.end());
    vector<int> dp(N*N);
    for(int i=0;i<u.size();i++){
        for(auto x:v[u[i]]){
            dp[x] = max(dp[x], dp[u[i]] + 1);
        }
    }
    int ans = 0;
    for(int i=0;i<N*N;i++) ans = max(ans, dp[i]);
    cout << ans+1 << endl;
}

Measured memory_bytes: 59120
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

bool hist[550][550];

int es[550][550];
vector<int> G[550];
int N;

bool output;
int prev[550];
bool used[550];
bool findpath(int v,int t){
	used[v]=true;
//	if(output) printf("%d %d\n",v,t);
	if(v==t) return true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i];
		if(es[u][v]==2) continue;
		if(es[u][v]==0&&es[v][u]==0) continue;
		if(used[u]) continue;
		es[u][v]++;
		es[v][u]--;
		prev[u]=v;
		bool flg=findpath(u,t);
		if(flg) return true;
		else{
			es[u][v]--;
			es[v][u]++;
		}
	}
//	used[v]=false;
	return false;
}


bool findpath2(int v,int t){
	used[v]=true;
//	if(output) printf("%d %d\n",v,t);
	if(v==t) return true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i];
		if(es[u][v]==2) continue;
		if(es[u][v]==0&&es[v][u]==0) continue;
		if(es[u][v]==1&&es[v][u]==1) continue;
		if(used[u]) continue;
		es[u][v]++;
		es[v][u]--;
		prev[u]=v;
		bool flg=findpath2(u,t);
		if(flg) return true;
		else{
			es[u][v]--;
			es[v][u]++;
		}
	}
//	used[v]=false;
	return false;
}

bool add(int u,int v){
	es[u][v]=1;
	es[v][u]=1;
	if(hist[u][v]==false){
		G[u].push_back(v);
		G[v].push_back(u);
	}
	hist[u][v]=true;
	hist[v][u]=true;
	for(int i=0;i<N;i++) used[i]=false;
	bool flg=findpath(0,N-1);
	return flg;
}

bool del(int u,int v){
	if(es[u][v]==1){
		es[u][v]=0;
		es[v][u]=0;
		return true;
	}
	if(es[u][v]==2) swap(u,v);
	es[u][v]=0;
	es[v][u]=0;
	for(int i=0;i<N;i++) used[i]=false;
	if(findpath2(u,v)){
		return true;
	}
	for(int i=0;i<N;i++) used[i]=false;
	findpath2(N-1,v);
	for(int i=0;i<N;i++) used[i]=false;
	findpath2(u,0);
//	for(int i=0;i<N;i++){
//		for(int j=0;j<N;j++) printf("%d ",es[i][j]);
//		printf("\n");
//	}
	output=true;
	for(int i=0;i<N;i++) used[i]=false;
	bool flg=findpath(0,N-1);
	return flg;
}

bool check(){
	for(int i=0;i<N;i++){
		int a=0,b=0;
		for(int j=0;j<N;j++){
			if(es[i][j]==0&&es[j][i]==2) a++;
			if(es[i][j]==2&&es[j][i]==0) b++;
		}
		if(a!=b&&i!=0&&i!=N-1) return false;
	}
	return true;
}

int main(){
	int E,Q;
	scanf("%d%d%d",&N,&E,&Q);
	for(int i=0;i<E;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		es[u][v]=1;
		es[v][u]=1;
		hist[u][v]=true;
		hist[v][u]=true;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int cur=0;
	while(true){
		for(int i=0;i<N;i++) used[i]=false;
		bool flg=findpath(0,N-1);
		if(flg==false) break;
		cur++;
	}
	for(int q=0;q<Q;q++){
		int type;
		scanf("%d",&type);
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		if(type==1){
			bool ok=add(u,v);
			if(ok) cur++;
		}else{
			bool ok=del(u,v);
			if(!ok) cur--;
		}
		printf("%d\n",cur);
	}
	return 0;
}

Measured memory_bytes: 2652
#include<stdio.h>
#include<string.h>
char s[1001];
int main(){
	int dn;
	scanf("%d",&dn);
	for(int di=0;di<dn;di++){
		scanf(" %s",s);
		int n=strlen(s);
		int res=s[0]-'0';
		int count=0;
		for(int i=1;i<n;i++){
			res+=s[i]-'0';
			count++;
			while(res>=10){
				res=res/10+res%10;
				count++;
			}
		}
		if(count%2==0)printf("Audrey wins.\n");
		else printf("Fabre wins.\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include<stdio.h>
int main()
{
  int N,eliminate;
  int i,j;
  scanf("%d",&N);
  if(N%2 != 1)
  {
    eliminate = N + 1;
  }
  else
  {
    eliminate = N;
  }
  printf("%d\n",((N-1)*((N-1)+1))/2-eliminate/2);
  for(i=1;i<N;i++)
  {
    for(j=i+1;j<=N;j++)
    {
      if((i+j)!=eliminate)
      {
      printf("%d %d\n", i, j);
      }
    }
  }
  return 0;
}

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

int main() {
	long long n,m,i,j,k,ans,cur,res,mod=1000000007;
	string s,t;
	cin >> n >> s >> t;
	for(i=0; i<n; i++){
		cout << s[i] << t[i];
	}

	return 0;
}

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

int main(){
    int n,m;
    cin >> n;
    vector<int> S(n);
    rep(i,n) cin >> S[i];
    cin >> m;
    vector<int> T(m);
    rep(i,m) cin >> T[i];
    int ans = 0;
    rep(i,m){
        if(binary_search(S.begin(),S.end(),T[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3372
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int n,a[2100];
int vis[2100],flag[2100][2100],ind[2100];
priority_queue<int> que;
vector<int> vec[2100];
inline int gcd(int a,int b){
	if (!b) return a;
	return gcd(b,a%b);
}
void dfs(int u){
    vis[u]=true;
    for (int i=1;i<=n;i++)
	    if (!vis[i]&&flag[u][i]){
	        ind[i]++;
	        vec[u].push_back(i);
	        dfs(i);
	    }
}
void bfs(){
    for (int i=1;i<=n;i++)
		if (!ind[i]) que.push(i);
    while (!que.empty()){
        int u=que.top(); que.pop();
        printf("%d ",a[u]);
        for (int i=0;i<(int)vec[u].size();i++) que.push(vec[u][i]);
    }
}
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++)
	    for (int j=i+1;j<=n;j++)
    		if (gcd(a[i],a[j])!=1)
				flag[i][j]=flag[j][i]=1;
    for (int i=1;i<=n;i++)
		if (!vis[i]) dfs(i);
	bfs();
    return 0;
} 


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

int main() {
  int N[200];
  int i = 0;
  int l = 0;
  cin >> l;// 初回は無視
  while(cin >> l){
    N[i] = l;
    i++;
  }
  bool bEven = true;
  int c = 0;
  while(bEven){
    for(int j= 0; j < i; j++){
	  if(N[j] % 2 == 0){
        N[j] = N[j] / 2;
	  }else{
		bEven = false;
		j = i;
	  }
	}
	if(bEven){
      c++;
	}
  }
  cout << c << endl;
};

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
    {
        cout<<"vowel"<<endl;
    }else
    cout<<"consonant"<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    ans = s.split(',')
    print(*ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10020
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  b,q=b'.'*w,range(w)
  for i in range(h):
    s=input()
    a=[]
    a_add=a.append
    for x,y,z,c in zip(b,b'.'+s,s,q):
      if x==46>z:c+=1
      if y==46>z:i+=1
      if i>c:i=c
      a_add(i)
    b,q=s,a
  print(i)
main()


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

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

    static class DBannedK {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            long c[] = new long[n + 5];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                c[a[i]]++;
            }
            long ans = 0;
            for (int i = 1; i <= n; i++) {
                if (c[i] >= 2) {
                    ans += (c[i] * (c[i] - 1)) / 2;
                }
            }
            for (int i = 0; i < n; i++) {
                long temp1 = 0;
                long temp2 = 0;
                if (c[a[i]] >= 2) {
                    temp1 = (c[a[i]] * (c[a[i]] - 1)) / 2;
                    temp2 = ((c[a[i]] - 1) * (c[a[i]] - 2)) / 2;
                }
                out.println(ans - temp1 + temp2);
            }

        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 53612
k,n=map(int,input().split())
a=list(map(int,input().split()))

s = 0
for i in range(n):
    if i == n-1:
        s = max(s,a[0] + k - a[i])
    else:
        s = max(s,a[i+1] - a[i])
print(k-s)


Measured memory_bytes: 26444
#include <cstdio>
#include <cmath>
int field[1000][1000];
int dp[1000][1000];
int h, w, n;
// 0---ì 1---
int main() {
    while (scanf("%d%d%d",&h,&w,&n)) {
        if (!h&&!w&&!n) break;
        for (int i=0; i<h; i++) for (int j=0; j<w; j++)
            scanf("%d",&field[i][j]);
        dp[0][0]=n;
        for (int i=1; i<w; i++) {
            if (field[0][i-1]&&dp[0][i-1]%2) {
                dp[0][i]=floor(dp[0][i-1]/2)+1;
            } else {
                dp[0][i]=floor(dp[0][i-1]/2);
            }
        }
        for (int i=1; i<h; i++) for (int j=0; j<w; j++) {
            dp[i][j]=0;
            if (!field[i-1][j]&&dp[i-1][j]%2) {
                dp[i][j]+=floor(dp[i-1][j]/2)+1;
            } else {
                dp[i][j]+=floor(dp[i-1][j]/2);
            }
            if (j&&field[i][j-1]&&dp[i][j-1]%2) {
                dp[i][j]+=floor(dp[i][j-1]/2)+1;
            } else {
                dp[i][j]+=floor(dp[i][j-1]/2);
            }
        }
        for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
            if (dp[i][j]%2==0) {
                field[i][j]^=1;
            }
            // printf("%d%c",dp[i][j],j==w-1?'\n':' ');
        }
        int nx=0, ny=0;
        while (nx<h&&ny<w) {
            if (field[nx][ny]) ny++;
            else nx++;
        }
        printf("%d %d\n",nx+1,ny+1);
    }
}

Measured memory_bytes: 8264
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		sc.close();

		List<Long> result = new ArrayList<>();

		result.add(a * c);
		result.add(a * d);
		result.add(b * c);
		result.add(b * d);

		Collections.sort(result);

		System.out.println(result.get(3));
	}
}


Measured memory_bytes: 27044
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int> coin(m);
    for(auto&e:coin){
        scanf("%d",&e);
    }
    int MAX_N=50001;
    vector<int> dp_coin(MAX_N);
    fill(dp_coin.begin(), dp_coin.end(), MAX_N);
    dp_coin[n]=0;
    for(int i=n;i>0;i--){
        for(int j=0;j<m;j++){
            if(i>=coin[j]){
                dp_coin[i-coin[j]]=min(dp_coin[i]+1,dp_coin[i-coin[j]]);
            }
        }
    }
    printf("%d\n",dp_coin[0]);
    return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
unsigned long long gcd(unsigned long long a, unsigned long long b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
	return a * b / gcd(a, b);
}
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li h, w;
    cin >> h >> w;
    li res = (w * h + 1) / 2;
    if (min(w, h) == 1)res = 1;
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=105;
int n,a,b,p[maxn],tax[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	n=rd(); a=rd(); b=rd();
	int x;
	go(i,n+1,1){
		x=rd();
		if(x <= a) tax[1]++;
		if(a < x && x <= b) tax[2]++;
		if(x > b) tax[3]++;
	}
	int ans=inf;
	go(i,4,1) ans=min(ans,tax[i]);
	printf("%d",ans);
	return 0;
}//Faze


Measured memory_bytes: 256
#include <stdio.h>
int ans[32],last;int mn(int a, int b) {return (a<b)?a:b;}void pintf() {for (int i=0;i<last;printf("%d ",ans[i++]));printf("%d\n",ans[last]);}
void dfs(int val,int q) {val-=q;if (!val) {--last,pintf();return;}for (int i=mn(val,q);i>=1;i--) ans[last++]=i,dfs(val,i);last--;}
int main() {int N;while (1) {scanf("%d",&N);if (!N) return 0;last=0;dfs(N<<1,N);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (ll i=0;i<(n);i++)
using namespace std;
#define vecout(v) for(int i=0;i<v.size();i++) {cout<<v[i]<<endl;}
typedef long long ll;

map<int, int> mp;

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int num(int m){
    int res=0;
    for(auto p : mp){
        if(p.second>=m) res++;
    }
    return res;
}

int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(auto p : prime_factor(i)){
            mp[p.first]+=p.second;
        }
    }
    int ans=(num(74)+num(24)*(num(2)-1)+num(14)*(num(4)-1)+num(4)*(num(4)-1)*(num(2)-2)/2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <cctype>

static bool Input(std::string &s, std::string &p)
{
	if (0x00 == &s || 0x00 == &p) {
		return false;
	}

	std::cin >> s;
	std::cin >> p;
	if ((0 < s.size() && 100 >= s.size()) &&
			(0 < p.size() && 100 >= p.size())) {
		return true;
	}

	return false;
}

static bool isInclusion(const std::string s, const std::string p)
{
	int pos = 0;
	std::string tmp(s);
	std::string new_str;

	while (0 <= (pos = tmp.find_first_of(p.at(0)))) {
		new_str = tmp.substr(pos, p.size());
		unsigned int len = new_str.size();
		if (p.size() > len) {
			new_str += s.substr(0, p.size() - len);
		}
		if (0 == new_str.compare(p)) {
			return true;
		}
		tmp = tmp.substr(pos + 1);
	}

	return false;

}
int main()
{
	std::string s, p;

	if (true == Input(s, p)) {
		if (true == isInclusion(s, p)) {
			std::cout << "Yes" << std::endl;
		} else {
			std::cout << "No" << std::endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3220