akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] od = new int[100001];
        int[] ev = new int[100001];
        int[] p = new int[4];
        int[] q = new int[4];
        for(int i = 0; i < n/2;i++){
            int ai = sc.nextInt();
            od[ai]++;
            if(q[0] < od[ai]){
                if(p[0] != ai){   
                    p[1] = p[0];    q[1] = q[0];
                }
                p[0] = ai;  q[0] = od[ai]; 
            }else if(q[1] < od[ai]){
                p[1] = ai;   q[1] = od[ai];   
            }
            ai = sc.nextInt();
            ev[ai]++;
            if(q[2] < ev[ai]){
                if(p[2] != ai){
                    p[3] = p[2];    q[3] = q[2];
                }
                p[2] = ai;   q[2] = ev[ai];
            }else if(q[3] < ev[ai]){
                p[3] = ai;   q[3] = ev[ai];
            }
        }
        if(p[0] != p[2])    System.out.println(n-q[0]-q[2]);
        else System.out.println(Math.min((n-q[0]-q[3]), (n-q[1]-q[2])));
    }
}

Measured memory_bytes: 60596
#include <bits/stdc++.h>
using namespace std;
const int INF=1<<29;
const int MAXN=10010;
int N,M,A[MAXN],B[MAXN],F[MAXN];
int main()
{
	cin>>M>>N;
	for (int i=1;i<=N;++i) scanf("%d%d",&A[i],&B[i]);
	for (int j=1;j<=M;++j) F[j]=INF;
	long long Ans=INF;
	for (int i=1;i<=N;++i)
		for (int j=A[i];j<=M;++j)
			F[j]=min(F[j],F[j-A[i]]+B[i]);
	for (int i=1;i<=N;++i)
		for (int j=0;j<=M;++j)
		{
			int v=M-j;
			if (v%A[i]==0) v=v/A[i];
			else v=v/A[i]+1;
			Ans=min(Ans,F[j]+1LL*B[i]*v);
		}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    int big = *max_element(ALL(l));
    int sum = 0;
    rep(i, n){
        sum += l[i];
    }
    if(big < sum - big){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
alp='abcdefghijklmnopqrstuvwxyz'
N=int(input())
S=input()
out=0
for i in range(1, N):
  X=S[:i]
  Y=S[i:]
  xs=[0]*26
  ys=[0]*26
  tmp=0
  for j in range(len(X)):
    xs[alp.index(X[j])]=1
  for j in range(len(Y)):
    ys[alp.index(Y[j])]=1
    
  for j in range(26):
    if xs[j]==1 and ys[j]==1:
      tmp+=1
      
  if out<tmp:
    out=tmp
print(out)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct edge{int to,cost;};
typedef pair<int,int> P;
typedef long long ll;
const ll INF=1000000000LL;
const ll MOD=1000000007LL;
int main(){
	string s;
	cin>>s;
	int c[27]={};
	if(s=="zyxwvutsrqponmlkjihgfedcba"){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<s.length();i++){
		c[s[i]-'a']++;
	}
	char p='0';
	for(int i=0;i<26;i++){
		if(!c[i]){
			p='a'+i;
			break;
		}
	}
	if(p!='0'){
		cout<<s;cout<<p<<endl;
	}else{
		int st,ma;
        st=0;
		for(int i=s.length()-1;i>=0;i--){
			ma=s[i]-'a';
			int mi=INF;
			for(int j=i+1;j<s.length();j++){
				if(ma<s[j]-'a'){
					mi=min(s[j]-'a',mi);
				}
			}
			if(mi!=INF){
				s[i]=mi+'a';
				st=i;
				break;
			}
		}
		for(int i=0;i<=st;i++){
			cout<<s[i];
		}
		cout<<endl;
	}

}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};

int role(int a){
	int ret = 0;
	int e =a;
	while(e % 2 == 0){
		ret++;
		e = e/2;
	}
	return ret;
}

int main(){
	int ans = inf;
	int N;
	cin >> N;
	int in;
	for(int i = 0; i < N; i++){
		cin >> in;
		if(in % 2 == 1){ans = 0;break;}
		else{
			ans = min(ans, role(in));
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000009];
int dp[1000090];
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4736
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int W = scanner.nextInt();
        int[] v = new int[N];
        int[] w = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = scanner.nextInt();
            w[i] = scanner.nextInt();
        }
        int[][] dp = new int[N + 1][W + 1];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j - w[i] >= 0) {
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - w[i]] + v[i]);
                } else {
                    dp[i + 1][j] = dp[i][j];
                }
            }
        }
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 31008
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)
{
	double a,b,c;
	double d,e,f;
	double delta;
	double delta_one;
	double delta_two;
	double x,y;
	
	while( scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		delta = (a*e) -(b*d);
		delta_one  = (c*e) - (f*b);
		delta_two = (a*f) - (c*d);
		x = delta_one/delta;
		y = delta_two/delta;
		x = x * 1000;
		y = y * 1000;
		x = (int)x;
		y = (int)y;
		x = x/1000;
		y = y/1000;

		printf("%0.3lf %0.3lf\n",x,y);	
	}
	return 0;
}

