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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;
    Vec d(k);
    cin>>d;
    auto ok=[&](ll x){
        string s = to_string(x);
        bool ok = true;
        rep(i,s.length()){
            rep(j,d.size()){
                if(s[i]-'0' == d[j]){
                    ok = false;
                }
            }
        }
        return ok;
    };
    REP(x,n,1e6){
        if(ok(x)){
            out(x);
            return  0;
        }
    }
}


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


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)
		cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define fr front()
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

#define ll long long
#define oo 1e18 + 7
#define int long long

const int N = 3e3 + 5;
const int VAL = 2e5 + 5;
int n , m , k , mod = 1e9 + 7;
int dp[N] , fact[VAL] , rfact[VAL];
ii a[N];
/// dp[i] là số cách để đi tới đích mà cái bẫy cuối cùng nó đi là cái bẫy thứ i.

int mul(int a , int b)
{
    return (a * b) % mod;
}

int add(int a , int b)
{
    return (a + b) % mod;
}

int sub(int a , int b)
{
    return ((a - b) % mod + mod) % mod;
}

int powmod(int a , int b)
{
    int ret = 1;
    while(b)
    {
        if(b & 1)
            ret = mul(ret , a);
        a = mul(a , a);
        b >>= 1;
    }
    return ret;
}

int C(int n , int k)
{
    return mul(fact[n] , mul(rfact[n - k] , rfact[k]));
}

main()
{
    //freopen("Y.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    FOR(i , 1 , k)
        cin >> a[i].fi >> a[i].se;
    sort(a + 1 , a + 1 + k);
    fact[0] = 1;
    FOR(i , 1 , n + m)
        fact[i] = mul(fact[i - 1] , i);
    rfact[n + m] = powmod(fact[n + m] , mod - 2);
    FORD(i , n + m - 1 , 0)
        rfact[i] = mul(rfact[i + 1] , i + 1);
    FOR(i , 1 , k)
    {
        dp[i] = C(a[i].fi + a[i].se - 2 , a[i].fi - 1);
        FOR(j , 1 , i - 1)
            if(a[j].se <= a[i].se)
                dp[i] = add(dp[i] , mul(-dp[j] , C(a[i].fi - a[j].fi + a[i].se - a[j].se , a[i].fi - a[j].fi)));
    }
    int res = C(n + m - 2 , n - 1);
    FOR(i , 1 , k)
        res = sub(res , mul(dp[i] , C(n - a[i].fi + m - a[i].se , n - a[i].fi)));
    cout << res;
}


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

