akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int gi(){
	int x = 0;
	int w = 1;
	char ch = getchar();
	while ((ch < '0' || ch > '9') && ch != '-')
		ch = getchar();
	if (ch == '-') {
		w = 0;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar();
	}
	return w ? x : -x;
}

const int N = 605;
const int mod = 1e9+7;
int n, m, cnt, vis[N], f[2][N][N], ans;

inline void add(int &x,int y) {
	x += y;
	x >= mod ? x -= mod : x;
}

int main() {
	n = gi();
	for (int i = 1; i <= n; ++i){
		int x = gi();
		int y = gi();
		if (x != -1 && y != -1) 
			vis[x] = vis[y] = 2;
		else if (x != -1 || y != -1)
			vis[x != -1 ? x : y] = 1;
		else 
			++cnt;
	}
	for (int i = 1; i <= n << 1; ++i)
		if (vis[i] != 2)
			vis[++m] = vis[i];
	f[0][0][0] = 1; 
	for (int i = m, nxt = 1, lst = 0; i; --i, lst = nxt, nxt ^= 1) {
		memset(f[nxt], 0, sizeof(f[nxt]));
		for (int j = 0; j <= m; ++j)
			for (int k = 0; k <= m; ++k)
				if (f[lst][j][k])
					if (vis[i]) {
						add (f[nxt][j+1][k], f[lst][j][k]);
						if(k)
							add(f[nxt][j][k-1], f[lst][j][k]);
					}else{
						add(f[nxt][j][k+1], f[lst][j][k]);
						if (j)
							add(f[nxt][j-1][k], 1ll * f[lst][j][k] * j % mod);
						if (k)
							add(f[nxt][j][k-1], f[lst][j][k]);
					}
	}
	ans = f[m & 1][0][0];
	for (int i = 1; i <= cnt; ++i)
		ans = 1ll * ans * i % mod;
	printf("%d\n",ans);
}

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


using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};

const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    init();

    int n, x, y;
    cin>>n>>x>>y;
    vector<int> c(n), w(n);
    for (int i = 0; i<n; i++) {cin>>c[i]>>w[i]; c[i]--;}
    vector<vector<pair<int, int>>> a(n);
    for (int i = 0; i<n; i++) a[c[i]].push_back(mp(w[i], i));
    DSU dsu(n);

    vector<pair<int, pair<int, int>>> first;
    for (int i = 0; i<n; i++) if (a[i].size())
    {
        sort(a[i].begin(), a[i].end());
        first.push_back(mp(a[i][0].first, mp(i, a[i][0].second)));
        for (auto it: a[i])
        {
            if (it.first + a[i][0].first<=x) dsu.union_sets(it.second, a[i][0].second);
        }
    }

    sort(first.begin(), first.end());
    for (int i = 0; i<min(2, (int)first.size()); i++)
    {
        for (int j = 0; j<n; j++) if (j!=first[i].second.first)
        {
            for (auto it: a[j]) if (it.first + first[i].first<=y) dsu.union_sets(it.second, first[i].second.second);
        }
    }

    vector<bool> visited(n);

    int answer = 1;

    vector<vector<int>> bruh(n);
    for (int i = 0; i<n; i++) bruh[dsu.find_set(i)].push_back(c[i]);

    for (auto vec: bruh) if (vec.size())
    {
        sort(vec.begin(), vec.end());
        answer = mul(answer, facs[vec.size()]);

        int cur = 1;
        for (int i = 1; i<vec.size(); i++)
        {
            if (vec[i]==vec[i-1]) cur++;
            else
            {
                answer = mul(answer, invfacs[cur]); cur = 1;
            }
        }
        answer = mul(answer, invfacs[cur]);
    }
    cout<<answer;
}

Measured memory_bytes: 33392
import itertools
import math

N = int(input())
X = []
Y = []

for i in range(N):
	x,y = map(int,input().split())
	X.append(x)
	Y.append(y)
	
def des(i, j):
	return math.sqrt( (X[i] - X[j]) ** 2.0 + (Y[i] - Y[j]) ** 2.0)
	
s = 0
for c in itertools.combinations(range(N), 2):
	s += des(c[0],c[1])
	