Measured memory_bytes: 1236
import sys
readline = sys.stdin.readline
N, K =  list(map(int, readline().split()))
deque = list(map(int, readline().split()))

items = []
ans = 0
for l in range(K+1):
    for m in range(K - l + 1):
        if l + m > N: break
        litems = deque[0:l]
        mitems = deque[N-m:]
        arr = litems + mitems
        arr.sort()
        items.append(arr)

        d = K - l - m
        for n in range(min(len(arr), d+1)):
            ans = max(ans, sum(arr[n:]))

print(ans)

Measured memory_bytes: 3444
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp

    def get_upside(self):
        return self.pips[0]

    def get_frontside(self):
        return self.pips[1]

    def get_rightside(self):
        return self.pips[2]


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.get_frontside() != q_pips[1]:
            die.spin_die_clockwise()

        print(die.get_rightside())


def main():
    die = init_die()
    question_rightside(die)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7764
class Movedice:
    def __init__(self,list,position):
        self.list=list
        self.position=position
    def sortnumber(self):
        self.list[0],self.list[self.position]=self.list[self.position],self.list[0]
        self.list[5-self.position],self.list[5]=self.list[5],self.list[5-self.position]
        self.list[0],self.list[5]=self.list[5],self.list[0]
        return list

number=list(map(int,input().split()))
destination=list(input())
for i in range(len(destination)):
    if destination[i]=='N':
        movedice=Movedice(number,4)
        movedice.sortnumber()
    elif destination[i]=='E':
        movedice=Movedice(number,2)
        movedice.sortnumber()
    elif destination[i]=='W':
        movedice=Movedice(number,3)
        movedice.sortnumber()
    else:
        movedice=Movedice(number,1)
        movedice.sortnumber()
print(number[0])



Measured memory_bytes: 5604
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  ll t = 100 * (n - m) + 1900 * m;
  REP(i, 0, m) {
    t*=2;
  }
  cout << t << "\n";
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         0x3f3f3f3f
#define sc(n)       scanf("%d",&n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define ARC(n)      for(i=0;i<n;i++)
#define ASC(n,aa)   for(i=0;i<n;i++)scanf("%lld",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         100050
#define NUM2        1000000000

int pp[NUM];
vector<int>primes;
void sieve()
{
    pp[0]=pp[1]=1;
    int i;
    for(i=2;i*i<=NUM;i++)
    {
        if(!pp[i])
        {
            primes.PB(i);
            for(int j=i+i;j<NUM;j+=i)
            {
                pp[j]=1;
            }
        }
    }
    for(;i<NUM;i++)
    {
        if(!pp[i])
        {
            primes.PB(i);
        }
    }
}
int main()
{
    sieve();
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int x;
        cin >> x ;
        cout << *lower_bound(all(primes),x) ;
    }
}
//printf("Case %d: ",++QQ);


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

