akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        char[] orgArray = sc.next().toCharArray();
        boolean check = false;

        for(int i=0; i<array.length; i++){
            char[] newArray = new char[array.length];

            for(int j=0; j<array.length; j++){
                newArray[j] = array[j];
            }

            char last = newArray[array.length-1];
            for(int j=1; j<newArray.length; j++){
                array[j] = newArray[j-1];
            }
            array[0] = last;

            check = arrayIsSame(orgArray, array);
            if(check){
                break;
            }
        }

        if(check) System.out.println("Yes");
        else System.out.println("No");
    }

    boolean arrayIsSame(char[] orgArray, char[] newArray){
        for(int i=0; i<orgArray.length; i++){
            if(orgArray[i] != newArray[i]){
                return false;
            }
        }
        return true;
    }
}


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

int main() {
    long long n, m;
    std::cin >> n >> m;
    std::vector<long long> a(n), cnt(m + 2), from(m + 1);
    std::map<long long, std::map<long long, long long>> to;
    std::cin >> a[0];
    for (int i = 1; i < n; i++) {
        from[a[i - 1]]++;

        std::cin >> a[i];
        to[a[i]][a[i - 1]]++;
        cnt[a[i - 1] + 1]++;
        cnt[a[i] + 1]--;
        if (a[i] < a[i - 1]) {
            cnt[m + 1]--;
            cnt[0]++;
        }
    }

    for (int i = 1; i < m + 2; i++) {
        cnt[i] += cnt[i - 1];
    }

    auto p(a);
    std::sort(p.begin(), p.end());
    p.erase(std::unique(p.begin(), p.end()), p.end());

    auto ret = 0ll;
    for (int i = 1; i < n; i++) {
        if (a[i] == p[0]) {
            ret++;
        } else if (a[i - 1] > a[i]) {
            ret += a[i] - p[0] + 1;
        } else {
            ret += a[i] - a[i - 1];
        }
    }

  	auto curr = ret;
    for (int i = 1; i < p.size(); i++) {
        for (auto& el : to[p[i - 1]]) {
            curr += el.second * ((p[i - 1] - el.first + m) % m - 1);
        }
        curr -= (p[i] - p[i - 1]) * cnt[p[i]];
        curr += from[p[i - 1]];
        ret = std::min(curr, ret);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 16128
import sys
input = sys.stdin.readline
import numpy as np

mod = 998244353
N = int(input())
A = [int(input()) for _ in range(N)]

L = sum(A)//2
dp1 = np.zeros((L+1,), dtype=int)
dp2 = np.zeros((L+1,), dtype=int)
dp1[0] = 1
dp2[0] = 1
for a in A:
    if a >= L+1: continue
    dp1 = (dp1 + np.concatenate((np.zeros((a,), dtype=int), dp1[:L+1-a]))) % mod
    dp2 = (dp2 + np.concatenate((np.zeros((a,), dtype=int), 2*dp2[:L+1-a]))) % mod

p1 = 0
p2 = 0
for s in range(1,L+1):
    p1 = (p1 + dp1[s]*6)%mod
    p2 = (p2 + dp2[s]*3)%mod
ans = (pow(3, N, mod) + 3 - 3*pow(2, N, mod) - p2 + p1) % mod
print(ans)

Measured memory_bytes: 14220
import bisect


def resolve():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))
    ans = 0
    for bi in b:
        ans += bisect.bisect_left(a, bi) * (n - bisect.bisect_right(c, bi))
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 23032
program abc129c
  implicit none
  integer(16) :: n, m, i, j, moder
  integer(16), allocatable :: a(:), dp(:)
  logical, allocatable :: ok_step(:)

  moder=10**9+7

  read(*,*) n, m
  allocate(a(m),ok_step(0:n),dp(0:n))

  ok_step(:) = .True.
  do i = 1, m
    read(*,*) a(i)
    ok_step(a(i)) = .False.
  end do

  dp(:) = 0
  dp(0) = 1
  do i = 0, N-1
    do j = i+1, min(n, i+2)
      if (ok_step(j)) then
        !j段目が壊れていない時
        dp(j) = dp(j) + dp(i)
        dp(j) = mod(dp(j),moder)
      endif
    enddo
  enddo

  print *, dp(n)

end program abc129c