print(s*2 / N)

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> a(M * 2)
  ;for (int i = 0; i < M * 2; i++) {
    cin >> a.at(i);
  }
  
  vector<int> count(N)
    
  ;for (int i = 0; i < M * 2; i++) {
    for (int j = 0; j < N; j++) {
      if (a.at(i) == j+1) {
        count.at(j)++;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int avg(int *c,int n) {

	int sum=0,max=-1,min=1000;
	int i;

	for(i=0;i<n;i++) {
		if(c[i]>max)
			max=c[i];
		if(min>c[i])
			min=c[i];
	}

	for(i=0;i<n;i++)
		sum+=c[i];

	return (sum-max-min)/(n-2);
}

int main() {

	int n;
	int *c;
	int i,Answer[20],a=0;


	for(;;) {
		scanf("%d",&n);
		if(n==0)	break;
		c=(int *)malloc(n*sizeof(int));
		for(i=0;i<n;i++)
			scanf("%d",&c[i]);
		Answer[a]=avg(c,n);
		a++;
		free(c);
	}

	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> P(N);
  vector<int> Q(N);
  for(int i=0; i<N; i++){
    int p;
    cin>>p;
    P.at(i)=p;
  }
  for(int i=0; i<N; i++){
    int q;
    cin>>q;
    Q.at(i)=q;
  }
  map<vector<int>, int> order;
  int iter=1;  
  vector<int> v(N);
  for(int i=0; i<N; i++) v.at(i)=i+1;
  while(next_permutation(v.begin(), v.end())){
    order[v]=iter;
    iter++;
  }
  cout<<abs(order[P] - order[Q])<<endl;
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

stack<int>s;
char ch[11];

int main()
{
    while(cin>>ch)
    {
        
        if(ch[0] == '+')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a+b);
        }
        else if(ch[0] == '-')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(b-a);
        }
        else if(ch[0] == '*')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a*b);
        } else{
            s.push(atoi(ch));
        }
    }
    cout << s.top() << endl;
    return 0;
}



Measured memory_bytes: 3116
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;


public class Main {
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	int m=2019;
	long[] p10=new long[(int)3e5];
	{
		p10[0]=1;
		for (int i=1;i<p10.length;++i) p10[i]=p10[i-1]*10%m;
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		char[] cs=sc.next().toCharArray();
		long[] cnt=new long[m];
		long pre=0;
		cnt[0]=1;
		for (int i=cs.length-1;i>=0;--i) {
			pre=(pre+(int)(cs[i]-'0')*p10[cs.length-1-i])%m;
			++cnt[(int)pre];
		}
		long ans=0;
		for (int i=0;i<m;++i) {
			ans+=cnt[i]*(cnt[i]-1)/2;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

Measured memory_bytes: 36680
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#define _GLIBCXX_DEBUG//.at(i)を[i]と書いても許される
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
 string s;
int main(){
	cin>>s;
	SORT(s);
		bool a = true;
		for(int i = 0;i < s.size()-1; i++){
		if(s.at(i+1)==s.at(i)){
			a = false;
			cout<<"no"<<endl;
			break;
		}
		}
		if(a){
			cout<<"yes"<<endl;
		}
}

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

#define ar array
#define ll long long int

bool check(ll x, ll y, ll z) {
    return x + y > z and y + z > x and x + z > y and x != y and y != z and x != z;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       int n;
       cin >> n;
       vector<ll> a(n);
       for (ll &x : a)
            cin >> x;
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                for (int k = j + 1; k < n; ++k) {
                    if (check(a[i], a[j], a[k]))
                        ++ans;
                }
            }
        }
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);

