akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int,input().split()))
flag = 1
for i in range(1,n):
  if h[i] < h[i-1]:
    flag = 0
    break
  if h[i] > h[i-1]:
    h[i] -= 1
if flag == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<vector<vector<int> > > dp;
class stone{
public:
    int place;
    int smooth;
    stone(int a,int b):place(a),smooth(b){}
};
int n,m;

int func(int,int,int,vector<vector<stone> >&);
int main(){
    while(cin>>n>>m&&n){
        dp.resize(n);
        vector<vector<stone> > map(n);
        for(int i=0;i<n;++i){
            int num;
            cin>>num;
            dp[i].resize(num);
            for(int j=0;j<num;++j){
                dp[i][j].resize(m+1);
                int a,b;
                cin>>a>>b;
                map[i].push_back(stone(a,b));
            }
        }
        for(int i=0,I=dp.size();i<I;++i){
            for(int j=0,J=dp[i].size();j<J;++j){
                for(int k=0,K=dp[i][j].size();k<K;++k){
                    dp[i][j][k]=-1;
                }
            }
        }
        int ans = 1<<30;
        for(int i=0;i<map[0].size();++i){
            ans = min(ans,func(0,i,m,map));
        }
        if(m>0){
            for(int i=0;i<map[1].size();++i){
                ans = min(ans,func(1,i,m-1,map));
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

int func(int tate,int yoko,int chance,vector<vector<stone> >&map){
    int res = 1<<30;
    if(tate+1==n){
        return 0;
    }
    if(chance>0&&tate+2==n){
        return 0;
    }
    int dnum = dp[tate][yoko][chance];
    if(dnum>=0){
        return dnum;
    }
    for(int i=0,I=map[tate+1].size();i<I;++i){
        int danger = abs(map[tate+1][i].place-map[tate][yoko].place)*(map[tate+1][i].smooth+map[tate][yoko].smooth);
        res=min(res,danger+func(tate+1,i,chance,map));
    }
    if(chance>0){
        for(int i=0,I=map[tate+2].size();i<I;++i){
            int danger = abs(map[tate+2][i].place-map[tate][yoko].place)*(map[tate+2][i].smooth+map[tate][yoko].smooth);
            res=min(res,danger+func(tate+2,i,chance-1,map));
        }
    }
    dp[tate][yoko][chance]=res;
    return res;
}


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

int D,N;
int T[202];
struct Shirt {
    int A,B;
    int C;
    Shirt(int A,int B,int C) :
        A(A),B(B),C(C){}
    Shirt() {}
};

Shirt shirt[202];
// i日目にj番目の服を着る
int dp[202][202];
int main() {
    cin>>D>>N;
    rep(i,D) cin>>T[i];
    rep(i,N) {
        int A,B,C;
        cin>>A>>B>>C;
        shirt[i] = Shirt(A,B,C);
    }
    rep(i,D) {
        rep(j,N) {
            rep(k,N) {
                if(!(shirt[k].A<=T[i+1] && T[i+1]<=shirt[k].B)) continue;
                if(!(shirt[j].A<=T[i] && T[i]<=shirt[j].B)) continue;
                dp[i+1][k] = max(dp[i+1][k],dp[i][j] + abs(shirt[k].C-shirt[j].C));
            }
        }
    }
    cout<<(*max_element(dp[D-1],dp[D-1]+N))<<endl;
    return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define MOD 1000000007
int powi(int a, int b, int mod){
    long long res = 1;
    long long x, y;
    y = 1;
    x = a % mod;
    while (y <= b){
        if ((b&y) == y){
            res *= x;
            res %= mod;
        }
        x *= x;
        y *= 2;
        x %= mod;
    }
    return res;
}

/*
* mod가 소수이고, div가 mod의 배수가 아니어야 함
*/
int get_mod_inverse(int div, int mod) {
    return powi(div, mod - 2, mod);
}

int cache[100005];
int factorial(int num)
{
    if(num <= 1)
        return 1;
    if(cache[num])
        return cache[num];
    return cache[num] = ((ll)factorial(num - 1) * num) % MOD;
}

bool check[100005];
int main() {
    ios_base::sync_with_stdio(false);
    int N, dup_idx;
    vector<int> vec;
    cin >> N;
    for(int i = 0; i <= N; ++i)
    {
        int here;
        cin >> here;
        vec.push_back(here);
        if(check[here]) {
            dup_idx = i;
        }
        check[here] = 1;
    }
    int dup2;
    for(int i = 0; i <= N; ++i)
    {
        if(vec[i] == vec[dup_idx]) {
            dup2 = i;
            break;
        }
    }

    for(int len = 1; len <= N + 1; ++len)
    {
        ll ans = factorial(N + 1);
        ans = (ans * get_mod_inverse(factorial(len), MOD)) % MOD;
        ans = (ans * get_mod_inverse(factorial(N + 1 - len), MOD)) % MOD;
        int lc = dup2;
        int rc = N - dup_idx;
        int totc = lc + rc;
        if(totc >= len - 1) {
            ll sub = factorial(totc);
            sub = (sub * get_mod_inverse(factorial(len - 1), MOD)) % MOD;
            sub = (sub * get_mod_inverse(factorial(totc - len + 1), MOD)) % MOD;
            ans = (ans + MOD - sub) % MOD;

        }
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3832
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = new string(Console.ReadLine().OrderBy(x => x).ToArray());
        string t = new string(Console.ReadLine().OrderByDescending(x => x).ToArray());
        Console.WriteLine(s.CompareTo(t) == -1 ? "Yes" : "No");


    }
}


Measured memory_bytes: 13536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int ka[2000010];

int com(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod*mod_pow(ka[y], mod - 2, mod) % mod;
}

int a, b, c, d;

signed main() {
	ka[0] = 1;
	for (int i = 1; i <= 2000005; i++)ka[i] = ka[i - 1] * i%mod;
	cin >> a >> b >> c >> d;
	int p = com(c + d + 2, c + 1);
	int q = com(a + b, a);
	int r = com(a + d + 1, a);
	int s = com(b + c + 1, b);
	cout << (p + q - r - s + 2 * mod) % mod << endl;
}

Measured memory_bytes: 15872
S = input()
K = int(input())

#ランレングス圧縮
rle = []
pre = 'A'
chain = 1
for c in S:
    if c == pre:
        chain += 1
    else:
        if pre != 'A':
            rle.append([pre,chain])
        
        pre = c
        chain = 1
rle.append([pre,chain])

ans = 0

#1種類の文字列の場合
if len(rle) == 1:
    ans = (rle[0][1] * K) // 2

#2種類以上の文字列の場合
else:
    #先頭と末尾が同じ文字
    if rle[0][0] == rle[-1][0]:
        #先頭、末尾、つなぎ目の対応
        ans += rle[0][1]//2
        ans += rle[-1][1]//2
        rle[0][1] += rle[-1][1]
        rle[-1][1] = 0
        ans += rle[0][1]//2 * (K-1)

        #Sの中での連続文字の対応
        mid_chains = 0
        for i in range(1,len(rle)):
            mid_chains += rle[i][1]//2
        ans += mid_chains * K

    #先頭と末尾が異なる文字
    else:
        mid_chains = 0
        for i in range(len(rle)):
            mid_chains += rle[i][1]//2
        ans += mid_chains * K


#print(rle)
print(ans)

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

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  regex re(R"(\d+)");
  if(regex_match(S.substr(0,A),re) && S.at(A)=='-' && regex_match(S.substr(A+1,B),re)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  5 14:58:17 2019

@author: Owner
"""

K, S = map(int, input().split())

cnt = 0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-(x+y) and S-(x+y)<=K :
            cnt+=1
print(cnt)

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 3");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 4");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(A => int.Parse(A)).ToArray();
        int X = wkArr[0];
        int Y = wkArr[1];

        int[] Group1Arr = new int[] { 1, 3, 5, 7, 8, 10, 12 };
        int[] Group2Arr = new int[] { 4, 6, 9, 11 };
        int[] Group3Arr = new int[] { 2 };

        if (Group1Arr.Contains(X) && Group1Arr.Contains(Y)
         || Group2Arr.Contains(X) && Group2Arr.Contains(Y)
         || Group3Arr.Contains(X) && Group3Arr.Contains(Y)) {
            Console.WriteLine("Yes");
        }
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int h, w;
    string a[1001];

    cin >> h >> w;
    REP(i, h)
    cin >> a[i];

    ll dp[1001][1001];

    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
                continue;

            (dp[i + 1][j] += dp[i][j]) %= MOD;
            (dp[i][j + 1] += dp[i][j]) %= MOD;
        }

    cout << dp[h - 1][w - 1] << endl;

    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,t1,t2;
	string s;
	cin>>s;
	t=s.size();
	for(int i=0;i<=t;i++)
	{
		if(s[i]=='p')t1++;
	}
	cout<<s.size()/2-t1;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES(n)          cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n)          cout << ((n) ? "Yes" : "No"  ) << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  string a, b, c; cin >> a >> b >> c;
  int ans = 0;
  rep(i, n) {
    set<char> s;
    s.insert(a[i]);s.insert(b[i]);s.insert(c[i]);
    if (s.size() == 3) ans += 2;
    else if (s.size() == 2) ans += 1;
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;

vector<vector<ll>> net;

bool is_connected(const ll x, const ll y){
    vector<bool> visited(net.size(), false);
    queue<ll> q;
    visited.at(0) = true;
    q.push(0);
    while(!q.empty()){
        ll i = q.front();
        q.pop();
        for(ll j : net.at(i)){
            if((i == x && j == y) || (i == y && j == x)){
                continue;
            }
            if(visited.at(j)){ continue; }
            visited.at(j) = true;
            q.push(j);
        }
    }
    for(bool b : visited){
        if(!b){
            return false;
        }
    }
    return true;
}

int main(){
    ll n, m;
    cin >> n >> m;
    net.resize(n);
    vector<pair<ll, ll>> edges;
    for(int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).push_back(b);
        net.at(b).push_back(a);
        edges.push_back(make_pair(a, b));
    }

    ll ans = 0;
    for(auto p : edges){
        ans += !is_connected(p.first, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, h, m = gets.split(" ").map(&:to_i)

hr = h * 30.0 + m * 0.5
mr = m * 6.0
r = hr > mr ? hr - mr : mr - hr
r = 360 - r if r > 180

ans = (a ** 2) + (b ** 2) - (2 * a * b * Math.cos(r * Math::PI / 180.0))
puts Math.sqrt(ans)


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll x;
	cin >> x;
	ll y = x%11;
	if (y == 0)cout << x / 11 * 2 << endl;
	else cout << (y <= 6 ? x / 11*2 + 1 : x / 11*2 + 2) << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let s = input[0]
	let oda = 0
	while(1) {
		s = s.replace(/(dream$|dreamer$|erase$|eraser$)/, '')
		oda++
		if(s === '') {
			console.log('YES')
			return
		}
		if(oda > input[0].length / 5) {
			console.log('NO')
			return
		}
	}
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9292
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, i, j, max, min;
	int *R;

	scanf("%d", &n);
	R = malloc(sizeof(int*) * n);

	for (i = 0; i < n; i++) {
		scanf("%d", R + i);
	}

	max = R[1] - R[0];
	if (R[0] < R[1]) min = R[0];
	else min = R[1];
	
	for (i = 2; i < n; i++) {
		if (max < R[i] - min) max = R[i] - min;
		if (min > R[i]) min = R[i];
	}

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

	return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc117 c
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        long[] x = in.nl(m);
        long ans = 0;
        Arrays.sort(x);
        if(n<m){
            ArrayList<Long> dif = new ArrayList<>();
            for (int i = 1; i < m; i++) {
                dif.add(x[i]-x[i-1]);
            }
            Collections.sort(dif);
            for (int i = 0; i < m-n; i++) {
                ans += dif.get(i);
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 36140
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = na()
print(math.ceil((a+b)/2))

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0,Bob = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      Bob += a.at(i);
    }
    else{
      Alice += a.at(i);
    }
  }
  cout << Bob - Alice << endl;
}

Measured memory_bytes: 3576
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static class UnionFindTree {
	    private int[] parent;    //親ノード
	    private int[] rank;      //高さ or 次数
	    public UnionFindTree(int size) {
	        parent = new int[size];
	        rank = new int[size];
	        for (int i = 0; i < size; i++) {
	            makeSet(i);
	        }
	    }
	    public void makeSet(int x) {
	        parent[x] = x;
	        rank[x] = 0;
	    }
	    public void union(int x, int y) {
	        final int xRoot = find(x);
	        final int yRoot = find(y);
	        if (rank[xRoot] > rank[yRoot]) {
	            parent[yRoot] = xRoot;        //x の木に結合
	        }
	        else if(rank[xRoot] < rank[yRoot]) {
	            parent[xRoot] = yRoot;        //y の木に結合
	        }
	        else if (xRoot != yRoot) {        //同じ高さで根が違うとき
	            parent[yRoot] = xRoot;        //x の木に結合
	            rank[xRoot]++;                //x の木の高さを加算
	        }
	    }
	    public int find(int x) {
	        if (x != parent[x]) {    //根でないとき
	            parent[x] = find(parent[x]);    //直接、根に繋ぐ(経路圧縮)
	        }
	        return parent[x];
	    }
	    public boolean same(int x, int y) {
	        return find(x) == find(y);
	    }
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		UnionFindTree uf = new UnionFindTree(N);
		for(int i = 0 ; i < M ; ++i){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			uf.union(a, b);
		}
		Set<Integer> s = new HashSet<Integer>();
		for(int i = 0 ; i < N ; ++i){
			s.add(uf.find(i));
		}
		int ret = s.size() - 1;
		System.out.println(ret);
	}
}


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

#define X first
#define Y second
#define int long long

using namespace std;

void pudge(){
    int n;
    string a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        cout << a[i] << b[i];
}

signed main(){
#ifdef LOCAL
    freopen("pudge.in", "r", stdin);
    freopen("pudge.out", "w", stdout);
#endif
    ios_base::sync_with_stdio;
    cin.tie(0);
    cout.tie(0);

    pudge();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define MOD 1000000007

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  int a,b,c,d[20]={0};
  
  cin >> a >> b >> c;
  d[a]++;
  d[b]++;
  d[c]++;
  if(d[5]==2 && d[7]==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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


int main() {
  
  long long L,R;
  cin >> L >> R;

  int restL = L % 2019;
  int dis = 2019 - restL;

  if(dis + L <= R) {
      cout << 0 << endl;
  }else {
      int mini = 20000;
      for(int i = L;i < R;i++) {
          for(int j = i + 1;j <= R;j++) {
              int rest = ((i % 2019) * (j % 2019)) % 2019;
              mini = min(rest,mini);
          }
        }

        cout << mini << endl;
   }
  
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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

ll box(double a)
{
	ll b = a;
	return b;
}

int main() {
	ll n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	ll counta = 0;
	ll countb = 0;
	ll countc = 0;
	vl kiroku(n);
	for (int i = 0; i < n; i++) {
		if (i < k) { //検証必要あり
			if (t[i] == 'r') {
				kiroku[i] = 1;
			}
			if (t[i] == 's') {
				kiroku[i] = 2;
			}
			if (t[i] == 'p') {
				kiroku[i] = 3;
			}
		}
		else {
			if (t[i] != t[i - k]) {
				if (t[i] == 'r') {
					kiroku[i] = 1;
				}
				if (t[i] == 's') {
					kiroku[i] = 2;
				}
				if (t[i] == 'p') {
					kiroku[i] = 3;
				}
			}
			else {
				if (t[i] == 'r') {
					if (kiroku[i - k] == 1) {
						kiroku[i] = 4;
					}
					else {
						kiroku[i] = 1;
					}
				}
				if (t[i] == 's') {
					if (kiroku[i - k] == 2) {
						kiroku[i] = 4;
					}
					else {
						kiroku[i] = 2;
					}
				}
				if (t[i] == 'p') {
					if (kiroku[i - k] == 3) {
						kiroku[i] = 4;
					}
					else {
						kiroku[i] = 3;
					}
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (kiroku[i] == 1) {
			counta++;
		}
		if (kiroku[i] == 2) {
			countb++;
		}
		if (kiroku[i] == 3) {
			countc++;
		}
	}
	cout << counta * p + countb * r + countc * s << endl;
	return 0;
}

Measured memory_bytes: 4316
# coding: utf-8

K, N = map(int,input().split())
A = list(map(int,input().split()))
l_max = 0
for i in range(N-1):
    if l_max < A[i+1] - A[i]:
        l_max = A[i+1] - A[i]
        

if l_max < K - A[-1] + A[0]:
    l_max = K - A[-1] + A[0]

ans = K - l_max
print(ans)

Measured memory_bytes: 25840
import java.io.IOException;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] Args) throws IOException{
        final int n = Integer.parseInt(sc.next());
        int taro = 0, hanako = 0;
        for(int i = 0; i<n; i++){
            final String tc = sc.next();
            final String hc = sc.next();
            final int judge = tc.compareTo(hc);
            if(judge<0) hanako += 3;
            else if(judge>0) taro += 3;
            else{
                taro++;
                hanako++;
            }
        }
        System.out.println(taro+" "+hanako);
    }
}

Measured memory_bytes: 28992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll x;
    cin>>x;
    ll n=100;
    ll ans=0;
    while(n<x){
        n+=(n/100);
        ans++;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
 
int main(void){
  	int N;
	std::cin >> N;
  	int h[N];
  
  	for(int i = 0; i < N; i++){
    	std::cin >> h[i];
    }
 
  	int count = 0;
  	int start, end;
  
  	bool all_zero = false;
  	while(!all_zero){
      	all_zero = true;
		start = end = 0;
  		while(end < N){
    		if(h[end] == 0){
        		if(start < end){	
              		for(int i = start; i < end; i++){
            			h[i] -= 1;
	            	}
    	      		++count;
                }
              	++end;
              	start = end;
        	}
          	else {
              	all_zero = false;
              	if(end == N-1){
                	for(int i = start; i <= end; i++){
            			h[i] -= 1;
	            	}
    	      		++count;
                }
            	++end;
            }
    	}
    }
  
  	std::cout << count;
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

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

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

const ll INF = 1LL << 50;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int a[m], b[m];
	ll c[m];
	REP(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		c[i] = -c[i];
	}
	
	ll d[n];
	REP(i, n) d[i] = INF;
	
	d[0] = 0;
	
	REP(loop, n - 1) {
		REP(i, m) {
			if (d[a[i]] != INF && d[b[i]] > d[a[i]] + c[i]) {
				d[b[i]] = d[a[i]] + c[i];
			}
		}
	}
	
	ll ans = d[n - 1];
	
	
	bool negative[n];
	REP(i, n) negative[i] = false;
	
	REP(loop, n) {
		REP(i, m) {
			if (d[a[i]] == INF) continue;
			
			if (d[b[i]] > d[a[i]] + c[i]) {
				d[b[i]] = d[a[i]] + c[i];
				negative[b[i]] = true;
			}
			
			if (negative[a[i]]) {
				negative[b[i]] = true;
			}
		}
	}
	
	if (negative[n - 1]) cout << "inf" << endl;
	else cout << -ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long long int N;
	cin >> N;
	long long int yen = 100;
	long long int ans = 0;
	while (yen < N) {
		yen = 1.01*yen;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

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

		int a = sc.nextInt();
		String s = sc.next();

		for(int i=0;i<s.length();i++) {
			char c = s.charAt(i);
			if(c+a<91){
			    System.out.print((char)(c+a));
			}else{
			    System.out.print((char)(c+a-26));
			}
			
		}
		// 出力
		System.out.println("");
    }
}


Measured memory_bytes: 27324
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
LL n,K;
LL ans;
int main()
{
	file();
	read(n),read(K);
	if(K==0)printf("%lld\n",1ll*n*n);
	else
	{
		For(i,K+1,n)
		{
			ans+=n/i*(i-K);
			ans+=max(n%i-K+1,0ll);
		}
		printf("%lld\n",ans);
	}
	return 0;
}


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

class Program {
    static long MAX = 2000;
    static long MOD = 1000000007;
    static long[] fac = new long[MAX];
    static long[] finv = new long[MAX];
    static long[] inv = new long[MAX];

    static void Main (string[] args) {
        COMinit ();

        int S = int.Parse (Console.ReadLine ());

        if (S >= 3) {
            long ans = 1;

            for (int i = 2; i <= Math.Floor ((double) S / 3); i++) {
                ans = (ans + COM (S - 2 * i - 1, i - 1)) % MOD;
            }
            ans = ans % MOD;
            if (ans < 0) {
                ans += MOD;
            }
            Console.WriteLine (ans);
        } else {
            Console.WriteLine (0);
        }

    }

    static void COMinit () {
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    static long COM (int n, int k) {
        if (n < k) {
            return 0;
        }
        if (n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
}

//dotnet run --project test

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a;
	cin>>a;
	if(a<=599)cout<<"8\n";
	else if(a<=799)cout<<"7\n";
	else if(a<=999)cout<<"6\n";
	else if(a<=1199)cout<<"5\n";
	else if(a<=1399)cout<<"4\n";
	else if(a<=1599)cout<<"3\n";
	else if(a<=1799)cout<<"2\n";
	else cout<<"1\n";
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f; 
typedef long long ll;

 char a[1000005]; 
 
int main(){
	int n,i,j,len,L=0,R=0;
	int sum1=0,sum2=0;
	int left=0,right=0;
	int minl=INF,minr=INF;
	scanf("%d",&n);
	while(n--){
		scanf("%s",&a);
		int l=0,r=0,sum=0;
		len=strlen(a);
		for(i=0;i<len;i++){
			if(a[i]=='('){
				sum++;
				sum1++;
			}
			else {
				sum2++;
				if(sum==0)l++;
				else sum--;
			}
		}
		sum=0;
		for(i=len-1;i>=0;i--){
			if(a[i]==')')sum++;
			else {
				if(sum==0)r++;
				else sum--;
			}
		}
		if(l==0&&r==0)continue;
		else if(l==0&&r!=0)R+=r;
		else if(l!=0&&r==0)L+=l;
		
			
			else {
				minl=min(minl,l);
				minr=min(minr,r);
				left+=l;
				right+=r;
			}
		
	}
	if((minl>R||minr>L)&&(minl!=INF)&&(minr!=INF))cout<<"No"<<endl;
	else if(left+L!=right+R)cout<<"No"<<endl;
	else {
		if(L&&R)cout<<"Yes"<<endl;
		else if(L==0&&R==0&&left==0&&right==0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	i64 ans = 1;
	i64 x = pow(10, 9) + 7;
	rep2(i, 1, n) {
		ans = (ans*i) % x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>
#include <iomanip>/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> */

using namespace std;
//using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define db double
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


void Solve()
{
    string s,t;
	lli ans=0,f[27],n,m,prev=0;
	cin>>s>>t;
	memset(f,0,sizeof(f));
	n=s.length(),m=t.length();
	map<lli,vector<lli> > mp;
    //vector<vectpr<lli> > mp; 
	rep(i,0,n)
	{
		f[s[i]-'a']++;
		mp[s[i]-'a'].push_back(i);
	}
 
    lli cpos=0,ind;
    rep(i,0,m)
    {
        ind = t[i]-'a';
        if(f[ind]==0)
        {
            cout<<"-1\n";
            return;
        }

         itr it =(lower_bound(mp[ind].begin(),mp[ind].end(),prev));////first bada index kimba equal to kete bele asuchi
        if(it==mp[ind].end())//nua substring bana index pachhare achhi
        {
            ans++;
            //I am the start in this new substring
            prev=mp[ind].at(0) + 1;
        }
        else
        {
            //jedi current charecter ta previous thu agara achhi simply lower bound
            prev=(*it) + 1;
        }
        
    }
    cout<<((lli)(n*ans+prev))<<"\n";
}
int main()
{
	fast();
	
	Solve();
	return 0;
}


Measured memory_bytes: 1736
from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N, Q = map(int, readline().split())
  AB = [[int(x) for x in readline().split()] for _ in range(N-1)]
  PX = [[int(x) for x in readline().split()] for _ in range(Q)]
  
  graph = [[] for _ in range(N+1)]
  for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
  
  value = [0] * (N+1)
  for px in PX:
    value[px[0]] += px[1]
  
  stack = deque([1])
  parent = [0] * (N+1)
  while stack:
    x = stack.popleft()
    for y in graph[x]:
      if y == parent[x]:
        continue
      parent[y] = x
      stack.append(y)
      value[y] += value[x]
      
  print(' '.join(map(str, value[1:])))
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 126728
#!python
# -*- coding: utf-8 -*-


def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break

N = int(input())
D, X = map(int, input().split(' '))
A = list(map(int, get_input()))
Y = X

for A_i in A:
    n = 0
    while n * A_i + 1 <= D:
        Y += 1
        n += 1

print(Y)


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

int main() {
	int life1, att1, life2, att2;
	scanf("%d%d%d%d", &life1, &att1, &life2, &att2);
	while(life1>0 && life2>0) {
		life2 -= att1;
		if(life2<=0) break;
		life1 -= att2;
	}
	puts(life1>0 ? "Yes":"No");
	
	return 0;
}

Measured memory_bytes: 3688
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()

    for i in range(len(S)):
        if S[i] == 'A':
            a = i
            break
    for i in range(len(S) - 1, -1, -1):
        if S[i] == 'Z':
            z = i
            break

    print(z - a + 1)


if __name__ == '__main__':
    main()


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

int main(){
int A,B;
cin>>A>>B;
string S;
cin.ignore();
getline(cin,S);
char K[]={'a','b','c'};
if(S[B-1]=='A'){
    S[B-1]='a';
}else if(S[B-1]=='B'){
    S[B-1]='b';
}else{
    S[B-1]='c';
}
cout<<S<<endl;
}

Measured memory_bytes: 256
N = int(input())
t = [0]*4
for i in range(N):
  s = input()
  if s == 'AC':
    t[0]+=1
  elif s == 'WA':
    t[1]+=1
  elif s == 'TLE':
    t[2]+=1
  else:
    t[3]+=1


print('AC x ' + str(t[0]))
print('WA x ' + str(t[1]))
print('TLE x ' + str(t[2]))
print('RE x ' + str(t[3]))

Measured memory_bytes: 9188
def resolve():
    N = input()

    if N == '10000':
        print(0)
        return

    if int(N) <= 1000:
        print(1000 - int(N))
        return

    if (N[1] == '0' and N[2] == '0' and N[3] == '0'):
        print(0)
        return

    ans = 1000 * (int(N[0]) + 1) - int(N)
    print(ans)



resolve()

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

int main() {
    string a,b;
    cin>>a>>b;
    if (a>b) cout<<'>'<<endl;
    else if(a==b) cout<<'='<<endl;
    else cout<<'<'<<endl;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int sum = 0;
    for(int i = 0;i < n;i++){
        if(a[i]%2==0){
            while(a[i]%2==0){
                a[i]/=2;
                sum++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;
int main(){
  string s;
  cin >> s;

  string dsp;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0' || s[i] == '1'){
      dsp.push_back(s[i]);
    } else if(dsp != "") {
      dsp.pop_back();
    }
  }
  cout << dsp << endl;
  return 0;
}


Measured memory_bytes: 3616
using System;
using System.Linq;

namespace ITP1_11_B {
    class Program {
        static void Main(string[] args) {
            int[][] map = new int[6][];
            map[0] = new int[] { -1, 2, 4, 1, 3, -1 };
            map[1] = new int[] { 3, -1, 0, 5, -1, 2 };
            map[2] = new int[] { 1, 5, -1, -1, 0, 4 };
            map[3] = new int[] { 4, 0, -1, -1, 5, 1 };
            map[4] = new int[] { 2, -1, 5, 0, -1, 3 };
            map[5] = new int[] { -1, 3, 1, 4, 2, -1 };

            int[] dice = Console.ReadLine().Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');
                int top = int.Parse(input[0]);
                int front = int.Parse(input[1]);
                int topIndex = 0;
                int frontIndex = 0;
                for (int j = 0; j < 6; j++) {
                    if (dice[j] == top)
                        topIndex = j;
                    else if (dice[j] == front)
                        frontIndex = j;
                }
                int rightIndex = map[topIndex][frontIndex];
                Console.WriteLine(dice[rightIndex]);
            }
        }
    }
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            var N = NK[0];
            var K = NK[1];

            double count = 0;

            for (int i = 1; i <= N; i++)
            {
                if (i<K)
                {   var jou = (int)Math.Ceiling(Math.Log(K / i, 2));
                    count += 1 / (N * Math.Pow(2, jou));
                }
                else
                {
                    count += 1 / N;
                }
            }

            Console.WriteLine(count);

        }


    }
}


Measured memory_bytes: 11348
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
    int n;
    scanf("%d", &n);
    int a[n], cnt=1, ans=0, flag=0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        if (a[i]!=cnt) {
            ans++;
        } else {
            cnt++;
        }
        if (a[i]==1) {
            flag=1;
        }
    }
    if (flag==1) {
        printf("%d\n", ans);
    } else {
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;


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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ans := 99999999
	if a+b < ans {
		ans = a + b
	}
	if a+c < ans {
		ans = a + c
	}
	if c+b < ans {
		ans = c + b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[210000];
char T[210000];
string ret="~";
char tmp[210000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s%s",S,T);
	int s=strlen(S);
	int t=strlen(T);
	int fi=-1;
	int la=-1;
	for(int i=0;s*i<=a;i++){
		if((a-i*s)%t==0){
			la=i;
			if(fi==-1)fi=i;
		}
	}
	int ind=0;
	for(int i=0;i<fi;i++){
		for(int j=0;j<s;j++)tmp[ind++]=S[j];
	}
	for(int i=0;i<(a-s*fi)/t;i++){
		for(int j=0;j<t;j++)tmp[ind++]=T[j];
	}
	string str=tmp;
	ret=min(ret,str);
	ind=0;
	for(int i=0;i<(a-s*fi)/t;i++){
		for(int j=0;j<t;j++)tmp[ind++]=T[j];
	}
	for(int i=0;i<fi;i++){
		for(int j=0;j<s;j++)tmp[ind++]=S[j];
	}
	str=tmp;
	ret=min(ret,str);
	ind=0;
	for(int i=0;i<(a-s*la)/t;i++){
		for(int j=0;j<t;j++)tmp[ind++]=T[j];
	}
	for(int i=0;i<la;i++){
		for(int j=0;j<s;j++)tmp[ind++]=S[j];
	}
	str=tmp;
	ret=min(ret,str);
	ind=0;
	for(int i=0;i<la;i++){
		for(int j=0;j<s;j++)tmp[ind++]=S[j];
	}
	for(int i=0;i<(a-s*la)/t;i++){
		for(int j=0;j<t;j++)tmp[ind++]=T[j];
	}
	
	str=tmp;
	ret=min(ret,str);
	printf("%s\n",ret.c_str());
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int cmp(const void *a, const void *b){
  int x,y;
  x = *(int*)a;
  y = *(int*)b;
  return y-x;
}
int main(){
  int N,i,Al=0,Bob=0;
  int a[100];
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&a[i]);
  qsort(a,N,sizeof(int),cmp);

  for(i=0;i<N;i++){
    if(i%2==0)Al+=a[i];
    else Bob+=a[i];
  }
  printf("%d\n",Al-Bob);
  return 0;
}


Measured memory_bytes: 256