akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    if h > w:
        h, w = w, h
    ans = h
    for w1 in range(w//3-2, w//3+3):
        s1 = w1 * h
        w2 = w-w1
        for h1 in range(h//2 + 1):
            s2 = w2 * h1
            s3 = w2 * (h-h1)
            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    h, w = w, h
    for w1 in range(w//3-2, w//3+3):
        s1 = w1 * h
        w2 = w-w1
        for h1 in range(h//2 + 1):
            s2 = w2 * h1
            s3 = w2 * (h-h1)
            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n,k,R,S,P,ans,cnt;
char L;
string s;
int f(char s){
    if(s=='r')return P;
    if(s=='s')return R;
    if(s=='p')return S;
}
int main(void){
    cin>>n>>k>>R>>S>>P>>s;
    for(int i=0;i<k;i++){
        L='o';
        cnt=0;
        for(int j=i;j<n;j+=k){
            if(L=='o'){
                L=s[j];
                cnt++;
            }
            else if(L==s[j]){
                cnt++;
            }
            else if(L!=s[j]){
                ans+=f(L)*((cnt+1)/2);
                L=s[j];
                cnt=1;
            }
        }
        ans+=f(L)*((cnt+1)/2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H,W,h,w;
    while (1) {
        scanf("%d %d",&H,&W);
        if (H == 0 && W == 0) {
            break;
        } else {
                for (h=0;h<H;h++) {
                    for (w=0;w<W;w++) {
                        if(((h+w)%2)==1){
                            printf(".");
                        }else if(((h+w)%2)==0){
                            printf("#");
                        }
                    }
                    printf("\n");
                }
            }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s[3];
    rep(i,3) cin>>s[i];
    cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    var(int, N);
    string res;

    vector<int> a(N, -1);

    const auto ask = [&](int n) -> int {
        string res;
        cout << n << endl;
        cin >> res;
        if (res == "Vacant") return a[n] = 0;
        if (res == "Male") return a[n] = 1;
        return a[n] = 2;
    };

    if (ask(0) == 0) return 0;
    int begin = 0;
    int end = N;

    int cnt = 0;
    while (++cnt <= 20 && end - begin > 1) {
        const int mid = (begin + end) / 2;
        if (ask(mid) == 0) return 0;

        if ((a[begin] == a[mid]) == ((mid - begin) & 1)) {
            end = mid;
        } else {
            begin = mid;
        }
    }

    return 255;
}


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

typedef long long ll;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll lcm=(c*d)/(__gcd(c,d));

    ll n,m,l,k,p,q;
    n=b/c;
    k=(a-1)/c;

    n=n-k; //koyta c diya jay

    m=b/d;
    k=(a-1)/d;

    m=m-k;//koyta d diya jay

    l=b/lcm;
    k=(a-1)/lcm;

    l=l-k;////koyta lcm diya jay

    ll ans= (b-a+1) -n-m+l;
    /*cout<<"n "<<n<<endl;
    cout<<"m "<<m<<endl;
    cout<<"l "<<l<<endl;*/
    cout<<ans<<endl;





}


Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]
H[0]-=1
s = True
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1]-=1
    if H[i] > H[i+1]:
        s = False
        break
if s:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def>pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf=1000000019;
int main(){
	int a;
	cin>>a;
	cout<<a/500*500<<endl;
}










Measured memory_bytes: 3112
using System;

public class Class1
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        int r = int.Parse(input[0]);
        int g = int.Parse(input[1]);
        int b = int.Parse(input[2]);

        string ans = "";

        if((g*10+b)%4 == 0)
        {
            ans = "YES";

        }
        else
        {
            ans = "NO";
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    vector<int>sum;
    sum.push_back(c[0][0]+c[1][1]+c[2][2]);
    sum.push_back(c[0][1]+c[1][2]+c[2][0]);
    sum.push_back(c[0][2]+c[1][0]+c[2][1]);
    sum.push_back(c[0][2]+c[1][1]+c[2][0]);
    sum.push_back(c[0][1]+c[1][0]+c[2][2]);
    sum.push_back(c[0][0]+c[1][2]+c[2][1]);

    for(int i=0;i<5;i++){
        if(sum[i]!=sum[i+1]){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int n;
int a[8], b[8];
bool used[9];
int c[8], cnt = 0;

int idx1 = -1, idx2 = -1;

void rec(int k = 0){
    if(k == n){
        cnt++;
        bool ok1 = true, ok2 = true;
        for(int i = 0; i < n; i++){
            if(c[i] != a[i]){
                ok1 = false;
            }
            if(c[i] != b[i]){
                ok2 = false;
            }
        }
        if(ok1){
            idx1 = cnt;
        }
        if(ok2){
            idx2 = cnt;
        }
    }
    else{
        for(int i = 1; i <= n; i++){
            if(!used[i]){
                used[i] = true;
                c[k] = i;
                rec(k + 1);
                used[i] = false;
            }
        }
    }
}

void solve(){
    cin >> n;
    cina(0, n, a);
    cina(0, n, b);
    rec();
    cout << abs(idx1 - idx2);
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S, T := readString(), readString()
	fmt.Println(T + S)
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)


Measured memory_bytes: 35804
import sys
input=sys.stdin.readline
import math

def main():
    N,H = map(int, input().split())
    X = []

    k = 0 # （最強の）振り刀（の攻撃力）
    for _ in range(N):
        a,b = map(int, input().split())
        X.append((a,b))
        k = max(k,a)

    TK = [x for x in X if x[1] > k] # 強い投げ刀のリスト
    TK.sort(key=lambda x: x[1])

    ans = 0
    while H > 0:
        if TK:
            H -= TK.pop()[1]
            ans += 1
        else:
            ans += math.ceil(H/k)
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18924
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
ans = 10**10
for i in range(2**N):
    cost = 0
    rikai = [0 for i in range(M)]
    for j in range(N):
        if i>>j&1:
            cost += A[j][0]
            for k in range(M):
                rikai[k] += A[j][k+1]
    b = True
    for k in range(M):
        if rikai[k] >= X:
            continue
        b = False
    if b:
        ans = min(ans,cost)
print(-1 if ans == 10**10 else ans)



Measured memory_bytes: 84716
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, p; cin>>n>>p;
    string s; cin>>s;

    ll ans = 0;
    if(p == 2 || p == 5){
        for(int i=0; i<n; i++){
            if((s[i] - '0') % p == 0) ans += (i + 1);
        }
    }
    else{
        reverse(s.begin(), s.end());
        ll base = 1, cur = 0;
        vector<ll> mod(n);
        for(int i=0; i<n; i++){
            mod[i] = ((s[i] - '0') * base + cur) % p;
            cur = mod[i];
            base *= 10;
            base %= p;
        }

        vector<ll> cnt(p, 0);
        cnt[0]++;
        for(auto i:mod) cnt[i]++;

        for(int i=0; i<p; i++){
            ans += cnt[i] * (cnt[i] - 1) / 2;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2196
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll a[100000];

void init()
{
}

void solve()
{
    sort(a, a+N, greater<ll>());
    ll e[2] = {0, 0};
    REP(i, 2){
        REP(j, N){
            if(a[j] != 0 && a[j] == a[j+1]){
                e[i] = a[j];
                a[j] = a[j+1] = 0;
                break;
            }
        }
        if(e[i] == 0) break;
    }
    cout << e[0] * e[1] << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;
int main(){
    char a,b;
    bool res;
    scanf("%c %c",&a,&b);
    if(b=='H'){
        res = true;
    }else{
        res = false;
    }
    if(a=='H'){
        
    }else{
        res = !res;
    }
    if(res){
        printf("H\n");
    }else{
        printf("D\n");
    }
    return 0;
}

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

class Program
{
    static void Main()
    {
        var n = Int32.Parse(Console.ReadLine());
        var p = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var ans=0;
        for (var i=1;i<n-1;++i)
        {
            if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1]<p[i] && p[i]< p[i - 1])) ans++;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  cin >> n >> m;
  vs vec;
  rep(i,0,n){
    cin >> s;
    vec.pb(s);
  }
  sort(all(vec));
  rep(i,0,vec.sz)cout << vec[i];
  puts("");
  return 0;
}

Measured memory_bytes: 256
A = list(map(str,input().split()))
stack = []
for item in A:
    if item != '+' and item != '-' and item != '*':
        stack.append(str(item))
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])



Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int result = 0;
        if(A * C <= B) {
        	result = C;
        }
        else {
        	result = B / A;
        }
        System.out.println(result);
	}
}


Measured memory_bytes: 22740
import java.util.*;
import java.util.regex.Pattern;

public class Main {

    static int N;

    static Queue<Integer>[] queues;

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        N = s.nextInt();

        queues = new Queue[N+1];

        for (int i = 1; i <= N; i++) {

            queues[i] = new LinkedList<Integer>();

            for (int j = 0; j < N-1; j++) {

                queues[i].add(s.nextInt());
            }
        }


        boolean repeatFlag = true;

        int max = -1;

        int day[] = new int[N+1];

        while (repeatFlag) {

            repeatFlag = false;

            boolean endFlag = true;

            for (int i = 1; i <= N; i++) {

                Queue<Integer> queue = queues[i];

                if (queue.isEmpty() == true) continue;

                repeatFlag = true;

                while(queue.isEmpty() == false && queues[queue.peek()].peek() == i) {

                    int firstTeam = queue.peek();

                    endFlag = false;

                    int newDay = Math.max(day[firstTeam], day[i]) + 1;

                    day[firstTeam] = newDay;

                    day[i] = newDay;

                    max = Math.max(max, newDay);

                    queues[firstTeam].poll();

                    queue.poll();
                }


            }

            if (endFlag == true && repeatFlag == true) {

                System.out.println(-1);

                return;
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 289340
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <iomanip>   //setprecision(10) 

using namespace std;

int main() {
    int N = 0;
    cin >> N;
    int A[N];
    int cnt=0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i]%2==0) {
            if (A[i]%3==0||A[i]%5==0) {
                cnt++;
            }
        } else{
            cnt++;
        }
    }
    if (cnt!=N) {
        cout << "DENIED" << endl;
    } else {
        cout << "APPROVED" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
import { createInterface } from 'readline';

// find使わない版

const main = (lines: string[]) => {
  console.log(solve(lines));
};

export const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines);

  const N1: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.08) === A) {
      N1.push(i);
    }
  }

  const N2: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.1) === B) {
      N2.push(i);
    }
  }

  for (let i = 0; i < N1.length; i++) {
    for (let j = 0; j < N2.length; j++) {
      if (N1[i] === N2[j]) {
        return N1[i].toString();
      }
    }
  }

  return '-1';
};