  if ((a + b) % 2 == 1)
  {
    cout << "IMPOSSIBLE" << endl;
  }
  else
  {
    cout << (a + b) / 2 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N,a,b,c,i;
	scanf("%d", &N);
	for(i=0; i<N; i++ ){
		scanf("%d%d%d", &a, &b, &c);
		a = a*a;
		b = b*b;
		c = c*c;
		if(a == b+c || b == a+c || c == a+b) printf("YES\n");
		else printf("NO\n");
	}
        return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int main()
{
    int arr[5]={1,2,3,4,5};
    int a[5];int i;int j;
    for(i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(j=0;j<5;j++)
    {
        if
           (arr[j]!=a[j])
            cout<<arr[j];

    }
    return 0;
}


Measured memory_bytes: 3580
N,X,M = map(int,input().split())
A = [100001]*(2*(10**5)+100)
A[1] = X
S = {X}
ans = X
for i in range(2,min(2*M+1,N)+1):
  X = X**2
  X %= M
  ans += X
  A[i] = X
  if X in S:
    break
  S.add(X)
  #print(i)
#[print(A[i]) for i in range(6)]
if N == 1:
  print(X)
  exit()
elif i == N:
  print(ans)
else:
  j = A[:i+1].index(A[i])
  if i == j:
    print(ans)
  k = (N-i)//(i-j)
  l = (N-i)%(i-j)
  #print(j,k,l)
  ans += k*sum(A[j+1:i+1])+sum(A[j+1:j+l+1])
  print(ans)




Measured memory_bytes: 75728
n = int(input())
num = sum(list(range(n+1)))

a = int(n/3)
a = sum(list(range(a+1)))

b = int(n/5)
b = sum(list(range(b+1)))

c = int(n/15)
c = sum(list(range(c+1)))

print(num-(3*a)-(5*b)+(15*c))

Measured memory_bytes: 48412
// B - I miss you...
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string S;

int main(){
	cin>>S;
	rp(i,0,S.size()) S[i] = 'x';
	cout<< S <<endl;
}

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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;


using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define PI 3.1415926535897932384626433832795
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
    #ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int count[26] = {0};
    for(int i=0;i<s.size();i++)
    {
        count[s[i]-'a']++;
    }   

    ll sum = 1;

    for(int i=0;i<26;i++)
    {
        sum = (sum*(count[i]+1))%mod;
    }

    sum = ((sum-1)%mod + mod)%mod;
    cout << sum << "\n";    return 0;
}

Measured memory_bytes: 512
# ABC059 C - Sequence
n=int(input())
a=list(map(int,input().split()))

total=a[0]
ans=0
if total<=0:
    ans=1-total
    total=1

for aa in a[1:]:
    if total>0:
        y=total+aa
        if y<0:
            total=y
        else:
            ans+=y+1
            total=-1
    else:
        y=total+aa
        if y>0:
            total=y
        else:
            ans+=1-y
            total=1


total=a[0]
ans2=0
if total>=0:
    ans2+=total+1
    total=-1

for aa in a[1:]:
    if total>0:
        y=total+aa
        if y<0:
            total=y
        else:
            ans2+=y+1
            total=-1
    else:
        y=total+aa
        if y>0:
            total=y
        else:
            ans2+=1-y
            total=1

print(min(ans,ans2))
        


Measured memory_bytes: 14648
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int A, B;
    cin >> A >> B;
    cout << A * B << endl;

    return 0;
}

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

#define ll long long

using namespace std;

int main(){
    ll a,b; cin>>a>>b;
    ll mn,mx;
    mn = min(a,b);   mx = max(a,b);
    for(int i=0; i<mx; i++){
        cout<<mn;
    }
    cout<<"\n";
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

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

  int N, M, K;
  cin >> N >> M >> K;
  for (int n = 0; n <= N; n++) {
    for (int m = 0; m <= M; m++) {
      int tmp = n * M + m * N - n * m * 2;
      if (tmp == K) return cout << "Yes" << "\n", 0;
    }
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 10200000, mo = 998244353;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int n,fac[N],ifac[N],qz[N],mi[N],v[N];
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int main() {
	read(n);iniC(n);int res=1;rep(i,1,n)res=3LL*res%mo;
	mi[0]=1;rep(i,1,n)mi[i]=2*mi[i-1]%mo;
	rep(i,0,n/2)v[i]=1LL*C(n/2,i)*mi[i]%mo,qz[i]=qz[i-1],add(qz[i],v[i]);
	rep(i,0,n/2-1)res=(res-2LL*v[i]*qz[n/2-i-1])%mo;
	cout<<(res+mo)%mo;return 0;
}


Measured memory_bytes: 162048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <vector>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <ctime>
#include <numeric>
using namespace std;

#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(unique(all(x)) - (x).begin())
#define ld long double
#define int long long

void SOLVE() {
	int n, a, b;
	cin >> n >> a >> b;
	if (n < a) {
		cout << n << '\n';
		return;
	}
	if (n < a + b) {
		cout << a << '\n';
		return;
	}
	int ct = n / (a + b);
	int ost = n - ct * (a + b);
	int res = ct * a + min(ost, a);
	cout << res << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	int Q = 1;
	//cin >> Q;
	while (Q--) {
		SOLVE();
	}

	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int A[n]; for (int i=0; i<n; i++) cin >> A[i];

    for (int k=2; k <= m; k++)
        for (int i=0; i <= n-2; i++)
            if ( A[i] % k > A[i+1] % k ) swap( A[i], A[i+1] );

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


Measured memory_bytes: 3112
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Mar 30 20:32:41 JST 2020
 **/

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

signed main() {
    Int n, S;
    std::cin >> n >> S;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    Int ans = 1e9, j = 0, sum = 0;
    REP(i, n) {
        while (j < n && sum + a[j] < S) {
            sum += a[j];
            j++;
        }
        if (j != n) chmin(ans, j - i + 1);
        sum -= a[i];
    }
    std::cout << (ans == 1e9 ? 0 : ans) << std::endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn=1e5+6;
const int mod=1e9+7;
int n;
int sum[maxn][5];
char s[maxn];
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}     
int main(){
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='R')  sum[i][1]=sum[i-1][1]+1;
		else sum[i][1]=sum[i-1][1];
		
		if(s[i]=='G')  sum[i][2]=sum[i-1][2]+1;
		else sum[i][2]=sum[i-1][2];
		
		if(s[i]=='B')  sum[i][3]=sum[i-1][3]+1;
		else sum[i][3]=sum[i-1][3];
	}
	LL ans=0;
	for(int i=2;i<n;i++){
		if(s[i]=='R'){
			ans+=sum[i][2]*(sum[n][3]-sum[i][3]);
			ans+=sum[i][3]*(sum[n][2]-sum[i][2]);
		}
		if(s[i]=='G'){
			ans+=sum[i][1]*(sum[n][3]-sum[i][3]);
			ans+=sum[i][3]*(sum[n][1]-sum[i][1]);
		}
		if(s[i]=='B'){
			ans+=sum[i][2]*(sum[n][1]-sum[i][1]);
			ans+=sum[i][1]*(sum[n][2]-sum[i][2]);
		}
	}
	for(int i=1;i<=n;i++)
	   for(int k=1;k<n;k++){
	   	    if(i+k>n||i+2*k>n)
	   	        break;
	   	    if(s[i]!=s[i+k]&&s[i]!=s[i+2*k]&&s[i+k]!=s[i+2*k])
	   	        ans--;
	   }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 100

using namespace std;

long long r, D;

long long calc(long long x){
    return x * r - D;
}

int main(void){
    long long x;
    scanf("%lld %lld %lld", &r, &D, &x);

    for(int i = 0; i < 10; i++){
        x = calc(x);
        printf("%lld\n", x);
    }
}


Measured memory_bytes: 888
<?php

while(true){
    $num = explode(" ",trim(fgets(STDIN)));
    $x = $num[0];
    $y = $num[1];
    if($x == 0 && $y == 0){
        break;
    } elseif ($x < $y){
        echo $x." ".$y .PHP_EOL;
    } else {
        echo $y." ".$x .PHP_EOL;
    }
}

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

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<double> temp(N);
	rep(i, N) {
		int H;
		cin >> H;
		temp.at(i) = abs(T - H * 0.006 - A);
	}
	cout << min_element(temp.begin(), temp.end()) - temp.begin() + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if (b > c) {
            int tmp = b;
            b = c;
            c = tmp;
        }
        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        System.out.printf("%d %d %d\n", a, b, c);
    }
}


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

int lcs(char *,char *);

int main(){
  int q,i,j;
  char data1[1001],data2[1001];
  scanf("%d",&q);

  for(i = 0;i < q;i++){
    scanf("%s",data1);
    scanf("%s",data2);
    printf("%d\n",lcs(data1,data2));
  }
  

  return 0;
}

int lcs(char *data1,char *data2){
  int a[1001][1001],i,j,x,y;
  x = strlen(data1) + 1;
  y = strlen(data2) + 1;

  for(i = 1;i < x;i++){
    a[0][i] = 0;
  }
  for(i = 0;i < y;i++){
    a[i][0] = 0;
  }

  for(i = 1;i < x;i++){
    for(j = 1;j < y;j++){
      if(data1[i - 1] == data2[j - 1]){
        a[i][j] = a[i - 1][j -1] + 1;
      }
      else if(a[i - 1][j] >= a[i][j - 1]){
        a[i][j] = a[i - 1][j];
      }
      else{
        a[i][j] = a[i][j - 1];
      }
    }
  }
  return a[x - 1][y - 1];
}



Measured memory_bytes: 5740
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n;
  string s;
  cin >> n >> s;


