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

struct Card { 
    char suit, value;
};

void bubble(struct Card A[], int N)
{
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t      = A[j];
                A   [j]     = A[j - 1];
                A   [j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) 
{
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) { 
            if (A[j].value < A[minj].value) {
                minj = j;
            }
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) 
{
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}


int main(int argc, char const *argv[])
{
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



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

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;


int main() {
//   int N, K;
//   cin >> N >> K;
//   vector<int > S(4);
//   for(int i =0; i<4; i++){
//       cin >> S.at(i);
//   }
    int S;
    cin >> S;
    int a, b;
    a = S/100;
    b = S%100;
    if(a > 12){
        if(b<13 && b>0){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    } else if(a > 0) {
        if(b<13 && b>0){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }

    }
    else{
        if(b<13 && b>0){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}





Measured memory_bytes: 256
#include<set>
#include<cstdio>
#include<iostream>
using namespace std;
set<string>Set;
string s1, s2;
int main() {
	int N; cin >> N;
	cin >> s1; Set.insert(s1);
	for(int i=2;i<=N;i++) {
		cin >> s2;
		if( Set.count(s2) ) {
			cout << "No" << endl;
			return 0;
		}
		if( s2[0] != s1[s1.size()-1] ) {
			cout << "No" << endl;
			return 0;
		}
		s1 = s2;
		Set.insert(s2);
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int A, B;
  cin>>A>>B;
  
  int oriA = ceil(A*12.5);
  int oriB = 10*B;
  if(oriA>oriB+9 || oriB>oriA+11){
  	cout<<-1;
  }else{
    int res = min(oriA,oriB);
    if(oriA == oriB){
    	cout<< oriB;
    }else{
        if(oriA>oriB){
            cout<<oriA;
            // while(true){
            //     if((int)oriB*0.08 == A){
            //         cout<<oriB;
            //         break;
            //     }
            //     oriB++;
            // }
        }else{
            // while(true){
            //     if((int)oriA*0.1 == B){
            //         cout<<oriA;
            //         break;
            //     }
            //     oriA++;
            // }
            cout<<oriB;
        }

    }
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#E
import sys
input=sys.stdin.readline
n,m=map(int,input().split())

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n+1)]
        self.rank=[0]*(n+1)
    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same_check(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
for _ in range(m):
    x,y,z=map(int,input().split())
    x-=1; y-=1
    uf.union(x,y)
Ans=[0]*n
for i in range(n):
    Ans[uf.find(i)]=1
print(sum(Ans))

Measured memory_bytes: 71888
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];

        for(int i = 0; i < n+1; i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            b[i] = sc.nextInt();
        }

        long killCount = 0;

        for(int i = 0; i < n; i++){
            if(a[i] < b[i]){
                int cost = a[i];
                killCount += cost;
                a[i] -= cost;
                b[i] -= cost;

                if(a[i+1] < b[i]){
                    int costp = a[i+1];
                    killCount += costp;
                    a[i+1] -= costp;
                    b[i] -= costp;
                } else {
                    int costp = b[i];
                    killCount += costp;
                    a[i+1] -= costp;
                    b[i] -= costp;
                }
            } else {
                int cost = b[i];
                killCount += cost;
                a[i] -= cost;
                b[i] -= cost;
            }
        }
        System.out.println(killCount);
    }
}


Measured memory_bytes: 66280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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 ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll k; cin >> k;
    ll num = 7, count = 1;
    while(true){
        if(num%k == 0) {
            cout << count << endl;
            return 0;
        }
        count++;
        num *= 10;
        num += 7;
        num %= k;
        if(count >= 2*k){
            cout << -1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
n, m = (int(x) for x in input().split())
dic={}
for i in range(m):
    p, s = input().split()
    if p in dic:
        if dic[p][1]>0:
            pass
        elif s=="WA":
            dic[p][0]+=1
        elif s=="AC":
            dic[p][1]+=1
    else:
        if s=="WA":
            dic[p]=[1,0]
        else:
            dic[p]=[0,1]
for value in dic.values():
    if value[1]==0:
        value[0]=0
su_ac = 0
su_wa = 0
for value in dic.values():
    su_ac+=value[1]
    su_wa+=value[0]
print(su_ac, su_wa)
        


Measured memory_bytes: 25292
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    if B < C or D < A:
        ans = 0
    elif C > A:
        if D < B:
            ans = D - C
        else:
            ans = B - C
    else:
        if D < B:
            ans = D - A
        else:
            ans = B - A

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec.at(i);
    int ans = 0;
    for(int i=1;i<n-1;i++){
        if(vec.at(i-1) < vec.at(i) && vec.at(i) < vec.at(i+1)){
            //cout << vec.at(i);
            ans++;
        }else if(vec.at(i-1) > vec.at(i) && vec.at(i) > vec.at(i+1)){
            //cout << vec.at(i);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        l: f64,
    }
    let x = l / 3.0;


    println!("{}", x*x*x);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int cnt=0;
    int now=1;
    rep(i,n){
        if(a[i]==now)now++;
        else cnt++;
    }
    if(now==1)cout << -1;
    else cout << cnt;
    


}

/*



 */



Measured memory_bytes: 1024
X,K,D=map(int,input().split())
x=abs(X)
if x>K*D:
    ans=abs(x-K*D)
else:
    t=x//D
    p=abs(x-t*D)
    if (K-t)%2==0:
        ans=p
    else:
        ans=abs(p-D)
print(ans)

Measured memory_bytes: 9020
#include <stdio.h>

#define N 100001

int partition(int *, int, int);

int main () {
  int A[N], i, n = 0, p = 0;

  scanf("%d",&n);

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

  p = partition(A, 1, n);

  for(i = 1 ; i <= n ; i++) {
    if(i == p) printf("[%d] ",A[i]);
    else if(i < n) printf("%d ",A[i]);
    else printf("%d\n",A[i]);
  }

  return 0;
}


int partition(int *A, int p, int r) {
  int i, j, x = 0, tmp = 0;

  x = A[r];
  i = p - 1;

  for(j = p ; j < r ; j++) {
    if(A[j] <= x) {
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}



Measured memory_bytes: 2084
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	ll n , m ;
	cin >> n  ;
	map<ll, ll> mm;
	for (int i = 0; i < n- 1; i++){
		cin >> m; 
		mm[m]++;
	}

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




	return 0; 
}

Measured memory_bytes: 16108
/* https://atcoder.jp/contests/abc080/tasks/abc080_c */

#include <iostream>
#include <vector>
#include <limits>

#define INF std::numeric_limits<long long>::max()

/* {{{ Variables */
int N;
std::vector<std::vector<int>> P;
std::vector<std::vector<std::vector<int>>> F;
/* }}} */

/* {{{ Functions */
int dfs(int day, int open_style)
{
  if (day == 6) {
    return 0;
  }

  return 0;
}
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> N;

  F = std::vector<std::vector<std::vector<int>>>(N, std::vector<std::vector<int>>(5, std::vector<int>(2)));
  P = std::vector<std::vector<int>>(N, std::vector<int>(11));

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 5; ++j) {
      for (int k = 0; k < 2; ++k) {
        std::cin >> F.at(i).at(j).at(k);
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      std::cin >> P.at(i).at(j);
    }
  }
  /* }}} */

  /* {{{ Output */
  long long max_sum_P = -INF;

  for (int i = 1; i < 1024; ++i) {
    long long sum_P = 0;

    for (int j = 0; j < N; ++j) {
      long long c = 0;

      for (int k = 0; k < 10; ++k) {
        int f = F.at(j).at(k/2).at(k%2);

        c += i >> k & f;
      }

      sum_P += P.at(j).at(c);
    }

    max_sum_P = std::max(max_sum_P, sum_P);
  }

  std::cout << max_sum_P << std::endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int S[100000],a;
int binarySearch(int);

int main(){
  int T[50000];
  int b,i,c=0;

  scanf("%d",&a);
  for(i=0 ;i<a ;i++ )
    scanf("%d",&S[i]);
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&T[i]);
    c+=binarySearch(T[i]);
  }

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

  return 0;
}


int binarySearch(int k){

  int l=0,r,m;

  r=a ;

  while(l<r){
    m=(l+r)/2;
    if(S[m]==k)
      return 1;
    else if(S[m]<k)
      l=m+1;
    else if(S[m]>k)
      r=m;
  }
  return 0;
}
 



Measured memory_bytes: 2264
#include <iostream>
#include <vector>
#include <math.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> Rt(n);
	rep(i,n) cin >> Rt[i];
	
	int ans = -1000000001;
	int a = 1000000001;
	rep(i,n - 1){
		a = min(a, Rt[i]);
		ans = max(ans, Rt[i + 1] - a);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
program ccc

implicit none
integer(8) :: i, n, res1, res2
integer(8),allocatable,dimension(:) :: h

read(*,*) n
allocate(h(n))
read(*,*) h

res1 = 0
res2 = 0

do i=n,2,-1
if (h(i-1)>=h(i)) then
res1 = res1 + 1
res2 = max(res1,res2)
else
res1 = 0
end if
end do

write(*,'(i0)') res2

end program

Measured memory_bytes: 1536
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e6+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){
   
    fio;
    string s,t;
    cin>>s>>t;
    ll n=sz(s);
    ll m=sz(t);
    ll dp[n+1][m+1];
    fr(i,0,n){
        fr(j,0,m){
            if(i==0 or j==0)dp[i][j]=0;
            else if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll l=dp[n][m];
   // cout<<l<<"\n";
    vc v(l);
    ll a=n,b=m;
    while(a>0 and b>0){
        if(s[a-1]==t[b-1]){
            v[l-1]=s[a-1];
            a--;b--;
            l--;
        }
        else if(dp[a-1][b]>dp[a][b-1])a--;
        else b--;
    }
    fr1(i,sz(v))cout<<v[i];
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>


#define REP(i, n) for (ll i = 0; i < n; i++)
using ll = long long;
using ld = long double;

using namespace std;

#define K 1000


ll N;
ld x[50];
ld y[50];

inline ld dist(ld ax, ld ay, ld bx, ld by) {
  return (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
}

int main() {
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }

  ld delta = 1.0;
  ld diff = 0;

  ld rx, ry;
  rx = ry = 500;

  while (delta > 1e-8) {
    for (ll t = 0; t < K; t++) {
      diff = 0;
      ll k = 0;

      REP(i, N) {
        ld d = hypot(rx - x[i], ry - y[i]);
        if (d > diff) {
          diff = d;
          k = i;
        }
      }

      rx += (x[k] - rx) * delta;
      ry += (y[k] - ry) * delta;
    }

    delta /= 2.0;
  }

  cout << setprecision(15) << diff << endl;

  return 0;
}


Measured memory_bytes: 384
import javax.swing.*;
import java.util.*;



/**
 * Created by santa on 2016/10/16.
 */

public class Main {

    static final long MOD = 1000000007;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);


        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int c = scanner.nextInt();

        if(a >= c){
            System.out.println("delicious");
        }else{
            if(b + a >= c){
                System.out.println("safe");

            }else{
                System.out.println("dangerous");
            }
        }


    }




} // MainClass


Measured memory_bytes: 22996
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := nextInt(), nextInt()
	V := make([]int, N)
	for i := 0; i < N; i++ {
		V[i] = nextInt()
	}

	ans := 0
	for a := 0; a <= min(N, K); a++ {
		for b := 0; a+b <= min(N, K); b++ {
			v := make([]int, 0)
			cur := 0
			for i := 0; i < a; i++ {
				v = append(v, V[i])
				cur += V[i]
			}
			for i := 0; i < b; i++ {
				v = append(v, V[N-1-i])
				cur += V[N-1-i]
			}

			sort.Ints(v)
			for i := 0; i < min(K-a-b, len(v)); i++ {
				if v[i] < 0 {
					cur -= v[i]
				}
			}
			ans = max(ans, cur)

		}
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1664
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
ll dp[3010][3010][4];
int main(){

    ll r,c,k;
    cin>>r>>c>>k;
    vector<vector<ll>> t(r,vector<ll>(c,0));
    rep(i,k){
        ll r1,c1,v1;
        cin>>r1>>c1>>v1;
        t[r1-1][c1-1]=v1;
    }

    rep(i,r){
        rep(j,c) {
            for(int l=2;l>=0;l--){dp[i][j][l+1]=max(dp[i][j][l+1],dp[i][j][l]+t[i][j]);}
            rep(l, 4) {
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][l]);
                dp[i][j+1][l]=max(dp[i][j+1][l],dp[i][j][l]);

            }
        }

//        cout<<"a"<<endl;
//        rep(i,r+1){
//            rep(j,c+1){
//                rep(l,4){
//                    cout<<dp[i][j][l]<<" ";
//                }
//            }
//            cout<<endl;
//        }
    }
 //   cout<<"b"<<endl;
    ll ans = 0;

    rep(i,4){
        ans = max(dp[r][c-1][i],ans);
    }
    cout<<ans<<endl;




    
return 0;
}


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

using namespace std;

using int64 = long long;

// Does coordinate compression.
// Arguments:
// - raw_xs: Values to compress.
// Returns:
// - xs: Compressed values.
// - to_raw: A mapping from a compressed value to a raw value.
// Verified: CF573Div1D
tuple<vector<int>, vector<int>> Compress(const vector<int>& raw_xs) {
  unordered_set<int> raw_x_set(raw_xs.begin(), raw_xs.end());
  vector<int> to_raw(raw_x_set.begin(), raw_x_set.end());
  sort(to_raw.begin(), to_raw.end());
  unordered_map<int, int> to_index;
  for (int i = 0; i < to_raw.size(); i++) {
    to_index[to_raw[i]] = i;
  }
  vector<int> xs;
  for (int raw_x : raw_xs) {
    xs.push_back(to_index[raw_x]);
  }
  return make_tuple(xs, to_raw);
}


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

  int n;
  cin >> n;
  vector<int> raw_xs(n);
  for (int i = 0; i < n; i++) {
    cin >> raw_xs[i];
  }
  vector<int> xs;
  tie(xs, ignore) = Compress(raw_xs);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 != xs[i] % 2) ans++;
  }
  cout << ans / 2 << endl;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define UP    0
#define DOWN  1
#define FORE  2
#define BACK  3
#define RIGHT 4
#define LEFT  5

struct Dice
{
  int face[6];
  Dice(){}
  Dice(int up, int down, int fore, int back, int right, int left)
  {
    face[UP] = up; face[DOWN] = down;
    face[FORE]  = fore; face[BACK] = back;
    face[RIGHT] = right; face[LEFT] = left;
  }
  void roll(int a, int b, int c, int d) {
    swap(face[a], face[c]);
    swap(face[b], face[d]);
    swap(face[c], face[d]);
  }
  void roll2fore() { roll(FORE, BACK, UP, DOWN); }
  void roll2back() { roll(BACK, FORE, UP, DOWN); }
  void roll2right() { roll(RIGHT, LEFT, UP, DOWN); }
  void roll2left() { roll(LEFT, RIGHT, UP, DOWN); }
  void rotate_clockwise() { roll(FORE, BACK, RIGHT, LEFT); }
  void rotate_counterclockwise() { roll(FORE, BACK, LEFT, RIGHT); }
  void print_face()
  {
    printf("UP   : %d\n", face[UP]);
    printf("DOWN : %d\n", face[DOWN]);
    printf("FORE : %d\n", face[FORE]);
    printf("BACK : %d\n", face[BACK]);
    printf("RIGHT: %d\n", face[RIGHT]);
    printf("LEFT : %d\n", face[LEFT]);
  }
};



signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  while(cin >> n, n) {
    Dice dice(1, 6, 2, 5, 3, 4);
    int ans = 1;
    rep(i, n) {
      string s;
      cin >> s;
      switch(s[0]) {
      case 'N': dice.roll2back(); break;
      case 'E': dice.roll2right(); break;
      case 'S': dice.roll2fore(); break;
      case 'W': dice.roll2left(); break;
      case 'R': dice.rotate_clockwise(); break;
      case 'L': dice.rotate_counterclockwise(); break;
      }
      ans += dice.face[UP];
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3112
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  const scanIntArray = (length: number) => {
    const array = new Array<number>(length);
    for (let i = 0; i < length; i++) array[i] = parseInt(scan());

    return array;
  };

  return { scan, scanInt, scanIntArray };
};

// ----

const descendingSorter = (a: number, b: number) => b - a;

// ----

function Main(input: string): void {
  const { scanInt, scanIntArray } = createScanFunctions(input);
  const n = scanInt();
  const a = scanIntArray(3 * n);

  a.sort(descendingSorter);

  let totalStrength = 0;
  const len = 2 * n;

  for (let i = 1; i < len; i += 2) {
    totalStrength += a[i];
  }

  log(totalStrength);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

class TopologicalSort
{
    using Graph = vector<vector<int>>;
    // 頂点数
    int V;
    vector<vector<int>> G;
    void dfs(int v, vector<int> &res, vector<int> &used)
    {
        used[v] = 1;
        for (auto to : G[v])
            if (used[to] == 0)
            {
                dfs(to, res, used);
            }
        res.push_back(v);
    }

  public:
    TopologicalSort(int _v) : V(_v), G(_v) {}
    void addEdge(int a, int b)
    {
        assert(0 <= a && a < V);
        assert(0 <= b && b < V);
        G[a].push_back(b);
    }
    vector<int> topologicalSort()
    {
        vector<int> ide(V);
        for (int i = 0; i < V; i++)
        {
            for (auto to : G[i])
            {
                ide[to]++;
            }
        }
        vector<int> res;
        vector<int> used(V);
        for (int i = V - 1; i >= 0; i--)
        {
            if (ide[i] == 0)
            {
                dfs(i, res, used);
            }
        }
        if (res.size() == 0)
            res = {-1};
        reverse(res.begin(), res.end());
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    TopologicalSort g(n);
    vector<vector<int>> rev(n);
    for (int i = 0; i < n - 1 + m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.addEdge(a, b);
        rev[b].push_back(a);
    }
    vector<int> ts = g.topologicalSort();
    vector<int> res(n, -1), pri(n);
    for (int i = 0; i < n; i++)
        pri[ts[i]] = i;
    res[ts[0]] = 0;
    for (int i = n - 1; i > 0; i--)
    {
        int v = ts[i];
        int ma = -1, idx = -1;
        for (auto u : rev[v])
        {
            if (pri[u] > ma)
            {
                ma = pri[u];
                idx = u;
            }
        }
        res[v] = idx + 1;
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '('; __print(x.first); cerr << ','; __print(x.second); cerr << ')';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> v(n);
  vector<long long> pref(n);
  long long ans = 0;
  for (int& i : v) cin >> i;
  for (int i = 0; i < n; i++) {
    if (i) pref[i] = v[i] + pref[i - 1];
    else pref[i] = v[i];
  }
  debug(pref);
  for (int i = 0; i < n; i++) {
    long long sums = pref[n - 1] - pref[i];
    ans += ((v[i]) * (sums % mod)) % mod;
  }
  cout << ans % mod << '\n';
  return 0;
}

Measured memory_bytes: 5552
"""
https://atcoder.jp/contests/abc104/tasks/abc104_c
"""
D,G=map(int,input().split())
l = [list(map(int, input().split()))  for _ in range(D)]

minP = 10 ** 100
for i in range(2**D):
  point, tmpP = 0,0
  for j in range(D):
    if (i>>j)&1:
      point += 100*l[j][0]*(j+1) + l[j][1]
      tmpP += l[j][0]
  if point>=G:
    minP = min(minP, tmpP)
  else:
    for j in range(D-1,-1,-1):
      if (i>>j)&1:
        continue
      else:
        for _ in range(l[j][0]):
          point += (j+1)*100
          tmpP += 1
          if point>=G:
            break
      if point >= G:
        break
  minP = min(minP, tmpP)
print(minP)

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long

using namespace std;


int main()
{
    string s;
    cin >> s;
    s.erase(s.size() - 8, 8);
    cout << s;
   return 0;
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};
int main(){
    int N;cin >> N;
    int H, W;cin >> H >> W;
    cout << (N - H + 1) * (N - W + 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  if (D == 25) cout << "Christmas" << endl;
  if (D == 24) cout << "Christmas" << " " << "Eve" << endl;
  if (D == 23) cout << "Christmas" << " " << "Eve" << " " << "Eve" << endl;
  if (D == 22) cout << "Christmas"  << " " << "Eve" << " " << "Eve" << " " << "Eve" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string ans;

    

    if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3])
    {
        ans = "No";
    }
    else if ((S[0] == S[1] && S[1] == S[2])|| (S[0] == S[1] && S[1] == S[3])|| (S[1] == S[2] && S[2] == S[3]))
    {
        ans = "No";
    }
    else if ((S[0] == S[1] )&& (S[2] == S[3] ) || (S[0] == S[2]) && (S[1] == S[3]) || (S[0] == S[3]) && (S[1] == S[2]))
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";

    }
    cout << ans;

    return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int n;
    cin>>n;
    ll a[n+1],b[n+1],aa=0;
    rep(i,n+1){
        cin>>a[i];
        aa+=a[i];
    }
    b[0]=1-a[0];
    aa-=a[0];
    for(int i=1;i<n+1;i++){
        aa-=a[i];
        b[i]=min(2*b[i-1]-a[i],aa);
        if(i!=n && b[i]<=0){
        cout<<"-1"<<endl;
        return 0;
        }
    }
    if(b[n]!=0){
        cout<<"-1"<<endl;
        return 0;
    }
    ll ans=0;
    rep(i,n+1) ans+=a[i]+b[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5220
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>
int main(){
    int t, p,cont=0;
    scanf("%d %d", &t,&p);
    for(int i=0; i<t; i++){
        double a, b, eq=0;
        unsigned long long pp=0, eq1=0, qq=0;
        scanf("%lf %lf", &a, &b);
        pp=pow(a, 2);
        qq=pow(b, 2);
        eq1= pp+ qq;
        eq= sqrt(eq1);
        ///printf("%lf\n",eq);
        if(eq <= p)
            cont++;
    }
    printf("%d\n", cont);
    
    return 0;
}

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

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll sum(ll a) {
	ll ans = 0;
	while (a) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

void solve() {

	ll K;
	cin >> K;

	ll n = 1, x = 1;
	for (ll i = 0; i < K; i++) {
		cout << n << endl;
		if ((n + x) / (double)sum(n + x) > (n + x * 10) / (double)sum(n + x * 10)) {
			x *= 10;
		}
		n += x;
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#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

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("input.out", "w", stdout);
    ll x, y; cin >> x >> y;
    int ans{};
    while (x <= y) {
        x *= 2;
        ++ans;
    }
    cout << ans << nl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n-1;i++){
        ans=ans+(n-1)/i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    private static int n;
    private static int A;
    private static int B;
    private static int C;
    private static int[] l;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        System.out.println(dfs(0, 0, 0, 0));
    }

    public static int dfs(int cur, int a, int b, int c) {
        if (cur == n) {
            if (a != 0 && b != 0 && c != 0) {
                return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C);
            }
            return Integer.MAX_VALUE - 10000;
        }

        int ret = dfs(cur + 1, a, b, c);
        int retA = dfs(cur + 1, a + l[cur], b, c);
        if (a != 0) {
            retA += 10;
        }
        int retB = dfs(cur + 1, a, b + l[cur], c);
        if (b != 0) {
            retB += 10;
        }
        int retC = dfs(cur + 1, a, b, c + l[cur]);
        if (c != 0) {
            retC += 10;
        }
        return Math.min(Math.min(ret, retA), Math.min(retB, retC));
    }

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> d(n);
    ll ans = 0;
    rep (i, n) cin >> d[i];
    rep (i, n) {
        FOR (j, i + 1, n) {
            ans += d[i] * d[j];
        }
    }    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a, b] <- readInts
  print $ solve a b

{-
0 1 0 1 -
0 0 1 1 -
0 0 0 0 1

0 to 4
000 001 010 011 100
n = 5
L   0
L+1 0
L+2 1

q is odd then 
L   2 (if q is odd then 1 else 0)
L+1 4 (if r > 2 and (4 - r) is odd then 1 else 0)
L+2 8 (if r > 4 and (8 - r) is odd then 1 else 0)
-}

solve a b = solveSub a 1 0 `xor` solveSub (b + 1) 1 0 `xor` calcLsb a `xor` calcLsb (b + 1)
  where
    calcLsb x = if (odd $ x `div` 2) then 1 else 0
    solveSub :: Int -> Int -> Integer -> Integer
    solveSub x i acc =
      if d > x
        then next
        else solveSub x (i + 1) next
      where
        d = bit (i + 1)
        r = x `mod` d
        next = if (r > bit i) && odd (d - r) then acc + (bit i) else acc


-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<ll> a(n), diff(n-1);
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	for(int i = 0; i < n-1; i++)
	{
		diff[i] = a[i+1]-a[i];
	}
	// for(int i = 0; i < n-1; i++) cout<<diff[i]<<" ";
	// 	cout<<endl;
	int maxim = 0, curr = 0;
	for(int i = 0; i < n-1; i++)
	{
		if(diff[i]<=0)
		{
			curr++;
		}
		else
		{
			maxim = max(maxim, curr);
			curr = 0;
		}
	}
	maxim = max(maxim, curr);
	cout<<maxim<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  int N;cin >> N;
  ll odd = 1;
  repeat(i,N){
    int A;cin >> A;
    odd *= !(A&1)+1;
  }
  ll total = pow(3,N);
  cout << total-odd<<endl;
  return 0;
}


Measured memory_bytes: 512
a, b, k = [int(i) for i in input().split()]

def listing(numb):
    temp = []
    for i in range(1, numb+1):
        if numb % i == 0:
            temp.append(i)
    return temp

alist = listing(a)
blist = listing(b)

alist.sort(reverse=True)
blist.sort(reverse=True)
counter = 0

for i in alist:
    if i in blist:
        counter += 1
        if counter == k:
            print(i)
            break

Measured memory_bytes: 3188
N = int(input())
S = input()

ans = S.count("R") * S.count("G") * S.count("B")

for i in range(1,N-1):
  for j in range(i+1,N):
    k = 2 * j - i
    if k > N:
      break
    if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[k-1] != S[i-1]:
      ans -= 1
      
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    ll A, B, N;
    
    cin >> A >> B >> N;

    ll x = min(B - 1, N);

    cout << A * x / B - A * (x / B) << endl;
    
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		int h = 0, n2 = 0, w = 0;
		for(int i = 1; i <= 3500; ++i) {
			for(int j = 1; j <= 3500; ++j) {
				long tmp = (long)i * (long)j * (long)n;
				long tmp2 = (long)4 * (long)i * (long)j - (long)j * (long)n - (long)i * (long)n;
				if(tmp2 <= 0)continue;
				if(tmp % tmp2 == 0) {
					h = i;
					n2 = j;
					w = (int)(tmp / tmp2);
				}
			}
		}
		System.out.println(h + " " + n2 + " " + w);
	}

}


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

int main()
{
    string s1,s2, s_beg="", s_end="";
    char c;
    int i, j, t, f, q, count;

    cin>>s1;
    cin>>q;

    count = 0;
    for(i=0; i<q; i++)
    {
        cin>>t;

        if(t==1)
            count++;
        else
        {
            cin>>f;

            if(f==1)
            {
                cin>>s2;

                if(count%2 == 0)
                    s_beg = s2 + s_beg;
                else
                    s_end = s_end + s2;
            }
            else
            {
                cin>>s2;

                if(count%2 == 1)
                    s_beg = s2 + s_beg;
                else
                    s_end = s_end + s2;
            }
        }
    }

    s1 = s_beg + s1 + s_end;

    if(count%2==0)
        cout<<s1<<endl;
    else
    {
        reverse(s1.begin(),s1.end());
        cout<<s1<<endl;
    }


    return 0;
}


Measured memory_bytes: 1464
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(int, N, M);
	vector<int> a(M), b(M);
	loop(i, M){
		cin >> a[i] >> b[i];
		--a[i]; --b[i];
	}
	ll cnt = 0;
	loop(e, M){
		vector<vector<int>> can_visit(N);
		vector<bool> visited(N, false);
		loop(i, M) if(i != e){
			can_visit[a[i]].push_back(b[i]);
			can_visit[b[i]].push_back(a[i]);
		}
		[impl=[&](auto func, int n)->void{
			if(visited[n]) return ;
			visited[n] = true;
			for(int t : can_visit[n])
				func(func, t);
		}]{
			impl(impl, 0);
		}();
		loop(i, N){
			if(!visited[i]){
				++cnt;
				break;
			}
		}
	}
	cout << cnt << endl;
}



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

int main(){
    int a, b;
    scanf("%d %d",&a, &b);
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        printf("Possible");
    }else{
        printf("Impossible");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,ans=0;
  cin >> N;
  int a[N]={};
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  int c=1;
  rep(i,N){
    if(i<N && a[i]==a[i+1]) c++;
    else{
      if(c==a[i]);
      else if(c<a[i]) ans+=c;
      else ans+=c-a[i];
      c=1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024