akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  int n; cin>>n;
  vector<long long> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(), a.end(), greater<>());

  long long ans = a[0];
  int pos = 1;
  rep(i, n-2) {
    ans += a[pos];
    if (i % 2 == 1) pos += 1;
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
int ans;
int main(){
  int N,W;cin>>N>>W;
  int dp[110][10100];
  //dp[i][w] i個メまでで価値vの最大
  //ans=sigma_w(dp[N][w])
  rep(i,N){
    int v,w;cin>>v>>w;
    for(int j=1;j<=W;++j){
      dp[i+1][j]=dp[i][j];
      if (j-w<0) continue;
      dp[i+1][j]=max(dp[i+1][j],dp[i][j-w]+v);
      dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w]+v);
    }
  }
  rep(i,W+1) ans=max(dp[N][i],ans);
  cout<<ans<<endl;
}



Measured memory_bytes: 7068
#__author__ = "tatuo"
#__date__ = "$Mar 3, 2018 12:34:20 PM$"

import math
import re
import sys


def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result




arr_data = getinputdata()

n=int(arr_data[0][0])

#print(arr_data[1])

if("Y" in arr_data[1]):
    
    print("Four")
    
else:
    
    print("Three")

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

using namespace std;

int main() {
		int N, Q;
		string S;
		cin >> N >> Q;
		cin >> S;

		int l[N], r[N];
		for ( int i = 0; i < Q; i++ ) cin >> l[i] >> r[i];

		int cum_sum[N + 1];
		cum_sum[0] = 0;
		int flg = 0;
		for ( int i = 0; i < N; i++ ) {
				if ( S[i] == 'C' && flg ) {
						cum_sum[i + 1] = cum_sum[i] + 1;
						flg = 0;
				} else if ( S[i] == 'A' ) {
						cum_sum[i + 1] = cum_sum[i];
						flg = 1;
				} else {
						cum_sum[i + 1] = cum_sum[i];
						flg = 0;
				}
		}

		for ( int i = 0; i < Q; i++ ) {
				cout << cum_sum[r[i]] - cum_sum[l[i]] << endl;
		}

		return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; ll K;
    cin >> n >> K;
    VL a(n); cin >> a;


    VI k(40, 0);
    for (int j = 0; K; j++) {
        k[j] = K % 2;
        K /= 2;
    }
    reverse(all(k));

    VI bit(40, 0);
    FOR(i, 0, n) {
        ll b = a[i];
        for (int j = 0; b; j++) {
            bit[j] += b % 2;
            b /= 2;
        }
    }
    reverse(all(bit));

    vector<VL> dp(41, VL(2, -1));
    dp[0][0] = 0;
    FOR(i, 0, 40)FOR(small, 0, 2) {
        if (dp[i][small] == -1)continue;
        eFOR(x, 0, (small ? 1 : k[i])) {
            ll num = (1LL << (40 - i - 1)) * (ll)(x ? n - bit[i] : bit[i]);
            chmax(dp[i + 1][small || x < k[i]], dp[i][small] + num);
        }
    }
    cout << max(dp[40][0], dp[40][1]) << "\n";
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
void bubblesort(char bubble[][3],int N);
void selectionsort(char select[][3],int N);
int main(void){
	int i;
	int N;
	scanf("%d",&N);
	char buffer[N][3];
	char bubble[N][3];
	char select[N][3];
	for(i=0;i<N;i++){
		scanf("%s",buffer[i]);
	}
	for(i=0;i<N;i++){
		strcpy(bubble[i],buffer[i]);
		strcpy(select[i],buffer[i]);
	}
	bubblesort(bubble,N);
	selectionsort(select,N);
	//1行目
	for(i=0;i<N;i++){
		if(i!=N-1) printf("%s ",bubble[i]);
		else printf("%s\n",bubble[i]);
	}
	//2行目
	printf("Stable\n");
	//3行目
	for(i=0;i<N;i++){
		if(i!=N-1) printf("%s ",select[i]);
		else printf("%s\n",select[i]);
	}
	//4行目
	for(i=0;i<N;i++){
		if(strcmp(bubble[i],select[i])!=0){
			printf("Not stable\n");
			return 0;
		}
	}
	printf("Stable\n");
	return 0;
}
void bubblesort(char bubble[][3],int N){
	char tempsuit;
	char tempnum;
	int i,j;
	for(i=0;i<N;i++){
		for(j=N-1;j>i;j--){
			if(bubble[j-1][1]>bubble[j][1]){
				tempsuit=bubble[j-1][0];
				tempnum=bubble[j-1][1];
				bubble[j-1][0]=bubble[j][0];
				bubble[j-1][1]=bubble[j][1];
				bubble[j][0]=tempsuit;
				bubble[j][1]=tempnum;
			}
		}
	}
}
void selectionsort(char select[][3],int N){
	char tempsuit;
	char tempnum;
	int i,j;
	int minj;
	for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(select[minj][1]>select[j][1]){
				minj=j;
			}
		}
		tempsuit=select[i][0];
		tempnum=select[i][1];
		select[i][0]=select[minj][0];
		select[i][1]=select[minj][1];
		select[minj][0]=tempsuit;
		select[minj][1]=tempnum;
	}
}