  int a = 0;
  char store = 'A';
  for (int i = 0; i < n; i++){
    if (store != s[i]){
      store = s[i];
      a++;
    }
  }


  cout << a << endl;

  return 0;
}


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

using namespace std;

int n;
int a[112123];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (a[a[i]] == i) ans++;
	cout << ans / 2 << '\n';
	return 0;
}



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

int N;
double p[3010];
double dp[3010][3010] = {0};

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


cin >> N;
rep(i,N) cin >> p[i];

dp[0][0] = 1;

rep(i,N) {
    rep(j,N) {
        dp[i+1][j] += (1-p[i]) * dp[i][j];
        dp[i+1][j+1] += p[i] * dp[i][j];
    }
}
double ans = 0;
rrep(j,N) {
    if(j > N/2) ans += dp[N][j];
}
cout << fixed << setprecision(10) << ans << endl;
return 0;
}

Measured memory_bytes: 70784
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef double db;
const int N=1e6+5,mo=1e9+7;
int fac[N],rev[N],i,cnt1,f[N],w[N],ans,n;
int ksm(int x,int y)
{
    if (y<0) y=1ll*(-y)*(mo-2)%(mo-1);
    int ret=1;
    while (y)
    {
        if (y&1) ret=1ll*ret*x%mo;
        y>>=1;
        x=1ll*x*x%mo;
    }
    return ret;
}
int c(int m,int n)
{
    return 1ll*fac[m]*rev[n]%mo*rev[m-n]%mo;
}
void predo(int n)
{
    fac[0]=1;
    fo(i,1,n) fac[i]=1ll*fac[i-1]*i%mo;
    rev[n]=ksm(fac[n],mo-2);
    fd(i,n,1) rev[i-1]=1ll*rev[i]*i%mo;
}
int calc(int x)
{
    //2*x-n+2=cnt1
    cnt1=2*x-n+2;
    if (cnt1>x||cnt1<0) return 0;
    return c(x,cnt1);
}
int main()
{
    scanf("%d",&n);
    predo(n);
    fo(i,0,n-2)
    {
        f[i]=1ll*c(n-2,i)*fac[i]%mo;
        w[i]=calc(i-1);
        f[i]=(f[i]+1ll*c(n-2,i-1)*fac[i]-1ll*w[i]*fac[i])%mo;
        if (!i) f[i]=1;
        ans=(ans+1ll*f[i]*fac[n-1-i])%mo;
    }
    if (ans<0) ans+=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;
  vi H(N);
  cin >> H;
  vi dp(N,INF);
  dp[0] = 0;
  rep(i,N-1) rep(j,1,K+1){
    if(i+j>=N) continue;
    chmin(dp[i+j],dp[i]+abs(H[i+j]-H[i]));
  }
  cout << dp[N-1] << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1792
s = input()
ans = 'None'

a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(a)):
	if s.find(a[i]) == -1:
		ans = a[i]
		break
	