Measured memory_bytes: 3712
def resolve():
    '''
    code here
    '''
    N = int(input())
    cards = [int(item) for item in input().split()]

    all_sum = sum(cards)

    
    def candi_abs(sumu):
        # print(sumu, all_sum - sumu, abs(2*sumu - all_sum))
        return abs(2*sumu - all_sum)

    res = 3 * 10**9
    sumu = 0
    for i in range(N-1):
        sumu += cards[i] 
        res = min(res, candi_abs(sumu))

    print(res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 24832
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(h==0 && w==0)
            break;
        else
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
            cout<<"#";
            }
            cout<<endl;
        }
         cout<<endl;

    }
    return 0;
}



Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
class InputReader {
    BufferedReader buf;
    StringTokenizer tok;

    public InputReader() {
        buf = new BufferedReader(new InputStreamReader(System.in));
//        try {
//            Path currentRelativePath = Paths.get("");
//            String s = currentRelativePath.toAbsolutePath().toString();
//            String curDir = System.getProperty("user.dir");
//            System.out.println("current dir: " + s);
//            buf = new BufferedReader(new FileReader("/Users/wangdong/Dropbox/LC_Java/src/test/resources/testA.txt"));
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
    }

    public boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(buf.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    public String next() {
        if (hasNext()) return tok.nextToken();
        return null;
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public  Double nextDouble() {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }

    public BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }
}


public class Main {
  public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
       	out.println(2 * Math.PI * n);
        out.close();
    }
  
}