int main(void)
{
    int N;
    cin >> N;
    int X[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }

    long long Xsum = accumulate(X, X+N, 0LL);
    long long Xaverage = Xsum / N;

    long long sumMin = 0;
    for (int i = 0; i < N; i++) {
        sumMin += pow(X[i] - Xaverage, 2);
    }
    long long tmp = 0;
    Xaverage++;
    for (int i = 0; i < N; i++) {
        tmp += pow(X[i] - Xaverage, 2);
    }
    if (sumMin > tmp) {
        sumMin = tmp;
    }

    cout << sumMin << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

ll A, B, C, D;

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}

bool judge() {
	if (A < B) return false;
	if (B > D) return false;
	if (B <= C) return true;
	ll g = gcd(B, D);
	return B - g + (A % g) <= C;
}

int main() {
	int t;
	cin >> t;
	rep(i, t) {
		cin >> A >> B >> C >> D;
		if (judge()) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
cnt = [0] * (N+1)  # cnt[1] から cnt[N] まで使う

for i in range(N):
    cnt[A[i]] += 1

shurui = 0
for n in range(1, N+1):
    if cnt[n] > 0:
        shurui += 1

if shurui <= K:
    print(0)
else:
    cnt.sort(reverse=True)
    print(sum(cnt[K:shurui]))

Measured memory_bytes: 24996
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, Q;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    cin >> Q;
    long long temp = 0;
    map<long long, long long> m;
    for(int i = 0; i < N; i++){
        m[A[i]]++;
        temp += A[i];
    }
    for(int i = 0; i < Q; i++){
        long long B, C;
        cin >> B >> C;
        if(m[B] != 0){
            temp -= B * m[B];
            temp += C * m[B];
            m[C] += m[B];
            m[B] = 0;
        }
        cout << temp << endl;
    }
}

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


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

Measured memory_bytes: 256
# coding:utf-8
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9112
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

data Mode = UpdateLow | UpdateHigh deriving Eq

main = do
  n <- getInt
  as <- getIntList

  let solve (b:bs) x mode stocks money
        | mode == UpdateLow && b <= x = solve bs b mode stocks money
        | mode == UpdateLow && b >  x =
          let newStocks = money `div` x
              money' = money - x * newStocks
          in
            solve bs b UpdateHigh (stocks + newStocks) money'
        | mode == UpdateHigh && b >= x = solve bs b mode stocks money
        | otherwise =
          let money' = money + stocks * x
          in
            solve bs b UpdateLow 0 money'
      solve [] x mode stocks money = money + x * stocks

  print $ solve as inf UpdateLow 0 1000

Measured memory_bytes: 3812
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make(ll,n);
    make2(string,s,t);
    ll a=0;
    for(ll i=1;i<=n;i++){
        if(s.substr(n-i,i)==t.substr(0,i)) a=i;
    }
    cout<<2*n-a<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
static const int N = 8;

int main() {
    int n; cin >> n;
    int x[N], y[N];
    double sum = 0.0;
    int indices[N];
    int factorial = 1;

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

    do {
        for (int i = 0; i < n - 1; i++) {
            int j = indices[i];
            int k = indices[i + 1];
            sum += hypot(x[k] - x[j], y[k] - y[j]);
        }
    } while (next_permutation(indices, indices + n));

    for (int i = 1; i <= n; i++) factorial *= i;
    cout << setprecision(14) << sum / 1.0 / factorial << endl;

    return 0;
}


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

const vector<string> patterns = {"dream", "dreamer", "erase", "eraser"};

const int MAXN = 2e5;
int N;
string s;
bool dp[MAXN];

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

	cin >> s;
	N = int(s.size());
	dp[N] = true;
	for (int i = N-1; i >= 0; i--) {
		for (const auto& p : patterns) {
			if (i + int(p.size()) <= N && s.substr(i, p.size()) == p && dp[i + int(p.size())]) {
				dp[i] = true;
			}
		}
	}

	if (dp[0]) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}

	return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,k;cin >> n >> k;
    vec<double> p(n);
    rep(i,n){
        int l;
        cin >> l;
        p[i]=(1.0+l)/2.0;
    }
    //i番目~i+k-1番目
    //i+k-1==n-1 <=> i=n-k
    vec<double> wa(n-k+1);
    rep(i,k)wa[0]+=p[i];
    rep2(i,1,n-k+1){
        wa[i]=wa[i-1]-p[i-1]+p[i+k-1];
    }
    double ans=0.0;
    rep(i,n-k+1){
        ans=max(ans,wa[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6232
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
struct __test {} test;
using namespace std;
template <typename T>const __test &operator<<(const __test& d,
const T& v) {return cerr << "\033[31m" << v << "\033[0m",d;}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 1e5+5;
ll a[N],n,l;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> l;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 1; i < n; ++i) {
		if(a[i]+a[i+1] >= l) {
			cout << "Possible\n";
			for(int j = 1; j < i; ++j)
				cout << j << "\n";
			for(int j = n-1; j > i; --j)
				cout << j << "\n";
			cout << i << "\n";
			return 0;
		}
	}
	cout << "Impossible\n";
	return 0;
}

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

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

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

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   string s;
    cin >> s;
    
    if(s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';
    
    cout << s;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3660
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        const long mod = 1000000007;

        //入力
        long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = tmp[0];
        long m = tmp[1];

        //壊れている段数を保持する
        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++)
        {
            a[i] = 0;
        }
        for (int i = 0; i < m; i++)
        {
            long s = long.Parse(Console.ReadLine());
            a[s] = s;

        }
        
        //DPテーブルの初期化は不要
        long[] dp = new long[n+1];
        dp[0] = 1;
        if (dp[1] == 0)
        {
            dp[1] = 1;
        }

        for (int i = 2; i <= n; ++i)
        {
            if (a[i - 1] == 0)
            {
                dp[i] += dp[i - 1];
            }
            if (a[i - 2] == 0)
            {
                dp[i] += dp[i - 2];
            }
            dp[i] %= mod;
        }


        Console.WriteLine(dp[n]);
    }

}


