akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 200100100100100100
#define MOD 1000000007

int N;
int H[5001],P[5001];
vector<pair<int,int>>v;
ll dp[5001][5001]; //processed, used

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  cin>>N;
  for (int i=0;i<N;i++){
    cin>>H[i]>>P[i];
    v.push_back({H[i],P[i]});
  }
  sort(v.begin(),v.end(),[](pair<int,int>p1, pair<int,int>p2){return p1.first+p1.second<p2.first+p2.second;});
  for (int i=0;i<=N;i++)
    for (int j=0;j<=N;j++)
      dp[i][j]=INF;
  dp[0][0]=0;
  int ans=0;
  for (int i=0;i<N;i++){
    for (int j=0;j<=i;j++){
      if (dp[i][j]<=v[i].first)
	dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+v[i].second);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  for (int i=0;i<=N;i++)
    for (int j=0;j<=N;j++)
      if (dp[i][j]!=INF) ans=max(ans,j);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 195840
a = []
while True:
    b = map(int, raw_input().split())
    if b == [-1, -1, -1]:
        break
    a.append(b)
for list in a:
    m, f, r = list
    if m == -1 or f == -1:
        print 'F'
    elif m + f >= 80:
        print 'A'
    elif m + f >= 65:
        print 'B'
    elif m + f >= 50:
        print 'C'
    elif m + f >= 30:
        if r >= 50:
            print 'C'
        else:
            print 'D'
    else:
        print 'F'

Measured memory_bytes: 6412
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

void solve() {
    int h, w, k, ans = 0;
    cin >> h >> w >> k;
    vector<string> grid(h);
    for (int i=0;i<h;++i) cin >> grid[i];
    for (int m1=0;m1<(1<<h);++m1) {
        for (int m2=0;m2<(1<<w);++m2) {
            int cnt = 0;
            for (int i=0;i<h;++i) for (int j=0;j<w;++j) {
                if (m1 & (1<<i)) continue;
                if (m2 & (1<<j)) continue;
                if (grid[i][j] == '#') ++cnt;
            }
            if (cnt == k) ++ans;
        }
    }
    cout << ans << '\n';
} 

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

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

using namespace std;

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

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

	int x;
	cin >> x;
	if (x >= 400 && x < 600) cout << "8\n";
	else if (x >= 600 && x < 800) cout << "7\n";
	else if (x >= 800 && x < 1000) cout << "6\n";
	else if (x >= 1000 && x < 1200) cout << "5\n";
	else if (x >= 1200 && x < 1400) cout << "4\n";
	else if (x >= 1400 && x < 1600) cout << "3\n";
	else if (x >= 1600 && x < 1800) cout << "2\n";
	else cout << "1\n";


    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int sum =0;
  int x;
  for ( int i = 0 ; i < N ; i++) {
    cin >> x;
    if ( x * 2 < K ) {
      sum += x * 2;
    }
    else {
      sum += (K - x) * 2;
    }
      }
  cout << sum << endl;
  // ここにプログラムを追記
}


Measured memory_bytes: 256
import sys
M,K=map(int,input().split())

if M==0:
    if K==0:
        print(0,0)
    else:
        print(-1)
    sys.exit()

if M==1:
    if K==0:
        print(0,0,1,1)
    else:
        print(-1)
    sys.exit()

if K==0:
    ANS=[]
    for i in range(2**M):
        ANS.append(i)
        ANS.append(i)
    print(*ANS)
    sys.exit()

if not(1<=K<2**M):
    print(-1)
    sys.exit()

LIST=[]

for i in range(2**M):
    if K==i:
        continue
    LIST.append(i)

ANS=[K]+LIST[::-1]+[K]+LIST
print(*ANS)
    


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

int n, a[22][22];
long long dp[22][2100000], mod = 1e9+7;