print(ans)

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

char Getgrade(int middle, int last, int again){
    int sum = middle + last;
    char grade;
    if(middle == -1 && again ==-1) grade = 'F';
    else if(last == -1 && again == -1) grade ='F';
    else if(sum >= 80) grade = 'A';
    else if(sum >= 65 && sum < 80) grade = 'B';
    else if(sum >= 50 && sum < 65) grade = 'C';
    else if(sum >= 30 && sum < 50) {
        if( again >= 50) grade ='C';
        else grade = 'D';
    }
    else if(sum < 30) grade = 'F';

    return grade;
}

int main(){
    int m, f, r;

    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        cout << Getgrade(m, f, r) << endl;

    }
    return 0;
}


Measured memory_bytes: 3092
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vi a(n);
	loop(i,n)
	cin>>a[i];
	int ans=0;
	int count=0;
	l00p(i,1,n)
	{
		if(a[i]>a[i-1])
		{
			ckmax(ans,count);
			count=0;
		}
		else 
		count++;
	}
	ckmax(ans,count);
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3764
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


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

using namespace std;

int N;
double P[3010];
double memo[3010][3010]; // N, banyak yang head
bool vstd[3010][3010];
double dp(int n, int m) {
	if (n < m) return 0;
	if (n < 1) return 1;
	if (m < 0) return 1;
	if (vstd[n][m]) return memo[n][m];
	vstd[n][m] = 1;
	double &ans = memo[n][m];
	ans = dp(n - 1, m) * (1 - P[n]) + dp(n - 1, m - 1) * P[n];

	return ans;
}
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
	}

	cout << fixed << setprecision(18) << dp(N, (N + 1)/2) << endl;
	return 0;
}