Measured memory_bytes: 2080
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include <climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

struct SegmentTree{
    static const int MAX_N = 1<<17;
    int n,dat[2 * MAX_N -1];
    SegmentTree(int n_){
        n=1;
        while(n<n_) n*= 2;
        for(int i=0;i<2*n-1;i++) dat[i] = INT_MAX;
    }
    void update(int k,int a){
        k += n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    int query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return INT_MAX;
        if(a<=l && r<=b) return dat[k];
        else{
            int vl = query(a,b,k*2+1,l,(l+r)/2);
            int vr= query(a,b,k*2+2,(l+r)/2,r);
            return min(vr,vl);
        }
    }
    int query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    SegmentTree sg(n);
    rep(i,q){
        int c,x,y;
        cin>>c>>x>>y;
        if(c) cout<<sg.query(x,y+1)<<endl;
        else sg.update(x,y);
    }
    return 0;
}


Measured memory_bytes: 4136
import sys
input = sys.stdin.readline
h, w, m = map(int, input().split())
a = [0] * h
b = [0] * w
H, W = [0] * m, [0] * m
for i in range(m):
    H[i], W[i] = map(int, input().split())
    H[i] -= 1
    W[i] -= 1
    a[H[i]] += 1
    b[W[i]] += 1
a1 = max(a)
a2 = max(b)
s = sum(i == a1 for i in a)
t = sum(i == a2 for i in b)
ans = 0
for i in range(m):
    if a[H[i]] == a1 and b[W[i]] == a2:
        ans += 1
print(a1 + a2 - 1 if ans == s * t else a1 + a2)


Measured memory_bytes: 78860
/* Stay hungry, stay foolish. */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
using namespace std;
template <class T> inline void read(T &x) {
	int t; bool flag=false;
	while((t=getchar())!='-'&&(t<'0'||t>'9')) ;
	if(t=='-') flag=true,t=getchar(); x=t-'0';
	while((t=getchar())>='0'&&t<='9') x=x*10+t-'0';
	if(flag) x=-x;
}
int main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,c1=0,c2=0;
	read(n);
	for(int i=1,tmp;i<=n;++i) {
		read(tmp);
		if(tmp&1) ++c1;
		else ++c2;
	}
	c2+=c1/2;
	if(c1&1) {
		if(c2) puts("NO");
		else puts("YES");
	} else {
		puts("YES");
	}
	return 0;
}



Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import qualified Data.ByteString.Char8 as BS
import Data.Coerce

main = do
  n :: Int <- readLn
  s <- BS.getLine
  let loop :: Int -> Int -> Int -> N
      loop !t !k !i | BS.length s == i = if k == 0 then 1 else 0
                    | BS.index s i == 'W' = if k == 0
                                            then 0
                                            else if even k
                                                 then fromIntegral k * loop t (k-1) (i+1)
                                                 else fromIntegral (t+1) * loop (t+1) (k+1) (i+1)
                    | otherwise = if k == 0
                                  then fromIntegral (t+1) * loop (t+1) 1 (i+1)
                                  else if even k
                                       then fromIntegral (t+1) * loop (t+1) (k+1) (i+1)
                                       else fromIntegral k * loop t (k-1) (i+1)
  print $ loop 0 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}


Measured memory_bytes: 4476
n,x,d = map(int, input().split())
if d<0:
    d = -d
    x = -x

if d != 0:
    ans = 0
    it = list()
    for i in range(n+1):
        it.append((i*x%d,i))
    it.sort()
    prev = -1
    lsall = []
    ls = [100,-100]
    for idx,i in it:
        if prev != idx:
            lsall.append(ls)
            lsall.sort()
            mnp_,mxp_ = lsall[0]
            for j in range(1,len(lsall)):
                mn_,mx_ = lsall[j]
                if mxp_ < mn_:
                    mxp_ = mx_
                    mnp_ = mn_
                else:
                    ans -= mxp_-mn_+1
                    mxp_ = max(mx_,mxp_)
                    mnp_ = min(mn_,mnp_)
            lsall = list()
            ls = None
            prev = idx
        plus = x*i//d
        mn = i*(i-1)//2 + plus
        mx = i*(n-1+n-i)//2 + plus
        if ls is None:
            ans += mx - mn + 1
            ls = [mn,mx]
        else:
            mnp,mxp = ls
            if mxp + 1 < mn or mnp - 1 > mx:
                ans += mx - mn + 1
                lsall.append(ls)
                ls =[mn,mx]
            else:
                ans += max(mx-mxp,0)
                ans += max(mnp-mn,0)
                ls = [min(mn,mnp),max(mx,mxp)]
    
    

    lsall.append(ls)
    lsall.sort()
    mnp,mxp = lsall[0]
    for i in range(1,len(lsall)):
        mn,mx = lsall[i]
        if mxp < mn:
            mxp = mx
            mnp = mn
        else:
            ans -= mxp-mn+1
            mxp = max(mx,mxp)
            mnp = min(mn,mnp)
    print(ans)