Measured memory_bytes: 14688
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
typedef struct {
    ll idx;
    ll num;
    ll lv;
    ll rv;
} Q;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll P[100010];
    rep(i,0,N) cin >> P[i];
    vector<Q> arr(100010);
    arr[0] = (Q){0, -1, -1, 1};
    arr[1] = (Q){1, -1, 0, 2};
    rep(i,0,N){
        arr[i+2] = (Q){i+2, P[i], i+1, i+3};
    }
    arr[N+2] = (Q){N+2, -1, N+1, N+3};
    arr[N+3] = (Q){N+3, -1, N+2, N+4};
    ll pos[100010] = {};
    rep(i,0,N) pos[P[i]] = i+2;

    ll ans = 0;
    rep(n,1,N){
        ll p = pos[n];
        ll lv = arr[p].lv;
        ll lv2 = arr[lv].lv;
        ll rv = arr[p].rv;
        ll rv2 = arr[rv].rv;
        if(lv == 1){
            ans += n * (rv2 - rv) * (p - lv);
        }else if(rv == N+2){
            ans += n * (lv - lv2) * (rv - p);
        }else{
            ans += n * (lv - lv2) * (rv - p);
            ans += n * (rv2 - rv) * (p - lv);
        }
        arr[lv].rv = arr[p].rv;
        arr[rv].lv = arr[p].lv;
    }
    print(ans);



    
}