const parseLines = (lines: string[]) => {
  const [A, B] = lines[0].split(' ').map(e => +e);
  const obj = { A, B };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) {
    console.log(message, ...optionalParams);
  }
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines: string[] = [];
  createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


Measured memory_bytes: 11724
#include <stdio.h>

int selectionsort(int A[100], int N);

int main(){
  int A[100], N, i, x;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d", &A[i]);
  x=selectionsort(A,N);
  for(i=0;i<N-1;i++) printf("%d ", A[i]);
  printf("%d\n", A[N-1]);
  printf("%d\n", x);
  return 0;
}

int selectionsort(int A[100], int N){
  int i, j, k, minj, count=0, v;
  for(i=0;i<=N-2;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj])minj=j;
    }
    if(A[i]!=A[minj]){
      v=A[i];
      A[i]=A[minj];
      A[minj]=v;
      count++;
    }
  }
  return count;
}




Measured memory_bytes: 2084
//??????????????????not working
#include<iostream>
#include<iomanip>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> xy_t;

void koch(int n,xy_t s,xy_t t){

    if(n==0){
        return;
    }
    
    xy_t a,b,c;
    double th=M_PI*60.0/180.0;
    xy_t rot(cos(th),sin(th));
    
    a=(2.0*s+1.0*t)/xy_t(3,0);
    c=(1.0*s+2.0*t)/(xy_t(3,0));
    b=rot*(c-a)+a;

    koch(n-1,s,a);
    cout<<fixed<<setprecision(8)<<a.real()<<" "<<a.imag()<<"\n";
    koch(n-1,a,b);
    cout<<fixed<<setprecision(8)<<b.real()<<" "<<b.imag()<<"\n";
    koch(n-1,b,c);
    cout<<fixed<<setprecision(8)<<c.real()<<" "<<c.imag()<<"\n";
    koch(n-1,c,t);
}

