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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    int max = Integer.MIN_VALUE;
    int secondMax = Integer.MIN_VALUE;
    for (int i = 0; i < n; i++) {
      int v = Integer.parseInt(sc.next());
      a[i] = v;
      if (max < v) {
        max = v;
      } else if (secondMax < v) {
        secondMax = v;
      }
    }
    for (int i = 0; i < n; i++) {
      int v = a[i];
      if (v == max) {
        pw.println(secondMax);
      } else {
        pw.println(max);
      }
    }
  }
}


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

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    ll n,k;
    ll L = ll(1000000007);
    cin >> n>> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll cnt = 0;
    rep(i,n-1){
        for(int j=(i+1);j<n;j++){
            if(a[i]>a[j]){
                cnt++;
            }
        }
    }
    ll ans = ((k%L)*(cnt%L))%L;
    cnt = 0;
    sort(a.begin(),a.end());
    rep(i,n-1){
        for(int j=(i+1);j<n;j++){
            if(a[i]<a[j]){
                cnt++;
            }
        }
    }
    cnt = cnt%L;
    if(k%2==0){
        ans += (((k/2)%L)*((k-1)%L))%L*cnt;
    }else{
        ans += (((k)%L)*(((k-1)/2)%L))%L*cnt;
    }
    ans = ans%L;
    co(ans);
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
C = [0] * n
A = [[] for i in range(n)]
for i in range(n):
    c = list(map(int, input().split()))
    C[i], A[i] = c[0], c[1:]

INF = 10 ** 9
ans = INF

for bit in range(0, 1 << n):
    cost = 0
    flag = True
    tmp = [0] * m
    for i in range(n):
        if bit & 1 << i:
            cost += C[i]
            for j in range(m):
                tmp[j] += A[i][j]
    for i in range(m):
        if tmp[i] < x:
            flag = False
    if flag:
        ans = min(ans, cost)

print(-1 if ans == INF else ans)

Measured memory_bytes: 9260
#include<cstdio>
const int mod=1000000007;
int N;
long long A[2],S[100010];
int nxt[100010][2],lim[100010][2],f[100010][2];
int main(){
	scanf("%d%lld%lld",&N,A,A+1);
	for(int i=0;i<N;i++)scanf("%lld",S+i);
	for(int t=0;t<2;t++){
		nxt[0][t]=1;
		for(int i=1;i<N;i++){
			for(nxt[i][t]=nxt[i-1][t];nxt[i][t]<N&&S[nxt[i][t]]-S[i-1]<A[t];nxt[i][t]++);
			if(nxt[i][t]==i)nxt[i][t]++;
		}
		lim[N-1][t]=N;
		for(int i=N-1;i--;)lim[i][t]=S[i+1]-S[i]<A[t]?i+1:lim[i+1][t];
	}
	f[N][0]=f[N][1]=1;
	for(int i=N;i--;){
		for(int t=0;t<2;t++){
			f[i][t]=f[i+1][t];
			if(nxt[i][!t]<=lim[i][t])f[i][t]=(f[i][t]+f[nxt[i][!t]][!t]-f[lim[i][t]+1][!t])%mod;
			(f[i][t]+=mod)%=mod;
		}
	}
	int ans=(f[0][0]-f[1][0]+mod)%mod+(f[0][1]-f[1][1]+mod)%mod;
	printf("%d\n",ans%mod);
}

Measured memory_bytes: 3328
#include<iostream>
#include<set>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	set<int> cpp;
	int m, n, i, o;

	cin >> n;
	r(i, n)
	{
		cin >> o;
		cpp.insert(o);
	}

	cin >> m;
	r(i, m)
	{
		cin >> o;
		if (!cpp.count(o)) cpp.insert(o);
		else  cpp.erase(o);
	}

	set<int>::iterator iter = cpp.begin();
	for (; iter != cpp.end(); iter++)
		cout << *iter << endl;

	return 0;
}