Measured memory_bytes: 4992
struct Get<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R: std::io::BufRead> Get<R> {
    pub fn new(stdin: R) -> Self {
        Get {
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut iter = buf.split_whitespace();
        loop {
            let x = iter.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn once<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
}
mod prime {
    #[allow(dead_code)]
    pub fn is_prime(n: usize) -> bool {
        match n {
            0 | 1 => false,
            2 => true,
            _ => {
                if n % 2 == 0 {
                    return false;
                }
                let mut i = 3;
                while i <= (n as f64).sqrt() as usize + 1 {
                    if n % i == 0 {
                        return false;
                    }
                    i+=2;
                }
                true
            }
        }
    }
    #[allow(dead_code)]
    pub fn prime_all(n: usize) -> Vec<usize> {
        let mut list = Vec::new();
        for i in 2..n + 1 {
            if is_prime(i) {
                list.push(i);
            }
        }
        list
    }
    #[allow(dead_code)]
    pub fn factorize(mut n: usize) -> Vec<(usize, usize)> {
        let mut list = Vec::new();
        if is_prime(n) {
            list.push((n, 1));
            return list;
        }
        let primes = prime_all((n as f64).sqrt() as usize + 1);
        for x in &primes {
            let x = *x;
            if n % x != 0 {
                continue;
            }
            list.push((x, 0_usize));
            while n % x == 0 {
                n/=x;
                let index = list.len() - 1;
                list[index].1 += 1;
            }
            if is_prime(n) {
                list.push((n,1));
                break;
            }
        }
        list
    }
}
fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let get = Get::new(stdin);
    solve(get);
}

use std::cmp;
fn solve<R: std::io::BufRead>(mut get:Get<R>) {
    let n:usize = get.once();
    let fact_list = prime::factorize(n);
    let mut ans = 0;
    //println!("{:?}",fact_list);
    for (p, e) in &fact_list {
        let mut sum = 0;
        for i in 1.. {
            sum+=i;
            if sum > *e {
                break;
            }
            ans+=1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2684
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
int h,w,ans;
int c[10][10];
int main(void){
    cin>>h>>w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>c[i][j];
        }
    }
    for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            
        }
    }
    }
    for(int i=0;i<h*w;i++){
        int a;
        cin>>a;
        if(a==-1||a==1)continue;
        ans+=c[a][1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    int n = 1;

    scanf("%d %d %d",&a,&b,&c);

    while((a * n) % b != c){
        n++;
        if(n == 999999){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1&&b==1&&c==0){
		printf("Open\n");
		return 0;
	}
	if(a==0&&b==0&&c==1){
		printf("Open\n");
		return 0;
	}
	printf("Close\n");
	return 0;
}

Measured memory_bytes: 1012
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

void print(vector<int> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i == v.size() - 1)
      cout << v[i] << endl;
    else
      cout << v[i] << ' ';
  }
}

void Insert(vector<int> &v, int &g, int &cnt) {
  int n = v.size();
  for (int i = g; i < n; i++) {
    int t = v[i];
    int j = i - g;
    while (j >= 0 && v[j] > t) {
      v[j + g] = v[j];
      j -= g;
      cnt++;
    }
    v[j + g] = t;
  }
}

void Shell(vector<int> &v) {
  int cnt = 0;
  int h = 0;
  vector<int> G;
  while (h <= v.size() / 9)
    h = h * 3 + 1;
  for (; h > 0; h /= 3) {
    G.push_back(h);
  }
  for (auto i = G.begin(), e = G.end(); i != e; i++) {
    Insert(v, *i, cnt);
  }
  cout << G.size() << endl;
  print(G);
  cout << cnt << endl;
  for (auto &&var : v) {
    cout << var << endl;
  }
}

int main() {
  int n, tmp;
  string s;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    v.push_back(k);
  }

  Shell(v);

  return 0;
}



Measured memory_bytes: 6960
#include<bits/stdc++.h>
#include<bitset>
#define ll long long
#define P pair<int, int>
#define PP pair<int,pair<int, int>>
#define pb push_back
#define pp pop_back
#define lson root << 1
#define INF (int)2e9 + 7
#define rson root << 1 | 1
#define LINF (unsigned long long int)1e18
#define mem(arry, in) memset(arry, in, sizeof(arry))
using namespace std;