else:
    if x != 0:
        print(n+1)
    else:
        print(1)




Measured memory_bytes: 56944
#include <stdio.h>

char a[20], b[20], c[20];

int main() {
  scanf("%s %s %s", a, b, c);
  int _a = 0, _b = 0;
  while (a[_a]) ++_a;
  while (b[_b]) ++_b;
  puts((a[_a - 1] == b[0] && b[_b - 1] == c[0]) ? "YES" : "NO");
  return 0;
}



Measured memory_bytes: 128
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

-- returns (b^n) % m
local function modpow(b, n, m)
    if n == 0 then
        return 1
    else
        return b * modpow(b, n - 1, m) % m
    end
end

---
local MOD = 998244353
local N = io.read("*n")
local a = {}
local S = 0
for i=1,N do
    a[i] = io.read("*n")
    S = S + a[i]
end


local function fill90000(t, v)
    for i=1,90000 do
        t[i] = v
    end
end

local function default0(t)
    local mt = {
        __index = function(t,k)
            return 0
        end
    }
    setmetatable(t, mt)
end

-- ∑A = S/2 and ∑B = S/2 and ∑C = 0
local function getY()
    if S % 2 == 1 then
        return 0
    end
    local cache = {}
    --default0(cache)
    fill90000(cache, 0)
    cache[0] = 1
    local curmax = 0
    for i=1,N do
        local cur = a[i]
        curmax = curmax + cur
        for s=curmax,cur,-1 do
            cache[s] = (cache[s] + cache[s-cur]) % MOD
        end
    end
    return cache[math.floor(S/2)]
end

-- ∑A >= S/2
local function getX()
    local cache = {}
    --default0(cache)
    fill90000(cache, 0)
    cache[0] = 1
    local curmax = 0
    for i=1,N do
        local cur = a[i]
        curmax = curmax + cur
        for s=curmax,cur,-1 do
            cache[s] = (2 * cache[s] + cache[s-cur]) % MOD
        end
        for s=cur-1,0,-1 do
            cache[s] = 2 * cache[s] % MOD
        end
    end
    local sum = 0
    for s = math.ceil(S/2), curmax, 1 do
        sum = sum + cache[s]
    end
    return sum
end

local X, Y = getX(), getY()
local Total = modpow(3, N, MOD)
--dbgpr(Total, X, Y)
local ans = (Total - (3 * X) % MOD + (3 * Y) % MOD) % MOD
print(ans)


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();

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

		String u = sc.next();

		if(s.equals(u)) {
			a -= 1;
		}else {
			b -= 1;
		}

		System.out.println(a + " " + b);
	}

}

