akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int A, B;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> A >> B;
	int ans = max(A+B, A-B);
	ans = max(ans, A*B);
	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	int n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	ll ans = 4e18;
	ll sum = 0, now = 0;
	rep(i, n) {
		if (i % 2) {
			if (sum + a[i] <= 0) {
				now += 1 - (sum + a[i]);
				sum = 1;
			} else {
				sum += a[i];
			}
		} else {
			if (sum + a[i] >= 0) {
				now += sum + a[i] + 1;
				sum = -1;
			} else {
				sum += a[i];
			}
		}
	}
	ans = min(ans, now);
	sum = 0, now = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			if (sum + a[i] <= 0) {
				now += 1 - (sum + a[i]);
				sum = 1;
			} else {
				sum += a[i];
			}
		} else {
			if (sum + a[i] >= 0) {
				now += sum + a[i] + 1;
				sum = -1;
			} else {
				sum += a[i];
			}
		}
	}
	ans = min(ans, now);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] anum = new int[n];
        for(int i=0; i<n; i++){
            anum[sc.nextInt() - 1]++;
        }
        sc.close();

        int ans = 0;
        Arrays.sort(anum);
        for(int i=0; i<n; i++){
            if(k > 0){
                k--;
            }else{
                ans += anum[n-i-1];
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 87300
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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

int N;
int a[110000];
int b[110000]; 
ll int ans;

int main () {
  cin >> N;

  Rep(i, N+1) cin >> a[i];
  Rep(i, N) cin >> b[i];

  ans = 0;

  Rep(i, N) {
    if (a[i] >= b[i]) {
      ans += b[i];
    } else {
      int diff = b[i] - a[i];
      
      if (diff > a[i+1]) {
        ans += a[i] + a[i+1];
        a[i+1] = 0;
      } else {
        ans += a[i] + diff;
        a[i+1] -= diff;
      }
    }
  }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

bool check(int ans, std::vector<int>::iterator iter, std::vector<int>::iterator enditer) {
    if (ans == 0) {
        return true;
    } else if (ans < 0) {
        return false;
    }
   
    if (iter == enditer) {
        return false;
    }
    
    bool result = check(ans, std::next(iter, 1), enditer) || check(ans-=(*iter), std::next(iter, 1), enditer);
    return result;
}

int main() {
    int N, Q, temp;
    std::vector<int> A;
    std::cin >> N;
    
    for (int i=0; i<N; i++) {
        std::cin >> temp;
        A.push_back(temp); 
    }
    
    std::cin >> Q;
    
    auto b = A.begin();
    auto e = A.end();
    
    for (int i=0; i<Q; i++) {
        std::cin >> temp;
        if (check(temp, b, e)) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

const int maxN = 200005;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int MOD = 2019;

class TaskD {
private:
	Debugger debugger;
	int n;
	string s;

	long long solve(int pos, int m){
		long long ans = m == 0;
		if(pos + 1 < n){
			ans += solve(pos+1,(m*10 + s[pos+1] - '0') % MOD);
		}
		return ans;
	}

public:
	void solveOne(int it){
		cin >> s;
		n = s.size();
		long long ans = 0;
		for(int pos = 0; pos < n; pos++){
			ans += solve(pos, s[pos] - '0');
		}
		vector<vector<long long>> dp(2, vector<long long>(MOD, 0));
		ans = 0;
		int current = 0, nxt = 1;
		for(int pos = 0; pos < n; pos++, swap(current, nxt)){
			dp[current][s[pos] - '0']++;
			for(int m = 0; m < MOD; m++){
				if(pos + 1 < n){
					dp[nxt][(m*10 + s[pos+1] - '0') % MOD] += dp[current][m];
				}
			}
			ans += dp[current][0];
			for(int m = 0; m < MOD; m++){
				dp[current][m] = 0;
			}
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	TaskD solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3764
import sys
from functools import lru_cache

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

def solve(N, A, B, C, D):
    INF = 10**18

    @lru_cache(None)
    def f(N):
        if N == 0:
            return 0
        if N == 1:
            return D
        ret = D * N
        q, r = divmod(N, 2)
        if r == 0:
            ret = min(ret, f(q) + A)
        else:
            ret = min(ret, f(q) + A + D, f(q + 1) + A + D)
        q, r = divmod(N, 3)
        if r == 0:
            ret = min(ret, f(q) + B)
        elif r == 1:
            ret = min(ret, f(q) + B + D)
        else:
            ret = min(ret, f(q + 1) + B + D)
        q, r = divmod(N, 5)
        if r == 0:
            ret = min(ret, f(q) + C)
        elif r == 1:
            ret = min(ret, f(q) + C + D)
        elif r == 2:
            ret = min(ret, f(q) + C + D + D)
        elif r == 3:
            ret = min(ret, f(q + 1) + C + D + D)
        else:
            ret = min(ret, f(q + 1) + C + D)
        return ret

    return f(N)

T = int(readline())
for _ in range(T):
    n, a, b, c, d = map(int, readline().split())
    print(solve(n, a, b, c, d))

Measured memory_bytes: 20320
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  int a[100005],b[100005],c[100005];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  
  ll ans = 0;
  for(int i=0;i<n;i++){
    ll numa = lower_bound(a,a+n,b[i]) - a;
    ll numc = c+n - upper_bound(c,c+n,b[i]);
    ans += numa * numc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	string p="";
	for (int i = 0; i < n; i++){
		p +=s[i];
		p +=t[i];
	}
	cout<<p<<endl;

}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){

	int card[4][14],n,i,j,d;
	char c;	
	scanf("%d",&n);
	
	for(i=0; i<4; i++){
		for(j=1; j<14; j++){
			card[i][j]=0;
		}
	}
	for(i=0; i<n; i++){
		scanf(" %c %d",&c,&d);
		if(c=='S') card[0][d]=1;
		else if(c=='H') card[1][d]=1;
		else if(c=='C') card[2][d]=1;
		else if(c=='D') card[3][d]=1;
	}
	for(i=0; i<4; i++){
		for(j=1; j<14; j++){
			if(card[i][j]==0){
				if(i==0) printf("S");
				else if(i==1) printf("H");
				else if(i==2) printf("C");
				else if(i==3) printf("D");
			
			printf(" ");
			printf("%d\n",j);
			}
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, d;
vl x, y;
/******* define variable end *******/
int solve() {
	cin >> n >> d;
	x.resize(n);
	y.resize(n);
	ll ans = 0;
	REP(i, n){
		cin >> x[i] >> y[i];
		if((ll)pow(x[i], 2) + (ll)pow(y[i], 2) <= (ll)pow(d, 2)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

int solve(vector<vector<int> > map, int x, int y, int walk) {
	int tmp = 1;
	int flag = 0;
	if (map[x - 1][y]) {
		map[x - 1][y] = 0;
		int result = solve(map, x - 1, y, walk + 1);
		if (tmp < result) tmp = result;
		map[x - 1][y] = 1;
		flag++;
	}
	if (map[x + 1][y]) {
		map[x + 1][y] = 0;
		int result = solve(map, x + 1, y, walk + 1);
		if (tmp < result) tmp = result;
		map[x + 1][y] = 1;
		flag++;
	}
	if (map[x][y + 1]) {
		map[x][y + 1] = 0;
		int result = solve(map, x, y + 1, walk + 1);
		if (tmp < result) tmp = result;
		map[x][y + 1] = 1;
		flag++;
	}
	if (map[x][y - 1]) {
		map[x][y - 1] = 0;
		int result = solve(map, x, y - 1, walk + 1);
		if (tmp < result) tmp = result;
		map[x][y - 1] = 1;
		flag++;
	}
	if (!flag)return walk;
	return tmp;
}

int main() {
	while (1) {
		int m, n;
		cin >> m >> n;
		if (m == 0 && n == 0)break;
		vector<vector<int> > map(m + 2, vector<int>(n + 2, 0));
		for (int i = 0; i < m; i++)for (int j = 0; j < n; j++) cin >> map[i + 1][j + 1];

		int max = 0;
		for (int i = 0; i < m; i++)for (int j = 0; j < n; j++) {
			if (map[i + 1][j + 1] == 0)continue;
			map[i + 1][j + 1] = 0;
			int result = solve(map, i + 1, j + 1, 1);
			if (max < result)max = result;
			map[i + 1][j + 1] = 1;
		}

		cout << max << endl;
	}
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <cmath>
#include <cstdlib>
#include <sstream>

#include <boost/range/irange.hpp>
using boost::irange;

using namespace std;

constexpr int64_t digit(int64_t x)
{
    return x < 10 ? 1 : 1 + digit(x/10);
}

constexpr int64_t f(int64_t a, int64_t b)
{
    return max(digit(a), digit(b));
}

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

    int64_t n;
    cin >> n;
    
    auto answer = numeric_limits<int64_t>::max();
    
    for( const auto a : irange<int64_t>(1, sqrt(n)+1) )
    {
        const auto d = div(n, a);
        if(d.rem != 0) continue;
        const int64_t& b = d.quot;
        answer = min(answer, f(a, b));
    }
    
    cout << answer << '\n';

    return 0;
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'A') {
    cout << 'T';
  } else if(c == 'T') {
    cout << 'A';
  } else if(c == 'C') {
    cout << 'G';
  } else if(c == 'G') {
    cout << 'C';
  }
  cout << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int A,B;
	cin >> A >>B;
	A += B;
	if (A >= 24){
		A -= 24;
	}
	cout << A <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n,x,cont=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x%2&&i%2){
            cont++;
        }
    }
    cout<<cont<<endl;

    return 0;

}

Measured memory_bytes: 3608
N,K = map(int, input().split())
R,S,P = map(int, input().split())
a = input()

a1 = a.replace("r","P")
a1 = a1.replace("p","S")
a1 = a1.replace("s","R")
  
for j, i in enumerate(a1):
  if j < K:
    pass
  else:
    if i == a1[j-K]:
      a1 = a1[:j] + "n" + a1[j+1:]
    else:
      pass
    
point1 = a1.count("P") * P
point2 = a1.count("R") * R
point3 = a1.count("S") * S

ans =  point1 + point2 + point3

print(ans)

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

bool f(const string& S, const vector<pair<char, int> >& td, int index){
    if(index == -1){
        return true;
    }
    if(index >= S.size()){
        return false;
    }
    for(const auto&a: td){
        char t,d; tie(t,d) = a;
        if(t == S[index]){
            index += d;
            if(index < 0){
                return true;
            }
            if(index >= S.size()){
                return false;
            }
        }
    }
    return false;
}

int solve(string S, vector<pair<char, int> > td){
    int ok = -1;
    int ng = S.size();
    while(abs(ok-ng) > 1){
        int mid = (ok+ng)/2;
        if(f(S, td, mid)) {
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return ok+1;
}

int main(void){
    int N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<pair<char, int> > td(Q);
    for(auto &a:td){
        char t; char d; cin >> t >> d;
        a.first = t;
        a.second = (d == 'L' ? -1 : 1);
    }
    int left = solve(S, td);
    reverse(S.begin(), S.end());
    for(auto &a:td){
        a.second *= -1;
    }
    int right = solve(S, td);
    cout << max((int(S.size()) - left - right), 0) << endl;
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    map<ll, ll> M;

    REP(i, N){
        ll a;
        cin >> a;
        M[a]++;
    }

    ll ans = 0;

    for(auto iter=M.begin(); iter!=M.end(); iter++){
        if(iter->first < iter->second){
            ans += iter->second - iter->first;
        }
        if(iter->first > iter->second){
            ans += iter->second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6272
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<pair<int, int>>v;
	for (int i = 2; i <= N; i++) {
		v.push_back({ 1,i });
	}
	M = (N - 2)*(N - 1) / 2;
	for (int i = 2; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (M > K) {
				v.push_back({ i,j });
				M--;
			}
		}
	}
	if (M != K) {
		cout << -1 << endl;
		return 0;
	}
	cout << v.size() << endl;
	for (auto i : v) {
		cout << i.first << " " << i.second << endl;
	}
}

Measured memory_bytes: 384
n, m = map(int, input().split(' '))
A = []
i = 0
while i < n:
    a = list(map(int, input().split(' ')))
    A.append(a)
    i += 1
x = []
j = 0
while j < m:
    x.append(int(input()))
    j += 1
ans = ''
p = 0
while p < n:
    q = 0
    a0 = 0
    while q < m:
        a0 += A[p][q] * x[q]
        q += 1
    ans += str(int(a0)) + '\n'
    p += 1
print(ans[:-1])


Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, int>;
const int MAXN = 100005;

void my_ass(bool p){
	if(!p){
		puts("-1");
		exit(0);
	}
}

int n, leaf_size[MAXN];
pi a[MAXN];
vector<int> gph[MAXN];

lint get_dist(int x, int d){
	lint ret = d;
	for(auto &i : gph[x]) ret += get_dist(i, d + 1);
	return ret;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld",&a[i].first);
		a[i].second = i;
	}
	sort(a + 1, a + n + 1);
	fill(leaf_size + 1, leaf_size + n + 1, 1);
	for(int i=n; i>1; i--){
		lint nxt = a[i].first - n + 2 * leaf_size[i];
		int pos = lower_bound(a + 1, a + n + 1, pi(nxt, -1)) - a;
		if(a[pos].first == nxt && pos < i){
			gph[pos].push_back(i);
			leaf_size[pos] += leaf_size[i];
		}
		else my_ass(0);
	}
	my_ass(get_dist(1, 0) == a[1].first);
	for(int i=1; i<=n; i++){
		for(auto &j : gph[i]){
			if(i < j) printf("%d %d\n", a[i].second, a[j].second);
		}
	}
}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++) cin >> a[i];
  int ans=IINF,tmp=0;
  for(int i=0;i<5;i++){
    tmp=0;
    for(int j=0;j<5;j++){
      if(i!=j) tmp+=(a[j]+9)/10*10;
    }
    tmp+=a[i];
    ans=min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static char[] assign;
	public static char[] ans;
	public static int n;

	public static boolean check() {

		int i = n - 1;
		for(int cnt = 0; cnt < 3; cnt++) {
			i %= n;
			int next = (i + 1) % n;
			int back = (i + n - 1) % n;

			if(assign[i] == 'o' && ans[i] == 'S') {
				if(ans[back] == 'S' && ans[next] == 'W') {
					return false;
				}else if(ans[back] == 'W' && ans[next] == 'S') {
					return false;
				}
			}
			else if(assign[i] == 'o' && ans[i] == 'W') {
				if(ans[back] == 'S' && ans[next] == 'S') {
					return false;
				}else if(ans[back] == 'W' && ans[next] == 'W') {
					return false;
				}
			}
			else if(assign[i] == 'x' && ans[i] == 'S') {
				if(ans[back] == 'S' && ans[next] == 'S') {
					return false;
				}else if(ans[back] == 'W' && ans[next] == 'W') {
					return false;
				}
			}
			else if(assign[i] == 'x' && ans[i] == 'W') {
				if(ans[back] == 'S' && ans[next] == 'W') {
					return false;
				}else if(ans[back] == 'W' && ans[next] == 'S') {
					return false;
				}
			}

			i++;
		}

		return true;
	}

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

		n = sc.nextInt();
		assign = sc.next().toCharArray();

		for(int cnt = 0; cnt < 4; cnt++) {
			ans = new char[n];

			if(cnt == 0) {
				ans[0] = 'S';
				ans[1] = 'S';
			}
			else if(cnt == 1) {
				ans[0] = 'S';
				ans[1] = 'W';
			}
			else if(cnt == 2) {
				ans[0] = 'W';
				ans[1] = 'S';
			}
			else if (cnt == 3) {
				ans[0] = 'W';
				ans[1] = 'W';
			}

			// i番目はi-1番目とi-2番目によって定まる(i >= 1)
			for (int i = 1; i < n; i++) {

				int next = (i + 1) % n;
				int back = (i + n - 1) % n;

				if(assign[i] == 'o') {
					if(ans[i] == 'S') {
						if(ans[back] == 'S') {
							ans[next] = 'S';
						}
						else if(ans[back] == 'W') {
							ans[next] = 'W';
						}
					}
					else if(ans[i] == 'W') {
						if(ans[back] == 'S') {
							ans[next] = 'W';
						}
						else if(ans[back] == 'W') {
							ans[next] = 'S';
						}
					}
				}
				else if(assign[i] == 'x') {
					if(ans[i] == 'S') {
						if(ans[back] == 'S') {
							ans[next] = 'W';
						}
						else if(ans[back] == 'W') {
							ans[next] = 'S';
						}
					}
					else if(ans[i] == 'W') {
						if(ans[back] == 'S') {
							ans[next] = 'S';
						}
						else if(ans[back] == 'W') {
							ans[next] = 'W';
						}
					}
				}
			}

			if(check()) {
				String str = String.valueOf(ans);
				System.out.println(str);
				return;
			}
		}
		System.out.println(-1);
	}
}


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

const ll INF = 1LL << 60;

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

ll N; 
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    vector<ll> left_gcd(N), right_gcd(N);
    left_gcd[0] = A[0];
    right_gcd[N - 1] = A[N - 1];

    for (int i = 1; i < N; i++) {
        left_gcd[i] = gcd(left_gcd[i - 1], A[i]);
    }
    // rep(i, N) {
    //     cout << left_gcd[i] << " ";
    // }
    // cout << endl;
    for (int i = N - 2; i >= 0; i--) {
        right_gcd[i] = gcd(right_gcd[i + 1], A[i]);
    }
    // rep(i, N) {
    //     cout << right_gcd[i] << " ";
    // }
    ll ans = 0;
    rep(i, N) {
        if (i == 0) {
            ans = max(ans, right_gcd[i + 1]);
        } else if (i == N - 1) {
            ans = max(ans, left_gcd[i - 1]);
        } else {
            ll tmp = gcd(left_gcd[i - 1], right_gcd[i + 1]);
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int height[maxn];
ll beauty[maxn], seg[4 * maxn], dp[maxn];
ll query(int index, int left, int right, int tar) {
    if (left > tar)
        return 0;
    if (right <= tar)
        return seg[index];
    int mid = (left + right) / 2;
    return max(query(2 * index, left, mid, tar), query(2 * index + 1, mid + 1, right, tar));
}
void update(int index, int left, int right, int pos, ll val) {
    if (left == right) {
        seg[index] = max(seg[index], val);
        return;
    }
    int mid
     = (left + right) / 2;
    if (pos <= mid)
        update(2 * index, left, mid, pos, val);
    else
        update(2 * index + 1, mid + 1, right, pos, val);
    seg[index] = max(seg[2 * index], seg[2 * index + 1]);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> height[i];
    for (int i = 0; i < n; ++i)
        cin >> beauty[i];
    for (int i = 0; i < n; ++i) {
        dp[i] = query(1, 0, n, height[i] - 1) + beauty[i];
        update(1, 0, n, height[i], dp[i]);
    }
    cout << *max_element(dp, dp + n) << '\n';
}

Measured memory_bytes: 10368
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    List<Integer> a = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      a.add(sc.nextInt());
    }
    a.add(a.get(0) + k);
    int max_Length = 0;
    for(int j = 0; j < n; j++){
      int temp = a.get(j+1) - a.get(j);
      if(temp > max_Length){
        max_Length = temp;
      }
    }
    int ans = k - max_Length;
    System.out.println(ans);
  }
}

Measured memory_bytes: 84612
# -*- coding: utf-8 -*-

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G


if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i])




Measured memory_bytes: 45532
#include <iostream>
#include <complex>
using namespace std;
int main(void){
    int x1,x2,y1,y2;
    complex<double> a, b, c, d,change,i;
    cin >> x1 >> y1 >> x2 >> y2;
    a = complex<double>(x1,y1);
    b = complex<double>(x2,y2);
    i = complex<double>(0,1);
    change = b-a;
    change = change*i;
    c = change + b;
    change = change*i;
    d = change+c;
    cout << c.real() << " " << c.imag()<<" " << d.real() << " "  << d.imag() << endl;
}

Measured memory_bytes: 256
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

def get_bits(num)
  res = []
  (2**num).times{|i|
    res << i.to_s(2).rjust(num, "0")
  }
  return res
end

def naive(s, x, y)
  rui = s.count("T")
  bits =  get_bits(rui)
  dir = [1, 0, -1, 0]
  bits.each{|bit|
    vec = 0
    t_pos = 0
    pos = [0,0]
    s.each_char{|c|
      if c == "F"
        pos[0] += dir[vec]
        pos[1] += dir[vec^1]
      else
        if bit[t_pos] == "0"
          vec += 1
        else
          vec -= 1
        end
        if vec == 4 || vec == -5
          vec = 0
        end
        t_pos += 1
      end
    }
    p pos

    if pos[0] == x && pos[1] == y
      # puts "Yes"
      #  exit
    end
  }
  puts "No"
end

def check(moves, target)
  len = moves.length
  if len == 0
    return target == 0
  end
  dp = Array.new(len){Hash.new()}
  dp[0][moves[0]] = true
  dp[0][-moves[0]] = true
  (1...len).each do |i|
    dp[i - 1].each do |key, _|
      dp[i][key+moves[i]] = true
      dp[i][key-moves[i]] = true
    end
  end
  return dp[len - 1][target]
end


s = s()
x, y = li()
t_cnt = s.count("T")

moveCount = [Array.new(t_cnt/2+1, 0),Array.new(t_cnt/2+1, 0)]

currentVec = 0
j = 0
s.each_char{|c|
  if c=="F"
    moveCount[currentVec][j] += 1
  else
    if currentVec == 1
      j+=1
    end
    currentVec ^= 1
  end
}

if t_cnt == s.length
  if x==0 && y==0
    puts  "Yes"
  else
    puts "No"
  end
  exit
end

offset = moveCount[0].shift

if check(moveCount[0], x-offset)&&check(moveCount[1], y)
  puts "Yes"
else
  puts "No"
end





Measured memory_bytes: 266492
module Main where

import           Data.List
import           Control.Monad

main :: IO ()
main = do
    [h, w] <- (map read . words) <$> getLine :: IO [Int]
    list   <- map (map read . words) <$> (replicateM h) getLine :: IO [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (concatMap fst) res1
    let res2    = (goRight . map last) list2
    let result2 = fst res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight list@[_         ] = ([], list)
goRight (     a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in (fst res, a : (snd res))
    else
        let res = goRight (mapSnd (+ 1) b : xs)
        in  ((fst a, fst b) : (fst res), mapSnd (subtract 1) a : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d list =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)
        list

mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst f = mapTuple f id
mapSnd f = mapTuple id f


Measured memory_bytes: 84476
from itertools import accumulate as ac

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

l = []
c = 0

if N==1:
    l.append(S[0])
else:
    for i in range(N-1):
        c += 1
        if S[i]!=S[i+1]:
            l.append(c)
            c = 0
    if c:
        l.append(c+1)

if S[0]==0:
    l = [0]+l
if S[-1]==0:
    l.append(0)

size = len(l)
*a, = ac([0]+l)
group_size = min(2*K+1,size)

ans = 0
for i in range(group_size, size+1, 2):
    ans = max(ans, a[i]-a[i-group_size])
print(ans)

Measured memory_bytes: 10000
using System;
using System.Collections.Generic;
using System.Linq;
namespace aizu
{
    class OnlineJudge
    {
        static Dictionary<string, int> paper = new Dictionary<string, int>(200);
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null){
                Drop(input.Split(',').Select(d => int.Parse(d)).ToArray());
            }
            int[] item = (from q in paper select q.Value).ToArray();
            Console.WriteLine(100 - item.Count());
            Console.WriteLine(item.Max());
        }
        static void Drop(int[] input)
        {
            switch(input[2]) {
                case 3:
                    PaperInc(input[0] - 2, input[1]);
                    PaperInc(input[0] + 2, input[1]);
                    PaperInc(input[0], input[1] - 2);
                    PaperInc(input[0], input[1] + 2);
                    goto case 2;
                case 2:
                    PaperInc(input[0] - 1, input[1] + 1);
                    PaperInc(input[0] - 1, input[1] - 1);
                    PaperInc(input[0] + 1, input[1] + 1);
                    PaperInc(input[0] + 1, input[1] - 1);
                    goto case 1;
                case 1:
                    PaperInc(input[0] - 1, input[1]);
                    PaperInc(input[0] + 1, input[1]);
                    PaperInc(input[0], input[1] - 1);
                    PaperInc(input[0], input[1] + 1);
                    PaperInc(input[0], input[1]);
                    break;
            }
        }
        static void PaperInc(int x, int y)
        {
            if(x >= 0 && x < 10 && y >= 0 && y < 10) {
                string point = x + " " + y;
                if(!paper.ContainsKey(point)){
                    paper.Add(point, 0);
                }
                ++paper[point];
            }
        }
    }
}

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

int main(){
	set<string> st;
	int n;
	cin>>n;
	string a;
	rep(i,n){
		cin>>a;
		st.insert(a);
	}

	cout<<st.size()<<endl;
}

Measured memory_bytes: 19252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

const ll mod=1000000007;

int main() {
    int N,K;
    cin>>N>>K;
    vi x(N);
    rep(i,N) cin>>x[i];
    int ans=0;
    rep(i,N) {
        ans+=min(x[i]*2,(K-x[i])*2);
    }
    cout<<ans<<endl;
}

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

using ll = long long;

int main() {
    ll N, Q;  cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    for (ll i = 0; i < N; ++i) {
        ll a;  cin >> a;
        fw.add(i, a);
    }

    for (ll _ = 0; _ < Q; ++_) {
        ll q;  cin >> q;
        if (q == 0) {
            ll p, x;  cin >> p >> x;
            fw.add(p, x);
        }
        else if (q == 1) {
            ll l, r;  cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
}


Measured memory_bytes: 8204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	string C;
	cin >> N >> C;
	vector<int> a(N+1), b(N+1);
	for (int i = 0; i < N; ++ i) {
		a[i+1] = a[i];
		b[i+1] = b[i];
		if (C[i] == 'R') ++ a[i+1]; else ++ b[i+1];
	}
	int r = 1LL<<30;
	for (int i = 0; i <= N; ++ i) {
		r = min(r, max(b[i], a[N]-a[i]));
	}
	cout << r << endl;
}


Measured memory_bytes: 5240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, q;
    cin >> n;
    map<int, ll> m;
    ll sum = 0;
    rep(i, n){
        int ai;
        cin >> ai;
        m[ai]++;
        sum += ai;
    }
    cin >> q;
    vector<ll> ans(q);
    rep(i, q){
        int bi, ci;
        cin >> bi >> ci;
        sum -= bi * m[bi];
        sum += ci * m[bi];
        m[ci] += m[bi];
        m[bi] = 0;
        ans[i] = sum;
    }
    rep(i,q){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

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

int main()
{
	int N;
	int M;
	int L;
	int A[100000];
	int ans = 0;
	int flag = 0;


	scanf("%d%d",&N,&M);

	if(N%M!=0)
		printf("%d\n",1+(N/M));
	else
		printf("%d\n", (N / M));

	/*
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}*/

}
		

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

using namespace std;

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

    switch (s[0])
    {
        case 'A':
            cout << "T" << endl;
            break;
        case 'T':
            cout << "A" << endl;
            break;
        case 'C':
            cout << "G" << endl;
            break;
        case 'G':
            cout << "C" << endl;
            break;
        default:
            break;
    }

    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

string str;
int n;
ll ans;
map<string,ll> mp;

char A[31];

void dfs2(int a,int b){
	if(a + b == n){
		ans += mp[A];
		return;
	}
	int now = a + b;
	A[a] = str[2*n-now-1];
	dfs2(a+1,b);
	A[a] = '-';
	A[30-b] = str[2*n-now-1];
	dfs2(a,b+1);
	A[30-b] = '-';
}

void dfs(int a,int b){
	if(a + b == n){
		mp[A]++;
		return;
	}
	int now = a + b;
	A[a] = str[now];
	dfs(a+1,b);
	A[a] = '-';
	A[30-b] = str[now];
	dfs(a,b+1);
	A[30-b] = '-';
}


int main(){
	cin >> n >> str;
	REP(i,31)A[i] = '-';
	dfs(0,0);
	DBG(cout << "!!!" << endl;)
	REP(i,31)A[i] = '-';
	dfs2(0,0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <double> a(n);
    for (auto &i : a) {
        cin >> i;
        i = (i + 1) / 2.0;
    }
    double sum = 0, ans = 0;
    for (int i = 0; i < k; i++) {
        sum += a[i];
    }
    ans = sum;
    for (int i = k; i < n; i++) {
        sum -= a[i - k];
        sum += a[i];
        umax(ans, sum);
    }
    cout << fixed;
    cout.precision(10);
    cout << ans << '\n';
}


Measured memory_bytes: 4760
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

int main(){
    int ans;
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]){
            ans++;
        }
    }

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


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

int main(){
	int i,j,k,dis;
	char str[81],tmp[81];

	while(gets(str)){
		i = 0;
		while(str[i] != '\0'){
			dis = 't'-str[i];
			j = i;
			tmp[0] = '\0';
			while(isalpha(str[j])){
				tmp[j-i] = (str[j]-'a'+dis)%26+'a';
				j++;
				tmp[j-i] = '\0';
			}
			if(!strcmp(tmp,"the") || !strcmp(tmp,"this") || !strcmp(tmp,"that")){
				for(k = 0;str[k] != '\0';k++){
					if(isalpha(str[k])){
						str[k] = (str[k]-'a'+dis)%26+'a';
					}
					printf("%c",str[k]);
				}
				printf("\n");
				break;
			}
			i = j+1;
		}
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll ans = 0;
    ll n,k;
    cin >> n >> k;
    while(n){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    int N; cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++)
        cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            for(int k = j+1; k < N; k++) {
                if(L[k] >= L[i]+L[j])
                    break;
                ans++;
            }
        }
    }

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


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_, bs =
    List.partition (( <= ) 3200) @@
    Array.to_list @@
    Array.init n @@ fun _ ->
      Scanf.scanf "%d " @@ fun a -> a in
  let x = List.length as_ in
  let y =
    List.length @@
    List.sort_uniq compare @@
    List.map (fun a -> a / 400) bs in
  Printf.printf "%d %d\n" (max (min 1 x) y) (x + y)

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int i;
  int chk=1;
  for(i=n-1;i>=0;i--){
    if(s[i]=='m'){
      i-=4;
      if(i<0||s.substr(i,5)!="dream")chk=0;
    }else if(s[i]=='e'){
      i-=4;
      if(i<0||s.substr(i,5)!="erase")chk=0;
    }else if(s[i]=='r'){
      i-=5;
      if(i<0||s.substr(i,6)!="eraser"){
        i--;
        if(i<0||s.substr(i,7)!="dreamer")chk=0;
      }
    }else chk=0;
  }
  if(chk==1)cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 512
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  var primeCounts = new Int32Array(50001);

  for(var i = 1; i < 5135; i++){
    for(var k = 1; k <= i; k++){
      var sum = primeNumbers[i] + primeNumbers[k];
      if(sum > 50000)
        break;
        primeCounts[sum]++;
    }
  }
  var i = 0;
  while(c = +input[i++]){
    console.log(primeCounts[c]);
  }
  
}
   
function calcPrimeNumbers(){
  var max = 50021;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(5134 + 1);
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i]){
      primeNums[++c] = i;
    }
  }
     
  return primeNums;
}

Measured memory_bytes: 13652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N){
    int b, a;
    int ret = -1;
    for (int i = 1; i < N; i++) {
        a = i;
        b = N - a;
        int t = 0;
        while (true) {
            if (a == 0) {
                break;
            }
            t += a%10;
            a /= 10;
        }
        while (true) {
            if (b == 0) {
                break;
            }
            t += b%10;
            b /= 10;
        }
        if (ret < 0) {
            ret = t;
        } else {
            ret = min(ret, t);
        }
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    solve(N);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 7748
#include <iostream>

using namespace std;

int main(void)
{
    int R;
    cin >> R;
    if(1200 > R){
        cout << "ABC" << endl;
    }else if(2800 > R){
        cout << "ARC" << endl;
    }else {
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 504
def digitsum(s):
    su = 0
    for i in range(len(s)):
        su += int(s[i])

    return su

def main():
    N = int(input())

    ans = 10**10
    for a in range(1, N):
        b = N - a
        tmp = digitsum(str(a)) + digitsum(str(b))

        ans = min(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    std::string S,T;
    std::cin>>S>>T;
    int max=0;
    int buf;
    for(int i=0;i<=S.size()-T.size();++i){
        buf=0;
        for(int j=0;j<T.size();++j){
            if(S[i+j]==T[j]){
                buf++;
            }
        }
        if(buf>max){
            max=buf;
        }
    }
    std::cout<<T.size()-max<<std::endl;
}

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

int main() {
    int n, l; cin >> n >> l;
    int minval = 10000000;
    for (int i = 1; i <= n; i++) {
        int tmp = l+i-1;
        if (abs(tmp) < abs(minval)) {
            minval = tmp;
        }
    }
    cout << (2*l+n-1)*n/2 - minval << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int s;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s += (a - 1);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()

def is_int(s):
    try:
        int(s)
        return True
    except ValueError:
        return False

ans = 0
if is_int(s[0:a]) == True:
    if s[a] == "-":
        if is_int(s[a+1:]) == True:
            print("Yes")
            ans = 1
if ans == 0:
    print("No")


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> a >> b >> d;

	l_ans = d/a * b;

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3640