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

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

    public static void main(String[] args) {
        FastReader scanner = new FastReader();
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        int m = S.length(), n = T.length();

        int[][] DP = new int[m + 1][n + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (S.charAt(i - 1) == T.charAt(j - 1)) {
                    DP[i][j] = DP[i - 1][j - 1] + 1;
                } else {
                    DP[i][j] = Math.max(DP[i - 1][j], DP[i][j - 1]);
                }
            }
        }

        int counter = DP[m][n];

        char[] LCS = new char[counter + 1];
        LCS[counter] = ' ';

        int i = m, j = n;
        while (i > 0 && j > 0) {
            if (S.charAt(i - 1) == T.charAt(j - 1)) {
                LCS[counter - 1] = S.charAt(i - 1);
                i--;
                j--;
                counter--;
            } else if (DP[i - 1][j] > DP[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }

        for (int k = 0; k < DP[m][n]; k++) {
            System.out.print(LCS[k]);
        }
    }

}

Measured memory_bytes: 80956
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=998244353;

int N;
LL A;
LL B;
LL K;
LL fact[314514];
LL revf[314514];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

LL Comb(LL n, LL k) {
  if (n < k) return 0;
  if (k < 0) return 0;
  return fact[n]*revf[k] % MOD * revf[n-k] % MOD;
}