int n;
int a[200], b[200];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i], b[a[i]]++;
    int t = 0, cnt = 0;
    for(int i = 1; i <= 100; i++) if(b[i]) t++;
    for(int i = 2; i <= n; i++) {
        if(a[i] == a[i - 1]) {
            a[i] = ++t;
            cnt++;
        }
    }
    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {
	int INF = 1<<28;
	int N = 220;
	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if( (n|m) == 0) break;
			
			int[][] l = new int[N][N]; for(int[] a: l) fill(a, INF);
			int[][] s = new int[N][N]; for(int[] b: s) fill(b, INF);
			
			for(int i=0;i<n;i++) {
				l[i][i] = s[i][i] = 0;
			}
			
			for(int i=0;i<m;i++) {
				int x = sc.nextInt()-1, y = sc.nextInt()-1, t = sc.nextInt();
				String sl = sc.next();
				if(sl.charAt(0) == 'L') l[x][y] = l[y][x] = min(l[x][y], t);
				else s[x][y] = s[y][x] = min(s[x][y], t);
			}

			for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
				l[i][j] = min(l[i][j], l[i][k] + l[k][j]);
				s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
			}
			
			int R = sc.nextInt();
			int r[] = new int[R];
			for(int i=0;i<R;i++) r[i] = sc.nextInt()-1;
			
			int[][] dp = new int[R][N]; for(int[] a: dp) fill(a, INF);
			dp[0][r[0]] = 0;
			
			for(int i=0;i<R-1;i++) for(int j=0;j<n;j++) { //ship now
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + l[r[i]][r[i+1]]);
				for(int k=0;k<n;k++) { //ship next
					dp[i+1][k] = min(dp[i+1][k], dp[i][j] + l[r[i]][j] + s[j][k] + l[k][r[i+1]]);
				}
			}
			
//			for(int[] a: l)debug(a);
//			for(int[] a: s)debug(a);
//			for(int[] a: dp)debug(a);
			
			int ans = INF;
			for(int i=0;i<n;i++) ans = min(ans, dp[R-1][i]);
			System.out.println(ans);
		} 
	}
	
	void debug(Object...os) {
		System.err.println(deepToString(os));
	}
	
	public static void main(String[] args ) {
		new Main().run();
	}
}

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