Measured memory_bytes: 78592
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for (int n = 0; n < N; n++) {
            switch (in.next()) {
                case "AC":
                    ac++;
                    break;
                case "WA":
                    wa++;
                    break;
                case "TLE":
                    tle++;
                    break;
                case "RE":
                    re++;
                    break;
            }
        }

        out.println("AC x " + ac);
        out.println("WA x " + wa);
        out.println("TLE x " + tle);
        out.println("RE x " + re);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 48892
/*input
8 12 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n;
	cin>>n;
	int ans=0;
	REP(i,n){
		int x;
		cin>>x;
		ans=__gcd(ans,x);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vint A;
	scan(N);
	rep(i,N){
		int a;
		scan(a);
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	int max1=0,max2=0;
	int count=0;
	int nownum=0;
	for(int i=A.size()-1;i>=0;i--){
		if(A[i]==nownum) count++;
		else{
			nownum=A[i];
			count=1;
		}
		if(count==2||count==4){
			if(max1==0) max1=A[i];
			else if(max2==0){
				max2=A[i];
				break;
			}
		}
	}
	ll menseki=(ll)max1*max2;
	prin(menseki);

	return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, W;
string s;

int main() {
    cin >> n >> W;

    VVi dp(n+1, Vi(W+1, 0));
    REP2(i, 1, n+1) {
        int v, w; cin >> v >> w;
        REP(j, W+1) {
            if (j < w) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v);
        }
    }
    std::cout << dp[n][W] << '\n';

    return 0;
}



Measured memory_bytes: 6768
let () =
  let n = read_int () in
  let rec doit i m ans =
    if i = n then ans
    else
      let r = read_int () in
      doit (i + 1) (if m < r then m else r) (if ans > (r - m) then ans else r - m) in
  Printf.printf "%d\n" (doit 1 (read_int ()) min_int)

Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    string S;
    cin >> S;

    REP(i,3) {
        if (S[i] == 'R') ans++;
    }

    if (S == "RRR") cout << 3 << endl;
    else if (S == "RRS"  || S == "SRR") cout << 2 << endl;
    else if (ans >= 1) cout << 1 << endl;
    else cout << 0 << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(std::string S){
    ll ans = 700;
    rep(i, 3){
        if(S.at(i)=='o')
            ans += 100;
    }
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,cnt[MAXN],vis[MAXN],ans;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read();
	Rep(i,1,n)cnt[i]=1;vis[1]=1;
	Rep(i,1,m){
		int a=read(),b=read();
		vis[b]|=vis[a],cnt[a]--,cnt[b]++;
		if(cnt[a]==0)vis[a]=0;
	}Rep(i,1,n)ans+=vis[i]&&cnt[i];
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
long long N, K;
int main() {
    cin >> N >> K;
    long long sum = 1;
    for(int i = 0; i < N; ++i) {
        if(i == 0) {
            sum *= K;
        }else {
            sum *= K-1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define fileio(in, out) freopen("in", "r", stdin); freopen("out", "w", stdout)
const int mod = (int)(1e9) + 7;
//endregion

int main() {
    io();
    int n;
    in(n);
    vii arr(n);
    fori (i, n) {
        in(arr[i].first);
        arr[i].second = i+1;
    }
    qsort(arr);
    forr (i, arr) {
        outs(i.second);
    }
}


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

int gcd(int a, int b, int c)
{
  return __gcd(__gcd(a, b), c);
}

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

  int ans = 0;
  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        ans += gcd(i, j, k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636