Measured memory_bytes: 33368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[][][] m = new int[4][3][10];
        for(int i = 0; i < 4; ++i) {
            for(int j = 0; j < 3; ++j) {
                for(int k = 0; k < 10; ++k) {
                    m[i][j][k] = 0;
                }
            }
        }
        for(int i = 0; i < n; ++i) {
            m[s.nextInt()-1][s.nextInt()-1][s.nextInt()-1] += s.nextInt();
        }
        for(int i = 0; i < 4; ++i) {
            for(int j = 0; j < 3; ++j) {
                for(int k = 0; k < 10; ++k) {
                    System.out.print(" " + m[i][j][k]);
                }
                System.out.println();
            }
            if(i < 3) System.out.println("####################");
        }
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
 
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
    
  int A, B;
  vector<int> judge(N);
  for (int j = 0; j < M; j++) {
    cin >> A >> B;
    if (H.at(A-1) <= H.at(B-1)) {
      judge.at(A-1) = 1;
    }
    if (H.at(A-1) >= H.at(B-1)) {
      judge.at(B-1) = 1;
    }
  }
  
  int count;
  for (int k = 0; k < N; k++) {
    if (judge.at(k) == 0) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 4048
#include <iostream>

using namespace std;

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

    if (N < 11)
        cout << "Yes" << endl;
    else if (N % 2 == 0 && N <= 18)
        cout << "Yes" << endl;
    else if (N % 3 == 0 && N <= 27)
        cout << "Yes" << endl;
    else if (N % 4 == 0 && N <= 36)
        cout << "Yes" << endl;
    else if (N % 5 == 0 && N <= 45)
        cout << "Yes" << endl;
    else if (N % 6 == 0 && N <= 54)
        cout << "Yes" << endl;
    else if (N % 7 == 0 && N <= 63)
        cout << "Yes" << endl;
    else if (N % 8 == 0 && N <= 72)
        cout << "Yes" << endl;
    else if (N % 9 == 0 && N <= 81)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
 
int main() {
  int n, ans = 0;
  //string s;
  vector<int> a(9);
  rep(i, 9) cin >> a.at(i);
  cin >> n;
  vector<int> b(n);
  //if(1) {}
  rep(i, n) {
    cin >> b.at(i);
    rep(j, 9) if(a.at(j) == b.at(i)) a[j] = 200;
  }
  if(a[0] + a[1] + a[2] == 600) ans = 1;
  if(a[3] + a[4] + a[5] == 600) ans = 1;
  if(a[6] + a[7] + a[8] == 600) ans = 1;
  if(a[0] + a[3] + a[6] == 600) ans = 1;
  if(a[1] + a[4] + a[7] == 600) ans = 1;
  if(a[2] + a[5] + a[8] == 600) ans = 1;
  if(a[0] + a[4] + a[8] == 600) ans = 1;
  if(a[2] + a[4] + a[6] == 600) ans = 1;
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

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

    int cmin=1e9;
    for(int i=0;i<n;i++){
        int cost,time;
        cin >> cost >> time;
        if(time<=t){
            if(cmin>=cost){
                cmin=cost;
            }
        }
    }
    if(cmin==1e9) cout << "TLE" << endl;
    else cout << cmin << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadInts();
            var ans = 0;

            for (int i = ab[0]; i <= ab[1]; i++)
            {
                var str = i.ToString();
                if (str[0] == str[4] && str[1] == str[3])
                {
                    ans++;
                }
            }

            WriteLine(ans);
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }


        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        public static void debuglist(List<int> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debuglist(List<string> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(int[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(string[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<min({(a%2)*(b*c),(b%2)*(a*c),(c%2)*(a*b)})<<endl;
  return 0;
}


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

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

    int n; cin >> n;
    int mnSum = INT_MAX;
    int mxSum = INT_MIN;
    int mnDiff = INT_MAX;
    int mxDiff = INT_MIN;

    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        mnSum = min(mnSum, x + y);
        mxSum = max(mxSum, x + y);
        mnDiff = min(mnDiff, x - y);
        mxDiff = max(mxDiff, x - y);
    }

    cout << max(abs(mnSum - mxSum), abs(mnDiff - mxDiff));
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            int N = Integer.parseInt(br.readLine());
            int A[] = new int[N];
            String strSplit[] = br.readLine().split(" ");
            int B[] = new int[N-1];
            
            for(int i=0; i<N-1; i++){
                B[i] = Integer.parseInt(strSplit[i]);
            }

            A[0] = B[0];
            for(int i=1; i<N-1; i++){
                A[i] = Math.min(B[i],B[i-1]);
            }
            A[N-1] = B[N-2];
            
            int result = 0;
            for(int i=0; i<N; i++){
                result = result + A[i];
            }
            
            System.out.println(result);
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int x;
    cin >> x;
    int ans = 0;
    bool mini = true;
    for (int i = 1; i <= x; i++) {
        mini = true;
        int maxi = i * i;
        while (mini) {
            if (maxi <= x) {
                ans = max(ans, maxi);
                maxi *= i;
                if (maxi == 1) goto next;
            }
            else goto next;
        }
        next:;
    }
    cout << ans << endl;
}

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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n; 
	ll ans=0, c=0;
	cin >> n;
	for(int i=0; i<n; ++i) {
		int a;
		cin >> a;
		if(a<c)
			ans+=(c-a);
		else
			c=a;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int a,b;
    bool end_f = false;
    cin >> a >> b;
    for(int i = max(int(a/0.08),int(b/0.1)) - 1; i <= 1250; ++i){
        if (int(i * 0.08) == a and int(i * 0.1) == b){
            cout << i;
            end_f = true;
            break;
        }
        if (int(i * 0.08) > a || int(i * 0.1) > b) break;
    }
    if (!end_f) cout << -1;
}

Measured memory_bytes: 256
n=int(input())
a=0
l = {}
for i in range(1,10):
  for j in range(1,10):
    l[(i,j)] = 0

for i in range(1,n+1):
  s = str(i)
  if s[-1] != '0':
    a += 2*l[(int(s[-1]),int(s[0]))]
    l[(int(s[0]),int(s[-1]))] += 1
    if s[-1] == s[0]:
      a += 1

print(a)

Measured memory_bytes: 40812
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = 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;
    }
}

// 二項係数計算
ll 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;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
int main(){
  string s,t;cin>>s>>t;
  set<char>ss,tt;
  rep(i,0,s.size()){
    ss.insert(s[i]);
  }
  rep(i,0,t.size()){
    tt.insert(t[i]);
  }
  for(auto u:tt){
    if(!ss.count(u)){
      cout<<-1<<endl;return 0;
    }
  }
  vvll m(26,vll(0));
  rep(i,0,s.size()){
    m[s[i]-'a'].push_back(i+1);
  }
  ll ans=0,now=0;
  rep(i,0,t.size()){
    auto it=upper_bound(m[t[i]-'a'].begin(),m[t[i]-'a'].end(),now);
    if(it==m[t[i]-'a'].end()){
      ans+=m[t[i]-'a'][0]+s.size()-now;
      now=m[t[i]-'a'][0];
    }
    else {
      ans+=*it-now;
      now=*it;
    }

  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4628
#include<iostream>
using namespace std;
int main(){
int a,b,c,t;

cin >> a >> b >> c;
if(a>b){t=a;a=b;b=t;}
if(b>c){t=b;b=c;c=t;}
if(a>b){t=a;a=b;b=t;}
cout << a << " " << b << " " << c << endl;
return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll a, b; cin >> a >> b;
    string ans = "Yay!";
    if(a > 8 || b > 8) ans = ":(";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
/*input
3
1 1 1 1 1 1 0 0 1 1
0 1 0 1 1 1 1 0 1 0
1 0 1 1 0 1 0 1 0 1
-8 6 -2 -8 -8 4 8 7 -6 2 2
-9 2 0 1 7 -5 0 -2 -6 5 5
6 -6 7 -9 6 -5 8 0 -9 -7 -7
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[105][10],n,p[105][11],cnt[105];
long long solve(int mask){
	long long cnt[105],ans=0;
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<n;++i){
		for(int j=0;j<10;++j)
			if(a[i][j]&&(mask&(1<<j))) ++cnt[i];
		ans+=p[i][cnt[i]];
	}
	return ans;
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,x,y;
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<10;++j)
				cin>>a[i][j];
			}
	for(int i=0;i<n;++i)
		for(int j=0;j<=10;++j)
			cin>>p[i][j];
	ans=solve(1);
	for(int i=2;i<1024;++i) ans=max(ans,solve(i));
	cout<<ans;
}

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

using namespace std;

int main()
{
	int D, G;
	cin >> D >> G;
	vector<int> p(D, 0), c(D, 0);
	for (int i = 0;i < D;i++) {
		cin >> p[i];
		cin >> c[i];
	}
	int min = 1000000000;
	//全部解く問題の種類をbit全探索する.
	for (int bit = 0;bit < (1 << D);bit++) {
		int count = 0;
		int sum = 0;
		//全部解く問題についての点数と問題数を足しておく。
		for (int i = 0;i < D;i++) {
			if (bit & (1 << i)) {
				sum += c[i] + p[i] * 100 * (i+1);
				count += p[i];
			}
		}
		if (sum >= G) {
			min = std::fmin(min, count);
		}
		else {
			//点数の高いほうから解く
			for (int i = D - 1;i >= 0;i--) {
				//既に全部解いている場合は飛ばす。
				if (bit & (1 << i)) {
					continue;
				}
				else {
					//ひたすら足していき、点数に届いたら抜ける。
					for (int j = 0;j < p[i];j++) {
						if (sum >= G) {
							break;
						}
						else {
							sum += 100 * (i + 1);
							count++;
						}
					}
				}
			}
			min = std::fmin(min, count);
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }.toIntArray()

  val bool = BooleanArray(n) { a[it] % 2 == 0 }

  var ans = 0
  var first = 1
  for (i in 0 until n) {
    var now = 2
    if (bool[i]) {
      now = 1
    }

    val tmp = n - 1 - i
    ans += first * now * Math.pow(3.0, tmp.toDouble()).toInt()


    if (bool[i]) {
      first *= 2
    }
  }

  println(ans)
}


Measured memory_bytes: 31392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll T,N;
#define p(i,n,vect) for(ll i=0;i<(ll)n;++i) {cout<<vect[i]<<" ";} cout<<"\n";
void solve()
{
    string str;
    cin>>str;
    ll N=str.length();
    if(str[N-1]=='s')
    {
        str.append("es");
    }
    else
    {
        str.append("s");
    }
    cout<<str<<"\n";
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   
    
    solve();
}

Measured memory_bytes: 3684
S = input()
N = len(S)

l = 0
r = N-1

def check(t):
    l = 0
    N = len(t)
    r = N-1
    while l<=r:
#        print(t[l],t[r])
        if t[l] == t[r]:
            l+=1
            r-=1
            continue
        return False
    return True

if check(S) and check(S[:N//2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

char c[5] = {'M', 'A', 'R', 'C', 'H'};
ll cnt[5];

ll solve(){
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < 5; ++j){
            if(s[0] == c[j]) cnt[j]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 5; ++i){
        for(int j = i + 1; j < 5; ++j){
            for(int k = j + 1; k < 5; ++k){
                ll cur = cnt[i] * cnt[j] * cnt[k];
                ans += cur;
            }
        }
    }
    return ans;
}

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

    cout << solve() << "\n"; 
    
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	cout << "Christmas";
	inc(i, 25 - n) { cout << " Eve"; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <math.h>
#include <random>
#include <cstdio>
using namespace std;

const int LOOP = 1000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		//===============================================

		///random
        int i=rand()%N;
        int j=rand()%N;
        int t=r[i];
        r[i]=r[j];
		r[j]=t;
        score = Evaluate(r);
		if(score<mi){
            mi=score;
		}else{
            if(Changes(cnt)){
                mi=score;
            }else{
                int a=r[i];
                r[i]=r[j];
                r[j]=a;
            }
		}
		//===============================================
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
    srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N;
int a[maxn];
void solve(){
	int ans = 0;
	for(int i =1;i<=N;i++){
		for(int j = i+1;j<=N;j++){
			for(int k = j+1;k<=N;k++){
				if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
				if(a[i]+a[j] > a[k] && a[i]+a[k] > a[j] && a[j]+a[k] > a[i]) {
					ans++;
					// cout<<i<<" "<<j<<" "<<k<<'\n';
				}
			}
		}
	}
	cout<<ans<<'\n';
}
int main(){
	// debug;
	ios;

	cin>>N;
	for(int i =1;i<=N;i++) cin>>a[i];
	solve();
	
	return 0;
}


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

using namespace std;


#define MOD 1e9+7
#define ll long long int


void solve()
{
	int k;
	cin>>k;
	int a,b;cin>>a>>b;
	for(int i=a;i<=b;i++)
		if(i%k==0)
		{
			cout<<"OK\n";
			return;
		}
	cout<<"NG\n";
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifndef ONLINE_JUDGE 
      	freopen("_input.txt", "r", stdin); 
  	freopen("_output.txt", "w", stdout); 
  	#endif 
	

    solve();

	
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
  	cin>>a>>b;
  	if(a==1) a=100;
  	if(b==1) b=100;
  	if(a==b) cout<<"Draw";
  	else if(a>b) cout<<"Alice";
  	else cout<<"Bob";
}

Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			if(s.equals("RRR")) {
				System.out.println(3);
			}else if(s.equals("RRS")||s.equals("SRR")){
				System.out.println(2);
			}else if(s.equals("RSS")||s.equals("SRS")||s.equals("SSR")||s.equals("RSR")) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
			
			
			
	    }
				
	}
	


Measured memory_bytes: 35580
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    ans = "first" if any(a % 2 == 1 for a in A) else "second"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12704
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    string b;
    cin>>a>>b;
    int b1=b[0]-'0';
    int b2=b[2]-'0';
    int b3=b[3]-'0';
    ll ats=a*(100*b1+10*b2+b3);
    cout<<ats/100<<endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;
 
class Main {
    public static void main(String args[]) {
        int i,j,k=0;
		Scanner sc =new Scanner(System.in);
		int [][][]a=new int[1000][2][12];
		int [] S=new int [1000];
		
		S[0]=sc.nextInt();
		boolean judgment;
		
		do{
			
			
			for (i=0;i<12;i++)
				{a[k][0][i]=sc.nextInt();a[k][1][i]=sc.nextInt();}
			k++;
			S[k]=sc.nextInt();
		}while(S[k]!=0);

		for (j=0;j<k;j++){
		judgment = false;	
		for (i=0;i<12;i++){
			S[j]-=(a[j][0][i]-a[j][1][i]);
			//System.out.println(S[j]);
			if (S[j]<=0)
				{judgment=true;break;}}
		
		if (judgment) System.out.println(i+1);
		else System.out.println("NA");}

    }
}

Measured memory_bytes: 37472
n=int(input())

a=list(map(int,input().split()))
b=[]
sum=0

for i in range(n):
  cnt=1
  while (a[i])%(2**cnt)==0:
    cnt+=1
  b.append(cnt-1)

for i in range(n):
  sum=sum+b[i]
  
print(sum)

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    }
    else
    {
        cout << (a + b) / 2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
int n,sum=0;

void dfs(ll tmp,int flag){
	if(tmp > n) return;
	if(tmp<=n && flag==7) sum++;
	dfs(tmp*10 + 3, flag|1);
	dfs(tmp*10 + 5, flag|2);
	dfs(tmp*10 + 7, flag|4);
}

int main(void){
	scanf("%d",&n);
	dfs(0,0);
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b;
  if (c - b >= 0) {
    ans += b;
    c -= b;
  } else {
    ans += c;
    c = 0;
  }

  if (c - a >= 0) {
    ans += a;
    c -= a;
  } else {
    ans += c;
    c = 0;
  }

  if (c > 0) ans++;

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!



void solve(){
    ll n;
    cin>>n;
    
    vector<vll> grid(2,vll (n,0));
    for(ll j=0;j<n;j++){
        cin>>grid[0][j];
        grid[1][j]=grid[0][j];
    }
    for(ll i=1;i<n;i++){
        grid[0][i]+=grid[0][i-1];
    }
    
    for(ll i=n-1-1;i>=0;i--){
        grid[1][i]+=grid[1][i+1];
    }
    
    ll ans=INT_MAX;
    for(int i=0;i<n-1;i++){
        ans=min(ans,abs(grid[0][i]-grid[1][i+1]));
    }
    cout<<ans<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 7956
n = gets.chomp.to_i
ws = n.times.map { gets.chomp }

rule = true
last_c = ws[0][0]
said = []
ws.each do |word|
  if word.start_with?(last_c) && !said.include?(word)
    last_c = word[-1]
    said << word
  else
    rule = false
    break
  end
end
puts rule ? 'Yes' : 'No'


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int index = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if(a[i] == 1) index = i;
  }
  if(n == k)
  {
    cout << 1 << endl;
    return 0;
  }
  /*auto check = [&](int offset)
  {
    int c;
    if(index != 0) {
      for (int i = index - offset; i >= 0; i = i - k) {
        if (i != index) i++;
        c++;
      }
    }
    if(index != n - 1) {
      for (int i = index + k - offset; i < n; i = i + k) {
        if (i != index) i--;
        c++;
      }
    }
    return c;
  };
  for(int i = 0; i <= k; i++)
  {
    int temp = check(i);
    if(!(index == 0 && i == k))
    {
      temp++;
    }else if(!(index == n - 1 && i == 0))
    {
      temp++;
    }
    count = min(count, temp);
  }*/
  long long int min_count = n;
  for(int i = 0; i < n; i++)
  {
    if(index < i || i + k < index) continue;
    long long int count = 0;
    if(i != 0)
    {
      for (int j = i; j >= 0; j = j - k) {
        if (j != i) j++;
        count++;
      }
    }
    if(i != n - 1) {
      for (int j = i; j < n; j = j + k) {
        if (j != i) j--;
        count++;
      }
    }
    min_count = min(min_count, count);
  }
  /*if(index != 0) {
    for (int i = index; i >= 0; i = i - k) {
      if (i != index) i++;
      count++;
    }
  }
  if(index != n - 1) {
    for (int i = index; i < n; i = i + k) {
      if (i != index) i--;
      count++;
    }
  }*/
  cout << min_count << endl;
  return 0;
}


Measured memory_bytes: 640
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    let a = a.chars().collect_vec();
    println!("{}",if (a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3]) {"Yes"}else{"No"})
}

Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


//////////////////////////////////////////////////////////////////////////////////////

int main(){
    int h, w, k;
    int ans = 0;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i = 0;i < h;i++){
        for (int j = 0;j < w;j++){
            cin >> c[i][j];
        }
    }

    for (int bith = 0;bith < (1 << h);bith++){
        for (int bitw = 0;bitw < (1 << w);bitw++){
            int count = 0;
            for (int i = 0;i < h;i++){
                for (int j = 0;j < w;j++){
                    if (((bith >> i) & 1) || (((bitw >> j) & 1))){
                        continue;
                    }

                    if (c[i][j] == '#'){
                        count++;
                    }
                }
            }
                    if (count == k){
                        ans++;
                    }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 1000000007
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}vector<vector<int>>v(100005);
vector<vector<ll>>dp(100005,vector<ll>(2));vector<bool>vis(100005,0);ll temp=1;
ll dfs(ll root)
{
    vis[root]=1;dp[root][0]=1;dp[root][1]=1;
    for(int i=0;i<v[root].size();i++)
    {
        if(!vis[v[root][i]])
        {
            dfs(v[root][i]);
            dp[root][0]=((dp[root][0]%mod)*(dp[v[root][i]][0]%mod+dp[v[root][i]][1]%mod)%mod)%mod;
            dp[root][1]=((dp[root][1]%mod)*(dp[v[root][i]][0]%mod))%mod;
        }
    }
}
int main()
{io
int n;cin>>n;
for(int i=1;i<n;i++)
{
    int x,y;cin>>x>>y;
    v[x].pb(y);v[y].pb(x);
}
dfs(1);
cout<<(dp[1][0]%mod+dp[1][1]%mod)%mod;

}









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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	ll sum = 0;

	cin >> n;

	REP(i, n) {
		sum += i + 1;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B; string S;
    cin >> A >> B >> S;
    
    string ans = "Yes";
    for(int i = 0; i < A; i++) {
        if(S.at(i)=='-') ans = "No";
    }
    if(S.at(A)!='-') ans = "No";
    for(int i = A+1; i < A+B+1; i++) {
        if(S.at(i)=='-') ans = "No";
    }
    cout << ans << endl;
}


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

#define int long long

int n,m,g[55][55],t;
vector<int> e[55];
int found=0,u=0;
int f[55][1<<21];

void dfs(int x,int pre)
{
	if(x==t)
	{
		found = 1;
		return;
	}
	for(int y=1;y<=n;y++)
		if(g[x][y] && y!=pre)
		{
			dfs(y,x);
			if(found)
			{
				e[g[x][y]].push_back(u);
				return;
			}
		}
}

signed main()
{
	cin>>n;
	for(int i=1,x,y;i<n&&cin>>x>>y;i++)
		g[x][y] = g[y][x] = i;
	cin>>m;
	for(int i=1,x;i<=m&&cin>>x>>t;i++)
	{
		found = 0, u = i;
		dfs(x,0);
	}
	f[0][0] = 1;
	for(int i=0;i<n-1;i++)
		for(int s=0;s<=(1<<m)-1;s++)
		{
			f[i+1][s] += f[i][s];
			int t=s;
			for(int j=0;j<e[i+1].size();j++)
				t |= 1<<e[i+1][j]-1;
			f[i+1][t] += f[i][s];
		}
	cout<<f[n-1][(1<<m)-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 405164
#include <bits/stdc++.h>
#include<iostream>
#include <string>
#include <typeinfo>
using namespace std;
 
int main() {
  vector<int>a(3);
    for(int i = 0;i < 3;i++)cin >> a[i];
  sort(a.begin(),a.end());
  
  int ans;
  int tmp = a[0] - a[1];
  ans = abs(a[1] - a[2] + tmp);
cout << ans;
} 


Measured memory_bytes: 3564
import bisect


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    a = sorted(a)
    c = sorted(c)

    res = 0
    for i in b:
        res += bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i))

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105424
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a + b + c) % 17 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

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 + 1) {
    ans += min(a[i] + a[i + 1], b[i]);
    a[i + 1] -= max(0, b[i] - a[i]);
    if (a[i + 1] < 0) a[i + 1] = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<ll> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    vector<ll> y(n-k+1);
    for(int i=0;i<n-k+1;i++){
        y[i]=x[i+k-1]-x[i];
        y[i]+=min(abs(x[i]),abs(x[i+k-1]));
    }
    sort(all(y));
    cout<<y[0]<<endl;


}


Measured memory_bytes: 1408
def push(x):
    global top
    top += 1
    stack[top] = x
    
def pop():
    global top
    top -= 1
    return stack[top + 1]

input_list = input().split()
len_input_list = len(input_list)
stack = [0] * 105
top = 0

for i in range(len_input_list):
    if input_list[i] == '+':
        a = pop()
        b = pop()
        push(a + b)
    elif input_list[i] == '-':
        a = pop()
        b = pop()
        push(b - a)
    elif input_list[i] == '*':
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(input_list[i]))
        
res = pop()

print(res)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    string S, T;
    cin >> S >> T;
    ll sl = S.length();
    ll tl = T.length();
    ll maxcnt = 0;
    for(int i=0; i<sl-tl+1; ++i){
        ll cnt = 0;
        for(int j=0; j<tl; ++j){
            if(S[i+j]==T[j]) cnt++;
        }
        maxcnt = max(maxcnt, cnt);
    }
    cout << tl-maxcnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	set<int> st;
	REP(i,3){
		int a;
		cin>>a;
		st.insert(a);
	}
	
	if(st.size()==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

public class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] skewers = Console.ReadLine().Split().Select(i => int.Parse(i))
			.OrderByDescending(i => i).ToArray();
		int ans = 0;
		for (int i = 1; i < 2 * n; i += 2)
		{
			ans += skewers[i];
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 3160