Measured memory_bytes: 21844
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    cl = []
    for i in range(M//2):
        cl.append((i+1,(M//2)*2+1-i))
    for i in range(-(-M//2)):
        l = (M//2)*2+i+2
        cl.append((l,l+(-(-M//2)-i)*2-1))
    
    for i in range(M):
        print(*cl[i])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 73924
N,X = map(int, input().strip().split(' '))
x = sorted(list(map(int, input().strip().split(' '))) + [X])

def gcd(a,b):
  if a > b:
    a,b = b,a
  if b%a == 0:
    return a
  else:
    return gcd(b%a,a)

dx = [x[i+1]-x[i] for i in range(len(x)-1)]
now = dx[0]
for i in range(1,len(dx)):
  now = gcd(now, dx[i])
print(now)


Measured memory_bytes: 14252
#include<iostream>
#include<cmath>
using namespace std;
long long n;
int main()
{
    cin>>n;
    int m=sqrt(n);
    for(int i=m;i>=1;i--)
        if(n%i==0){
            int s=1;
            i=n/i;
            while(i>=10) i/=10,s++;
        	cout<<s;
        	return 0;
        }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args){

        Scanner in =new Scanner(System.in);
        String winlose=in.next();

        int count_win=0;

        for(int i=0;i<winlose.length();i++){
            if(winlose.charAt(i)=='o'){
                count_win++;
            }
        }

        int check=count_win+(15-winlose.length());
        
        if(check>=8) {
            System.out.print("YES");
        }
        else System.out.print("NO");
    }
}

Measured memory_bytes: 23764
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let n: u32 = read();

	let mut flag = true;
	for i in 1..10 {
		for j in 1..10 {
			if i*j == n {
				println!("Yes");
				flag = false;
			}
		}
		if !flag {
			break;
		}
	}
	if flag {
		println!("No");
	}
	
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    int N;
    cin>>N;
    cout<<(N%2?N/2+1:N/2)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<map>
#include<algorithm>

using namespace std;

int masu[14][14];
int cont;

void saiki(int x,int y){
	masu[x][y]=0;
	if(masu[x+1][y]==1)
	saiki(x+1,y);
	if(masu[x][y+1]==1)
	saiki(x,y+1);
	if(masu[x-1][y]==1)
	saiki(x,y-1);
	if(masu[x][y-1]==1)
	saiki(x,y-1);
}

int main(){
	while(1){
		for(int i=0;i<14;i++){
			for(int j=0;j<14;j++){
				masu[i][j]=0;
			}
		}
		for(int i=1;i<=12;i++){
			char st[13];
			if(scanf("%s",st)==EOF){
				goto A;
			}
			for(int j=0;j<12;j++){
				if(st[j]=='0'){
					masu[i][j+1]=0;
				}else{
					masu[i][j+1]=1;
				}
			}
		}
		cont=0;
		for(int i=1;i<=12;i++){
			for(int j=1;j<=12;j++){
				if(masu[i][j]==1){
					cont++;
					saiki(i,j);
				}
			}
		}
		printf("%d\n",cont);
	}
	A:;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)
	if S[0] != 'A' {
		fmt.Println("WA")
		return
	}

	c := strings.Count(S[2:len(S)-1], "C")
	if c != 1 {
		fmt.Println("WA")
		return
	}

	for i := 1; i < len(S); i++ {
		s := S[i]
		if !(('a' <= s && s <= 'z') || s == 'C') {
			fmt.Println("WA")
			return
		}
	}

	fmt.Println("AC")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll ans = 1;
  ll mod = (ll)1e18;
  vector<ll> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(begin(a), end(a));
  if(a[0]== 0)
    return cout << 0, 0;
  for(int i=0; i<n; i++){
    if(mod/ans>=a[i])
      ans *= a[i];
    else
      return cout << -1 , 0;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3992
#include<iostream>
using namespace std;
long long A[100010]={0},B[100010]={0};
int main(){
	int N;
	cin>>N;
	for(int i=0;i<=N;i++){
		cin>>A[i];
	}//怪兽 
	for(int i=0;i<N;i++){
		cin>>B[i];
	}//英雄 
	long long ans=0;
	for(int i=0;i<N;i++){
	    int sen=B[i]-A[i];
		if(A[i]>B[i]){
			ans=ans+B[i];
		}else{
			ans=ans+A[i];
			if(sen>=A[i+1]){
				ans=ans+A[i+1];
				A[i+1]=0;
			}else{
				ans=ans+sen;
				A[i+1]=A[i+1]-sen; 
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
ll a,b,c,d;
void solve(){
    cin>>a>>b>>c>>d;
    int flag=1;
    if(a<b) {
        flag=0;
    }
    else if(a%b>c) {
        flag=0;
    }
    else {
        if(d<b){
            flag=0;
        }
        else if(d%b!=0 && b>c+1){
            ll x;
            int cnt=0;
            a%=b;
            d%=b;
            while(cnt<=100000 && flag){
                if(a>c) flag=0;
                x=b-(b-a)%d;
                if(x==b) x=b-d;
                if(x>c) flag=0;
                a=(x+d)%b;
                cnt++;
            }
        }
    }
    if(flag) puts("Yes");
    else puts("No");
}
int main(){
    int t;
    cin>>t;
    while(t--) solve();
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n), d(n), e(n);
  rep(i, n) { c[i] = 0; d[i] = -1; e[i] = -1; }
  rep(i, n) {
    cin >> a[i];
    c[a[i] - 1] += 1;
    d[a[i] - 1] = i;
  }
  rep(i, n) {
    cin >> b[i];
    c[b[i] - 1] += 1;
    if (e[b[i] - 1] == -1) e[b[i] - 1] = i;
  }
  rep(i, n) {
    if (c[i] > n) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  int maxDelta = 0;
  rep(i, n) {
    int Delta = d[i] - e[i] + 1;
    if (d[i] == -1 || e[i] == -1) Delta = 0;
    if (maxDelta < Delta) {
      maxDelta = Delta;
    }
  }

  rep(i, n) {
    if (i == n - 1) cout << b[(i + n - maxDelta) % n] << endl;
    else cout << b[(i + n - maxDelta) % n] << " ";
  }

  return 0;
}
/*
*/


Measured memory_bytes: 7184
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/11/20 07:34:58
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  string s ;cin>>s;
  int ans = 0;
  char p = '\0';
  for (int i = 0; i < n; i++) {
    if (p != s[i]) {
      ans++;
    }
    p = s[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3684
#include <stdio.h> 

int main(void)
{
    long coin, i1, i2, sum;
    scanf("%ld", &coin);
  
    if (coin < 0 || coin > 1000000000)
        return 1;

    i1 = coin / 500;
    sum = coin - (500 * i1);
    i2 = sum / 5;

    // printf("output i1: %ld\n", i1);
    // printf("output sum: %ld\n", sum);
    // printf("output i2: %ld\n", i2);

    printf("%ld", (i1 * 1000) + (i2 * 5));
  
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
//bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int main()
{
    ll a,b,c,d,e,x,t,n,k,p,q,r,y,yy,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    char ch;
    deque<char>d1,d2,d3;
    vector<ll>v,vv,vz;
    map<ll,ll>mp;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>s1>>s2; ct=0;
    for(ll i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i]) ct++;
    }
    cout<<ct<<endl;
}






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

int main(){
    int a,b;
    while( cin >> a >> b , a||b ){
        int n, dp[20][20] = {0};
        dp[1][1] = 1;
        
        cin >> n;
        for(int i=0 ; i < n ; i++ ){
            int x,y;
            cin >> x >> y;
            dp[y][x] = -1; // 交差点(x,y)までの経路の数が求まっていないので-1で初期化する
        }
        
        for(int y=1 ; y <= b ; y++ ){
            for(int x=1 ; x <= a ; x++ ){
                if( dp[y][x] != -1 ){
                    if( y != 1 && dp[y-1][x] != -1 ){
                        dp[y][x] += dp[y-1][x];
                    }
                    if( x != 1 && dp[y][x-1] != -1 ){
                        dp[y][x] += dp[y][x-1];
                    }
                }
            }
        }
        // (a,b)までの経路の数を出力
        cout << dp[b][a] << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){

  int n,a[100000],m,b,result=0,i;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];
  cin>>m;
  for(i=0;i<m;i++){
    cin>>b;
    if(b<a[0]||a[n-1]<b) continue;
    int l=0,r=n,m;
    while(r-l){
      m=(r+l)/2;
      if(b==a[m]){
        result++;
        break;
      } else if(b>a[m]) l=m+1;
      else r=m;
    }
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 3400
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <set>
using namespace std;

typedef long long llong;

llong inf = 1e14;

inline llong pw(llong x, int b) {
    llong res = 1;
    for (int i = 0; i < b; i++) {
        if (res >= inf / x)
            res = inf;
        else
            res *= x;
    }
    return res;
}

inline llong minsum(llong n, int k) {
    llong a = 1, b = n + 1;
    while (b - a > 1) {
        llong m = (a + b) / 2;
        if (pw(m, k) <= n)
            a = m;
        else
            b = m;
    }
    for (int i = 0; i <= k; i++) {
        llong vala = pw(a, k - i);
        llong valb = pw(b, i);
        llong val = (vala >= inf / valb) ? inf : vala * valb;
        if (val >= n)
            return (k - i) * a + i * b;
    }
    assert(false);
    return -1;
}

int main() {
    llong n, a;
    scanf("%lld %lld", &n, &a);
    llong ans = inf;
    for (int k = 1; k <= 50; k++) {
        ans = min(ans, (k - 1) * a + minsum(n, k));
    }
    printf("%lld\n", ans);
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			
			if(left&&right)
				cnt++;
		}
		
		if(ans<cnt)
			ans=cnt;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
 
int main(){
    int n;
    cin>>n;
    pair<pair<string,int>,int> books[n];
 
    string s;
    int p;
    rep(i,n){
        cin>>s>>p;
        books[i] = make_pair(make_pair(s,-p),i);
    }
    sort(books,books+n);
    rep(i,n)cout<<(books[i].second)+1<<endl;
}

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

#define ll long long

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

	ll s=0;
	for(int i=0;i<=n;i++)
	{
		if(i%3==0&&i%5==0)
		{

		}
		else if(i%3==0)
        {

        }
        else if(i%5==0)
        {

        }
		else
		{
			s+=i;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	if(ss[0] == 'S')
	{
		cout << "Cloudy" << endl;
	}
	else if(ss[0] == 'C')
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
	return 0;
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i) {
      cin >> A[i] >> B[i];
    }

    int ans_A = 0, ans_B = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i] > B[i]) {
        ans_A += A[i] + B[i];
      } else if (A[i] == B[i]) {
        ans_A += A[i], ans_B += B[i];
      } else {
        ans_B += A[i] + B[i];
      }
    }

    cout << ans_A << ' ' << ans_B << endl;
  }
}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const long long mod = 1000000007;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	cin >> N >> M;
	bool hasAC[N];
	fill_n(hasAC, N, false);
	string S[M];
	int p[M], hi[N], pen = 0, ac = 0;
	fill_n(hi, N, 0);
	for (int i = 0; i < M; ++i) cin >> p[i] >> S[i];
	for (int i = 0; i < M; ++i) {
		if (S[i] == "AC") hasAC[p[i] - 1] = true;
		else if (!hasAC[p[i] - 1]) ++hi[p[i] - 1];
	}
	for (int i = 0; i < N; ++i) {
		if (hasAC[i]) ++ac, pen += hi[i];
	}
	cout << ac << " " << pen;
	return 0;
}

Measured memory_bytes: 6656
X = int(input())

RATE = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]

your_rate = 8

for i in range(len(RATE)-1):
    if RATE[i] <= X < RATE[i+1]:
        print(your_rate)
        break
    else:
        your_rate -= 1

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

int A[1005];
int B[1005];

int memo[10005];
int DP(int H, int N)
{
	if(H <= 0)
		return 0;
	
	if(memo[H] != -1)
		return memo[H];
		
	int minimum = INT_MAX;
	for(int i = 0; i < N; i++)
		minimum = min(minimum, DP(H - A[i], N) + B[i]);
	
	memo[H] = minimum;
	return minimum;
}

int main()
{
	int H, N;
	scanf("%d%d", &H, &N);
	
	for(int i = 0; i < N; i++)
		scanf("%d%d", &A[i], &B[i]);
	
	for(int i = 0; i <= H; i++)
		memo[i] = -1;
	
	printf("%d", DP(H, N));
}

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

template<typename T>
struct Dijkstra{
    const T inf=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n;
    vector<vector<pair<int,T>>> G;
    vector<T> d;
    Dijkstra(int n):n(n),G(n),d(n){}
    void add_edge(int u,int v,T w){
        G[u].emplace_back(v,w);
    }
    vector<T> build(int s){
        fill(d.begin(),d.end(),inf);
        d[s]=0;
        priority_queue<P,vector<P>,greater<P>> pq;
        pq.emplace(d[s],s);
        while(!pq.empty()){
            P p=pq.top(); pq.pop();
            int v=p.second;
            if (d[v]<p.first) continue;
            for (auto &e:G[v]){
                int u=e.first; T c=e.second;
                if (d[v]+c<d[u]){
                    d[u]=d[v]+c;
                    pq.emplace(d[u],u);
                }
            }
        }
        return d;
    }
};

const ll INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E,r; cin >> V >> E >> r;
    Dijkstra<ll> G(V);
    rep(i,E){
        int s,t; ll d; cin >> s >> t >> d;
        G.add_edge(s,t,d);
    }
    vector<ll> d=G.build(r);
    rep(i,V){
        if (d[i]>INF*6) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 19372
#include <stdio.h>

int main(int argc , char *argv[]){
    int n,q;
    int i,j;
    int N[100000];
    int Q[50000];
    int count=0;
    int right,left,mid;
    int key;
    
    /* scan N[] */
    scanf("%d",&n);
    if(n>=100001)return 0;
    
    for(i=0;i<n;i++){
        scanf("%d",&N[i]);
    }
    /* -------- */
    
    /* scan Q[] */
    scanf("%d",&q);
    if(q>=50001)return 0;
    
    for(i=0;i<q;i++){
        scanf("%d",&Q[i]);
    }
    /* --------- */
    
    
    for(i=0;i<q;i++) {
        key=Q[i];
        left=0;
        right=n;
        
        while(left < right){
            mid = (right+left)/2;
            if(key == N[mid]){count++;break;}
            if(key > N[mid])left=mid+1;
            else if(key<N[mid])right=mid;
        }
        
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define take_input freopen("input.txt","r",stdin),freopen("output.txt","w",stdout); 
#define ll long long int
const ll mod=1e9+7;
ll go(ll *a,ll low,ll high,ll dif)
{
	if(low>=high)
		return INT_MAX;
	ll mid=(low+high)>>1;
	if(a[mid+1]-a[mid]!=dif)
		return a[mid]+dif;
	if(mid>0 and a[mid]-a[mid-1]!=dif)
		return a[mid-1]+dif;
	if(a[mid]==a[0]+mid*dif)
		return go(a,mid+1,high,dif);
	return go(a,low,mid-1,dif);
}
int main()
{
	fast;
	// take_input;
	ll k;
	string s;
	cin>>k>>s;
	if(s.length()<=k)
		cout<<s<<endl;
	else
	{
		cout<<s.substr(0,k)+"...";
	}
	cout<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;


int main(){
    int n, m, R;
    cin >> n >> m >> R;
    int r[10];
    rep(i, R){
        cin >> r[i];
        r[i]--;
    }
    int d[200][200];
    rep(i, 200) fill(d[i], d[i] + 200, INF);
    vector<int> vec[200];
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        vec[a].push_back(a);
        vec[b].push_back(b);
        d[a][b] = c;
        d[b][a] = c;
        d[a][a] = 0;
        d[b][b] = 0;
    }

    for(int i = 0; i< n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    vector<int> route;
    for(int i = 0; i < R; i++){
        route.push_back(i);
    }
    int ans = INF;
    do{
        int tmp = 0;
        for(int i = 0; i < R-1; i++){
            tmp += d[r[route[i]]][r[route[i+1]]];
        }
        ans = min(tmp, ans);

    } while(next_permutation(all(route)));
    cout << ans << endl;

}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
typedef pair<pair<int, int>, int> ppi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 1e5 + 3;

ll N, K, A[MAX];

int main(){
    scanf("%lld %lld", &N, &K);
    for(int i = 1; i <= N; i++){
        scanf("%lld", A + i);
    }
    sort(A, A + N + 1);
    ll ans = 1e18;
    int idx = lower_bound(A, A + N + 1, 0) - A;
    for(int i = 0; i <= K; i++){
        if(idx - i < 0 || idx + (K - i) > N)continue;
        ll l = A[idx - i], r = A[idx + (K - i)];
        ll s1 = 2 * abs(l) + abs(r);
        ll s2 = 2 * abs(r) + abs(l);
        ans = min(ans, min(s1, s2));
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int i;
  int h[10];
  int pri;
  int swapC=6;
  
  for(i=0;i<10;i++){
    scanf("%d",&h[i]);
  }

  while(swapC!=0){
    swapC=0;
    for(i=0;i<9;i++){
      if(h[i]<h[i+1]){
	swapC++;
	pri=h[i];
	h[i]=h[i+1];
	h[i+1]=pri;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",h[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	auto isprime = [&](int x)->bool{
		for(int j = 2;j * j <= x;j++){
			if(x % j == 0)return false;
		}
		return true;
	};
	while(!isprime(N))N++;
	out(N);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<pair<int, int>> v(N);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		pair<int, int> p = { A,i + 1 };
		v[i] = p;
	}
	sort(v.begin(), v.end());

	for (int i = 0; i < N; i++) {
		if (i) cout << ' ';
		cout << v[i].second;
	}
	cout << endl;
}

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

typedef pair<int, int> pii;

const int MN = 1 << 18;

int N;
int A[MN];

pii mrg(pii a, pii b) {
    vector<int> tmp;
    tmp.push_back(a.first);
    tmp.push_back(b.first);
    tmp.push_back(a.second);
    tmp.push_back(b.second);
    sort(tmp.begin(), tmp.end());
    return { tmp[3], tmp[2] };
}

pii cc[1 << 18][18];
pii dp(int mask, int p) {
    if(p == N) return { A[mask], 0 };
    pii &ret = cc[mask][p];
    if(ret != pii(-1, -1)) return ret;

    ret = dp(mask, p + 1);
    if(mask & (1 << p)) {
        pii t = dp(mask ^ (1 << p), p + 1);
        ret = mrg(ret, t);
    }
    return ret;
}

int ans[MN];

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

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

    for(int i = 0; i < (1 << N); i++) for(int j = 0; j < N; j++) cc[i][j] = {-1, -1};
    for(int i = 1; i < (1 << N); i++) {
        ans[i] = dp(i, 0).first + dp(i, 0).second;
        ans[i] = max(ans[i], ans[i - 1]);
        printf("%d\n", ans[i]);
    }
}


Measured memory_bytes: 42112
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = sorted(inpl(), reverse = True)
b = [0,2,5,5,4,5,6,3,7,6]
dp = [0] * (n+1)

for i in a:
    w,v = b[i],i
    for j in range(n+1):
        if j < w:
            continue
        if j%w == 0 or dp[j-w]:
            dp[j] = max(dp[j], dp[j-w]*10 + v)
    # print(dp)
print(dp[-1])

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

int main(void)
{
    int n, l;
    cin >> n >> l;
    vector<string> ls;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        ls.push_back(s);
    }
    sort(ls.begin(), ls.end());
    for(int i = 0; i < ls.size(); i++)
        cout << ls[i];
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a;
	string s;
	cin>>a>>s;
	if (a<3200) cout<<"red";
	else cout<<s;
	
	return 0;
}



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

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

int arr[105];
bool winner[100005];

int main() {

	int n, k;
	scanf("%d %d", &n, &k);

	fo(i, n) scanf("%d", &arr[i]);

	fo(i, k) if (!winner[i])
		fo(j, n) if (i + arr[j] <= k)
			winner[i + arr[j]] = true;

	cout << (winner[k] ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 3892
#include <iostream>

using namespace std;

int main(void){
	while(true){
		int line[10];
		char tmp;
		cin >> line[0] >> tmp;
		if(cin.eof())
			break;
		for(int i=1;i<10;i++)
			cin >> line[i] >> tmp,line[i]+=line[i-1];
		double v1,v2;
		cin >> v1 >> tmp >> v2;
		double t=line[9]/(v1+v2);
		double tar=v1*t;
		int i;
		for( i=0;i<10;i++)
			if(tar<=line[i])
				 break;
		cout << i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

int main()
{
	int N, M; cin >> N >> M;

	vector<int> to1(N + 1, 0);
	vector<int> toN(N + 1, 0);

	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1) { to1[b] = 1; }
		if (b == 1) { to1[a] = 1; }
		if (a == N) { toN[b] = 1; }
		if (b == N) { toN[a] = 1; }
	}

	for (int i = 0; i <= N; ++i)
	{
		if (to1[i] == 1 && toN[i] == 1)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // 点の入力
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // 誤差つき等号判定
ld dot(Point a, Point b) {return real(conj(a) * b);} // 内積
ld cross(Point a, Point b) {return imag(conj(a) * b);} // 外積

ll W,H,A,B,S;
ld ra,rb;
ld check(ld theta){
    ld res = 0.0;
    
    ld x = ra * cos(theta/2), y = ra*sin(theta/2);
    
    ld x2 = sqrt(rb*rb - y*y);
    ld ox = x2 + x;
    
    ld theta2 = 2 * asin(y/rb);
    
    ld SAB = 0.5 * ra * ra * sin(theta) + 0.5 * rb * rb * sin(theta2);
    
    ld S1 = pi * ra * ra * theta / (2*pi);
    ld S2 = pi * rb * rb * theta2 / (2*pi);
    
    res = S1 + S2 - SAB;
    return res;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    while(cin >> W >> H >> A >> B >> S, W|H|A|B|S){
        bool f = false;
        if(A > B) {
            swap(A,B);
            f = true;
        }
        ra = sqrt(A/pi);
        rb = sqrt(B/pi);
        ld l = 0, r = 2*pi;
        for(int i = 0; i < 300; i++){
            ld m = (l + r)/2.0;
            ld area = check(m);
            if(area > S){
                r = m;
            }else{
                l = m;
            }
        }
        ld theta = r;
        
        ld XA,YA,XB,YB;
        
        XB = rb + 0.0001; YB = rb + 0.0001;
        
        if(XB + rb > (ld)W + 0.0001 || (YB + rb) > (ld)H + 0.0001){
            cout << "impossible" <<endl;
            continue;
        }
        
        ld x = ra * cos(theta/2), y = ra*sin(theta/2);
        ld x2 = sqrt(rb*rb - y*y);
        ld ox = x2 + x;
        
        bool f2 = false;
        for(ld T = 0.0; T < pi + eps; T += 0.0001){
            ld X = XB + ox * cos(T);
            ld Y = YB + ox *sin(T);
            if(((X + ra) < (ld)W + 0.0001) && ((X - ra) > -0.0001)){
                if(((Y + ra) < (ld)H + 0.0001) && ((Y - ra) > -0.0001)){
                    XA = X; YA = Y;
                    f2 = true;
                    break;
                }
            }
        }
        if(!f2){
            cout << "impossible" << endl;
            continue;
        }
        if(f){
            swap(XA,XB);
            swap(YA,YB);
            swap(ra,rb);
        }
        cout << fixed << setprecision(10) << XA << " " << YA << " " << ra << " " << XB << " " << YB << " " << rb << endl;
    }
    return 0;
}

Measured memory_bytes: 3460
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val h = Array.fill(n)(sc.nextLong()).reverse
  var max = 0
  var cnt = 0
  for (i <- 0 until n - 1) {
    if (h(i) <= h(i+1)) {
      cnt += 1
    } else {
      if (cnt > max) {
        max = cnt
      }
      cnt = 0
    }
  }
  // 最後が移動可能だったケース
  if (cnt > max) {
    max = cnt
  }
  println(max)
}

Measured memory_bytes: 60376