int main(){
   xy_t s(0,0);
   xy_t t(100,0);
   int n;
   cin>>n;

   cout<<fixed<<setprecision(8)<<s.real()<<" "<<s.imag()<<"\n";
   koch(n,s,t);
   cout<<fixed<<setprecision(8)<<t.real()<<" "<<t.imag()<<"\n"; 
}

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

typedef pair<pair<string, int>, int> P;

bool cmp(const P &a, const P &b) {
    if (a.first.first == b.first.first) {
        return a.first.second > b.first.second;
    } else {
        return a.first.first < b.first.first;
    }
}

int main() {
    int N; cin >> N;
    vector<P> res(N);
    for (int i = 0; i < N; i++) {
        cin >> res[i].first.first;
        cin >> res[i].first.second;
        res[i].second = i+1;
    }
    sort(res.begin(), res.end(), cmp);
    for (int i = 0; i < N; i++) {
        cout << res[i].second << endl;;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

vector<int> split(string s){
    if(s.size()==1) return vector<int>(1,stoi(s));
    vector<int> ret;
    int x = -1;
    REP(i,s.size()){
	if(s[i] == ' '){
	    ret.PB(stoi(s.substr(x+1,i-x-1)));
	    x = i;
	}
    }
    ret.PB(stoi(s.substr(x+1,s.size()-x)));
    return ret;
}

int main(){
    while(true){
	string s;
	getline(cin,s);
	if(s == "0") break;
	vector<int> c = split(s);
	int ans = 0;
	bool flg = false;
	REP(i,c.size()){
	    if(c[i] >= 10) ans += 10;
	    else ans += c[i];
	    if(c[i]==1) flg = true;
	}
	if(ans <= 11 && flg) ans += 10;
	if(ans > 21) ans = 0;
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i < n-1 and a[i]+1==a[i+1]:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

/*
異なる2文字a[l],a[r]について、[l, r]を反転
a[l]=a[r]なら
[l-1,r-1]を反転させるのと同じ
*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S;
    cin >> S;
    vi cnt(26);

    ll ans = 1; // 反転させない
    each(c, S) {
        c -= 'a';
        rep(i, 26)if (i != c) {
            ans += cnt[i];
        }
        cnt[c]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 1000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = 1;
	ll x = 0, y = 0, z = 0;
	for (int i = 0; i < n; i++) {
		ll cnt = 0;
		if (x == a[i]) cnt++;
		if (y == a[i]) cnt++;
		if (z == a[i]) cnt++;
		ans *= cnt;
		ans %= mod;
		if (x == a[i]) x++;
		else if (y == a[i]) y++;
		else if (z == a[i]) z++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 


int N_hoseki;
int K_sousa;

int main(){

    cin >> N_hoseki;
    cin >> K_sousa;

    int value[N_hoseki];
    vector<int> minus_value;


    for( int ni = 0 ; ni < N_hoseki ; ni++ ){
        cin >> value[ni];
    }

    int max_rindex;
    int max_lindex;
    int ans = 0;
    int getv;
    max_rindex = min(N_hoseki,K_sousa);
    for( int rget = 0 ; rget <= max_rindex ; rget++ ){
        max_lindex = min(K_sousa - rget, N_hoseki - rget);
        for( int lget = 0 ; lget <= max_lindex  ; lget++ ){
            getv = 0;
            minus_value.clear();

            for( int nr = 0 ; nr < rget ; nr++ ){
                getv += value[nr];
                if(value[nr]<0) minus_value.push_back(value[nr]);
            }
            int index;
            for( int nl = 0 ; nl < lget ; nl++ ){
                index = N_hoseki - 1 - nl;
                getv += value[index];
                if(value[index]<0) minus_value.push_back(value[index]);
            }

            sort(minus_value.begin(),minus_value.end());
            for( int nt = 0 ; nt < K_sousa - rget - lget ; nt++ ){
                if(minus_value.size()>0){
                    getv += -1 * minus_value[0];
                    minus_value.erase(minus_value.begin());
                }
            }
            //cout << getv << ":" << rget << "-" << lget << endl;
            if(ans < getv) ans = getv;
        }
    }

    cout << ans;



}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n-k+1):
    if x[i] * x[i+k-1] < 0:
        ans.append(abs(x[i]) + abs(x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1])))
    else:
        ans.append(max(abs(x[i]), abs(x[i+k-1])))
print(min(ans))


Measured memory_bytes: 14224
#include <stdio.h>

int main(){
	int x, y;

	while (1){
		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0){
			return 0;
		}
		if (x <= y){
			printf("%d %d\n", x, y);
		}
		if (x > y){
			printf("%d %d\n", y, x);
		}
	}
}

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

int main() {
	int a, odd, even;
	cin >> a;
	if (a % 2 == 0) {
		even = a / 2;
		odd = a / 2;
		cout << odd * even << endl;
	}
	else {
		even = a / 2;
		odd = a / 2 + 1;
		cout << odd * even << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? n==1 ? x: b_pow(x,n>>1)*b_pow(x,(n>>1)+(n&1)) : 1;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int n,m;
int ret;

long long edge[64];
map<ll,int> done[64];

void bt(int pos,ll cur,int cnt){
	if(cnt >= ret) return;
	
	if(cur == (1ll<< n)-1 ){
		ret = cnt;
		return;
	}
	if(pos == n)return;
	
	bt(pos+1,cur|edge[pos],cnt+1);
	bt(pos+1,cur,cnt);
}
int main(){
	while(cin >> n >> m ,n){
		rep(i,n)edge[i] = (1ll<<i);
		rep(i,m){
			int a, b;
			cin >> a >> b;
			edge[a] |= (1ll<<b);
			edge[b] |= (1ll<<a);
		}
		ret = INT_MAX;
		bt(0,0,0);
		cout << ret << endl;
	}
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl
int main(){
  ll i,j;
  ll n;
  ll a[200000];
  ll a2[200000];
  ll aMai[200000];
  ll b;
  ll sum=0;
  ll countA=0;
  ll countB=0;
 
  cin >> n;
  rep0(i,n){
    cin >> a[i];
    a2[i] = i+1;
    aMai[i] = a[i] - a2[i];
    if(aMai[i]<0){
      aMai[i] = (-1) * aMai[i];
    }
  }
  vector<ll> vec(n);
  
  rep0(i,n){
    vec[i] = a[i]-a2[i];
  }
  
  sort(vec.begin(),vec.end());
  
  //rep0(i,n) test(vec[i]);
  
  if(n%2==0 && vec[(n+1)/2-1] != vec[(n+1)/2]){
    rep0(i,n){
      if(vec[i] == vec[(n+1)/2-1]){
        countA++;
      }
      else if(vec[i] == vec[(n+1)/2]){
        countB++;  
      }
    }
    if(countA>countB)
      b = vec[(n+1)/2-1];
    else
      b = vec[(n+1)/2];
  }
  else{
    b = vec[(n+1)/2 -1];
  }
  //test(countA);
  //test(countB);
  
  
  rep0(i,n){
    if(vec[i]-b < 0){
      sum += (-1)*(vec[i]-b);
    }
    else{
      sum += vec[i] - b;
    }
  }
  cout << sum << endl;
    
   
  //rep0(i,n)
    //test(vec[i]); 
  
}

Measured memory_bytes: 4992
n=gets.to_i
a=gets.split.map &:to_i
c=a.reverse
b=[]
if n%2==0

 (n/2).times do |i|
    b<< c[i*2]
  end
  (n/2).times do |i|
    b<< a[i*2]
  end
else
   (n/2+1).times do |i|
    b<< c[i*2]
  end
  (n/2).times do |i|
    b<< a[i*2+1]
  end
end
puts b*(" ")

Measured memory_bytes: 27140
#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;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1), b(n);
	rep(i, n+1) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll ans = 0;
	rep(i, n) {
		if(b[i] <= a[i]) {
			ans += b[i];
			a[i] -= b[i];
		} else {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			int next = a[i+1] - b[i];
			if(next >= 0) {
				ans += b[i];
				a[i+1] -= b[i];
			} else {
				ans += a[i+1];
				a[i+1] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class DistinctOrNot
{
    static void Main(string[] args)
    {
        var times = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        var output = "YES";

        var hashset = new HashSet<string>();

        foreach (var i in input)
        {
            // 既に追加済みのキーが来た場合はfalseになる
            if (!hashset.Add(i))
            {
                output = "NO";
                break;
            }
        }

        Console.WriteLine(output);
    }
}

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

int main() {
  int64_t N;
  int64_t cnt = 0;
  cin >> N;
//  N = 200000;
  vector<int> a(N+2,0), b(N+2,0);
  for( int64_t i=1; i<N+1; ++i) {
    cin >> a[i];
  }

  for(int64_t i=N; i>N/2; --i ) {
    b[i] = a[i];
    if( b[i] == 1 ) ++cnt;
  }
  for(int64_t i=N/2; i>0; --i ) {
    for(int64_t j=i*2; j<N+1; j+=i ) {
      b[i] ^= b[j];
//      cout << i << " " << j << " " << b[j] << endl;
    }
    b[i] ^= a[i];
    if( b[i] == 1 ) ++cnt;
  }
  cout << cnt << endl;
  for(int64_t i=0;i<N;++i) {
    if (b[i+1] == 1) {
      cout << (i+1) << " ";
    }
  }
  cout << endl;

}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=110;
ll dp[maxn][maxn*3];
ll n,s,w[maxn],v[maxn];
 
int main(){
    cin>>n>>s;
    for (int i=1; i<=n ;i++)
        cin>>w[i]>>v[i];
    w[0]=w[1]-1;
    ll sum=0;
    for (int i=1; i<=n ;i++) w[i]-=w[0],sum+=w[i];
    ll ans=0;
 
    for (int i=1; i<=n ;i++){
        for (int j=i;j >=1;j--){
            for (int k=sum;k>=w[i];k--){
                dp[j][k]=max(dp[j][k],dp[j-1][k-w[i]]+v[i]);
                if(1ll*j*w[0]+k<=s) ans=max(dp[j][k],ans);
            }
        }
    }
 
    cout<<ans<<endl;
    return 0;
}


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

#define llint long long int

using namespace std;

int main()
{
    int D, T, S;

    cin >> D >> T >> S;

    if (D <= T * S)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e8;

int main() {
    int n, m, s, g1, g2;
    while (cin >> n >> m >> s >> g1 >> g2 && n){
        s--;
        g1--;
        g2--;
        VVI d(n,VI(n,INF));
        REP(i,n) d[i][i] = 0;
        REP(i,m){
            int x, y, z;
            cin >> x >> y >> z;
            x--;
            y--;
            d[x][y] = z;
        }
        REP(i,n) REP(j,n) REP(k,n){
            d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
        }
        int ans = INF;
        REP(i,n) ans = min(ans, d[s][i]+d[i][g1]+d[i][g2]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>

int main(void){
    int N,T,count=0;
    scanf("%d",&N);
    scanf("%d",&T);
    int min = 1000;
    for (int i;i<N;i++){
        int t,c;
        scanf("%d",&c);
        scanf("%d",&t);
        if (t <= T && c < min){
            min = c;
        } else if (t > T)
        {
            count++;
        }
        
    }

    if (count == N){
        printf("TLE");
    } else {
        printf("%d",min);
    }
}

Measured memory_bytes: 128
#create date: 2020-04-26 21:03

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    s = set()
    for _ in range(n):
        s.add(ns())
    print(len(s))

if __name__ == "__main__":
    main()

Measured memory_bytes: 31088
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;

		if (c[0] == c[1]) {
			System.out.println(1 + " " + 2);
			return;
		}
		for (int i = 0; i < n - 2; i++) {
			if (c[i] == c[i + 1] || c[i] == c[i + 2] || c[i + 1] == c[i + 2]) {
				System.out.println((i + 1) + " " + (i + 3));
				return;
			}
		}
		System.out.println(-1 + " " + -1);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 12784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;




int main() {
	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << "0" << endl;
	}
	else {
		cout << "10" << endl;
	}





	return 0;
}

Measured memory_bytes: 256
h, w=map(int,input().split())
if (w == 1) | (h == 1):
    print(1)
elif h % 2 == 0:
    print(int(h * w / 2))
elif h % 2 == 1 & w % 2 == 1:
    print(int((h - 1) * w / 2) + int(w / 2) + 1)
else:
    print(int((h - 1) * w / 2) + int(w / 2))


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

int main() {
   string S;
   cin >> S;
   if (S=="RRR") cout << 3 << endl;
   else if (S=="SSS") cout << 0 << endl;
   else if (S=="RRS" || S=="SRR") cout << 2 << endl;
   else cout << 1 << endl;
}

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

int main() {
  std::string S;

  std::cin >> S;

  if (S == "abc" |
      S == "acb" |
      S == "bac" |
      S == "bca" |
      S == "cab" |
      S == "cba")
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
char c[100];
int main(){
	cin>>c;
	int sum=0;
	int l=strlen(c);
	/*for(int i=0;i<l;i++){
		if(c[i]>='a'&&c[i]<='z'){
			sum++;
			if(sum==1)cout<<c[i];
			if()
		}
	}*/
	cout<<c[0]<<l-2<<c[l-1]<<endl;
	return 0;
}

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

int main() {
  double A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  double second;
  second = abs(B- A) / (V - W);
  // 追いつかない場合
  if (V <= W ){
    cout << "NO" << endl;
  }
  // T秒以内に追いつく場合
  else if(second <= T){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	string s;
	cin >> s;
	int i;
	int ans = 0;
	for (i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]) ans++;
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define ldb long double
#define clr(x) memset(x,0,sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
const int size1 = 1e5+7;
const int size2 = 1e4;

//ll fact[size1];
 
ll pw(ll x,ll y,ll mod)
{
    if(y==0)return 1;
    ll p =pw(x,y/2,mod);
    p = (p*p)%mod;
    if(y%2==1)p = (p*x)%mod;
    return p;
}
ll gcd(ll a,ll b)
{
	if(b==0)return a;
	a = a%b;
	return gcd(b,a);
}
// ll inverse(ll x,ll mod)
// {
//     return pw(x,mod-2,mod);
// }
// ll ncr(ll n,ll r,ll mod)
// {
//     ll num = fact[n];
//     ll den = (fact[r] * fact[n-r])%mod;
//     den = inverse(den,mod);
 
//     ll ans = (num*den)%mod;
//     return ans;
// }
// vector<ll> adj1[size1];
// vector<ll> adj[size1];
// ll d[size1];
// ll n,m;
// void dikstra(ll s)
// {
//     for(ll i=1;i<=n;i++)d[i]=1e9;
//     d[s] = 0;
//     priority_queue<pll, vector<pll>, greater<pll>> q;
//     q.push({0, s});
//     while(!q.empty())
//     {
//         ll v = q.top().ss;
//         ll d_v = q.top().ff;
//         q.pop();
//         if(d_v!=d[v])continue;
//         for(auto to:adj1[v])
//         {
//             ll len = 1;
//             if(d[v] + len < d[to])
//             {
//                 d[to] = d[v]+len;
//                 q.push({d[to],to});
//             }
//         }
//     }
// }
// vector<ll> adj[size1];
// void dfs(ll v,ll p)
// {
// 	for(auto u:adj[v])
// 	{
// 		if(u!=p)
// 		{
// 			dfs(u,v);
// 		}
// 	}
// }
const ll mod = 1e9+7;
int main()
{
    //cout<<setprecision(12)<<fixed;
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 	
 	
    ll T;
    //cin>>T;
    T = 1;
    ll cas=1;
    while(T--)
    {
        //cout<<"Case #"<<cas<<": ";cas++;
        string s,t;cin>>s>>t;

        ll n = s.length(), m = t.length();

        ll ans = 1e18;
        for(ll i=0;i<n-m+1;i++){
            string temp = s.substr(i,m);
            ll cnt = 0;
            for(ll j=0;j<m;j++){
                if(temp[j]!=t[j])cnt++;
            }
            ans = min(ans,cnt);
        }
        cout<<ans<<endl;
    }
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;
string s;

signed main() {
    cin >> n >> s;
    if (n%2) cout << "No" << endl;
    else {
        bool f=true;
        rep(i,n/2) if (s[i] != s[i+n/2]) f=false;
        if (f) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int count = 0;
  
  vector<int>H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int M = H.at(0);
  
  for (int i = 0; i < N; i++) {
    if (H.at(i) >= M){
      count++;
      M = H.at(i);
    }
  }
  cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double>> pq;
  
  double temp;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    pq.push(temp);
  }
  
  double a, b; // 1番目と2番目に小さい価値
  for (int i = 1; i <= N - 1; i++) {
    a = pq.top();
    pq.pop();
    b = pq.top();
    pq.pop();
    pq.push((a + b) / 2);
  }
  
  double ans = pq.top();
  cout << ans;
}

Measured memory_bytes: 256
/*************************************************************************
    > File Name: C.cc
    > Author: sqwlly
    > Mail: sqw.lucky@gmail.com 
    > Created Time: 2019年02月16日 星期六 20时32分55秒
 ************************************************************************/

#include<bits/stdc++.h>

#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

using namespace std;

int main()
{
	int n,x;
	long long ans = 0, gcd = 0, a; 
	cin >> n >> a >> x;
	gcd = __gcd(a,1LL*x);
	for(int i = 2; i < n; ++i) {
		scanf("%d",&x);
		gcd = __gcd(1LL*x,gcd);
	}
	cout << gcd << endl;
    return 0;
}


Measured memory_bytes: 256
<?php

$loop = 0;
$N = 0;
$x = 0;
$a = 0;
while ($line = fgets(STDIN)){ 
  $arr = explode(" ", $line);
  if($loop == 0) {
    $N = (int)$arr[0];
    $x = (int)$arr[1];
  }
  $loop++;
};
$a = $arr;

$z = [];
$count = 0;
for($i=-1; $i<($N - 1); $i++){
  if ($i == -1) {
    $tmp = 0 + $a[$i + 1];
    if ($tmp > $x) {
      $sub = $tmp - $x;
      $a[$i + 1] = $a[$i + 1] - $sub;
      $count = $count + $sub;
    }
  } else {
    $tmp = $a[$i] + $a[$i + 1];  
    if ($tmp > $x) {
      $sub = $tmp - $x;
      $a[$i + 1] = $a[$i + 1] - $sub;
      $count = $count + $sub;
    }
  }
}

echo $count;

Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
vector<int> o;

int  main()
{
    cin>>a>>b>>c;
    for(int i=1;i<101;i++){
        if(a%i==0&&b%i==0){
            o.push_back(i);
        }
    }
    cout<<o[o.size()-c]<<endl;
}


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 mp make_pair
#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 M 1000000007

double dp[3000][3000];
double a[3000];

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	rep(i,n) cin>>a[i+1];
	rep(i,3000) fill(dp[i],dp[i]+3000,0);
	dp[0][0]=1;
	REP(i,1,n)
	{
		dp[i][0]=dp[i-1][0]*(1-a[i]);
		REP(j,1,i)
		{
			dp[i][j]=a[i]*dp[i-1][j-1] + (1-a[i])*dp[i-1][j];
		}
	}
	double ans=0;
	REP(i,(n/2)+1,n)
	{
		ans+=dp[n][i];
	}	
	cout<<fixed<<setprecision(11)<<ans;
	//debug3(f(1), f(2), f(3));
}

Measured memory_bytes: 71168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		if(a<b && b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26216
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String slist[] = s.split("");
        int price = 700;
        for(int i = 0; i < s.length(); i++){
            if(slist[i].equals("o")){
                price += 100;
            }
        }
        System.out.println(price);
    }
}


Measured memory_bytes: 35672