akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 8+5;
int n, m, vis[N][N];
char s[N][N];
void dfs(int x, int y)
{
    vis[x][y] = 1;
    if(s[x+1][y] == '#') dfs(x+1, y);
    else if(s[x][y+1] == '#') dfs(x, y+1);
}
int main()
{
    n = read(), m = read();
    for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    if(s[1][1] == '#') dfs(1, 1);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(s[i][j] == '#'&&!vis[i][j])
                return puts("Impossible"), 0;
    puts("Possible");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N=1e6+7;
char s[N],t[N];
int main(){
    scanf("%s%s",s,t);
    int n=strlen(s);
    for(int i=0;i<n;i++){
        char c=s[n-1];
        for(int j=n-1;j>=1;j--) s[j]=s[j-1];
        s[0]=c;
        if(strcmp(s,t)==0){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}


Measured memory_bytes: 3704
private var N: Int = 0
private var h: List<Int> = emptyList()
private var INF = Long.MAX_VALUE
private val memo = mutableMapOf<Int, Long>()

fun main(args: Array<String>) {
    N = readLine()!!.toInt()
    h = readLine()!!.split(" ").map(String::toInt)

    println(jump(N - 1))

}

private fun jump(i: Int): Long {

    if (memo.containsKey(i)) {
        return memo[i]!!
    }

    if (i == 0) {
        return 0
    }

    var res = INF

    // 足場 i-1 から来た場合
    res = Math.min(res, jump(i - 1) + Math.abs(h[i] - h[i - 1]))

    // 足場 i-2 から来た場合
    if (i > 1) {
        res = Math.min(res, jump(i - 2) + Math.abs(h[i] - h[i - 2]))
    }

    memo[i] = res
    return res
}


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

int main(void)
{
    int X,t;
    cin >> X >> t;

    if(X - t < 0)
        cout << 0 <<endl;
    else
        cout << X - t << endl;

    return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int H,W;
const int MAX_H = 100;
vector<string> S;
map<char,int> mp;

int main()
{
	cin >> H >> W;
	S.assign(H,"");
	FOR(i,0,H){
		cin >> S [i];
		FOR(j,0,W) mp [S [i] [j]]++;
	}

	int cnt [5] = {};
	if(H % 2 && W % 2){
		cnt [1] = 1;
		cnt [2] = (H - 1) / 2 + (W - 1) / 2;
		cnt [4] = (H * W - cnt [1] - cnt [2] * 2) / 4;
	}
	else if(H % 2){
		cnt [2] = W / 2;
		cnt [4] = (H * W - cnt [2] * 2) / 4;
	}
	else if(W % 2){
		cnt [2] = H / 2;
		cnt [4] = (H * W - cnt [2] * 2) / 4;
	}
	else{
		cnt [4] = H * W / 4;
	}

	bool ans = true;
	for(int i = 1;i <= 4;i *= 2){
		for(char c = 'a';c <= 'z';c++){
			if(mp [c] % (i * 2)){
				if(cnt [i] > 0){
					mp [c] -= i;
					cnt [i]--;
				}
			}
			if(mp [c] % i){
				ans = false;
				break;
			}
		}
		if(ans == false) break;
	}
	puts(ans ? "Yes" : "No");

	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 3e3 + 5;
ll dp[N][N][2];
int n;
int a[N];

void go(int l, int r, int turn){

	if(r - l < 1)
		return;
	ll &ans = dp[l][r][turn];
	if(ans != -1)
		return;

	ans = 0;

	if(r - l == 1){
		ans = max(a[r], a[l]);
		dp[l][r][turn^1] = min(a[l], a[r]);
		 // cout << l << "\t" << r << "\t" << turn << "\t" << ans << "\n";
		return;
	}

	go(l + 1, r, turn^1);
	go(l, r - 1, turn^1);

	if(a[l] + dp[l + 1][r][turn] > a[r] + dp[l][r - 1][turn]){
		ans = a[l] + dp[l + 1][r][turn];
		dp[l][r][turn^1] = dp[l + 1][r][turn^1];
	}
	else{
		ans = a[r] + dp[l][r - 1][turn];
		dp[l][r][turn^1] = dp[l][r - 1][turn^1];
	}
	// cout << l << "\t" << r << "\t" << turn << "\t" << ans << "\t" << dp[l][r][turn^1] << "\n";
}

int main()
{
	memset(dp, -1, sizeof(dp));
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}

	if(n == 1)
		return cout << a[1] << "\n", 0;

	go(1, n, 0);
	cout << dp[1][n][0] - dp[1][n][1] << "\n";
}

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

int main()
{
    
    int n, m;
    int s[6], c[6];
    
    //条件を入力
    scanf("%d%d", &n,&m );
    for ( int i=0; i<m; i++ ){
        scanf("%d%d", &s[i], &c[i]);
    }
    
     //n>=2 の時、存在しない場合を出力
    if ( n >= 2 ){

    for ( int i=0; i<m; i++ ){
        
        if ( s[i] == 1 && c[i] == 0 ){
            printf("-1\n");
            return 0;
        }
        
        for ( int j=0; j<m; j++ ){
            if ( s[i] == s[j] && c[i] != c[j] ){
                printf("-1\n");
                return 0;
            }
        }
    }
        
    }
    
    //n=1の場合の存在しない条件
    if ( n == 1 ){
        for ( int i=0; i<m; i++ ){
            for ( int j=0; j<m; j++ ){
                if ( s[i] == s[j] && c[i] != c[j] ){
                    printf("-1\n");
                    return 0;
                }
            }
        }
    }
    
    //条件を反映させる
    int ans[3] = {-1,-1,-1};
    
    for ( int i=0; i<m; i++){
        
        switch (s[i]){
            case 1:
                ans[0] = c[i];
                break;
            case 2:
                ans[1] = c[i];
                break;
            case 3:
                ans[2] = c[i];
                break;
            default:
                //NOT_REACHED
                break;
        }
        
    }
        
    
    
        //条件以外の桁を埋める
        if ( n == 1 ){
            if ( ans[0] == -1 ){
                printf("0\n");
                return 0;
            }
            printf("%d\n",ans[0]);
            return 0;
            
        } else if ( n == 2 ){
            
            if ( ans[0] == -1 ) {
                ans[0] = 1;
                if ( ans[1] == -1 ) ans[1] = 0;
                
            } else if ( ans[0] != -1 ) {
                
                if ( ans[1] == -1 ) ans[1] = 0;
            }
            printf("%d%d\n", ans[0],ans[1]);
            return 0;
            
        } else if ( n == 3 ){
            
            if ( ans[0] == -1 ){
                
                ans[0] = 1;
                if ( ans[1] == -1 ) ans[1] = 0;
                if ( ans[2] == -1 ) ans[2] = 0;
                
            } else if ( ans[0] != -1 ){
                
                if ( ans[1] == -1 ) ans[1] = 0;
                if ( ans[2] == -1 ) ans[2] = 0;
            }
            printf("%d%d%d\n",ans[0],ans[1],ans[2]);
            return 0;
    }

}


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


int main(){
	string A,B;
	cin >> A >> B;
	
	if(A.size()>B.size()){
		cout << "GREATER" << endl;
	}else if(A.size()<B.size()){
		cout << "LESS" << endl;
	}else if(A.size()==B.size()){
		for(int i=0;i<A.size();i++){
			if(A[i]>B[i]){
				cout << "GREATER" << endl;
				return 0;
			}else if(A[i]<B[i]){
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll N, M;
    cin >> N >> M;
    vll A(N);
    for(auto &a:A) cin >> a;
    ASC(A);
    vpll vp(M);
    REP(i, M) {
        ll l, r;
        cin >> l >> r;
        vp[i] = {r, l};
    }
    DESC(vp);
    ll i = 0;
    for(auto &p:vp) {
        ll j = i;
        for(;i<N&&i < j + p.second;i++) {
            A[i] = max(A[i], p.first);
        }
        if(i >= N) break;
    }
    out(SUM(A, 0LL));
}

int main() {
    fast_io;
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>
// math.hのライブラリをリンクする必要がある
// gcc b.c -o b -lm

#define PI 3.141592653589793

int main(int argc, char const *argv[]) {

    int a, b, C;
    double S, L, h;
    scanf("%d %d %d", &a, &b, &C);
    double radC = (PI*C)/180;
    S = (a * b * sin(radC))/2;
    double c = sqrt(a*a + b*b - 2*a*b*cos(radC));
    L = a + b + c;
    h = 2 * S / a;
    printf("%f %f %f\n", S, L, h);

    return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
    int n;
    vector<int> a,b;
    cin >> n;
    int x;
    for(int i = 0;i < n - 1;i++)
    {
        cin >> x;
        b.push_back(x);
    }
    a.push_back(b.at(0));
    for(int i = 0;i < n - 1;i++)
    {
        if(i != 0 && a.back() > b.at(i))
        {
            a.back() = b.at(i);
        }
        a.push_back(b.at(i));
    }
    cout << accumulate(a.begin(),a.end(),0);

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
string s;
cin>>n>>s;
if(s.size()%2!=0){
    cout<<"No"<<endl;
}else{
bool flag=true;
for(int i=0;i<s.size()/2;i++){
    if(s.at(i)!=s.at(i+s.size()/2)){
        flag=false;
    }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}
}










Measured memory_bytes: 256
import collections
H,W = map(int,input().split())
if H == W == 1:
    print(0)
    exit()
if (H == 1 and W == 2) or (H == 2 and W == 1):
    print(1)
    exit()
LL=[]
for i in range(H):
    LL.append(input())

L = ((1,0),(0,1),(-1,0),(0,-1))
q = collections.deque()
max_L = []
for i in range(H):
    for j in range(W):
        d = [[0]*W for i in range(H)]
        if LL[i][j] ==".":
            q.append((i,j))
            d[i][j] = 0
            max1 = 0
            while q:
                x,y = q.popleft()
                for dx,dy in L:
                    if 0>x+dx or x+dx>H-1 or 0>y+dy or y+dy>W-1 or d[x+dx][y+dy] !=0:
                        continue
                    if  LL[x+dx][y+dy] == ".":
                        d[x+dx][y+dy] = d[x][y] +1
                        q.append((x+dx,y+dy))
                        max1 = max(max1,d[x+dx][y+dy])
                        max_L.append(max1)
                        #print(q,d ,max1)
print(max(max_L)) 

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define inf 1012345678
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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 cnt(string s, string t) {
	int res = 0;
	rep(i, s.size()) {
		if(s[i] != t[i]) res++;
	}
	return res;
}

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

	string s;
	cin >> s;
	int n = s.size();

	int ans = 0;
	if(n % 2 == 0) {
		string t = s.substr(n/2, n/2);
		reverse(all(t));

		ans = cnt(s.substr(0, n/2), t);
	} else {
		string t = s.substr(n/2+1, n/2);
		reverse(all(t));

		ans = cnt(s.substr(0, n/2), t);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;
vector<int> G[MAX],G2[MAX],used(MAX),cnt(MAX);
set<pair<int,int>> SE;

void maketree(int u,int p){
    used[u]=1;
    for(int i=0;i<G[u].size();i++){
        int a=G[u][i];
        if(used[a]) continue;
        SE.insert({u,a});
        maketree(a,u);
    }
}

void solve(int u,int p){
    for(int i=0;i<G2[u].size();i++){
        int a=G2[u][i];
        if(a==p) continue;
        solve(a,u);
    }
    if(p==-1) return;
    if(cnt[u]%2){
        cout<<u+1<<" "<<p+1<<endl;
        cnt[u]++;
    }else{
        cout<<p+1<<" "<<u+1<<endl;
        cnt[p]++;
    }
}

int main(){
    
    int N,M;cin>>N>>M;
    
    if(M%2==1){
        cout<<-1<<endl;
        return 0;
    }
    
    vector<pair<int,int>> A(M);
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        A[i]={a,b};
    }
    
    maketree(0,-1);
    
    for(int i=0;i<M;i++){
        int a=A[i].first,b=A[i].second;
        if(SE.find(A[i])!=SE.end()) G2[a].push_back(b);
        else if(SE.find({b,a})!=SE.end()) G2[b].push_back(a);
        else{
            cout<<a+1<<" "<<b+1<<endl;
            cnt[a]++;
        }
    }
    
    solve(0,-1);
    
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  for (int i=1; i<=9; i++) {
    for (int j=0; j<=9; j++) {
      if (a==i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1e9 + 7;

int main(){ _

	int N;
	cin >> N;

	ll ans = 1;
	for(int i = 1; i <= N; i++){
		ans = (ans * i) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll k;
  cin >> k;

  /*ll a=k%10;
  if(a==1 || a==3 || a==7 || a==9){
    if(k==7){
      cout << 1 << endl;
      return 0;
    }
    vector<ll> v(k+1);
    ll m=7;
    for(ll i=0;i<inf;i++){
      if(v[m*10%k]!=0)break;
      m=m*10%k;
      v[m]++;
    }
    ll c=0;
    ll s=0;
    for(ll i=0;i<k;i++){
      if(v[i]!=0){
        c++;
        s+=v[i];
        s%=k;
      }
    }
    ll a=7;
    for(ll i=1;i<k+1;i++){

    }
  }
  else cout << -1 << endl;*/

  if(7%k==0){
    cout << 1 << endl;
    return 0;
  }
  ll a=7%k;
  ll s=7%k;
  for(ll i=2;i<(ll) pow(10,7);i++){
    a*=10;
    a%=k;
    s+=a;
    s%=k;
    if(s==0){
      cout << i << endl;
      break;
    }
  }
  if(s!=0)cout << -1 << endl;

}

Measured memory_bytes: 3620
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <math.h>
#include <vector>
#include <string>
typedef long long LL;
using namespace std;

int main(){
    int n;
    int q;
    string s;
    vector<int> l;
    vector<int> r;
    int tmp_l;
    int tmp_r;
    int ans;
    cin >> n >> q;
    vector<int> num_ac(n);
    cin >> s;
    for(int i=0; i<q; i++){
        cin >> tmp_l >> tmp_r;
        l.push_back(tmp_l);
        r.push_back(tmp_r);
    }
    num_ac[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i-1]=='A' && s[i]=='C'){
            num_ac[i] = num_ac[i-1]+1;
        }else{
            num_ac[i] = num_ac[i-1];
        }
    }
    for(int i=0; i<q; i++){
        ans = num_ac[r[i]-1] - num_ac[l[i]-2];
        if(s[l[i]-2]=='A' && s[l[i]-1]=='C'){
            ans--;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[45][45][45], g[45][45][45];
char a[45][45];
int n;
int main() {
    scanf("%d", &n);
    n <<= 1;
    for (int i = 1; i <= n; i++) {
        scanf("%s", a[i] + 1);
        f[i][i][i] = 1;
        for (int j = 1; j <= n; j++) {
            g[i][i][j] = a[i][j] == '1';
        }
    }
    for (int len = 3; len <= n; len += 2) {
        for (int i = 2; i + len - 1 <= n; i++) {
            int j = i + len - 1;
            for (int l = i; l <= j; l += 2) {
                for (int r = j; r > l; r -= 2) {
                    ll sum = 0;
                    for (int t = i; t <= l; t++) sum += f[i][l][t] * g[r][j][t];
                    for (int t = l + 1; t < r; t++) f[i][j][t] += sum * f[l + 1][r - 1][t];
                }
            }
            for (int x = i + 1; x < j; x++)
                for (int y = 2; y < j; y++) if (a[x][y] == '1') g[i][j][y] += f[i][j][x];
        }
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++) if (a[1][i] == '1') ans += f[2][n][i];
    return cout << ans << endl, 0;
}

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

using namespace std;

int main(){
    int K, N, i=0;
    int input, output;
    cin >> N >> K;
    
    set<int> num;

    while (i < K){
        cin >> input;
        num.insert(input);
        i++;
    }

    int a1, a2=10, a3=10, a4=10, a5=10;
    output = N;
    while (1){
        if (output >= 10000){a5 = output / 10000;}
        if (output >= 1000){a4 = (output % 10000) / 1000;}
        if (output >= 100){a3 = (output % 1000) / 100;}
        if (output >= 10){a2 = (output % 100) / 10;}
        a1 = (output % 10);
        if (num.find(a5) == num.end() && num.find(a4) == num.end() && num.find(a3) == num.end() && num.find(a2) == num.end() && num.find(a1) == num.end()){
            break;            
        }
        output += 1;
    }
    
    cout << output << endl;
    return 0;
}

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

int main(){
  int n,x,ans=1;
  cin>>n>>x;
  int len[n],d[n];
  d[0]=0;
  for(int i=0;i<n;i++){
    cin>>len[i];
  }
  for(int i=1;i<=n;i++){
    d[i]=d[i-1]+len[i-1];
    if(d[i]<=x)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int m, d;
  cin >> m >> d;

  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 10; j <= d; j++) {
      int d10 = j / 10;
      int d1 = j % 10;
      if (i == d1 * d10 && d10 >= 2 && d1 >= 2)
        ans++;
      }
  }

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


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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) {
    cout << A - 1 << " " << B << endl;
  } else {
    cout << A << " " << B - 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
board = [0]*(H+2)
board[0] = [1]*(W+2)
total = 0
for i in range(1,H+1):
    board[i] = [1]+list(1 if c == '#'else 0 for c in input())+[1]
    total += sum(1 for c in board[i] if c == 0)
board[H+1] = [1]*(W+2)

D = [[10e10] * (W+2) for _ in range(H+2)]
D[1][1] = 0
from heapq import heappush, heappop

q = [(0, (1, 1))]

while q:
    d, (i, j) = heappop(q)
    alt = d + 1

    for x, y in [(i+1,j), (i-1,j), (i,j+1), (i,j-1)]:
        if board[x][y] == 0:
            if D[x][y] > alt:
                D[x][y] = alt
                heappush(q, (alt, (x, y)))

#for r in range(H+2): print(*[board[r][c] for c in range(W+2)])
#for r in range(H+2): print(*[D[r][c] for c in range(W+2)])
if D[H][W] == 10e10:
    print(-1)
else:
    print(total - D[H][W] - 1)
    





Measured memory_bytes: 3188
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())
s = [A,B,C,D]
m = [E,F]
S=sorted(s, reverse=True)
M=sorted(m, reverse=True)
z = [S[0],S[1],S[2],M[0]]
print(math.floor(sum(z)))


Measured memory_bytes: 5660
check = 0
check2 = 0
kensa = 0
kekka = "" 
num = []
hantei = "OK"
INF = input().split()
gyosu = int(INF[1])
keta = int(INF[0])
out = []
for l in range(keta):
  out.append(0)


for i in range(gyosu):
  num.append([int(j) for j in input().split()])

if gyosu > 0 :
  check = int(num[0][0])
  check2 = int(num[0][1])
  
  for j in range(gyosu-1):
    for k in range(gyosu-1):
      if num[j][0] == num[k + 1][0]:
        if num[j][1] != num[k + 1][1]:
          hantei = "NG"
    
    if int(num[j][0]) < check: # 入力値にある最大桁数を計算
      check = int(num[j][0])
      check2 = int(num[j][1])
  if check2 == 0:
    if check == 1 and keta == 3:
      hantei = "NG"
    if check == 2:
      hantei = "tokubetu2"
    if check == 3:
      hantei = "tokubetu"

if hantei == "NG":
  print("-1")
else:
  for m in range(gyosu):
    
    out[(num[m][0] - 1)] = num[m][1]
  for n in range(keta):
    kekka = kekka + str(out[n])

  for p  in kekka:
      if p == "0":
        kensa = kensa + 1
      else:
        break
  kekka2 = kekka
  for q in range(kensa):
    if keta != 1:
      kekka = kekka.lstrip("0")
if hantei == "OK":
  if gyosu == 0:
    if keta == 1:
      print("0")
    elif keta == 2:
      print("10")
    else:
      print("100")
  else:
    if keta == 2:
      if kensa == 1:
        kekka = "1" + kekka
    if keta == 3:
      if kensa == 1:
        kekka = "1" + kekka
      if kensa == 2:
        kekka = "10" + kekka
    print(kekka)

if hantei == "tokubetu":
  print("0")


if hantei == "tokubetu2":
  #kekka2 = kekka2.lstrip("0")
  kekka2 = kekka2[1:]
  kekka2 = "1" + kekka2
  print(kekka2)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=1e5+10;
using i64 = int64_t;

int main() 
{
    sync;
    int n, p;
    cin >> n >> p;

    if (p == 2 || p == 5) {
        i64 ans = 0;
        for (int i = 0; i < n; ++i) {
            char c;
            cin >> c;

            int x = c - '0';
            if (x % p == 0)
                ans += i + 1;
        }

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

    string s;
    cin >> s;

    vector<int> count(p);
    count[0] = 1;

    int cum = 0, dig = 1;
    i64 ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        int x = s[i] - '0';

        cum = (cum + x * dig) % p;
        ans += count[cum];
        ++count[cum];

        dig = (dig * 10) % p;
    }

    cout << ans << endl;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n],sum=0;
        loop(i,0,n-1) cin>>a[i];
        loop(i,1,n-1)
        {
            if(a[i]<a[i-1])
            {
                sum+=(a[i-1]-a[i]);
                a[i]=a[i-1];
            }
        }
        cout<<sum;

    }
    return 0;
}


Measured memory_bytes: 5176
@d = gets.to_i
@c = gets.split.map &:to_i
@s = @d.times.map { gets.split.map &:to_i }

def score(schedule, range = 0...@d, last = [0] * 26)
  sat = 0
  range.each do |day|
    type = schedule[day]
    sat += @s[day][type]
    day += 1
    last[type] = day
    sat -= 26.times.sum { |i, day_last| @c[i] * (day + 1 - last[i]) }
  end
  sat
end

schedule = [0] * @d
last = [0] * 26
@d.times do |day|
  s_max, i_max = -10000000, 0
  26.times do |i|
    schedule[day] = i
    s = score(schedule, day..[day+8, @d-1].min, last.dup)
    s_max, i_max = s, i if s > s_max
  end
  schedule[day] = i_max
  last[i_max] = day + 1
end

schedule.each do |type|
  p type + 1
end

STDERR.puts score(schedule)


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

struct par {
	ll x, y;
	par(ll x, ll y) : x(x), y(y) {}
	bool operator<(const par& p) const {
		return x < p.x;
	}
};

ll xp(ll b, ll e) {
	if (e == 0) return 1;
	ll c = xp(b, e >> 1);
	c *= c;
	if (e & 1) c *= b;
	return c;
}

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

	ll n;
	cin >> n;

	vb isprime(n + 1, true);
	int psz = 0;
	vector<ll> primes, lp(n + 1, 0), cnt(n + 1, 0);
	isprime[0] = isprime[1] = false;
	for (int i = 2; i <= n;i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			primes.push_back(i);
			psz++;
		}
		for (int j = 0;j < psz and primes[j] <= lp[i] and i * primes[j] <= n;j++) {
			lp[i * primes[j]] = primes[j];
		}
		cnt[i] = (lp[i] == lp[i / lp[i]] ? cnt[i / lp[i]] + 1 : 1);
	}
	ll ans = 0;
	for (ll i = 1;i <= n;i++) {
		ll d = 1, x = i;
		while (x > 1) {
			d *= cnt[x] + 1;
			x /= xp(lp[x], cnt[x]);
		}
		ans += d * i;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 169032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		while(true) {
			c -= b;
			if(c <= 0) {
				System.out.println("Yes");
				return;
			}
			a -= d;
			if(a <= 0) {
				System.out.println("No");
				return;
			}
		}
	}
}

Measured memory_bytes: 35712
s = int(input())
numlist = [s]
while(True):
    if s % 2 == 0:
        s = s // 2
    else:
        s = s * 3 + 1
    numlist.append(s)
    if len(numlist) != len(set(numlist)):
        break
    
print(len(numlist))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

// c = a . b
void mult(vector<int>& c, const vector<int> &a, const vector<int>& b)
{
	const int n = a.size();
	for(int i = 0; i < n; ++i) {
		c[i] = a[b[i]];
	}
}

// b = a
void copy(vector<int> &b, const vector<int> &a)
{
	const int n = a.size();
	for(int i = 0; i < n; ++i) {
		b[i] = a[i];
	}
}

void rev(vector<int> &b, const vector<int> &a)
{
	const int n = a.size();
	for(int i = 0; i < n; ++i) {
		b[a[i]] = i;
	}
}

void unit(vector<int>& a)
{
	const int n = a.size();
	for(int i = 0; i < n; ++i) {
		a[i] = i;
	}
}

// b = a ^ k
void power(vector<int>& b, const vector<int> &a, const int k)
{
	static vector<int> temp, a2;
	const int n = a.size();

	a2.resize(n);
	temp.resize(n);
	copy(a2, a);
	unit(b);

	for(int x = 0; x < 31; ++x) {

		if((k >> x) & 1) {
			mult(temp, b, a2);
			copy(b, temp);
		}

		mult(temp, a2, a2);
		copy(a2, temp);
	}
}

void print_answer(const vector<int>& xs)
{
	const int n = xs.size();
	for(int i = 0; i < n; ++i) {
		printf("%d\n", xs[i] + 1);
	}
}

int main()
{
	int n, k;
	vector<int> ps, qs;

	scanf("%d%d", &n, &k);
	ps.resize(n);
	qs.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &ps[i]);
		ps[i] -= 1;
	}
	for(int i = 0; i < n; ++i) {
		scanf("%d", &qs[i]);
		qs[i] -= 1;
	}

	if(k == 1) {
		print_answer(ps);
		return 0;
	} else if(k == 2) {
		print_answer(qs);
		return 0;
	}

	int sec = k / 3;
	int rem = k % 3;

	int first = (sec - 1) * 2 + rem;
	int second = (rem == 0) ? 2 : 1;

	// fprintf(stderr, "first = %d, second = %d\n", first, second);

	vector<int> f[4];

	for(int i = 0; i < 4; ++i) {
		f[i].resize(n);
	}

	copy(f[0], qs);
	rev(f[1], ps);
	rev(f[2], qs);
	copy(f[3], ps);

	vector<int> g(n), temp(n);

	unit(g);
	for(int i = 0; i < 4; ++i) {
		mult(temp, g, f[i]);
		copy(g, temp);
	}

	power(temp, g, first / 4);

	copy(g, temp);
	for(int i = 0; i < first % 4; ++i) {
		mult(temp, g, f[i]);
		copy(g, temp);
	}

	vector<int> rg(n);
	rev(rg, g);

	vector<int> h(n);

	unit(h);
	for(int i = 0; i < second; ++i) {
		mult(temp, h, f[(first % 4 + i) % 4]);
		copy(h, temp);
	}

	vector<int> ans(n);

	mult(temp, g, h);
	mult(ans, temp, rg);

	print_answer(ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <set>
#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    auto dp = make_v(n, m, 0);
    REP(i, 0, n) {
        REP(j, 0, m) {
            cin >> dp[i][j];
        }
    }
    set<int> s;
    vector<int> process(n, 0);
    queue<int> q;
    int ans = n;
    while (s.size() < m) {
        {
            vector<int> cnt(m, 0);
            REP(i, 0, n) {
                cnt[dp[i][process[i]] - 1]++;
            }
            int mx = *max_element(cnt.begin(), cnt.end());
            REP(i, 0, m) {
                if (cnt[i] == mx) {
                    q.emplace(i + 1);
                }
            }
            chmin(ans, mx);
        }

        while (q.size()) {
            auto t = q.front();
            q.pop();
            s.insert(t);
            if (s.size() == m) continue;

            REP(i, 0, n) {
                while (process[i] < m && s.count(dp[i][process[i]])) {
                    process[i]++;
                }
            }
            vector<int> cnt(m, 0);
            REP(i, 0, n) {
                cnt[dp[i][process[i]] - 1]++;
            }
            int mx = *max_element(cnt.begin(), cnt.end());
            chmin(ans, mx);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
	int t=1;
	//cin>>t;
	while(t--){
		//logic_start

        int a,b,c;
        cin>>a>>b>>c;
        swap(a,b);
        swap(a,c);
        cout<<a<<" "<<b<<" "<<c<<endl;
		//logic_end

	} 
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String s = sc.next();
		String c = sc.next();
		System.out.println("A"+s.substring(0,1)+"C");
		sc.close();
	}

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int n, m, x;
int c[20];
int a[20][20];
int cost = 0;
int cur[20];
int ans = LONG_LONG_MAX;
void go(int ind)
{
    if (ind == n)
    {
        bool ok = 1;
        for (int i = 0; i < m; i++)
            if (cur[i] < x)
            {
                ok = 0;
                break;
            }
        if (ok)
            ans = min(ans, cost);
        return;
    }

    go(ind + 1);

    cost += c[ind];
    for (int i = 0; i < m; i++)
        cur[i] += a[ind][i];
    go(ind + 1);

    cost -= c[ind];
    for (int i = 0; i < m; i++)
        cur[i] -= a[ind][i];
}

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

    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    go(0);
    if (ans == LONG_LONG_MAX)
        cout << "-1";
    else
        cout << ans;
    return 0;
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		Long s = Long.parseLong(a);
		Long sum = 0l;
		long[] cnt = {1,1,2,4,8,16,32,64,128,256,512,1024,2048};
		for(int i = 0; i < l; i++){
			int pos = Integer.parseInt(""+a.charAt(i));
			for(int j = l-i-1; j > -1; j--){
				sum += pos*(long)Math.pow(10,j)*cnt[l-i-1-j];
				cnt[l-i-1-j] *= 2;
			}
		}
		sb.append(sum);
		System.out.println(sb);
	}
}

Measured memory_bytes: 8020
#include<stdio.h>
#include<math.h>

int main(){
  int a,b,c;
  scanf("%d %d",&a,&b);
  if(b<10) c=b+10*a;
  else if(b<100) c=100*a+b;
  else c=1000*a+b;
  if((int)sqrt(c)==sqrt(c))  printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            char [] cs = scan.next().toCharArray();
            for(int i=0;i<cs.length;i++){
            	if(cs[i]>='D')cs[i]-=3;
            	else cs[i]+=23;
            }
            System.out.println(cs);
        }
}

Measured memory_bytes: 12000
#include <stdio.h>
int main(void) {
	int n, q, t;
	int i, j, count = 0;
	int s[10001];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &s[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &t);
		s[n] = t;
		j = 0;
		while (s[j] != t)
			j++;
		if (j < n)
			count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 636
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,k:i64,
       mut a:[i64;n],
    }
    let mut cumsum = vec![0; n + 1];
    for i in 0..n {
        a[i] -= 1;
    }
    for i in 0..n {
        cumsum[i + 1] = (cumsum[i] + a[i]) % k;
    }
    for mut x in cumsum.iter_mut() {
        *x %= k;
    }
    let mut mp = BTreeMap::new();
    let mut ans = 0i64;
    for (i, &x) in cumsum.iter().enumerate() {
        let i = i as i64;
        let l = mp.entry(x).or_insert(0);
        ans += *l;
        *l += 1;
        if i >= k - 1 {
            *mp.entry(cumsum[(i - k + 1) as usize]).or_insert(0) -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 18184
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <vector>
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <string>
 
namespace fastinput
{
	/** Interface */
 
	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);
 
	/** Read */
 
	static const int buf_size = 16384;
 
	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}
 
	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}
 
	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}
 
	/** Write */
 
	static int write_pos = 0;
	static char write_buf[buf_size];
 
	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}
 
	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;
 
		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}
 
	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}
 
	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}
 
using namespace fastinput;
using namespace std;
 
const int K = 10;
 
int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	vector <int> things[26];
	for (int i = 0; i < s.length(); ++i)
		things[s[i] - 'a'].push_back(i);
	for (char c = 'a'; c <= 'z'; ++c)
	{
		for (int i = 0; i < things[c - 'a'].size(); ++i)
			for (int j = max(i - K, 0); j < i; ++j)
			{
				if (things[c - 'a'][i] - things[c - 'a'][j] <= 2 * (i - j))
				{
					cout << things[c - 'a'][j] + 1 << " " << things[c - 'a'][i] + 1 << endl;
					return 0;
				}
			}
	}
	cout << -1 << " " << -1 << endl;
 
	return 0;
}

Measured memory_bytes: 1104
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,m,a,b,memo = 0;
    cin >> n >> m;
    int c[m] = {0};
    
    rep(i,0,m){
        cin >> a >> b;
        c[i] = max(0,n-a);
    }
    
    sort(c,c+m);
    
    rep(i,0,m-1){
        memo += c[i];
    }
    
    cout << memo << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	char *lis[] = { "dream", "dreamer", "erase", "eraser" };

	char buf[8] = { 0 };
	int pos = n - 1, f = 6;
	bool ok = true;
	while (pos >= 0) {
		if (f < 0) {
			ok = false;
			break;
		}
		char c = s[pos];
		buf[f] = c;
		FOR(i, 0, 4) {
			char *str = lis[i];
			if (strcmp(str, buf + f) == 0) {
				f = 7;
			}
		}
		f--;
		pos--;
	}
	if (f != 6)
		ok = false;
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1]) {
		if (S[2] == S[3] && S[0] != S[2]) cout << "Yes";
		else cout << "No";
	} else if (S[0] == S[2]) {
		if (S[3] == S[1] && S[0] != S[3]) cout << "Yes";
		else cout << "No";
	} else if (S[0] == S[3]) {
		if (S[1] == S[2] && S[0] != S[1]) cout << "Yes";
		else cout << "No";
	} else cout << "No";
	return 0;
}