Measured memory_bytes: 21788
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] s = new String[n];
        for(int i = 0; i < n; i++) s[i] = scan.next();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for(int i = 0; i < n; i++){
            if(s[i].equals("AC")){
                ac++;
            }else if(s[i].equals("WA")){
                wa++;
            }else if(s[i].equals("TLE")){
                tle++;
            }else if(s[i].equals("RE")){
                re++;
            }
        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
        scan.close();
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const ll mod=1000000007LL; 

ll dp[3010][3010][2];

int main(void){
	ll n,m;
	cin >> n >> m;

	rep(i,n+1) dp[0][i][(i==0)]=1LL;

	rep(i,m)rep(j,n+1)rep(k,2){
		dp[i][j][k]%=mod;
		
		if(j-1>=0){
			int nk = k;
			if(j==1) nk = 1;
			dp[i+1][j-1][nk] += dp[i][j][k];
			dp[i+1][j][nk] += dp[i][j][k];
		}

		if(j+1<=n){
			const int nk = k;
			dp[i+1][j][nk] += dp[i][j][k];
			dp[i+1][j+1][nk] += dp[i][j][k];
		}
	}

	ll ans=0LL;
	rep(i,n+1) ans=(ans+dp[m][i][1])%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 141568
#include<stdio.h>
#include<string.h>

int main(void){
	int a=0,b=0,c=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a == b && b == c){printf("1\n");return 0;}
	if(a == b || b == c || c == a){printf("2\n");return 0;}
	printf("3\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////
#include <atcoder/convolution>

int main()
{
    int N, M;
    io >> N >> M;
    vi a(N), b(M);
    for (int i = 0; i < N; i++)
        io >> a[i];
    for (int i = 0; i < M; i++)
        io >> b[i];
    
    vi c = atcoder::convolution<998244353>(a, b);

    for (int i = 0; i < (int)c.size(); i++)
    {
        io << (i ? " " : "") << c[i];
    }
    io << BR;
}

Measured memory_bytes: 18992
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
signed main(){
    int n; cin >> n;
    int a[n],b[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[n-1-i];
    int x=0,y=n-1;
    rep(i,n){
        if(a[i]==b[i]){
            if(x<n&&b[x]!=a[i]&&a[x]!=b[i]) swap(b[i],b[x++]);
            else if(0<=y&&b[y]!=a[i]&&a[y]!=b[i]) swap(b[i],b[y--]);
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';
    rep(i,n) cout << b[i] << " ";
}




Measured memory_bytes: 5184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
  ll a, b;
  cin >> a >> b;
  cout << (((a * b) % 2) ? "Odd" : "Even") << endl;

	return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

th1 = "R"*(c-a)
th2 = "U"*(d-b)
th3 = "L"*(c-a)
th4 = "D"*(d-b)
th5 = "D"+"R"*(c-a+1)+"U"*(d-b+1)+"L"
th6 = "U"+"L"*(c-a+1)+"D"*(d-b+1)+"R"

ans=th1+th2+th3+th4+th5+th6
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
 
using namespace std;
#define int long long
typedef long long int64;
const int64 INF = 1LL << 60;
 
int64 fact[19];
 
signed main()
{
  fact[0] = 1;
  for(int i = 1; i < 19; i++) fact[i] = fact[i - 1] * 10;
 
  int D;
  cin >> D;
 
  int64 ret = 0;
 
  for(int length = 2; length <= 18; length++) {
    unordered_map< int64, int64 > dp;
    dp[0] = 1;
 
    for(int keta = 0; keta < length / 2; keta++) {
      map< int64, int64 > cat;
      unordered_map< int64, int64 > nextdp;
 
      int revketa = length - keta - 1;
 
 
      int64 aa = 0, bb = 0;
      for(int k = keta + 1; k < length / 2; k++) {
        int64 latte = INF, malta = -INF;
        for(int p = 0; p < 10; p++) {
          for(int q = 0; q < 10; q++) {
            latte = min(latte, (p - q) * fact[k] + (q - p) * fact[length - k]);
            malta = max(malta, (p - q) * fact[k] + (q - p) * fact[length - k]);
          }
        }
        aa += latte;
        bb += malta;
      }
 
 
      for(int p = 0; p < 10; p++) {
        if(revketa + 1 == length && p == 0) continue;
        for(int q = 0; q < 10; q++) {
          ++cat[(p - q) * fact[keta] + (q - p) * fact[revketa]];
        }
      }
 
      for(auto p : cat) {
        for(auto q : dp) {
          int64 sum = p.first + q.first;
          if(sum + aa > D || sum + bb < D) continue;
          nextdp[p.first + q.first] += q.second * p.second;
        }
      }
      swap(dp, nextdp);
    }
    if(length % 2 == 1) ret += dp[D] * 10;
    else ret += dp[D];
  }
 
  cout << ret << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int main(){
    int n,x;
    int a[100000];
    cin>>n>>x;
    rep(i,n) cin>>a[i];

    ll ans=0;
    repn(i,n-1){
        if(a[i-1]+a[i]>x){
            ans+=(a[i-1]+a[i])-x;
            a[i]-=(a[i-1]+a[i])-x;
            if(a[i]<0){
                a[i-1]+=a[i];
                a[i]=0;
            }
        }
    }

    cout<<ans<<endl;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int a, b, ans = 0;
  cin>>a>>b;
  ans += a-1;
  if(b >= a) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* Written by Nishant Mittal aka nishantwrp */
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define modnum 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'

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

// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};

//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();

/*

███╗   ██╗██╗███████╗██╗  ██╗ █████╗ ███╗   ██╗████████╗██╗    ██╗██████╗ ██████╗ 
████╗  ██║██║██╔════╝██║  ██║██╔══██╗████╗  ██║╚══██╔══╝██║    ██║██╔══██╗██╔══██╗
██╔██╗ ██║██║███████╗███████║███████║██╔██╗ ██║   ██║   ██║ █╗ ██║██████╔╝██████╔╝
██║╚██╗██║██║╚════██║██╔══██║██╔══██║██║╚██╗██║   ██║   ██║███╗██║██╔══██╗██╔═══╝ 
██║ ╚████║██║███████║██║  ██║██║  ██║██║ ╚████║   ██║   ╚███╔███╔╝██║  ██║██║     
╚═╝  ╚═══╝╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝    ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝     
                                                                                                       
*/
int ans = 0;


signed main()
{
FAST
int r;
cin>>r;
cout<<3*r*r;
return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
mod = 10**9+7

factorial=[1 for i in range(N*M+1)]
for i in range(1,N*M+1):
    if i==1:factorial[i]=1
    else:factorial[i] = factorial[i-1]*i % mod

def comb(n,k):
    return (factorial[n]*pow(factorial[n-k]*factorial[k], -1, mod))%mod
  
xscore = 0
for i in range(1,N):
  xscore += i * (N-i)
xscore %= mod
xscore *= M**2 * comb(N*M-2,K-2)
xscore %= mod

yscore = 0
for i in range(1,M):
  yscore += i * (M-i)
yscore %= mod
yscore *= N**2 * comb(N*M-2,K-2)
yscore %= mod

print((xscore + yscore) %mod)

Measured memory_bytes: 16936
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i ++) L[i] = A[left + i];
  for (int i = 0; i < n2; i ++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for (int k = left; k < right; k ++) {
    cnt ++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

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

int main() {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);

  for (i = 0; i < n; i ++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;
}


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

int main() {
  int N;
  cin >> N;
  int total = N % 10;
  int base = 10;
  int x = 1;
  while (N / base != 0) { 
    x += 1;
    base *= 10;
  }
  base = 10; 
  for (int i = 1; i < x; i++) {
    total = total + (N % (base * 10) - N % base) / base;
    base *= 10;
  }
  if (N % total == 0) {
    cout << "Yes" << endl;
  }
  else if (N % total != 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#define suml(X) ((X) > 1 ? ((X) * ((X) - 1)) / 2 : 0)
typedef long long ll;

int cmp(const void *, const void *);

ll arr[200005] = {};

int main()
{
	ll n;
	ll ans = 0;

	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &arr[i]);

		arr[i] = arr[i] + arr[i - 1];
	}

	qsort(arr, n + 1, sizeof(ll), cmp);
	arr[n + 1] = -1;

	ll cnt = 0;
	for (ll i = 0; i <= n; i++) {
		cnt++;

		if (arr[i + 1] != arr[i]) {

			ans = ans + suml(cnt);
			cnt = 0;

		}
	}

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

	return 0;
}

int cmp(const void *x, const void *y)
{
	if (*(ll *)x > *(ll *)y) {
		return 1;
	} else if (*(ll *)x == *(ll *)y) {
		return 0;
	} else {
		return -1;
	}
}


Measured memory_bytes: 3324
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
doub = ctr.most_common()[0][0]
i1 = src.index(doub)
i2 = src[::-1].index(doub)
doub_len = (i1+i2+1)

MOD = 10**9+7

fac = [1,1] + [0]*N
finv = [1,1] + [0]*N
inv = [0,1] + [0]*N
for i in range(2,N+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = []
for i in range(1,N+2):
    ans.append(ncr(N+1,i))
for i in range(doub_len):
    ans[i] -= ncr(doub_len-1, i)
    ans[i] %= MOD
print(*ans,sep='\n')

Measured memory_bytes: 33324
#include <stdio.h>
#include <string.h>

int main(){
  char a[103], b[103];
  scanf("%s %s", a, b);
  int alen = strlen(a), blen = strlen(b);
  int ans = 0;
  if(alen > blen){
    ans = 1;
  }else if(alen < blen){
    ans = -1;
  }else{
    int now = 0;
    while(now < alen){
      if(a[now] > b[now]){
	ans = 1;
	break;
      }else if(a[now] < b[now]){
	ans = -1;
	break;
      }else{
	now++;
      }
    }
  }
  if(ans == 1)  printf("GREATER\n");
  else if(ans == -1)  printf("LESS\n");
  else  printf("EQUAL\n");
  return 0;
}


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

using namespace std;

int main(){
  int i,j,k,a[3];
  string s;
  for(i=0;i<3;i++){
    cin >> a[i];
  }
  sort(a,a+3);
  int ans = 0;
  ans +=a[1]-a[0];
  ans+=a[2]-a[1];
  cout << ans << endl;
  return 0;
}


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

using namespace std;

long long sum_of_squares(map<int, int>& m) {
    long long s = 0;
    for (auto x : m) {
        s += ((long long) x.second) * x.second;
    }
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> x, y, z;
    // z = x + y
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        x[a + i] += 1;
        y[i - a] += 1;
        z[a + i] += 1;
        z[i - a] += 1;
    }
    long long answer = (sum_of_squares(z) - sum_of_squares(x) - sum_of_squares(y)) / 2;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 37936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		// 2020/1/30 No.151
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		char c = (char) (str.charAt(0) + 1);

		System.out.println(c);
	}
}


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

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=0; i<n; i++) 
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 

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

L power(L b,L e,L m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  pqdesc<pair<int, int>> q;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    q.emplace(b, a);
  }
  set<int, greater<int>> se;
  rep(i, m) se.insert(i);
  i64 ans = 0;
  while (q.size()) {
    int b, a;
    tie(b, a) = q.top(), q.pop();
    auto it = se.lower_bound(m - a);
    if (it == se.end()) {
      continue;
    }
    ans += b;
    se.erase(*it);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  vector<int> a(n);
  map<int,int> mp;
  for (int &z: a) {
    cin >> z;
    mp[z]++;
  }
  sort(ALL(a));
  auto b = a;
  b.erase(unique(ALL(b)), b.end());
  if (SZ(b) == 1) {
    kek(b[0] == 0 ? "Yes" : "No");
  }
  if (SZ(b) == 2) {
    if (b[0] != 0) kek("No");
    if (n % 3 != 0) kek("No");
    if (mp[0] != n / 3) kek("No");
    kek("Yes");
  }
  if (SZ(b) == 3) {
    if (b[0] == 0) kek("No");
    if ((b[0] ^ b[1]) != b[2]) kek("No");
    if (n % 3 != 0) kek("No");
    if (mp[b[0]] == n / 3 && mp[b[1]] == n / 3 && mp[b[2]] == n / 3) kek("Yes");
    kek("No");
  }
  kek("No");
  
  return 0;
}


Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    long N = sc.nextLong();
    long A = sc.nextLong();
    long ans = N;
    for (int i = 1; i < 63; i++) {
      long width = (long) Math.ceil(Math.pow(N, 1.0 / (i + 1)));
      long time = 0;
      long cur = 1;
      for (int j = 0; j < i; j++) {
        time += width + A;
        cur *= width;
      }
      for (int j = 0; j < i; j++) {
        long t = time + (N + cur - 1) / cur - j;
//        System.out.println(i + " " + width + " " + t);
        ans = Math.min(ans, t);
        cur = cur / width * (width - 1);
      }
      if (width == 1) break;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 10320
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#define ii pair<int,int>
#define ll long long
using namespace std;
const int N = 200*1000+15;


struct lap{
    int price;
    int quality;
    int pos;
};
bool fun(lap a1,lap a2){
    return a1.price<a2.price;
}
bool is(string number){
    for(int i = 0;i <number[i];i++){
        if(number[i]!='1' && number[i]!='4'){
            return false;
        }
    }
    if(number.find("444")!=number.npos){
        return false;
    }
    if(number[0] =='4'){
        return false;
    }
    return true;
}

int main() {
    int n;cin>>n;
    vector<int>a(n);
    for(int i = 0;i <n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int t = 0;
    for(int i = 0;i <n-1;i++){
        t+=a[i];
    }
    cout<<t+a[n-1]/2;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[210001];
int i,j,k,n,m,ans;
int main(){
	scanf("%s",ch+1);n=strlen(ch+1);
	for (i=1,j=n,ans=0;i<j;){
		if (ch[i]==ch[j]){
			i++;j--;continue;
		}
		if (ch[i]=='x'){
			i++;ans++;continue;
		}
		if (ch[j]=='x'){
			j--;ans++;continue;
		}
		ans=-1;break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,n;
    scanf("%d",&n);
    
    for(i=1; i<=n; i++){
        if(i%3==0 || i%10==3 || i/10==3 || i/10%10==3 || i/100==3 || i/100%10==3 || i/1000==3 || i/1000%10==3) printf(" %d",i);
    }
    printf("\n");
    return 0;
}

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

typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    
    if(N>=2 && M>=2)
        cout << (N-2)*(M-2) << endl;
    else if(N==1&&M==1)
        cout << 1 << endl;
    else if(N==1||M==1)
        cout << max(N,M)-2 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; bool flag = true;
  
  if(n == 2) cout << 2 << endl;
  else{
  while(flag){
    flag = false;
    
    for(int i=2; i < sqrt(n)+1; i++){
      if(n % i == 0){
        n++;
        flag = true;
        break;
      }
    }
    
    if(!flag){
      cout << n << endl;
    }
  }
  }
}

Measured memory_bytes: 256
//============================================================================
// Name : firstTrial.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 20;
int fact[N], last[N];
int Pow (int b, int e) {
	if (e == 0)
		return 1;
	int ret = Pow(b, e/2);
	ret = (1LL * ret * ret) % MOD;
	if ( e & 1 )
		ret = (1LL * ret * b) % MOD;
	return ret;
}
	void popFact (int n) {
	fact[0] = 1;
	for (int i = 1 ; i <= n ; i++)
		fact[i] = (1LL * fact[i - 1] * i) % MOD;
}
int getInverse (int n) {
	return Pow (n, MOD - 2);
}
int divide (int a, int b) {
	return (1LL * a * getInverse(b)) % MOD;
}
int nCr ( int n , int r ) {
	if(r > n || n < 0 || r < 0)
		return 0;
	return divide(divide(fact[n],fact[r]), fact[n - r]);
}
int main(){
	popFact(1e5 + 1);
	int n, pos1, pos2;
	scanf("%d", &n);
	memset(last, -1, sizeof last);
	for(int i = 0; i < n + 1; i++){
		int x;
		scanf("%d", &x);
		if(last[x] != -1)
			pos1 = last[x], pos2 = i;
		last[x] = i;
	}
	for(int i = 1; i <= n + 1; i++){
//		cout << n + 1 << "C" << i <''< ',' << n - pos2 << "C" << i - 1 << ',' << pos1 - 1 << 'C' << i - 1 << endl;
		printf("%lld\n", (0ll + nCr(n + 1, i) - nCr(n - pos2 + pos1, i - 1) + MOD) % MOD);
	}
	return 0;
}


Measured memory_bytes: 2048
N,K = map(int,input().split())
A = list(map(int,input().split()))

a = 0
for i in range(N):
  for j in range(i + 1,N):
    if A[i] > A[j]:
      a += 1
      
b = 0
A.sort()
for k in A:
  b += A.index(k) * K * (K - 1) // 2
  
print((a * K + b) % 1000000007)

Measured memory_bytes: 3188
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var A = ABC[0]; var B = ABC[1]; var C = ABC[2];
            var K = int.Parse(Console.ReadLine());

            var count = 0;
            while (A >= B)
            {
                count++;
                B *= 2;
            }
            while (B >= C)
            {
                count++;
                C *= 2;
            }
            Console.WriteLine(K >= count ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27544
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize
    }

    println!(
        "{}",
        (1..101)
            .filter(|&x| a % x == 0 && b % x == 0)
            .rev()
            .nth(k - 1)
            .unwrap()
    );
}


Measured memory_bytes: 4352
import math
from itertools import accumulate
from fractions import gcd

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

L = [0]+list(accumulate(a, gcd))
R = list(accumulate(reversed(a), gcd))[::-1]+[0]


ans = 0

for i in range(n):
    ans =max(gcd(L[i],R[i+1]),ans)

if n == 2:
    print(max(a))
else:
    print(ans)


Measured memory_bytes: 16136
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl


signed main(){
    
    int N,K;
    cin >> N >> K;
    cout << N-K+1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cctype>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int MAX_N = 7;
const int CSIZE = 50;
const int MAX_S = 3001;
int N, M, S;
int dp[CSIZE][MAX_S];

void solve() {
	memset(dp, 0, sizeof(dp));
	int n2 = N * N;
	dp[0][0] = 1;
	repa(k,1,M) {
		repd(i,n2,1) {
			repa(j,0,S) {
				if(j - k >= 0) {
					dp[i][j] += dp[i-1][j-k];
					if(dp[i][j] > 100000) {
						dp[i][j] -= 100000;
					}
				}
			}
		}
	}
	printf("%d\n", dp[n2][S]);
}

int main() {
	while(scanf("%d%d%d", &N, &M, &S), N | M | S) {
		solve();
	}
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;

    return 0;
}


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

using namespace std;

string s, t;

int main()
{
    cin >> s >> t;
    string ret = "No";

    for (int i = 0; i < s.length(); i++) {
        if (s == t) {
            ret = "Yes";
            break;
        }
        // rotation
        char x = s[s.length() - 1];
        for (int i = s.length() - 1; i >= 0; i--) {
            if (i == 0) s[i] = x;
            else        s[i] = s[i - 1];
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
  int h,n,soma=0;
  int forca[112345];

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

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

  for(int i=0; i<n; i++)
    soma+=forca[i];

  if(soma<h){
    printf("No\n");
  }
  else
  {
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) vc<vc<T>> xs(n, vc<T>(m)); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, k, n);
    Cins(int, n, a);
    a.push_back(a[0] + k);
    
    int ans = 0;
    For(i, n) Maxi(ans, a[i+1] - a[i]);
    Cout(k - ans);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath> 
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
const int maxn = 1e4+5;
const int INF = 0x3f3f3f3f;
int n,m;
int a[maxn];
int main()
{
	cin>>n>>m;
	int d,sum=0;
	for(int i=1;i<=m;i++)
	{
		cin>>d;
		sum+=d;
	}
	if(sum>n)
		cout<<-1<<endl;
	else
		cout<<(n-sum)<<endl;
	return 0;
}

Measured memory_bytes: 3196
import string
from collections import defaultdict

n = int(input())
s_list = [input() for i in range(n)]

alphabet = string.ascii_lowercase
count_dict = defaultdict(int)

for c in alphabet:
  min_count = float("inf")
  for s in s_list:
    count = s.count(c)
    min_count = min(min_count, count)
    count_dict[c] = min_count

final_string = ''

for k, v in count_dict.items():
  if v == 0:
    continue
  else:
    final_string += k * v

final_string_list = list(final_string)
final_string_list.sort()
    
final_string = ''.join(final_string_list)

print(final_string)



Measured memory_bytes: 3768
using System;

namespace Atcoderrr
{
    class Program
    {
        static void Main(string[] args)
        {
            int value;
            string input;
            input = Console.ReadLine();
            for (int i = 0; i < 2; i++)
            {
                if (input[i] == input[i + 1] && input[i + 1] == input[i + 2])
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> vs(H + 2, string(W + 2, '#'));
  vector<string> in(H);
  FOR(i,0,H) cin >> in[i];
  FOR(i,0,H) FOR(j,0,W) {
    vs[i+1][j+1] = in[i][j];
  }
  FOR(i,0,H+2) cout << vs[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

    int n;
    cin >> n;
    int a = -n;
    for (int i = 0; i < n; ++i)
    {
        int m;
        cin >> m;
        a += m;
    }
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
# author:  Taichicchi
# created: 16.09.2020 23:07:07

import sys

N, M = map(int, input().split())

k = []
s = []

for i in range(M):
    _k, *_s = map(int, input().split())
    k.append(_k)
    s.append(_s)

p = list(map(int, input().split()))
ans = 0


for i in range(2 ** N):
    sw = [0 for _ in range(N)]
    for j in range(N):
        if i >> j & 1:
            sw[j] = 1

    for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 9132
N = int(input())
h = list(map(int,input().split()))

dp = [0] * N
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])

Measured memory_bytes: 13928
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

int main(){
    int n;cin>>n;
    int a[n];rep(i,0,n-1)cin>>a[i];
    ll sum=0;rep(i,0,n-1)sum+=a[i];
    cout<<sum-n<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from math import ceil, sqrt
n = int(input())

if n == 2:
    print(2)
    exit()

n = n+1 if n % 2 == 0 else n

notPrime = True
while notPrime:
    notPrime = False
    for i in range(2, ceil(sqrt(n))):
        if n % i == 0:
            n += 2
            notPrime = True
            break


print(n)


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

int main(){
  int N, count = 0;
  string S;
  cin >> N >> S;
  
  if(S.find("ABC") == -1){
    cout << 0 << endl;
    return 0;
  }
  
  for(int i = 0; i <= N-3; i++){
  	if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
    	count++;
    }  	
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else if (a == b){
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  int a[200010];
  rep(i, n) cin >> a[i];
  int cnt = 0;
  int Min = INF;
  rep(i, n)
  {
    if (Min >= a[i])
      cnt++;
    Min = min(Min, a[i]);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>

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

using namespace std;

const string Y = "IDENTICAL";
const string N = "DIFFERENT";
const string C = "CLOSE";

string elim(string s) {
  string ret = "";
  bool toggle = false;
  rep(i,(int)s.size()) {
    if( s[i] == '"' ) { 
      if( toggle ) ret += "@";
      toggle = !toggle;
      continue;
    }
    if( toggle ) continue;
    ret += s[i];
  }
  return ret;
}

vector<string> extr(string s) {
  vector<string> vec;
  bool toggle = false;
  string buf = "";
  rep(i,(int)s.size()) {
    if( s[i] == '"' ) {
      if( toggle ) {
	vec.push_back(buf);
	buf = "";
      }
      toggle = !toggle;
      continue;
    }
    if( !toggle ) continue;
    buf += s[i];
  }
  return vec;
}

int main() {
  string s,t;
  while( cin >> s, s[0] != '.' ) {
    cin >> t;
    if( s == t ) {
      puts(Y.c_str());
    } else if( elim(s) != elim(t) ) {
      puts(N.c_str());
    } else {
      vector<string> v1 = extr(s);
      vector<string> v2 = extr(t);
      int diff = 0;
      if( v1.size() != v2.size() ) {
	puts(N.c_str());
      } else {
	rep(i,(int)v1.size()) {
	  if( v1[i] != v2[i] ) {
	    ++diff;
	    continue;
	  }
	}
	( diff == 1 ) ? puts(C.c_str()) : puts(N.c_str());
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3164
s=input()
lens=len(s)
#ACGT
acgt = set(["A","C","G","T"])
kekka = [0 for _ in range(lens)]

for i in range(lens):
    if s[i] in acgt:
        kekka[i] = 1

maxsum = 0

for i in range(lens):
    if kekka[i] == 1:
        sum = 0
        for j in range(i, lens):
            if kekka[j] == 1:
                sum += 1
            else:
                break
        if sum >= maxsum:
            maxsum = sum

print(maxsum)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;cin>>s;
  sort(s.begin(),s.end());
  if(s=="abc"){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main(){
  int a,b,c,d,e,f,g,h,i,j;
  cin>>a>>b>>c>>d;
  cin>>e>>f>>g>>h;
  i=a+b+c+d;
  j=e+f+g+h;
  if(i<j)cout<<j<<endl;
  if(i>j)cout<<i<<endl;
  if(i==j)cout<<i<<endl;
      
    
    
    

  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  string s;
  cin >> s;
  string tmp;
  string tmp1, tmp2;
  for(int i = 1; i < s.size()/2; i++){
    tmp = s.substr(0,s.size() - 2*i);
    int n = tmp.size();
    tmp1 = tmp.substr(0,n/2);
    tmp2 = tmp.substr(n/2,n/2);
    if(tmp1 == tmp2){
      cout << s.size() - 2*i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256