long long func(int r, int p){
//	cout << r << " " << p << "\n";
	if(r == n) return 1;
	if(dp[r][p] != -1) return dp[r][p];
	long long res = 0;
	for(int i=0; i<n; ++i)
		if((p>>i) % 2 == 1 && a[r+1][i+1] == 1){
			res += func(r+1, p-(1<<i));
			res %= mod;
		}
//	cout << r << " " << p << " " << res << "\n";
	return dp[r][p] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			cin >> a[i+1][j+1];
	for(int i=0; i<=n; ++i)
		for(int j=0; j<=(1<<n)-1; ++j)
			dp[i][j] = -1;
	cout << func(0, (1<<n)-1) << "\n";
}

Measured memory_bytes: 361216
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;


double _x1,_x2,_x3,_x4,________y1,________y2,________y3,________y4;

bool solve()
{
	if(_x2 < _x3 || _x4 < _x1){
		return false;
	} else if(________y2 < ________y3 || ________y4 < ________y1){
		return false;
	}

	return true;
}

int main(){
	while(cin>>_x1>>________y1>>_x2>>________y2>>_x3>>________y3>>_x4>>________y4){
		cout << (solve() ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
const int N = 5e5 + 10;
const int MOD = 1e9;

int d[5];
int main(){
	int a, b,c;
	while(~scanf("%d %d %d", &a, &b, &c)){
		int k;
		scanf("%d", &k);
		memset(d, 0,sizeof(d));
		d[0] = a, d[1] = b, d[2] = c;
		sort(d,d + 3);
		ll x = d[2];
		for(int i = 1; i <= k; i++)
			x *= 2;
		ll sum = x + d[0] + d[1];
		printf("%d\n",sum);
	}
}

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

typedef long long int lli;

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

    if (N&1)
        cout << 0 << endl;
    else {
        int num = 1;
        lli count = 0;
        lli base = 5;
        while(1) {
     //       cout << "base=" << base << endl;
            
            lli level  = (N/base)/2;
   //         cout << "level=" << level << " num=" << num << endl;
            count += level ;
            
            if (base >= N)
                break;
            base *= 5;
            num++;
        }

        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
U = 3001

ans = 0
dp = np.zeros(U, dtype=np.int64)
dp[0] = 1

for a in A:
    newDP = np.copy(dp)
    newDP[a:] += dp[:-a]
    newDP[0] += 1
    newDP %= mod
    dp = newDP

    ans += dp[S]
    ans %= mod

print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;
    ll cnt = 0;
    ll sum = 0;
    ll min_abs = INT_MAX;

    for (int i = 0;i < N;i++){
        ll a; cin >> a;
        min_abs = min(abs(a),min_abs);
        sum += abs(a);
        if(a < 0) cnt++;
    }

    if(cnt%2 == 0) cout << sum << endl;
    else cout << sum - min_abs*2 << endl;

    return 0;

}

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

const int MOD = 1e9 + 7;
vector<long long> fact, fact_inv;

// x^n の高速べき乗計算 O(logn)
long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

// 前処理 O(n + logMOD) のアルゴリズム
// cmb の計算量は O(1)
// n が 10^7 程度で、nCr の呼び出しクエリ数が多いときに有効
long long cmb(int n, int r) {
    if (r < 0 || r > n) return 0;
    return (fact[n] * (fact_inv[r] * fact_inv[n - r] % MOD)) % MOD;
}

int main() {
    int S;  cin >> S;
    int N = 1e6;
    // fact, fact_inv の前処理
    fact.resize(N + 1);
    for (int i = 0; i <= N; ++i) {
        if (i == 0) fact[i] = 1;
        else fact[i] = fact[i - 1] * i % MOD;
    }
    fact_inv.resize(N + 1);
    for (int i = N; i >= 0; --i) {
        if (i == N) fact_inv[i] = pow_mod(fact[N], MOD - 2);
        else fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
    }

    long long ans = 0;
    int n = 1;
    while (true) {
        int r = S - 3 * n;
        if (r < 0) break;
        ans = (ans + cmb(n + r - 1, r)) % MOD;
        ++n;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18772
#include<iostream>
#include<string>
using namespace std;
int main(){
	int l,i;
	string str;
	getline(cin,str);
	l=str.length();
	for(i=0;i<l;i++){
		if(str[i]=='.'||str[i]==' '){
			cout<<str[i];
			continue;
		}
		str[i]-=32;
		cout<<str[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());
    int min = v[k - 1] - v[0];
    for (int i = k; i < n; ++i) {
        int tmp = v[i] - v[i - k + 1];
        if (tmp < min)
            min = tmp;
    }
    cout << min << '\n';
}


Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, B, C;
  std::cin >> A >> B >> C;
  std::cout << std::min(C, B / A) << std::endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;


bool canS(int[10][] a, int x, int y) {
	if(0 < x && x < 9 && 0 < y && y < 9) {
		for(int i = -1; i <= 1; i += 2) {
			if(a[x+i][y] == 0 || a[x][y+i] == 0)
				return false;
		}
		return true;
	}
	return false;
}
bool canM(int[10][] a, int x, int y) {
	if(0 < x && x < 9 && 0 < y && y < 9) {
		for(int i = -1; i <= 1; ++i){
			for(int j = -1; j <= 1; ++j) {
				if(a[x+i][y+j] == 0)
					return false;
			}
		}
		return true;
	}
	return false;
}
bool canL(int[10][] a, int x, int y){
	return canS(a, x-1, y) && canS(a, x, y-1) && canS(a, x+1, y) && canS(a, x, y+1);
}
int[][] S = [[0,1,0],[1,1,1],[0,1,0]];
int[][] M = [[1,1,1],[1,1,1],[1,1,1]];
int[][] L = [[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]];

void apply(int[10][] a, int[][] b, int x, int y) {
	auto x_ = b.length/2;
	auto y_ = b.length/2;
	for(int i; i < b.length; ++i) {
		for(int j; j < b.length; ++j){
			a[x+i-x_][y+j-y_] -= b[i][j];
		}
	}
}
void unapply(int[10][] a, int[][] b, int x, int y) {
	auto x_ = b.length/2;
	auto y_ = b.length/2;
	for(int i; i < b.length; ++i) {
		for(int j; j < b.length; ++j){
			a[x+i-x_][y+j-y_] += b[i][j];
		}
	}
}

string dfs(int n, int[10][] a, int x, int y, int m) {
	if(n == 0) {
		if(m == 0)
			return "";
		else
			return null;
	}
	if(m > n*13) {
		return null;
	}
	while(y < 10) {
		if(2 < y && a[x][y-3] > 0)
			return null;
		if(a[x][y] > 0){
			if(canL(a, x, y)) {
				apply(a, L, x, y);
				auto ret = dfs(n-1, a, x, y, m-13);
				if(ret !is null) {
					return ret ~ to!string(x) ~ " " ~ to!string(y) ~ " 3\n";
				}
				unapply(a, L, x, y);
			}
			if(canM(a, x, y)) {
				apply(a, M, x, y);
				auto ret = dfs(n-1, a, x, y, m-9);
				if(ret !is null) {
					return ret ~ to!string(x) ~ " " ~ to!string(y) ~ " 2\n";
				}
				unapply(a, M, x, y);
			}
			if(canS(a, x, y)) {
				apply(a, S, x, y);
				auto ret = dfs(n-1, a, x, y, m-5);
				if(ret !is null) {
					return ret ~ to!string(x) ~ " " ~ to!string(y) ~ " 1\n";
				}
				unapply(a, S, x, y);
			}
		}
		++x;
		if(x == 10) {
			x = 0;
			++y;
		}
	}
	return null;
}

void main() {
	auto n = to!int(readln().strip());
	int[10][10] a;
	int m;
	for(int i; i < 10; ++i){
		auto s = readln().strip().split();
		for(int j; j < 10; ++j){
			a[j][i] = to!int(s[j]);
			m += a[j][i];
		}
	}
	write(dfs(n, a, 0, 0, m));
}

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

int main(void){
    char s[100001];

    scanf("%s", &s);

    for(int i = 0; i < strlen(s); i = i + 2){
        printf("%c", s[i]);
    }
    printf("\n");

    return 0;

} 


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string c1, c2;
	cin >> c1 >> c2;
	if (c1[0] == c2[2] && c1[2] == c2[0] && c1[1] == c2[1])
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e15 + 7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  string s;
  cin >> s;

  int c = 0;
  rep(i,s.size()) if(s[i] == 'B') c++;

  ll ans = 0;
  rep(i,s.size()){
      if(s[i] == 'B') {
        ans += (s.size() - c) - i;
        c--;
      }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int by4 = 0, by2 = 0, odd = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if (a%4 == 0) by4++;
        else if (a%2 == 0) by2++;
        else odd++;
    }
    // cout << by4 << ' ' << by2 << ' ' << odd << endl;
    if (by2 >= 1) odd++;
    if (by4 + 1 < odd) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(N-1) << endl;
}

int main(){
  double R; cin >> R;
  cout << fixed << setprecision(7);
  cout << 3.1415926535798932384626 * 2 * R << endl;
}

Measured memory_bytes: 3788
#include<math.h>
#include<stdio.h>
#define PI 3.14159265358979323846264338327950L

int main(){
  double A,B,H,M;
  scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
  double thetaH,thetaM,ans2;
  thetaH = 2*PI/12*(H + M/60);
  thetaM = 2*PI/60*M;
  
  ans2 = A*A + B*B - 2*A*B*cos(thetaH - thetaM);
  printf("%.20lf",sqrt(ans2));
}


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

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            //空白ずつ取得
            string[] input = Console.ReadLine().Split(' ');
            //int number = int.Parse(Console.ReadLine());

            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int remainder;
            IList<int> remainderList = new List<int>();

            while(true)
            {
                remainder = n % k;
                remainderList.Add(remainder);

                if (n < k)
                {
                    break;
                }
                n = n / k;
            }

            int digits = remainderList.Count;
            

            Console.WriteLine(digits);

        }
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<long long,long long>> ba(n);

  for (int i = 0; i < n; i++)
  {
    long long a,b;
    cin >> a >> b;
    ba[i] = make_pair(b,a);
  }

  sort(ba.begin(),ba.end());

  int sum=0;
  for (int i = 0; i < n; i++)
  {
    sum+=ba[i].second;
    if(sum>ba[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn 5008
int dp[2][nn];
int n,mod;
int cnt[nn];
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	cin>>n>>mod;int k=(n+1)/2;
	
	for(int i=2;i<=n;i++){
		int nt=0;
		for(int j=1;j<=k;j++) if(j>=i) nt--;
		for(int j=n-k+2;j<=n;j++) if(j>=i) nt++;
		cnt[nt+1]++;
	}
	
	int now=0;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)if(cnt[i]){
		now^=1;memset(dp[now],0,sizeof dp[now]);
		for(int j=0;j<=n;j++){
			for(int k=0;k<=(n-j)/i;k++)
			if(cnt[i]==1) add(dp[now][j+k*i],dp[now^1][j]);
			else add(dp[now][j+k*i],dp[now^1][j]*(k+1));
		}
	}
	
	int ans=0;
	for(int i=0;i<=n;i++) add(ans,dp[now][i]*(n-i));
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int s1, s2, max, cnt;
	int i;
	
	
	while (1) {
		scanf("%d%d", &s1, &s2);
		if (s1 == 0 && s2 == 0)
			break;
		max = s1 + s2; cnt = 0;
		for (i = 1; i < 5; i++) {
			scanf("%d%d", &s1, &s2);
			if (max < s1 + s2) {
				max = s1 + s2; cnt = i;
			}
		}
		switch (cnt) {
			case 0: printf("A "); break;
			case 1: printf("B "); break;
       		case 2: printf("C "); break;
			case 3: printf("D "); break;
			case 4: printf("E "); break;
		}
		printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 600
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 1000006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
#define P 1000000007
int n , x;
int A[MAXN] , B[MAXN]; map<int,int> ok;
void solve() {
    rep( i , 1 , 5 ) scanf("%d",A + i);
    rep( i , 1 , 5 ) if( !A[i] ) printf("%d\n",i);
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  int k;
  cin>>k;
  string s;
  cin>>s;
  vector<int> sum;
  int now=0;
  rep(i,n){
    if(i==0) now++;
    else if(s[i-1]==s[i]) now++;
    else{
      sum.push_back(now);
      now=1;
    }
  }
  sum.push_back(now);
  now=0;
  int lo=0;
  int hi=0;
  if(s[0]=='0'){
    rep(i,2*k){
      now+=sum[i];
      hi++;
      if(hi==sum.size()){
        cout<<now<<endl;
        return 0;
      }
    }
  }
  if(s[0]=='1'){
    rep(i,2*k+1){
      now+=sum[i];
      hi++;
      if(hi==sum.size()){
        cout<<now<<endl;
        return 0;
      }
    }
  }
  
  int ans=now;
  
  if(s[0]=='0'){
    now-=sum[lo];
    lo++;
    now+=sum[hi];
    hi++;
    if(hi<sum.size()){
      now+=sum[hi];
      hi++;
    }
    ans=max(now,ans);
  }
  
  while(hi<sum.size()){
    now-=sum[lo];
    now-=sum[lo+1];
    lo+=2;
    now+=sum[hi];
    if(hi+1<sum.size()) now+=sum[hi+1];
    hi+=2;
    ans=max(now,ans);
  }
  
  cout<<ans<<endl;
           
}


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

using namespace std;

typedef long long ll;
using pii = pair<int, int>;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int n;
    int *a, *b, *c;
    cin >> n;
    a = new int[MAX];
    b = new int[MAX];
    c = new int[MAX];
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }

    ll (*dp)[MAX];
    dp = new ll[3][MAX];
    rep(i, 3){
        fill(dp[i], dp[i]+MAX, 0);
    }
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    rep2(i, 1, n){
        rep(j, 3){
            rep(k, 3){
                if(j==k)continue;
                ll add = 0;
                if(j==0){
                    add = a[i];
                }
                else if(j==1){
                    add = b[i];
                }
                else{
                    add = c[i];
                }
                dp[j][i] = max(dp[j][i], dp[k][i-1] + add);
            }
        }
    }
    
    ll mi = 0;
    rep(i, 3){
        mi = max(dp[i][n-1], mi);
    }
    cout << mi << endl;

    return 0;
}


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

int main(){
  string S;
  cin>>S;
  int a=0,b=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      a++;
    }else{
      b++;
    }
  }
  cout<<2*min(a,b)<<endl;
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main(){
	ll h, w, dp[1005][1005], g[1005][1005]={0};
	char gr[1005][1005];
	dp[1][1] = 1;
	cin >> h >> w;
	rep(i,0,h-1){
		cin >> gr[i];
		rep(j,0,w-1) if(gr[i][j] == '.') g[i+1][j+1] = 1;
	}
	rep(i,1,h){
		rep(j,1,w){
			if(i == 1 && j == 1) continue;
			if(g[i-1][j] + g[i][j-1] == 0) dp[i][j] = 0;
			else if(g[i-1][j] == 0) dp[i][j] = dp[i][j-1];
			else if(g[i][j-1] == 0) dp[i][j] = dp[i-1][j];
			else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
		}
	}
	cout << dp[h][w] << endl;
    return 0;
}

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

int main() {
  int S ;
  cin >> S ;
  int H , I , J ;
  H = S / 100 ;
  S = S % 100 ;
  I = S / 10 ;
  S = S % 10 ;
  J = S ;
  cout << H + I + J  << endl;
}


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

using namespace std;

const int maxn = 1e5+10;

int a[maxn],n,res;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    int mx=0;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        mx = max(mx,a[i]);
    }
    for (int i=1;i<=n;i++)
        if (a[i]!=mx && a[i]!=mx-1) {
            cout<<"No"<<endl;
            return 0;
        }
    int cnt =0;
    for (int i=1;i<=n;i++)
        if (a[i]==mx) cnt++;
    if (cnt==n && mx == n-1) {
        cout<<"Yes"<<endl;
        return 0;
    }
    if (n-cnt+1 <= mx && mx <= n-cnt+cnt/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

int main(){

	int num, limit;

	while(std::cin >> num >> limit){

		if(num == 0 && limit == 0) break;

		std::vector<int> price;
		int sum_price = 0;
		//input
		for(int i = 0; i < num; ++i){
			int buf;
			std::cin >> buf;
			sum_price += buf;
			price.push_back(buf);
		}
		//sort
		std::sort(price.begin(),price.end(),std::greater<int>());
		//discount
		int discount = 0;
		int in_bag = 0;
		
		for(auto itr = price.begin(); itr != price.end(); ++itr){
			++in_bag;
			if(in_bag == limit){
				discount += *itr;
				in_bag = 0;
			}
		}

		std::cout << sum_price - discount << std::endl;
	}
	return 0;
}
	

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

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;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int h,w;cin>>h>>w;
  int hh,ww;cin>>hh>>ww;
  int ans=h*w-(hh*w+ww*h)+hh*ww;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 125568
using System;

namespace AOJ.Volume0
{
    public class AppleAndPeach
    {
        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                int apple = input.IndexOf("apple");
                int peach = input.IndexOf("peach");
                while (apple >= 0 || peach >= 0)
                {
                    int start_pos = 0;
                    string fruit = "";
                    // 先に出現した方を変換
                    if (apple < 0)
                    {
                        // peach→apple
                        fruit = "apple";
                        start_pos = peach;
                    }
                    else if (peach < 0)
                    {
                        // apple→peach
                        fruit = "peach";
                        start_pos = apple;
                    }
                    else if (apple > peach)
                    {
                        // peach→apple
                        fruit = "apple";
                        start_pos = peach;
                    }
                    else if (peach > apple)
                    {
                        // apple→peach
                        fruit = "peach";
                        start_pos = apple;
                    }
                    string left = input.Substring(0, start_pos);
                    string right = input.Substring(start_pos + 5);
                    input = left + fruit + right;

                    start_pos += 5;
                    apple = input.IndexOf("apple", start_pos);
                    peach = input.IndexOf("peach", start_pos);
                }

                Console.WriteLine(input);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9652
#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,L,ans,ans1,ans2,a,b;cin>>N>>L;
    ans=2*L;
    ans1=ans+N-1;
    ans2=ans1*N/2;
    a=abs(L);
    b=abs(L+N-1);
    if(L<=0&&N+L>=1){cout<<ans2<<endl;}
    else if(a>=b){cout<<ans2-L-N+1<<endl;}
    else if(a<=b){cout<<ans2-L<<endl;}
    

}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  long long x,i=0,hash;
  x=getKey(str);
  while(1){
    hash=(h1(x)+i*(h2(x)))%M;
    i++;
    if(strcmp(H[hash],str)==0)
      return 1;
    else if(strlen(H[hash])==0)
      return 0;
  }
  return 0;
}

int insert(char str[]){
  long long x,i=0,hash; 
  x=getKey(str);
  while(1){
    hash=(h1(x)+i*(h2(x)))%M;
    i++;
    if(strcmp(H[hash],str)==0)
      return 1;
    else if(strlen(H[hash])==0){
      strcpy(H[hash],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15460
use std::io;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
  input!{
    s: i32,
    w: i32
  };
  
  if s <= w {
    println!("unsafe");
  }else{
    println!("safe");
  }
  
}


Measured memory_bytes: 2172
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", if a <= b { a } else { a - 1 });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

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

int main(){
  int h,w; cin >> h >> w;
  int a[10][10];
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      cin >> a[i][j];
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      for(int k = 0; k < 10; ++k)
	a[j][k] = min(a[j][k],a[j][i]+a[i][k]);
  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      int x;cin >> x;
      ans += max(0,a[x][1]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3552
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n, a, b; usize);
    let mut n = n;

    let c = a + b;
    let mut ans = 0;
    if c < n {
        ans += a * (n / c);
        n = n % c;
    }

    ans += if a < n {a} else {n};

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
lp = []
for i in range(3,int(n**0.5)+1):
  for k in lp:
    if i%2 == 0 or i%k == 0:
      break
  else:
    lp.append(i)

ans = 0
for i in (range(n)):
  li = []
  for k in lp:
    tmp = i+1
    cnt = 0
    while tmp%k == 0:
      tmp //= k
      cnt += 1
    if cnt > 0:
      li.append(cnt)
  if li in [[1,1,1], [1,3], [3,1], [7]]:
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a0=0,b0=0,c0=0;
    char a[100],b[100],c[100];
    char p,q;
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    p=a[a0];
    a0++;
    while(p!='\0'){
        q=p;
        if(p=='a'){
            p=a[a0];
            a0++;
        }
        else if(p=='b'){
            p=b[b0];
            b0++;
        }   
        else if(p=='c'){
            p=c[c0];
            c0++;
        } 
    }

    printf("%c\n",q-32);

    return 0;

    
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n, x, d; cin >> n >> x >> d;
	if(x == 0 && d == 0) {
		cout << 1 << endl;
		return;
	}
	if(d == 0) {
		cout << n + 1 << endl;
		return;
	}
	static map<int, vector<pair<int, int>>> mp;
	for(int k = 0; k <= n; ++k) {
		int a = x * k % d, b = x * k / d;
		int p = b + k * (k - 1) / 2, q = b + k * (2 * n - k - 1) / 2;
		if(p > q) swap(p, q);
		mp[a].push_back(make_pair(p, q + 1));
	}
	int ans = 0;
	for(auto& X: mp) {
		auto vec = X.sc;
		sort(all(vec));
		int l = vec[0].fr, r = vec[0].sc;
		for(auto& ra: vec) {
			int p = ra.fr, q = ra.sc;
			if(p <= r) {
				r = max(r, q);
			} else {
				ans += r - l;
				l = p, r = q;
			}
		}
		ans += r - l;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 22144
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int a, b, c;

int main()
{
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", min(a+b+1, c)+b);
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;

class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int[] d = new int[6];

		Dice dice=new Dice();//さいころ１

		Dice dice2=new Dice();//さいころ２

		String anther="No"

				;
		for (int i = 0; i < 6; i++) {
			d[i] = scanner.nextInt();
			dice.num[i]=d[i];//さいころ１に目を入れる
		}


		for (int i = 0; i < 6; i++) {
			d[i] = scanner.nextInt();
			dice2.num[i]=d[i];//さいころ２に目を入れる
		}


		for(int i =0; i<4;i++){
			dice.Roll("S");  //水平軸に一回転
			for(int k =0;k<4;k++){
				dice.Roll("W");  //垂直軸に一回転
				for(int p=0;p<4;p++){
					dice.Roll("R"); //縦軸に一回転
					if(Arrays.equals(dice.num,dice2.num)){
						anther="Yes";
					}
				}
			}

		}
		System.out.println(	anther);



		scanner.close();
	}
}


class Dice {

	int num [];
	Dice(){
		num= new int[6];
	}

	int box=0;



	public void Roll(String order) {


		switch(order){//配列の各数字をサイコロの展開図に見立て動きを再現

		case "S" :

			box=num[0];
			num[0]=num[4];
			num[4]=num[5];
			num[5]=num[1];
			num[1]=box;


			break;

		case "N" :

			box=num[0];
			num[0]=num[1];
			num[1]=num[5];
			num[5]=num[4];
			num[4]=box;


			break;

		case "W" :

			box=num[0];
			num[0]=num[2];
			num[2]=num[5];
			num[5]=num[3];
			num[3]=box;


			break;

		case "E":


			box=num[0];
			num[0]=num[3];
			num[3]=num[5];
			num[5]=num[2];
			num[2]=box;


			break;

		case "R"://サイコロを縦軸で回転させる
			box=num[1];
			num[1]=num[2];
			num[2]=num[4];
			num[4]=num[3];
			num[3]=box;



		}


	}




}






Measured memory_bytes: 26300
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        int x = Integer.parseInt(scanner.next());
        int y = Integer.parseInt(scanner.next());

        Integer[] syukudai = new Integer[y];
        for(int i =0; i < y; i++) {
            syukudai[i] = Integer.parseInt(scanner.next());
        }

        int sum = Stream.of(syukudai).mapToInt(Integer::intValue).sum();
        if (x >= sum) {
            System.out.println(x - sum);
        } else {
            System.out.println(-1);
        }

    }
}

Measured memory_bytes: 38736
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		mut cs: Chars,
	}

	cs.sort();
	let s: String = cs.into_iter().collect();

	if s == "abc" {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a;
  cin >> a;
  for(int i=0; i<a.length(); i++){
    string b = a.substr(i,1);
    if(i%2==0){
      if(b=="L"){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(b=="R"){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
        
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};



int main(void){
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[[] for i in range (n)]
for i in range (n):
    a[i]=list(map(int,input().split()))

co=0
for i in range (n):
    x=0
    for j in range (m):
        x+=(a[i][j]*b[j])
    if(x+c>0):
        co+=1

print(co)

Measured memory_bytes: 3064
n = int(input())
csf = []
for i in range(n-1):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time <= csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = -time%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll n=max(a*c,max(b*d,max(a*d,b*c)));
  cout << n;
}

Measured memory_bytes: 3600
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val sn = (1 to n).map { i =>
    val Array(s, n) = scala.io.StdIn.readLine.split(" ")
    (s, n, i)
  }

  val ans = sn.sortWith {
    (a, b) =>
      if (a._1 != b._1) {
        a._1 < b._1
      } else {
        a._2.toInt > b._2.toInt
      }
  }

  ans.foreach(i => println(i._3))
}


Measured memory_bytes: 25388
#include<bits/stdc++.h>
using namespace std;
int dp[3030][3030];
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    //int dp[n][m];
    memset(dp,0,sizeof(dp));
    //if(s[0]==t[0])
    //dp[0][0]=1;
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++){
            if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[n][m]<<endl;
    string ans;
    int i=n,j=m;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
        ans.push_back(s[i-1]);
        i--;
        j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else j--;
    }
    //cout<<ans;
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 39500
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  const int ms = 2e5+5;
  int n; cin>>n;
  ll dp[ms][2], v[ms], ans;
  FORN(i,0,n) cin>>v[i];
  if(n & 1){
    dp[0][1] = v[0];
    dp[1][0] = v[1];
    dp[2][0] = v[2];
    dp[2][1] = v[0] + v[2];
    FORN(i,3,n){
      if(i & 1) dp[i][0] = max(dp[i-2][0], dp[i-3][1]) + v[i];
      else{
	dp[i][0] = max(dp[i-2][0], max(dp[i-3][0], dp[i-4][1])) + v[i];
	dp[i][1] = dp[i-2][1] + v[i];
      }
    }
    ans = max(dp[n-1][0], max(dp[n-2][0], dp[n-3][1]));
  }
  else{
    dp[0][0] = v[0];
    dp[1][0] = v[1];
    FORN(i,0,n){
      if(i & 1) dp[i][0] = max(dp[i-2][0], dp[i-3][0]) + v[i];
      else dp[i][0] = dp[i-2][0] + v[i];
    }
    ans = max(dp[n-1][0], dp[n-2][0]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7832
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)

def lcm(m, n):
	return m * n // gcd(m, n)

n = ni()
a = na()

l = a[0]
for i in range(n):
	l = lcm(l, a[i])

l -= 1
ans = 0
for i in range(n):
	ans += l % a[i]

print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>

int
main(int artc, char *argv[])
{
  char s[101];
  scanf("%s", s);
  int n = strlen(s);

  int i = 0;
  char t[] = "keyence"; int cnt; int flag = 0;
  for(int j = 0; j < 7; j++){
    cnt = 0;
    for(int k = 0; k <= j; k++){
      if(s[k] == t[k]) cnt++;
    }
    for(int k = j + 1; k < 7; k++){
      if(s[n - 7 + k] == t[k]) cnt++;
    }
    if(cnt == 7){
      flag++;
      break;
    }
  }

  if(flag > 0) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 128