Measured memory_bytes: 256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> List.sort compare

let vs = Array.make 1_000_001 false

let rec devideable i x =
  if i * i > x then false
  else if x mod i <> 0 then devideable (i + 1) x
  else vs.(i) || vs.(x / i) || devideable (i + 1) x

let rec loop ans = function
  | [] -> Printf.printf "%d\n" ans
  | (x, cnt) :: xs ->
    let d = devideable 1 x in 
    vs.(x) <- true;
    if cnt > 1 || d then loop ans xs
    else loop (ans + 1) xs

let () = 
  let rec f = function
    | (acc, []) -> acc
    | ((v, cnt) :: accs as acc, x :: xs) ->
      if x = v then f ((v, cnt + 1) :: accs, xs)
      else f ((x, 1) :: acc, xs)
    | _ -> failwith ""
  in
  loop 0 (List.rev (f ([(List.hd a, 1)], List.tl a)))

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

#define int long long

int32_t main()
{
    int n,m;
    cin>>n>>m;
    
    int w[n],v[n];
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
            dp[i][j]=0;
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            dp[i][j]=dp[i-1][j];
            
            if(j>=w[i-1])
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
                        
    cout<<dp[n][m];
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std ;

int main()
{
    int n;
    cin>>n;
    int a[n],tem,count[n],k=0,ans=0;

    memset(count,1,sizeof(count));

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    for(int i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            count[k]++;
        }
        else
            k++;
    }

    for(int j=0;j<k;j++)
    {
        if(count[j]%2==1)
        {
            ans++;
        }
    }
    cout<<ans<<endl ;
    return 0;
}


Measured memory_bytes: 4420