int main() {
  scanf("%d%lld%lld%lld", &N, &A, &B, &K);

  fact[0] = revf[0] = 1;
  reps(i, 1, N+10) {
    fact[i] = fact[i-1] * i % MOD;
    revf[i] = revf[i-1] * mypow(i, MOD-2) % MOD;
  }

  LL p = -1;
  LL q = -1;
  rep(i, B+1) {
    LL rem = K - A*i;
    if (rem < 0) break;
    if (rem%B == 0) {
      p = i;
      q = rem/B;
      break;
    }
  }

  if (p == -1) {
    puts("0");
    return 0;
  }

  LL g = __gcd<LL>(A, B);
  LL ans = 0;
  while (q >= 0) {
    ans += Comb(N, p) * Comb(N, q);
    ans %= MOD;

    q -= A/g;
    p += B/g;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b, k; cin >> a >> b >> k;
    int id = 0;

    for(int i=min(a,b); i>=1; i--){
        if(a%i == 0 && b%i == 0) id++;

        if(id == k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    D = [A[i + 1] - A[i] for i in range(n - 1)]

    for d in D:
        if d != 0:
            if d > 0:
                state = 1
            else:
                state = -1
            break
    else:
        print(1)
        return

    ans = 1
    cnt = 0

    for d in D:
        if d > 0:
            c_state = 1
            cnt += 1
        elif d < 0:
            c_state = -1
            cnt += 1
        else:
            continue
        if c_state != state:
            if cnt != 1:
                ans += 1
                cnt = 0
            state = c_state
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20100
#include <iostream>
using namespace std;
int main(){
    
    for(int n,t,l,b;cin>>n>>t>>l>>b,n;){
        int a[200]={};
        double dp[200][200]={1};
        for(int i=0,t1;i<l&&cin>>t1;i++) a[t1]=1;
        for(int i=0,t1;i<b&&cin>>t1;i++) a[t1]=2;
        for(int i=0;i<t;i++){
            for(int j=0;j<n;j++){
                for(int k=1;k<=6;k++){
                    int t1=j+k;
                    if(t1>n) t1=n-(t1-n);
                    if(a[t1]==2) dp[i+1][0]+=dp[i][j]/6;
                    else if(a[t1]==1) dp[i+2][t1]+=dp[i][j]/6;
                    else dp[i+1][t1]+=dp[i][j]/6;
                }
            }
        }
        double r=0;
        for(int i=0;i<t+1;i++) r+=dp[i][n];
        printf("%.10lf\n", r);
    }
    return 0;
    
}



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

int n;
int w[333];
int dp[333][333];

int rec(int le, int ri) {
    if (~dp[le][ri]) return dp[le][ri];
    if (le == ri) {
        return dp[le][ri] = 0;
    }
    if (ri - le + 1 == 2) {
        return dp[le][ri] = (abs(w[le] - w[ri]) <= 1 ? 2 : 0);
    }
    if (abs(w[le] - w[ri]) <= 1) {
        if (ri - 1 >= le + 1) {
            int t = (ri - 1) - (le + 1) + 1;
            dp[le][ri] = (rec(le + 1, ri - 1) == t ? rec(le + 1, ri - 1) + 2 : dp[le][ri]);
        }
    }
    for (int md = le + 1; md <= ri; md++) {
        dp[le][ri] = max(dp[le][ri], rec(le, md - 1) + rec(md, ri));
    }
    return dp[le][ri];
}

int main() {
    while (cin >> n && n) {
        for (int i = 0; i < n; i++) cin >> w[i];
        for (int i = 0; i < 333; i++) for (int j = 0; j < 333; j++) {
            dp[i][j] = -1;
        }
        int ans = max(0, rec(0, n - 1));
        cout << ans << endl;
    }
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[110];
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	sortup(a,n);
	int ans=0;
	for(int i=0;i<n&&x>=a[i];i++){
		ans++;
		x-=a[i];
	}
	printf("%d",ans-(x>0&&ans==n));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template
int n,a[200000],ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    int id1,id2;
    id1 = a[n]/2;
    id2 = a[n]/2;
    if(a[n]%2==1)id2++;
    int mn = INT_MAX;
    for(int i=1;i<n;i++){
        int temp;
        if(a[i]<=id1){temp=id1;}
        else temp=id2;
        if(abs(a[i]-temp)<mn){mn=abs(a[i]-temp);ans=a[i];}
    }
    cout<<a[n]<<" "<<ans<<newl;
}


Measured memory_bytes: 640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	ll n,z,w,ans;
	cin>>n>>z>>w;
	ll a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	if(n==1) ans=abs(a[0]-w);
	else{
		ans=max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<utility>
#include<iomanip>
#include<tuple>



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}
struct zahyou{
  int x;
  int y;
};





int main(){
  int N,M;
  cin>>N>>M;
  tuple<int,int,int>data[M];
  for(int i=0;i<M;i++){
    int p,y;
    cin>>p>>y;
    data[i]=make_tuple(y,p,i);
  }
  sort(data,data+M);
  int cnt[N+1];
  fill(cnt,cnt+N+1,0);
  pair<int,int>id[M];
  for(int i=0;i<M;i++){
    int y,p,idx;
    tie(y,p,idx)=data[i];
    cnt[p]++;
    id[idx]=make_pair(p,cnt[p]);
  }
  for(int i=0;i<M;i++){
    // setwで文字数、setfillで埋める文字を指定
    // iomanipをincludeする必要があるので注意
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << endl;

  }





  


  



}


  
  

  


Measured memory_bytes: 3840
/*  -*- coding: utf-8 -*-
 *
 * 1380.cc: Medical Checkup
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll hsum = 0;
  int maxh = 0;
  for (int i = 0; i < n; i++) {
    int hi;
    scanf("%d", &hi);

    hsum += hi;
    if (maxh < hi) maxh = hi;
    int k = (t < hsum) ? 1 : (t - hsum) / maxh + 2;
    printf("%d\n", k);
  }

  return 0;
}



Measured memory_bytes: 3212
function main(input){
  const args=input.split(' ');
  const num1=parseInt(args[0]);
  const num2=parseInt(args[1]);
  
  if(num1*num2 % 2 ===0){
    console.log('Even');
  }else{
    console.log('Odd');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

for d in range(D):
    i = imax(S[d])
    print(i + 1)


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

long long modinv(long long a, long long m) {
    long long x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        long long u = x / y;
        long long x0 = y; y = x - y * u; x = x0;
        long long r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

int main() {
    int n; cin >> n;
    const int M = 1000000007;
    long long f[n+1], fi[n+1];
    f[0] = fi[0] = 1;
    for (int i = 1; i <= n; i++)
        f[i] = i * f[i-1] % M;
    fi[n] = modinv(f[n], M);
    for (int i = n-1; i > 0; i--)
        fi[i] = (i+1) * fi[i+1] % M;
    long long ans = (n - 1) * f[n-1] % M;
    for (int k = 1; 2 * (k + 1) <= n; k++) {
        ans -= f[n-k-2] * fi[n-2*k-2] % M * f[n-k-1] % M;
    }
    cout << (ans % M + M) % M << endl;
}


Measured memory_bytes: 18768
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
#define MAX 2000001
#define VMAX 10000

int main()
{
	 unsigned short *A, *B;
	
	int C[VMAX + 1];
	int n, i, j;
	scanf("%d", &n);

	A = (unsigned short *)malloc(sizeof(short)*n+1);
	B = (unsigned short *)malloc(sizeof(short)*n+1);

	for (i = 0; i <= VMAX; i++) C[i] = 0;


	for (int i = 0; i < n; i++) {
		scanf("%hu", &A[i + 1]);
		C[A[i + 1]]++;
	}

	for (int i = 1; i <= VMAX; i++)C[i] = C[i] + C[i - 1];

	for (int j = 1; j <= n; j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}

	for (i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 11048
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const double PI = 3.1415926535;

int main() {
	// 小数点以下12ケタを表示させるためのおまじない
	cout << fixed << setprecision(12);

	double a, b, theta;
	cin >> a >> b >> theta;
	double rad = theta / 180.0 * PI;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
	cout << (0.5 * a * b * sin(rad)) << endl;
	cout << (a + b + c) << endl;
	cout << (b * sin(rad)) << endl;
	return 0;
}



Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int n;

void dfs(string s, char m){
  if(s.size()==n){
    cout << s << endl; return;
  } else {
    for(char c='a'; c<=m; c++){
      dfs(s+c, ((c==m)?(char)(m+1):m));
    }
  }
}
int main() {
  cin >> n;
  dfs("",'a');
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 100+5;
const int M = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

ll n, W;
ll w[N], v[N];
//dp[i]: weight nho nhat de dat duoc value i
//duyet nguoc de bo bot thu tu item
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> W;
	int maxVal = 0;
	for (int i=0; i<n; i++){
		cin >> w[i] >> v[i];
		maxVal += v[i];
	}
	vector<ll> dp(maxVal+1, 1e18L+5);
	dp[0] = 0;
	for(int i=0; i<n; i++){
		for(int j=maxVal; j>= v[i]; j--){
			dp[j] = min(dp[j], w[i]+ dp[j-v[i]]);
		}
	}
	int ans = 0;
	for(int i=0; i<=maxVal; i++){
		if (dp[i] <= W) ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
/*ex7_3
saitomo*/
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int col, row,i,j;
    int *count_row, *count_col;
    char **box;
    scanf("%d%d", &row, &col);
    // メモリ領域の確保
    count_row = (int*)calloc(row, sizeof(int));
    // エラーかの判定
    if (count_row == NULL){
        exit(1);
    }
    count_col = (int*)calloc(col, sizeof(int));
    if (count_col == NULL){
        exit(1);
    }
    box = (char**)calloc(row, sizeof(char*));
    if (box == NULL){
        exit(1);
    }
    for (int i=0; i<row; i++){
        box[i] = (char*)calloc(col, sizeof(char));
        if(box[i] == NULL){
            exit(1);
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c",&box[i][j]);
            count_row[i]=0;//値の初期化
            count_col[j]=0;
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            if(box[i][j]=='#'){
                count_row[i]=1;//行または列に＃が存在すれば1となる
                count_col[j]=1;
            }
        }
    }
    for(i=0;i<row;i++){
        if(count_row[i]==1){//行中に＃があるか判定
            for(j=0;j<col;j++){
                 if(count_col[j]){//列中に＃があるか判定
                      printf("%c",box[i][j]);//消えない部分をプリントする
                 }
            }
            printf("\n");//1行ごとに改行
        }
    }
    free(count_row);//メモリの解放
    free(count_col);
    for (int i=0; i<row; i++){
        free(box[i]);
    }
    free(box);

    return 0;
}


Measured memory_bytes: 1628
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a >= 9 || b >= 9) {
      cout << ":(" << endl;
  } else {
      cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

q = []
for i in range(n):
    q.append((p[i] + 1) * 0.5)
maxv = 0
for i in range(k):
    maxv += q[i]
cnt = maxv
for i in range(n):
    if i + k >= n:break
    cnt = cnt - q[i] + q[i + k]
    maxv = max(cnt, maxv)
print(maxv)

Measured memory_bytes: 24804
N = int(input())
ans = "No"

limit_cakes = N // 4
limit_donuts = N // 7

for i in range(0, limit_cakes+1):
    for j in range(0, limit_donuts+1):
        if 4*i + 7*j == N:
            ans = "Yes"
            break

print(ans)


Measured memory_bytes: 2940
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln; readln.split.sort().uniq.array.length.pipe!"(a+1)/2*2-1".writeln;
}


Measured memory_bytes: 4548
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ci cin
#define co cout
#define ed endl
#define vc vector
#define sr string
#define pb push_back
#define st(a,n) sort(a,a+n)
#define ms(a) memset(a,0,sizeof(a))
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,n,k) for(int i=n;i>=k;--i)
#define inf 0x3f3f3f3f
#define mod 10000019
#define maxn 1000
#define exp 1e-6
typedef long long ll;
using namespace std;
int main()
{
    int a;
    ci>>a;
    co<<a*(a+1)/2<<ed;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,k;
        cin >> n >> k;
        int i,a[n+1];
        for(i=1; i<=n; i++) cin >> a[i];
        int dp[n+1];
        for(i=1; i<=n; i++) dp[i]=INT_MAX;
        dp[1]=0;
        dp[2]=abs(a[2]-a[1]);
        for(i=3; i<=n; i++){
            for(int j=1; j<=k; j++)
            if((i-j)>0)
            dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
        cout << dp[n];
        

}

Measured memory_bytes: 1792
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int l[N],r[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d%d",&l[i],&r[i]);
  }
  int ans=0;
  for (size_t i = 0; i < N; i++) {
    ans=ans+r[i]-l[i]+1;
  }
  printf("%d", ans);
  return 0;
}


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

int main()
{
    long long int a,b,c,sum=0;
    vector<long long int>v1,v2,v3;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v1.push_back(b);
    }
    for(int i=0; i<a; i++)
    {
        cin>>b;
        sum=sum+b;
    }
    for(int i=0; i<a-1; i++)
    {
        cin>>b;
        v3.push_back(b);
    }
    //sort(v3.begin(),v3.end());
    for(int i=0; i<a-1; i++)
    {
        if(v1[i+1]-v1[i]==1)
        {
            sum=sum+v3[v1[i]-1];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,k,p[100111],ans;
vector<int> con[100111];
int dfs(int x)
{
//	cerr<<"dfs:"<<x<<endl;
	int ret=1;
	for(int i=0;i<con[x].size();i++)
	{
		ret=max(ret,dfs(con[x][i])+1);
	}
//	cerr<<x<<":"<<ret<<endl;
	if(p[x]!=1&&ret>=k)
	{
		ans++;
		return 0;
	}
	else return ret;
}
int main()
{
	getii(n,k);
	for(int i=1;i<=n;i++)geti(p[i]);
	if(p[1]!=1)p[1]=1,ans++;
	for(int i=2;i<=n;i++)con[p[i]].PB(i);
	dfs(1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
#define rep(i,n)   for(int i = 0; i < n; i++)
#define repR(i,n)  for(int i = n; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;
using namespace std;

int main(){
    int x,y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if ((i+1)%2==1 && a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

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

	int n = scan.nextInt();
	String s = scan.next();
	int k = scan.nextInt();

	char c = s.charAt(k-1);
	for(int i = 0; i < s.length(); i++){
	    if(s.charAt(i) != c){
		System.out.print('*');
	    }else{
		System.out.print(c);
	    }
	}
	System.out.println();
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int dp[2010][2010];

signed main(){
	int n,a[2010];
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		vec.emplace_back(a[i],i);
	}
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= n;j++) dp[i][j] = -INF;
	}
	dp[0][0] = 0;
	sort(all(vec),greater<P>());
	for(int i = 0;i < n;i++){
		int v = vec[i].second;
		for(int j = 0;j <= i;j++){
			chmax(dp[i + 1][j],dp[i][j] + abs(n - i + j - 1 - v) * a[v]);
			chmax(dp[i + 1][j + 1],dp[i][j] + abs(v - j) * a[v]);
		}
	}
	int ma = -INF;
	for(int i = 0;i <= n;i++) chmax(ma,dp[n][i]);
	cout << ma << endl;
}


Measured memory_bytes: 35128
#include <cstdio>

int main()
{
  long long a, b;
  scanf("%lld%lld", &a, &b);
  long long ans;
  switch ((b & 1) << 1 | (a & 1))
  {
    case 0:
      ans = b ^ (((b - a) / 2) & 1);
      break;
    case 1:
      ans = b ^ (((b - (a + 1)) / 2) & 1) ^ a;
      break;
    case 2:
      ans = ((b + 1 - a) / 2) & 1;
      break;
    case 3:
      ans = a ^ (((b - a) / 2) & 1);
      break;
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}

int n;
int main()
{
  cin >>n;
  int dx,dy;
  double dist,dist1;
  for(int i = 0;i < n;i++){
    int px,py;
    px = 0;
    py = 0;
    dist = dist1 = 0.0;
    int nx = 0;
    int ny = 0;
    while(cin>>dx>>dy,dx||dy){
      nx = dx + nx;
      ny = dy + ny;
     dist = (nx*nx+ny*ny);
     if(dist > dist1){
       px = nx;
       py = ny;
       dist1 = dist;
     }else if(dist==dist1){
       if(nx >px){
	 px = nx;
	 py = ny;
       }
     }
    }
    printf("%d %d\n",px,py);
  }

  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string ans;
  rep(i, ty - sy) ans.append("U");
  rep(i, tx - sx) ans.append("R");
  rep(i, ty - sy) ans.append("D");
  rep(i, tx - sx) ans.append("L");
  ans.append("L");
  rep(i, ty - sy + 1) ans.append("U");
  rep(i, tx - sx + 1) ans.append("R");
  ans.append("D");
  ans.append("R");
  rep(i, ty - sy + 1) ans.append("D");
  rep(i, tx - sx + 1) ans.append("L");
  ans.append("U");

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
parseInt(x::SubString{String}) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function abmp(a,b,p);if b==0;1;elseif b%2==0;k=abmp(a,div(b,2),p);(k*k)%p;else;(a*abmp(a,b-1,p))%p;end;end;;
function binarr(n,p);z=1;for i in 1:n;z=z*i%p;end;fac=Array{Int}(n+1);inv=Array{Int}(n+1);inv[n+1]=abmp(z,p-2,p)
for i in 0:n-1;inv[n-i]=(inv[n+1-i]*(n-i))%p;end;for i in 0:n;fac[i+1]=(((z*inv[i+1])%p)*inv[n+1-i])%p;end;fac;end;

function main()
	p = 1000000007
	n,k = readline() |> split |> parseMap
	a = binarr(n-k+1,p)
	b = binarr(k-1,p)
	for i in 1:min(k,n-k+1)
		println(a[i+1]*b[i]%p)
	end
	if k>n-k+1
		for i in n-k+2:k
			println(0)
		end
	end
end

main()

Measured memory_bytes: 166968
n = int(input())

class Node:
    def __init__(self):
        self.key = -1
        self.parent_id = -1
        self.left_id = -1
        self.right_id = -1


def insert(nodes,z):
    y = -1
    root_id = -1
    for i in range(len(nodes)):
        if nodes[i].parent_id == -1:
            root_id = i
            break

    x = root_id

    while x != -1:
        y = x
        if z.key < nodes[x].key:
            x = nodes[x].left_id
        else:
            x = nodes[x].right_id

    z.parent_id = y
    nodes.append(z)
    z_id = len(nodes) - 1
    if y == -1: pass
    elif z.key < nodes[y].key:
        nodes[y].left_id = z_id
    else:
        nodes[y].right_id = z_id


def pre(node_id):
    pre_list.append(nodes[node_id].key)
    left = nodes[node_id].left_id
    right = nodes[node_id].right_id

    if left != -1:
        pre(left)
    if right != -1:
        pre(right)


def Ino(node_id):
    if nodes[node_id].left_id != -1 :
        Ino(nodes[node_id].left_id)
    ino_list.append(nodes[node_id].key)
    if nodes[node_id].right_id != -1:
        Ino(nodes[node_id].right_id)

nodes = []
for i in range(n):
    cmd = input()
    op = cmd[0]

    if op == "i":
        z = Node()
        number = int(cmd[7:])
        z.key = number

        insert(nodes,z)

    if op =="p":
        pre_list = []
        ino_list = []
        for i in range(len(nodes)):
            if nodes[i].parent_id == -1:
                Ino(i)
                pre(i)
                break


        pre_list = list(map(str, pre_list))
        ino_list = list(map(str, ino_list))
        print(" ", end="")
        print(' '.join(ino_list))
        print(" ", end="")
        print(' '.join(pre_list))




Measured memory_bytes: 197932
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    n = int(input())
    a = [int(input()) for _ in range(n)]
    # l = [list(map(int, input().split())) for _ in range(n)]
    aa = sorted(a)

    max_1st = aa[-1]
    max_2nd = aa[-2]

    for i, a_i in enumerate(a):
        if max_1st == a_i:
            print(max_2nd)
        else:
            print(max_1st)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1
4
3"""
        output = """4
3
4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
5
5"""
        output = """5
5"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int A() {
	int n;

	scani(n);

	YesNo(7 == n % 10 || 7 == n / 10 % 10 || 7 == n / 100);


	return 0;
}

int B() {
	int n;

	scani(n);

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) {
			ans += i;
		}
	}

	printll(ans);

	return 0;
}

int Main() {
	int k;
	int ans = 0;

	scani(k);

	int a = 1, b = 1, c = 1;
	for (a = 1; a <= k; a++) {
		for (b = 1; b <= k; b++) {
			for (c = 1; c <= k; c++) {
				ans += GCD(GCD(a, b), c);
			}
		}
	}

	printi(ans);

	return 0;
}

int D() {
	int n;

	string s;
	scani(n);
	cin >> s;
	int r, g, b;
	r = g = b = 0;
	for (auto x : s) {
		switch (x) {
		case 'R':
			r++;
			break;
		case 'G':
			g++;
			break;
		default:
			b++;
			break;
		}
	}

	ll ans = (ll)r * g * b;
	ll sub = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) continue;
			int k = j * 2 - i;
			if (n <= k || s[k] == s[i] || s[k] == s[j]) continue;
				sub++;
		}
	}

	ans -= sub;

	printll(ans);

	return 0;
}

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


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long lli;