int prime_size(ll g){
	ll i = 2;
	int count = 0;
	while (true){
		int number = 0;
		while(g%i==0){
			g /= i;
			number++;
		}
		if(number!=0){
			count++;
		}
		if(i*i > g){
			break;
		}
		i++;
	}
	if(g!=1){
		count++;
	}
	return count;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

ll gcd(ll a, ll b){
    if(a < b){
        swap(a, b);
    }
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {

    ll A, B;
    cin >> A >> B;
	if(min(A, B)==1){
		cout << 1;
		return 0;
	}
	ll g = gcd(A, B);
	auto pf = prime_factorize(g);
	int count = prime_size(g) + 1;

	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n;
struct node{
    int id;
    int deg;
    bool operator < (const node &t)const
    {
        return deg>t.deg;
    }
}p[10010];
vector<int> G[10010];
int vis[10010];
int val[10010];
ll ansans;
int ans[10010];
bool cmp(int a,int b)
{
    return a>b;
}
void solve(int x)
{
    priority_queue<node> q;
    q.push(p[x]);
    vis[x] = 1;
    int cnt = 1;
    while(!q.empty()){
        node cur = q.top();
        ans[cur.id] = val[cnt++];
        q.pop();
        for(int i = 0;i < G[cur.id].size();i++){
            if(!vis[G[cur.id][i]]){
                q.push(p[G[cur.id][i]]);
                vis[G[cur.id][i]] = 1;
            }
        }
    }
}

int main()
{
	scanf("%d",&n);
	for(int i = 1; i<= n;i++){
        p[i].id = i;
        p[i].deg = 0;
        vis[i] = 0;
	}
	ansans = 0;
	int maxn = 0;
	int idx;
	for(int i = 1; i<= n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
        p[a].deg++;
        p[b].deg++;
        if(p[a].deg>maxn){
            maxn = p[a].deg;
            idx = a;
        }
        if(p[b].deg>maxn){
            maxn = p[b].deg;
            idx = b;
        }
	}
	for(int i = 1; i<= n;i++){
        scanf("%d",&val[i]);
	}
	sort(val+1,val+n+1,cmp);
	solve(idx);
	for(int i = 1;i <= n;i++){
        for(int j = 0 ;j < G[i].size();j++){
            ansans += min(ans[i],ans[G[i][j]]);
        }
	}
	printf("%lld\n",ansans/2);
	for(int i = 1;i <= n;i++){
        if(i == 1) printf("%d",ans[i]);
        else printf(" %d",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 1280
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    
    N := nextInt()
    
    highest := 0
    total := 0
    
    for i := 0; i < N; i += 1{
        p := nextInt()
        total += p
        highest = Max(highest, p)
    }
    
    fmt.Println(total - highest/2)
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    if ((c > a && c < b) || (c < a && c > b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


using namespace std;

int main()
{
  string S;
  cin >> S;
  int m = 10000;
  for( int i=0;i<S.length()-2;i++ )
    {
      int t = 100*int(S[i]-'0')+10*int(S[i+1]-'0')+int(S[i+2]-'0');
      int d = abs(t-753);
      if( d<m )
	{
	  m = d;
	}
    }
  cout << m << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def main():
    N, K = map(int, input().split())
    Nodes = [set() for _ in range(N)]
    MOD = 10 ** 9 + 7
    for i in range(N - 1):
        a, b = map(int, input().split())
        Nodes[a - 1].add(b - 1)
        Nodes[b - 1].add(a - 1)
    def helper(n, k, f):
        l = len(Nodes[n])
        r = (K - k) 
        j = 1 if k == 0 else 2
        for i in Nodes[n]:
            if i == f:
                continue
            r = r * helper(i, j, n) % MOD
            j += 1
        return r
    for i in range(N):
        if len(Nodes[i]) == 1:
            break
    return helper(i, 0, -1)

print(main())


Measured memory_bytes: 145680
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	rep(i, n) {
		if (ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	long long N,ans=0;
	cin>>N;
	vector<long long> A(N);
	for(int i=0;i<N;i++) cin>>A[i];

	for(int i=1;i<N;i++){
		if(A[i]<A[i-1]){
			ans+=A[i-1]-A[i];
			A[i] = A[i-1];
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int w=count(s.begin(),s.end(),'.'),b=0;
	int ans=w;
	for(int i=0;i<n;i++){
		b+=(s[i]=='#');
		w-=(s[i]=='.');
		ans=min(ans,b+w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])cout << "Bad" << endl;
  else cout << "Good" << endl;

}

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

int main(){
  int x, a, b, c;
  cin >> x;
  a = (x - (x % 100)) / 100;
  c = (x - (a * 100)) % 10;
  b = (x - (a * 100) - c) / 10;
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())
P = {'s':r, 'p':s, 'r':p}
 
mx = r*T.count('s')+s*T.count('p')+p*T.count('r')
if len(T)<k:
    print(mx)
else:
    for i in range(n-k):
        if T[i]==T[i+k]:
            mx -= P[T[i]]
            T[i+k] = '_'
print(mx)


Measured memory_bytes: 77304
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final long n = sc.nextLong();
		
		if(n == 0){
			System.out.println(0);
		}else{
			System.out.println(Long.numberOfTrailingZeros(Long.highestOneBit(n)) + 1);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 24488
#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define uint unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
#define PI 3.141592653589793238

using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	int a,b;
	cin>>n;
	cin>>a>>b;int i;
	for( i=a;i<=b;i++)
	{
		if(i%n==0)
		{
			cout<<"OK";break;
		}
	}
	if(i>b)
		cout<<"NG";
}


Measured memory_bytes: 3656
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	n, _ := strconv.Atoi(scanLine(scanner))

	min := int(math.Pow(10, 15))
	for index := 0; index < 5; index++ {
		input, _ := strconv.Atoi(scanLine(scanner))
		if min > input {
			min = input
		}
	}

	time := calcDivisionRoundUp(n, min)
	time += 5 - 1

	fmt.Print(time);
}

func scanLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func calcDivisionRoundUp(dividend int, divisor int) int {
	return int(math.Ceil(float64(dividend) / float64(divisor)))
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import math

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, V: int, B: int, W: int, T: int):
    if V <= W :
        print(NO)
        exit()
    
    x_dif = abs(A-B)
    v_dif = abs(W-V)

    if math.ceil(x_dif / v_dif) <= T:
        print(YES)
    else:
        print(NO)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, V, B, W, T)

if __name__ == '__main__':
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[201010];
int L[202020];
int R[202020];
ll LSS[202020];
ll RSS[202020];

ll B[201010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	FOR(i,N) B[i]=A[i];
	for(i=N-2;i>=0;i--) {
		LSS[i]=LSS[i+1];
		while(1) {
			x=lower_bound(B+i+1,B+N,B[i])-B;
			if(x==i+1) break;
			for(j=i+1;j<x;j++) {
				B[j]*=4;
				LSS[i]+=2;
			}
			for(j=x;j<N;j++) {
				if(B[j]>1LL<<40) {
					LSS[i]+=(N-j)*2;
					break;
				}
				if(B[j]>=B[j-1]) break;
				B[j]*=4;
				LSS[i]+=2;
			}
		}
	}
	FOR(i,N) B[N-i-1]=A[i];
	for(i=0;i<N;i++) {
		if(i) RSS[i]=RSS[i-1];
		RSS[i]++;
		while(1) {
			x=lower_bound(B+(N-1-i)+1,B+N,A[i])-B;
			if(x==(N-1-i)+1) break;
			for(j=(N-1-i)+1;j<x;j++) {
				B[j]*=4;
				RSS[i]+=2;
			}
			for(j=x;j<N;j++) {
				if(B[j]>1LL<<40) {
					RSS[i]+=(N-j)*2;
					break;
				}
				if(B[j]>=B[j-1]) break;
				B[j]*=4;
				RSS[i]+=2;
			}
		}
	}
	
	
	
	ll mi=LSS[0];
	
	for(i=1;i<N;i++) {
		ll tot=LSS[i]+RSS[i-1];
		mi=min(mi,tot);
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 7936
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();
        String c;
        if(a < b) {
            c = "<";
        } else if(a > b) {
            c = ">";
        } else {
            c = "==";
        }
        System.out.println("a " + c + " b");
    }

}


Measured memory_bytes: 26124
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h) cin >> c[i];
    int ans = 0;
    for(int tmp = 0; tmp < (1 << h); tmp++) {
        bitset<6> s(tmp);
        for(int tmo = 0; tmo < (1 << w); tmo++) {
            bitset<6> t(tmo);
            int count = 0;
            rep(i, h) {
                rep(j, w) {
                    if(c[i][j] == '#' && s[i] == 1 && t[j] == 1) count++;
                }
            }
            if(count == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,ans,counter=0;

  cin >> N;

  vector<int> A(N);

  for(int i=0;i<N;i++){
    cin >>A.at(i);
  }//入力終了

  sort(A.begin(),A.end());
 
  cout << A.at(A.size()-1) - A.at(0) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1000000001;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  vector<ll> c(3, 0);
  for(int i = 0; i < n; ++i){
    if(s[i] == 'R') c[0]++;
    if(s[i] == 'G') c[1]++;
    if(s[i] == 'B') c[2]++;
  }

  ll rgb = 0;
  for(int i = 1; i <= 1999; ++i){
    for(int j = 0; j+2*i < n; ++j){
      if(s[j] == 'R' && s[j+i] == 'G' && s[j+2*i] == 'B') rgb++;
      if(s[j] == 'R' && s[j+i] == 'B' && s[j+2*i] == 'G') rgb++;
      if(s[j] == 'B' && s[j+i] == 'R' && s[j+2*i] == 'G') rgb++;
      if(s[j] == 'B' && s[j+i] == 'G' && s[j+2*i] == 'R') rgb++;
      if(s[j] == 'G' && s[j+i] == 'R' && s[j+2*i] == 'B') rgb++;
      if(s[j] == 'G' && s[j+i] == 'B' && s[j+2*i] == 'R') rgb++;
    }
  }

  ll ans = c[0] * c[1] * c[2] - rgb;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        int[] num = new int[] { sc.nextInt(), sc.nextInt(), sc.nextInt() };
        Arrays.sort(num);
 
        ln(StringUtils.join(num, " "));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}
 
class StringUtils {
    public static String join(int[] array, String separator) {
        StringBuilder str = new StringBuilder(array[0] + "");
        for (int i = 1; i < array.length; i++) {
            str.append(separator).append(array[i] + "");
        }
        return str.toString();
    }
 
    public static String join(Object[] array, String separator) {
        StringBuilder str = new StringBuilder(array[0] + "");
        for (int i = 1; i < array.length; i++) {
            str.append(separator).append(array[i] + "");
        }
        return str.toString();
    }
}


Measured memory_bytes: 26180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<pair<int,int>,string> item;
main(){
	int n,i,w,s,S;
	for(string f;cin>>n,n;){
		vector<item>items;
		vector<int>num,result;
		for(i=0;i<n;i++)cin>>f>>w>>s,items.push_back(make_pair(make_pair(w,s),f)),num.push_back(i);
		S=99999;
		do{
			for(s=w=0,i=n-1;~i;i--){
				pair<int,int> weight=items[num[i]].first;
				if(weight.second<w)break;
				w+=weight.first;
				s+=(i+1)*weight.first;
			}
			if(i<0&&s<S)S=s,result=num;
		}while(next_permutation(num.begin(),num.end()));
		for(i=0;i<n;i++)cout<<items[result[i]].second<<endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>

using namespace std;

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

  long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (a[i] - 1);
  }

  cout << sum << endl;
}


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

int main(){
	int N,x,ans=0;
	cin>>N>>x;
	
	int a[N];
	for(int i=0;i<N;i++)
		cin>>a[i];
	
	sort(a,a+N);
	
	for(int i=0;i<N;i++){
		x-=a[i];
		if(x>=0){
			ans++;
		}
		else
			break;
	}
	
	if(x>0)
		ans--;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
char s[100];
char orgS[100];

int shim(char x){
  int ans = 101;
  int L = strlen(s);
  int check=0;
  for (int i=1;i<strlen(s);i++){
    if (s[0] !=s[i]){
      check = 1;
      break;
    }
  }if (check == 0)return 0;
  for (int i=0;i<100;i++){
    if (check == 0){
      ans = i;
      break;
    }
    check = 0;
    for (int j=0;j<L-1;j++){
      if (s[j+1] == x)s[j] = s[j+1];
      if (s[j+1] != x&&s[j] !=x){
        check++;
      }
    }
    L--;
  }
  for (int i=0;i<100;i++){
    s[i]=orgS[i];
  }
  return ans;
}


int main(){
  scanf("%s",s);
  for (int i=0;i<100;i++){
    orgS[i] = s[i];
  }
  int best = 101;
  for (char x = 'a';x <= 'z';x++){
    if (best > shim(x))best = shim(x);
  }
  printf("%d\n",best);
}





Measured memory_bytes: 128
using System;
class p
{
  static void Main()
  {
    int A = int.Parse(Console.ReadLine());
    int B = int.Parse(Console.ReadLine());
    int C = int.Parse(Console.ReadLine());
    int D = int.Parse(Console.ReadLine());
    Console.WriteLine(Math.Min(A, B) + Math.Min(C, D));
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m,ans,a,nk,count;
  while(cin>>n>>m){
    if(n==0&&m==0) break;
    int p[n];
    nk = n;
    count = 0;
    for(int i=0;i<n;i++) cin >> p[i];
    sort(p,p+n,greater<int>());
    ans = 0;
    a = 0;
    while(nk>=m){
      for(int i=a;i<(a+m)-1;i++) ans += p[i];
      a += m;
      nk -= m;
      count += m;
    }
    if(n>count){
      for(int i=count;i<n;i++) ans += p[i];
    }     
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100005
#define m 1000000007
#define dd double
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	if(s.compare(t.substr(0, t.length()-1))==0)
		cout<<"Yes";
	else cout<<"No";
}

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

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;
  cin >> n;
  
  ll ans =  ll(n/11);
  n -= 11*ans;
  ans*=2;
  
  ll act = (ans & 1)? 5: 6;
  ll sum = 0;
  
  while(sum < n)
  {
    sum += act;
    act = (act == 5) ? 6: 5;
    ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
			var lA = cin.ReadLong;
          	var lB = cin.ReadLong;
          	var lK = cin.ReadLong;
            // Process
			lA -= lK ;
          	if(lA < 0)
            {
              lB += lA;
              if(lB < 0) lB = 0 ;
              lA = 0 ;
            }
            // Output
            WriteLine($"{lA} {lB}");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 27912
from operator import itemgetter
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
ab.sort(key=itemgetter(1))
sum=0
for i in range(n):
    sum+=ab[i][0]
    if sum>ab[i][1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 53732
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

void bfs(int s, const vector< vector<int> >& graph, vector<int>& dis) {
  queue<int> q;
  q.push(s);

  while(not q.empty()) {
    int v = q.front(); q.pop();
    for (int u : graph[v]) {
      if (dis[u] != -1) continue;
      dis[u] = dis[v] + 1;
      q.push(u);
    }
  }
}

int main(){
  int n, x, y;
  cin >> n >> x >> y;

  vector< vector<int> > graph(n);
  for (int i = 1; i < n; ++i) {
    graph[i].push_back(i-1);
    graph[i-1].push_back(i);
  }
  graph[x-1].push_back(y-1);
  graph[y-1].push_back(x-1);

  vector<int> ans(n, 0);
  for (int v = 0; v < n; ++v) {
    vector<int> dis(n, -1);
    dis[v] = 0;
    bfs(v, graph, dis);

    for (int i = 0; i < n; ++i) {
      ans[dis[i]]++;
    }
  }

  for (int i = 1; i < n; ++i) {
    cout << ans[i] / 2 << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


int main(){
	fast_io;
	int n, m;
    cin>>n>>m;
    if(n == m) cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.1415926536
#define MOD 1000003
using namespace std;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	long long n;
	cin>>n;
	if(n<1200)		cout<<"ABC";
	else if(n<2800)	cout<<"ARC";
	else			cout<<"AGC";
	return 0;
}

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

using namespace std;
typedef long long ll;

ll dp[2010][2010];
const int mod = 1e9 + 7;

int main()
{
    dp[0][0] = 1;
    for (int i = 0; i < 2010; i++) dp[i][0] = 1;
    for (int i = 1; i < 2010; i++){
        for (int j = 1; j < 2010; j++){
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
            dp[i][j] %= mod;
        }
    }
    int n, k;
    cin >> n >> k;
    int B = k, R = n - k;
    for (int i = 1; i <= k; i++){
        ll ans = dp[R + 1][i];
        ans %= mod;
        ans *= dp[B - 1][i - 1];
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int sal[26],tal[26];
  for(int i=0;i<26;i++){
    sal[i]=-1; tal[i]=-1;
  }
  int judge=0;
  for(int i=0;i<S.size();i++){
    int x=(char)S[i]-'a';
    int y=(char)T[i]-'a';
    if(sal[x]==-1||sal[x]==y){
      if(tal[y]==-1||tal[y]==x){
        sal[x]=y; tal[y]=x;
      }
      else{
        judge++;
        break;
      }
    }
    else{
      judge++;
      break;
    }
  }
  if(judge==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n;cin>>n;
	if (n < 1200)cout << "ABC" << endl;
	else if(n < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll X, N; cin >> X >> N;
  vector<ll> p(N);
  rep(i, 0, N) {
  	cin >> p[i];
  }
  ll large = X, small = X;
  while(!notFound(p, small)) {
  	small--;
  }
  while(!notFound(p, large)) {
  	large++;
  }
  if (X - small > large - X) {
  	cout << large << endl;
  } else {
  	cout << small << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
    int c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9;
    cin >> c_1 >> c_2 >> c_3;
    cin >> c_4 >> c_5 >> c_6;
    cin >> c_7 >> c_8 >> c_9;
    bool condition_1 = c_2 - c_1 == c_5 - c_4 && c_5 - c_4 == c_8 - c_7;
    bool condition_2 = c_3 - c_2 == c_6 - c_5 && c_6 - c_5 == c_9 - c_8;
    bool condition_3 = c_4 - c_1 == c_5 - c_2 && c_5 - c_2 == c_6 - c_3;
    bool condition_4 = c_7 - c_4 == c_8 - c_5 && c_8 - c_5 == c_9 - c_6;
    if (condition_1 && condition_2 && condition_3 && condition_4){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll ma[5][5];
signed main()
{
    fast;
   
    ll a[5][5],i,j,k;
    for(i=1;i<=3;i++)
    {
    	for(j=1;j<=3;j++) cin>>a[i][j];
    }
    ll n;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	ll x;
    	cin>>x;
    	bool ok = false;
    	for(j=1;j<=3;j++)
    	{
    		for(k=1;k<=3;k++)
    		{
    			if(!ma[j][k] and a[j][k]==x)
    			{
    				ma[j][k] = 1;
    				ok = true;
    				break;
    			}
    		}
    		if(ok) break;
    	}
    }
    if(ma[1][1]==1 and ma[2][2]==1 and ma[3][3]==1) cout<<"Yes";
    else if(ma[1][3]==1 and ma[2][2]==1 and ma[3][1]==1) cout<<"Yes";
    else if(ma[1][1]==1 and ma[1][2]==1 and ma[1][3]==1) cout<<"Yes";
    else if(ma[2][1]==1 and ma[2][2]==1 and ma[2][3]==1) cout<<"Yes";
    else if(ma[3][1]==1 and ma[3][2]==1 and ma[3][3]==1) cout<<"Yes";
    else if(ma[1][1]==1 and ma[2][1]==1 and ma[3][1]==1) cout<<"Yes";
    else if(ma[1][2]==1 and ma[2][2]==1 and ma[3][2]==1) cout<<"Yes";
    else if(ma[1][3]==1 and ma[2][3]==1 and ma[3][3]==1) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
inf = int(1e20)
node,edge = map(int,input().split())
ed = []
for i in range(edge):
    e = list(map(int,input().split()))
    ed.append((e[0]-1,e[1]-1,-e[2]))
start = 0
goal = node-1



d = [inf for i in range(node)]
pre = [inf for i in range(node)]
d[start] = 0

for i in range(node):
    update = False
    for e in ed:
        if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
            d[e[1]] = d[e[0]]+e[2]
            update = True
            pre[e[1]] = e[0]
    if update==False:
        print(-d[goal])
        break
else:
    nowcos = d[goal]
    for i in range(node):
        for e in ed:
            if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
                d[e[1]] = d[e[0]]+e[2]
                pre[e[1]] = e[0]
    if nowcos != d[goal]:
        print('inf')
    else:
        print(-d[goal])

Measured memory_bytes: 3368
import java.io.*;
import java.util.*;

public class Main {
  private static boolean isEvenString(char[] cs, int length) {
    if (length % 2 != 0) {
      return false;
    }
    for (int i = 0; i < length / 2; i++) {
      if (cs[i] != cs[i + length / 2]) {
        return false;
      }
    }
    return true;
  }
  
  private static int solve(char[] cs) {
    for (int length = cs.length - 1; true; length--) {
      if (isEvenString(cs, length)) {
        return length;
      }
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
v1 a;
v3 dp;
ll bias = 3;

int main(){
    cin >> n;
    a = v1(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    dp = v3(2, v2(6, v1(n+1, -INF)));
    dp[0][3][0] = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j < 2;j++){
            for(ll k = -2;k <= 1;k++){
                ll x = k + bias;
                if(j == 0){
                    chmax(dp[0][x-1][i+1], dp[j][x][i]);
                    chmax(dp[1][x+1][i+1], dp[j][x][i] + a[i]);
                }else{
                    chmax(dp[0][x-1][i+1], dp[j][x][i]);
                }
            }
        }
    }
    ll d = n/2 - (n-n/2);
    cout << max(dp[0][d+bias][n], dp[1][d+bias][n]) << endl;
}


Measured memory_bytes: 34636
#include "bits/stdc++.h"
using namespace std;
using lint = long long;

struct BIT{
  vector<int> bit;
  int N;
  BIT() {init();}
  BIT(int N) : N(N){init();}
  void init(){
    bit.clear();
    bit.resize(N + 1,0);
  }
  int sum(int i){
    int s = 0;
    while(i > 0){
      s += bit[i];
      i -= i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i <= N){
      bit[i] += x;
      i += i & -i;
    }
  }
};

signed main(){
  int N, K; cin >> N >> K;
  vector<lint> sum(N + 1, 0);
  for(int i = 0; i < N; i++){
    lint x; cin >> x; sum[i + 1] = sum[i] + (x - K);
  }
  vector<lint> ss = sum;
  sort(ss.begin(), ss.end());
  ss.erase(unique(ss.begin(), ss.end()), ss.end());
  vector<lint> s(N + 1);
  for(int i = 0; i <= N; i++) s[i] = lower_bound(ss.begin(), ss.end(), sum[i]) - ss.begin();
  lint ans = 0;
  BIT bit(N + 10);
  for(int i = 0; i <= N; i++){
    ans += bit.sum(s[i] + 1);
    bit.add(s[i] + 1, 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
using System;
using System.Linq;
using System.Collections.Generic;
class P{
  static void Main(){
    var a=new List<int>();
    int s=int.Parse(Console.ReadLine());
    a.Add(s);
    for(int i=2;;i++){
      s=a.Last()%2==0?a.Last()/2:3*a.Last()
+1;
      if(a.Contains(s)){
        Console.WriteLine(i);
        break;
      }
      a.Add(s);
    }
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++)cin>>l[i];
    int cnt=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(l[i]==l[j]||l[i]==l[k]||l[j]==l[k])continue;
                if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[i]+l[k]>l[j])cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    for(int i=s.size()-t.size(); i>=0; i--){
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != '?' && s[i+j] != t[j]) goto ER;
        }
        for(int j=0; j<t.size(); j++) s[i+j] = t[j];
        for(int j=0; j<s.size(); j++){
            if(s[j] == '?') s[j] = 'a';
        }
        cout << s << endl;
        return 0;
        ER:;
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll x,y,K;
ll Q[100000];
ll A;
int main()
{
  cin>>K;
  x = 2LL;
  y = 2LL;
  rep(i,K) cin>>Q[i];
  rrep(i,K){
    A = Q[i];
    if(x <= A) x = A;
    else{
      x = ( ( (x - 1) / A) + 1 ) * A;
    }
    if(y < A){
      puts("-1");
      return 0;
    }
    else{
      y = ((y / A) + 1) * A - 1LL;
    }
    if(x > y){
      puts("-1");
      return 0;
    }
  }
  cout<<x<<" "<<y<<endl;
}


Measured memory_bytes: 1024
#! python3
# transformation.py

sent = input()

def print_(arr):
    global sent
    print(sent[int(arr[0]):int(arr[1])+1])

def reverse_(arr):
    global sent
    sent = sent[:int(arr[0])] + sent[int(arr[0]):int(arr[1])+1][::-1] + sent[int(arr[1])+1:]

def replace_(arr):
    global sent
    sent = sent[:int(arr[0])] + arr[2] + sent[int(arr[1])+1:]

ops = {'print': print_, 'reverse': reverse_, 'replace': replace_}

q = int(input())
for i in range(q):
    arr = input().split()
    ops[arr[0]](arr[1:])


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */
int main()
{
  ll n; cin>>n;
  ld a[n],ans=0.0; 
  fr(i,0,n)
    cin>>a[i];

  vector<vector<ld>> dp(n+1,vector<ld>(n+1,0.0));
  dp[1][0]=1-a[0]; dp[1][1]=a[0];
  fr(i,2,n+1)
  {
    fr(j,0,n+1)
    {
      if(j==0) dp[i][j]=dp[i-1][0]*(1-a[i-1]);
      else if(i==j) dp[i][j]=dp[i-1][j-1]*a[i-1];

      else dp[i][j]=dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*a[i-1];
    }
  }

  for(ll j=n;j>n/2;j--)
    ans+=dp[n][j];
  printf("%.9Lf",ans);
}

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

int main()
{
     int n,a,b,x,i,sum,ans=0;
         cin>>n>>a>>b;
         for(i=1;i<=n;i++)
         {
             x=i;
             sum=0;
             while ( x> 0 ) {
                sum +=  x% 10;
                    x /= 10;
            }
            if(sum>=a && sum<=b)
                ans=ans+i;

         }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <climits>

int caluculate(const std::vector<int>& ls){
    int max=INT_MIN,min=ls.at(0),diff=0;

   // for(int j=1;i<ls.size();j++){
   //     for(int i=0;i<j-1;i++){
   //         diff=ls.at(j)-ls.at(i);
   //         max=(std::max)(max,diff);
   //     }
   //     //std::cout<<ls.at(i)<<std::endl;
   // }
    for(int j=1;j<ls.size();j++){
            max=(std::max)(max,ls.at(j)-min);
            min=(std::min)(min,ls.at(j));
    }
    return max;
}

int main(){
    int n,x,maxValue;
    std::vector<int> ls(0);

    std::cin>>n;
    while(n--){
        std::cin>>x;
        ls.push_back(x);
    }
    //?????§??????????¨????
    maxValue=caluculate(ls);

    std::cout<<maxValue<<std::endl;
    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
 
int main(){
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T';
  }else if(b=='T'){
    cout << 'A';
  }else if(b=='C'){
    cout << 'G';
  }else if(b=='G'){
    cout << 'C';
  }
  return 0;
}

Measured memory_bytes: 256