int main()
{
    string str, joi = "JOI", ioi = "IOI";

    while( cin >> str ) 
    {
        int sum1 = 0, sum2 = 0;
        for( int i = 0; i < str.size() - 2; i++ )
        {
            string a = "";
            for( int j = i; j < i + 3; j++ )
            {
                a += str[j];
                if( a == joi )
                    sum1++;
                if( a == ioi )
                    sum2++;
            }
        }
        cout << sum1 << endl << sum2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
import java.io.*;  

public class Main {
    public static void main(String[] args) throws IOException {
	                                         
    	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf = br.readLine();
    String[] x = buf.split(" ",0);
   
    	int a = Integer.parseInt(x[0]);
    	int b = Integer.parseInt(x[1]);
    	int c = Integer.parseInt(x[2]);
    	if(a>b){
    		int temp = a;
    		    a = b;
    		    b =temp;
    	}
    	if(a>c){
    		int temp = a;
    		    a = c;
    		    c =temp;
    	}
    	if(b>c){
    	    int temp = b;
    		    b = c;
    		    c =temp;
    	}
    	
    	      
        System.out.println(a + " " + b +" "+c); 
    }
    
}

Measured memory_bytes: 24184
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Test
{
    public static void Main()
    {
        string R = Console.ReadLine();

        string N1 = R.Substring(0, 1);
        string N2 = R.Substring(1, 1);
        string N3 = R.Substring(2, 1);

        if (N1 == "7" || N2 == "7" || N3 == "7")
        {
            System.Console.WriteLine("Yes");
        }
        else 
        {
            System.Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 25788
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = list(readline().decode('utf8').strip())
for ops in itertools.product(['+', '-'], repeat=3):
    eq = A + ops[0] + B + ops[1] + C + ops[2] + D
    x = eval(eq)
    if x == 7:
        break
ans = eq + '=7'
print(ans)


Measured memory_bytes: 12420
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T> >;

const ll MOD=1e9+7;

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

  ll x,y;
  cin>>x>>y;
  ll z;

  if(x%y==0) cout<<"-1\n";
  else cout<<x<<'\n';
  return 0;
  for(ll d=2;d*d<=1e18;d++) if(y%d!=0){
      z=d;
      break;
    }

  if((ll)1e18/x>=z) cout<<x*z<<'\n';
  else cout<<"-1\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int rank = sc.nextInt();

        int[] results = IntStream.rangeClosed(1, Math.min(num1, num2)).filter(i -> (num1 % i == 0))
                .filter(i -> (num2 % i == 0)).sorted().toArray();

        System.out.println(results[results.length - rank]);
    }
}

Measured memory_bytes: 28500
import sys
input = sys.stdin.readline


def main():
    S = input().strip()

    ans = float("inf")
    for a, b, c in zip(S, S[1:], S[2:]):
        ans = min(ans, abs(753 - (int(a) * 100 + int(b) * 10 + int(c))))

    print(ans)
    


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  rep(i,S.size()-2){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ret++;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

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

func count(a int, b int, c int) int {
	if a == b {
		if a == c {
			return 1
		} else {
			return 3
		}
	} else {
		if a == c || b == c {
			return 3
		} else {
			return 6
		}
	}
}


func main(){
	var n,sum int
	fmt.Scan(&n)
	for i:=1 ; i<=n ; i++ {
		for j:=i; j<=n ; j++ {
			for k:=j ; k<=n; k++ {
				temp := gcd(gcd(i,j),k)
				num := count(i,j,k)
				sum += temp*num
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1776
#define _CRT_SECURE_NO_WARNINGS




#define	Rd(s) scanf("%d", &s)
#define	Rs(s) scanf("%s", &s)
#define	Rf(s) scanf("%f", &s)

#define RTNd(n, s, i) for (int i = 0;(i<n) ? scanf("%d", &s), true : false;i++)
#define RTNf(n, s, i) for (int i = 0;(i<n) ? scanf("%lf", &s), true : false;i++)

#define RTEs(s) while (fgets(s, sizeof(s), stdin) != NULL)
#define RTEc(s) while ((s = scanf("%c")) != EOF)

#define Pd(s) printf("%d", s);
#define Pf(s) printf("%f", s);

#define Pn printf("\n");

#define SORTV(v) sort(v.begin(), v.end())
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long lli;
using namespace std;

int main() {
	lli A[100000], B[100000];
	int N;
	lli maxA[100000], maxB[100000], minA[100000], minB[100000];
	lli ans = 1;
	Rd(N);
	RTNd(N, A[i], i);
	RTNd(N, B[i], i);

	maxA[0] = minA[0] = A[0];
	for (int i = 1;i < N;i++) {
		if (A[i] > A[i - 1]) {
			maxA[i] = minA[i] = A[i];
		}
		else {
			maxA[i] = maxA[i - 1];
			minA[i] = 1;
		}
	}

	maxB[N - 1] = minB[N - 1] = B[N - 1];
	for (int i = N - 2;i >= 0;i--) {
		if (B[i] > B[i + 1]) {
			maxB[i] = minB[i] = B[i];
		}
		else {
			maxB[i] = maxB[i + 1];
			minB[i] = 1;
		}
	}

	int max, min;
	for (int i = 0;i < N;i++) {
		max = (maxA[i] < maxB[i]) ? maxA[i] : maxB[i];
		min = (minA[i] > minB[i]) ? minA[i] : minB[i];
		if (max - min >= 0) {
			ans *= (max - min) + 1;
			ans %= 1000000007;
		}
		else {
			ans = 0;
			break;
		}
	}
	printf("%lld\n", ans);
}
//改行注意




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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

signed main(){
	string s=readString();
	int n=s.size();
	if((s.front()==s.back())^(n&1))
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){

  char c;

  cin>>c;
  if(c=='A')
    cout<<"T"<<endl;

  else if(c=='T')
    cout<<"A"<<endl;

  else if(c=='G')
    cout<<"C"<<endl;

  else if(c=='C')
    cout<<"G"<<endl;

  return 0;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const ll MAXN = 6000;

ll mypow(ll p, ll n){
    ll res = 1;
    while (n>0){
        if (n%2==0){
            p *= p;
            n /= 2;
        } else {
            res *= p;
            n--;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X;
    cin >> X;
    vector<ll> fifth(MAXN+1);
    for (ll i=0;i<=MAXN;i++){
        fifth[i] = mypow(i,5);
    }
    pair<int,int> ans;
    bool end = false;
    for (int i=0;i<=MAXN;i++){
        for (int j=0;j<=MAXN;j++){
            if (fifth[i] + fifth[j]==X){
                ans = make_pair(i,-j);
                end = true;
                break;
            } else if (fifth[i] - fifth[j] == X){
                ans = make_pair(i,j);
                end = true;
                break;
            }
        }
        if (end) break;
    }
    if (!end) cout << "NO ANSWER" << "\n";
    else cout << ans.first << " " << ans.second << "\n";
    
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<string> s;
	for (auto i = 0; i < H; ++i)
	{
		string temp;
		cin >> temp;
		s.push_back(temp);
	}

	auto result = true;
	int x[] = { 0, 1, 0, -1 };
	int y[] = { -1, 0, 1, 0 };
	for (auto i = 0; i < H; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			if (s[i][j] == '.')
			{
				continue;
			}

			result = false;
			for (auto k = 0; k < 4; ++k)
			{
				auto cx = j + x[k];
				auto cy = i + y[k];
				if (cx < 0 || cx >= W || cy < 0 || cy >= H)
				{
					continue;
				}

				if (s[cy][cx] == '#')
				{
					result = true;
					break;
				}
			}
			if (!result)
			{
				break;
			}
		}
		if (!result)
		{
			break;
		}
	}

	if (result)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


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

int main() {
    int N, fou, syotyou, res;
    bool flag = false;
    cin >> N;

    fou = N/4;
    syotyou = N/7;

    for (int i = 0; i <= fou; i++){
        for (int j = 0; j <= syotyou; j++){
            if (i*4 + j*7 == N){
                flag = true;
                break;
            }
        }
    }

    if (flag == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main( ){
    string l;
    int t=0;
	string max="";
	map<string,int> str;
	string s;
	while(cin>>s){
            if(s.length()>max.length())max=s;
            str[s]++;
            if(str[s]>t){
                t=str[s];
                l=s;
            }
	}
	cout<<l<<" "<<max<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void){
  int n, m, temp, j, pn;
  scanf("%d", &n);
  temp = n;
  j = 100;
  pn = 0;
  for(int i = 0; i < 3; i++){
    m = temp % 10;
    pn += j * m;
    temp /= 10;
    j /= 10;
  }
  if(n == pn) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n,k,a[MN];
int main(){
	scanf("%d%d",&n,&k);reg int ans=INT_MAX;
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i+k-1<=n;i++){
		reg int l=a[i],r=a[i+k-1];
		if(1ll*l*r>0)ans=min(ans,max(abs(l),abs(r)));
		else ans=min(ans,r-l+min(abs(l),abs(r)));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> w(k, vector<int>(k, 0)), b(k, vector<int>(k, 0));
	rip(i, n, 0) {
		int x, y;
		char c;
        scanf("%d %d %c",&x, &y, &c);
		if (bool((x / k % 2) ^ (y / k % 2)) ^ (c == 'W')) {
			w[x%k][y%k]++;
		}
		else {
			b[x%k][y%k]++;
		}
	}
	int ans = 0, al = 0;
	vector<int> X(k, 0), sX(k, 0);
	rip(i, k, 0) {
		rip(j, k, 0) {
			sX[i] += w[i][j] + b[i][j];
			X[i] += w[i][j];
		}
	}
	rip(i, k, 0) {
		int now = 0;
		rip(j, k, 0) {
			now += X[j];
		}
		rip(j, k, 0) {
			ans = max(ans, max(now, n - now));
			now += sX[j] - X[j] * 2;
		}
		rip(j, k, 0) {
			X[j] += b[j][i] - w[j][i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <algorithm>

void Frog(int &size, int stones[])
{
    int first = 0;
    int second = abs(stones[1] - stones[0]);

    for (int i = 2; i < size; i++)
    {
        int minCost = std::min(abs(stones[i-2] - stones[i]) + first, abs(stones[i-1] - stones[i]) + second);
        first = second;
        second = minCost;
    }
  
    printf("%d\n", second);
}
 
int main()
{
    int size;
    
    scanf("%d", &size);
    
    int stones[size];
    
    for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
    
    Frog(size, stones);
    
    return 0;
}


Measured memory_bytes: 512