int main(){
	lli a, b;
	cin >> a >> b;
	lli r=0;

	lli a0, b0;
	a0=a%4;
	b0=b%4;
	if(a0<=1) a0=2; else a0=1;
	if(b0==3) b0=2; else if (b0==0) b0=0; else b0=1;
	r+=(a0+b0)%2;

	for(int i=1; i<63; i++){
		lli a0, b0;
		a0=a%(1ll<<(i+1));
		b0=b%(1ll<<(i+1));
		r+=(((1ll<<i)-max(0ll, a0-(1ll<<i))+max(0ll, b0-(1ll<<i)+1ll))&1)<<i;
	}


	cout << r << endl;
	return 0;

}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  ll N,K;
  cin>>N>>K;
  cout<<cei(N-1,K-1);
return 0;}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int main(void){
    char a[200],b[200];
    int i,alen,blen;
    for(i=0;i<200;i++){
        a[i]=0;
        b[i]=0;
    }
    scanf("%s",&a);
    scanf("%s",&b);
    alen=strlen(a);
    blen=strlen(b);
    if(alen>blen){
        printf("GREATER\n");
        return 0;
    }else if(alen<blen){
        printf("LESS\n");
        return 0;
    }
    for(i=0;i<alen;i++){
        if(a[i]>b[i]){
            printf("GREATER\n");
            return 0;
        }
        if(a[i]<b[i]){
            printf("LESS\n");
            return 0;
        }
    }
    printf("EQUAL\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int mapp[10005];

int main()
{
	int i,j,k,m;
	long long ans=0,n;
	scanf("%lld%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&mapp[i]);
	}
	for(i=0;i<m;i++)
	{
		ans=ans+mapp[i];
	}
	if(ans>n)printf("-1");
	else printf("%d",n-ans);
	return 0;
}

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

int main() {
	int n;
	cin>>n;
	long long res = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		int x; cin>>x;
		mx = max(x, mx);
		res += x;
	}
	(res-mx > mx) ? cout<<"Yes\n" : cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long pow(long long x, long long y){
	long long r = 1;
	for (long long i = 0; i < y; i++){
		r = r * x % 1000000007;
	}

	return r;
}

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

	long long ans = pow(10, N) - 2 * pow(9, N) + pow(8, N);
	ans %= 1000000007;
	ans = (ans + 1000000007) % 1000000007;

	cout << ans;

	return 0;
}

Measured memory_bytes: 3620
import numpy as np
from numba import njit

@njit
def get_div_nums(n):
    divs = np.ones(n+1, dtype=np.int64)
    for i in range(2, n):
        divs[i::i] += 1
    return divs

def main():
    N = int(input())
    divs = get_div_nums(N)
    ans = divs[:N].sum()-1
    print(ans)
    #print(divs[:20])

if __name__ == "__main__":
    main()

Measured memory_bytes: 123704
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	cout << n / 3 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void add(long long &n , long long m){
    n += m;
    if(n >= mod){
        n -= mod;
    }
}
int main() {
    int n , m ; cin>>n>>m;
    vector<long long>dp(n + 1);
    int br[100009] = {0};
    for(int i = 0 ; i < m; ++i){
        int x ; cin>>x;
        br[x] = 1;
    }
    dp[0] = 1;
    for(int i = 0 ; i <= n ; ++i){
        if(br[i] == 1)dp[i] = 0;
        for(int j : {1 , 2}){
            if(i + j <= n)add(dp[i + j] , dp[i]);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>

int main()
{
    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    int angleH = (H * 360 + M * 6) / 6;
    int angleM = M * 360 / 30;

    int angle = std::abs(angleH - angleM);
    if (angle > 360)
        angle = 720 - angle;
    printf("%.10lf",sqrt(A * A + B * B - 2 * A * B * cos(angle * M_PI / 360)));
}

Measured memory_bytes: 4180
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<stdio.h>
 
using namespace std;
 
#pragma GCC optimize("Ofast")

void print_intary(int x[], int n)
{

}

int main(){
 int N;
 cin >> N;
 vector<int> P(N),Q(N);
 for(int i=0;i<N;++i) cin >> P[i];
 for(int i=0;i<N;++i) cin >> Q[i];
    long long  a=1,b=1;
    vector<int> v(N),r(N);
    for(int i=0;i<N;++i){
        v[i]=i+1;
        r[i]=i+1;
    }
    bool exitst=true;
    for(int i=0;i<N;++i){
        if(v[i]!=P[i]){
            exitst=false;
            break;
        }
    }
    if(exitst==false){
    while(next_permutation(v.begin(),v.end())){
        ++a;
        exitst=true;
        for(int i=0;i<N;++i){
            if(P[i]!=v[i]){
                exitst=false;
                break;
            }
        }
        if(exitst==true){
            break;
        }
    }
    }
        
    for(int i=0;i<N;++i){
        if(r[i]!=Q[i]){
            exitst=false;
            break;
        }
    }
    if(exitst==false){
        while(next_permutation(r.begin(),r.end())){
        ++b;
        exitst=true;
        for(int i=0;i<N;++i){
            if(Q[i]!=r[i]){
                exitst=false;
                break;
            }
        }
        if(exitst==true){
            break;
        }
    }
    }
    long long ans=abs(a-b);
    cout << ans;
}

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

long long aPrefixSum[200005], bPrefixSum[200005];
long long N, M, K;

int main()
{
	scanf("%lld%lld%lld", &N, &M, &K);
	
	for(long long i = 1; i <= N; i++)
	{
		long long Ai;
		scanf("%lld", &Ai);
		
		aPrefixSum[i] = aPrefixSum[i - 1] + (long long)(Ai);
	}
	
	for(long long i = 1; i <= M; i++)
	{
		long long Bi;
		scanf("%lld", &Bi);
		
		bPrefixSum[i] = bPrefixSum[i - 1] + (long long)(Bi);
	}
	
	long long ans = 0;
	for(long long i = 0; i <= N; i++)
	{
		long long aBooksRead = i;
		
		long long remBooks = (long long)(K) - aPrefixSum[i];
		if(remBooks < 0)
			break;
			
		long long bBooksRead = upper_bound(bPrefixSum + 1, bPrefixSum + M + 1, remBooks) - 1 - bPrefixSum;
		
		ans = max(ans, aBooksRead + bBooksRead);
	}
	
	printf("%lld", ans);
}


Measured memory_bytes: 6940
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <bitset>
#define SIZE 200000

using namespace std;

int main(){

    char S[25];
    cin >> S;
    cout << S[0] << S[1] << S[2] << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef pair<int,int>pii;
int main(){
    int h,w,t,n;
    while(cin>>h>>w>>t,h||w||t){
        cin>>n;
        while(n--){
            int r;
            cin>>r;
            if(sqrt(w*w+t*t)<r*2)cout<<"OK"<<endl;
            else cout<<"NA"<<endl;
        }
    }

}

Measured memory_bytes: 1156
def unko(a):
    if a == 1:
        return range(0, 10)
    if a == 2:
        return range(10, 100)
    if a == 3:
        return range(100, 1000)

def main():
    n, m = list(map(int, input().split()))

    scs = [list(map(int, input().split())) for i in range(m)]

    for i in unko(n):
        if all([str(i)[s-1] == str(c) for s, c in scs]):
            return i
    return -1            


print(main())

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = Integer.parseInt(scanner.nextLine())
    val b = Integer.parseInt(scanner.nextLine())
    val h = Integer.parseInt(scanner.nextLine())

    val area = (a + b) * h / 2

    println(area)
}


Measured memory_bytes: 31260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7

int main(){
    int n;
    cin >> n;
    // int a[n][26] = {};
    map<char, int> mp[n];
    rep(i, n){
        string s;
        cin >> s;
        rep(j, s.size()){
            // a[i][s[j]-'a']++;
            mp[i][s[j]]++;
        }
    }
    rep(j, 26){
        int MIN=50;
        rep(i, n){
            // MIN = min(MIN, a[i][j]);
            MIN = min(MIN, mp[i]['a'+j]);
        }
        rep(i, MIN){
            cout << (char)('a'+j);
        }
    }
    cout << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char s[110];
int p=0;
int g(int a,int b,int c){
  if(b==2)return a+c;
  if(b==3)return a-c;
  if(b==4)return a*c;
  return a/c;
}
int f(){
  int i,r=0,o[3];
  int n[3],a;
  char c[]={")=+-*/"};
  while(1){
    for(a=0;'0'<=s[p]&&s[p]<='9';p++)a=a*10+s[p]-'0';
    if(s[p]=='('){
      p++;
      a=f();
    }
    for(i=0;s[p]-c[i];i++);
    for(;r&&o[r-1]/2>=i/2;r--)a=g(n[r-1],o[r-1],a);
    n[r]=a;
    o[r++]=i;
    p++;
    if(i/2==0)return n[0];
  }
  return 0;
}
  
int main(){
  int n;
  scanf("%d",&n);
  while(n--){
    p=0;
    scanf("%s",s);
    printf("%d\n",f(s));
  }
  return 0;
}

Measured memory_bytes: 592