akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int i, n;
    cin >> n;
    vll a(n, 0);
    vll b(n, 0);
    fo(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end(), desc);
    vll c(n, 0);

    auto it = b.begin();
    fo(i, n)
    {
           if(a[i] != *it)
               c[i] = *it;
           else
           {
               it++;
               c[i] = *it;
               it = b.begin();
           }
    }
    fo(i, n)
    cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 6272
#include<stdio.h>
int main(){
  int n,x,i,j,k,sum,count;

  while(1){
    count=0;
    scanf("%d%d",&n,&x);

    if(n+x==0) break;

    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  sum=i+j+k;
	  if(sum==x) count++;
	}
      }
    }

    printf("%d\n",count);
  }
    return 0;
  }
	

Measured memory_bytes: 600
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,h1,w1,h2,w2,h3,w3,h,w;
	long long s,sav,mn,s1,s2,s3,smn,smx;
	scanf("%d %d",&h,&w);
	s=(long long)h*w;
	mn=s;
	if(h%3==0 || w%3==0)	mn=0;
	else {
		h1=h/3;	h3=h1+1;
		smn=(long long)h1*w;
		smx=(long long)h3*w;
		mn=min(mn,smx-smn);
		w1=w/3;	w3=w1+1;
		smn=(long long)w1*h;
		smx=(long long)w3*h;
		mn=min(mn,smx-smn);		
//		printf("smx=%lld smn=%lld\n",smx,smn);
		h1=h/2;	h2=h-h1;
		for(i=1;i<w;i++)	{
			s1=(long long)h1*i;
			s2=(long long)h2*i;
			s3=(long long)h*(w-i);
			smn=min(s1,s2);
			smn=min(smn,s3);
			smx=max(s1,s2);
			smx=max(smx,s3);
//			printf("smx=%lld smn=%lld\n",smx,smn);
			mn=min(mn,smx-smn);
		}
		w1=w/2;	w2=w-w1;
		for(i=1;i<h;i++)	{
			s1=(long long)w1*i;
			s2=(long long)w2*i;
			s3=(long long)w*(h-i);
			smn=min(s1,s2);
			smn=min(smn,s3);
			smx=max(s1,s2);
			smx=max(smx,s3);
			mn=min(mn,smx-smn);
		}		
	}
	printf("%lld\n",mn);
	return 0;
}

	


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A[]=new int [N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		long B[]=new long [N];
		long C=0;
		for(int i=0;i<N;i++) {
			C=C+(long)A[i];
			B[i]=C;
		}
		long abs;
		long ans=Long.MAX_VALUE;
		int d=0;
		int f=2;
		int i=0;
		for(i=1;i<N-2;i++) {
			long c=Long.MAX_VALUE;
			for(int k=d;k<i;k++) {
				abs=Math.abs(B[i]-B[k]-B[k]);
				if(abs<c) {
					c=abs;
					d=k;
				}else {
					break;
				}
			}
			long e=Long.MAX_VALUE;
			for(int k=f;k<N-1;k++) {
				abs=Math.abs((B[k]-B[i])-(B[N-1]-B[k]));
				if(abs<e) {
					e=abs;
					f=k;
				}else {
					break;
				}
			}
			long g=B[d];
			long h=B[i]-B[d];
			long m=B[f]-B[i];
			long j=B[N-1]-B[f];
			long k=Math.max(Math.max(g,h),Math.max(m,j));
			long l=Math.min(Math.min(g, h), Math.min(m,j));
			ans=Math.min(ans, k-l);
		}
	System.out.println(ans);
	}
}


Measured memory_bytes: 66432
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)

const ll mod =1e9+7;
const int N = 1e6+7;
using namespace std;

 
int main()
{

		int n,f=1;
		scf(n);

        ll x=1;
	
			vector<ll>v;
			
			int ctr=0;
		
	    for(int i=1;i<=n;i++)
		{
			ll a;
			lscf(a);
            
            if(a>1e9)
            ctr++;
            			
			v.pb(a);
		}
		
		sort(v.begin(),v.end());
		
		if(v[0]==0)
		{
			    f=0;
			    prin(0);
		}
		
		else if(ctr>=2)
		prin(-1),f=0;
			
		else{
			    
		cpp_int x=1;
		
		for(auto it:v)
		x*=it;
		
        if(x<=1000000000000000000&&x>=0&&f)
		cout<<x<<endl;
		
		else
		prin(-1);
			
		}
		
}

Measured memory_bytes: 4360
#include <stdio.h>

int num[10], n, k;

int check(a)
int a;
{   int i, j, tmp;
    while (a) {
        tmp = a % 10;
        a /= 10;
        if (num[tmp]) {
            return 0;
        }
    }
    return 1;
}

int main(void)
{   int i, j, tmp;

    scanf("%d%d", &n, &k);
    for (i = 0; i < k; i++) {
        scanf("%d", &tmp);
        num[tmp] = 1;
    }

    for (i = n; i < 100000; i++) {
        if (check(i)) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

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

// a^n mod を計算する
ll powmod(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0)
	{
        if (n & 1)
		{
			res = res * a % mod;
		}
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve()
{
	ll n, k;
	cin >> n >> k;
	
	vector<ll> pool(k + 1, 0);
	for(int i = k; i >= 1; --i)
	{
		pool[i] = powmod((k / i), n, MOD);
		for(int j = i * 2; j <= k; j += i)
		{
			pool[i] -= pool[j];
		}
	}


	ll ans = 0;
	for(ll i = 1; i <= k; ++i)
	{
		ans += (pool[i] * i) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
}


int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3980
import numpy as np


def submit():
    n = int(input())
    trans_max = [int(input()) for _ in range(5)]
    trans_min = np.min(trans_max)    

    # 何グループで最終地点に到達するか
    group_count = n // trans_min + int(n % trans_min > 0)
    print(5 + group_count - 1)        


if __name__ == "__main__":
    submit()

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    //i番目の人が、j番目の人に対して証言した内容を保存する2次元配列
    int graph[15][15];
    int N;
    cin >> N;
    //2次元配列の初期化（j番目の人が正しいことをいう人とも、審議不明のことをいう人とも設定していない状態）
    rep(i, N) rep(j, N) graph[i][j] = -1;
    //2次元配列への書き込み部分
    rep(i, N){
        int m;
        cin >> m;
        rep(j, m){
            int x, y;
            cin >> x >> y;
            x--;
            graph[i][x] = y;
        }
    }
    //正しいことをいう人の最大値を格納
    int ans = 0;
    //変数bitに格納されているビット全探索の状態を、配列dに書き換えている
    rep(bit, 1<<N){
        vector<int> d(N);
        rep(j, N) if((bit>>j)&1) d[j] = 1;

        bool is = true;
        rep(i, N){
            //i番目の人が、bit全探索の状態で、正しいことを言う人であると設定されているなら行う
            if(d[i]){
                //i番目の人から見て、j番目の人が、審議不明の発言をする人でないかどうかチェック
                rep(j, N){
                    if(graph[i][j] == -1) continue;
                    //d[j]には、j番目の人が正しい発言をする人であるかどうかが格納されているので、
                    //正しい発言をする人であるi番目の人の証言と、d[j]が異なっていれば、矛盾発生となる。
                    if(graph[i][j] != d[j]) is = false;
                }
            }
        }
        if(is) ans = max(ans, __builtin_popcount(bit));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

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


Measured memory_bytes: 26480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

bitset<20000> tmp,dp[80][80];
void solve(long long H, long long W, std::vector<std::vector<long long>> A, std::vector<std::vector<long long>> B){
  vector<vector<ll>> C(H,vector<ll>(W));
  For(i,H)For(j,W){
    C[i][j]=abs(A[i][j]-B[i][j]);
  }
  dp[0][0][C[0][0]+10000]=true;
  dp[0][0][-C[0][0]+10000]=true;
  For(i,H){
    For(j,W){
      tmp.reset();
      if(i==0&&j==0)continue;
      if(i>0){
        tmp|=dp[i-1][j];
      }
      if(j>0){
        tmp|=dp[i][j-1];
      }
      dp[i][j]=(tmp>>C[i][j])|(tmp<<C[i][j]);
    }
  }
  int i;
  for (i = 0; i<10000&&dp[H-1][W-1][i+10000]==false; i++)
  {
  }
  cout<<i<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    std::vector<std::vector<long long>> B(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&B[i][j]);
        }
    }
    solve(H, W, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 16128
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long total = 1;
		for (long i = 1; i <= n; i++) {
			total *= i;
			total %= MOD;
		}
		System.out.println(total);
	}
}


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

int main(){
	int f=0,s=0;
  	int data[3];
  
  	cin >> data[0] >> data[1] >> data[2];
  
  	for(int i=0;i<3;i++){
    	if(data[i]==5)f++;
      	else if(data[i]==7)s++;
    }
  	if((s==1)&&(f==2)){
    	cout << "YES";
    }else{
    	cout << "NO";
    }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 111;

int n, i, p;
pair<int, int> A[maxN], B[maxN];
multiset<int> S;
int ans;

int main()
{
 //   freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) cin >> A[i].first >> A[i].second;
    for (i = 1; i <= n; i++) cin >> B[i].first >> B[i].second;

    sort(A + 1, A + n + 1);
    sort(B + 1, B + n + 1);

    for (i = 1; i <= n; i++) {
        while (p + 1 <= n && A[p + 1] <= B[i]) {
            S.insert(A[p + 1].second);
            p++;
        }

        auto it = S.lower_bound(B[i].second);
        if (it != S.begin()) {
            it--;
            ans++;
            S.erase(it);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e6+9;
int n;
string s;

int main(){
    cin>>n>>s;
    for(auto u:s){
    	int v=u-'A';
    	v+=n;
    	v%=26;
    	cout<<char(v+'A');
    }
    return 0;
}


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

int main(){
    long int n,sum;
    while(1){
        cin >> n;
        if(n == 0) break;
        sum = 0;
        for(int i=1;i*i<=n;i++){
            if(n%i == 0) sum += i+(n/i);
            if(i*i == n) sum -= i;
        }
        if(sum < n*2) cout << "deficient number\n";
        else if(sum == n*2) cout << "perfect number\n";
        else cout << "abundant number\n";
    }
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
using ll = long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1L<<60;
const ll MOD=998244353;

struct H{
    ll to;
    ll cost;
    ll time;
};

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    ll S;
    cin >> S;
    vector<ll> U(M,0);
    vector<ll> V(M,0);
    vector<ll> A(M,0);
    vector<ll> B(M,0);
    vector<ll> C(N,0);
    vector<ll> D(N,0);
    for(ll i=0;i<M;i++){
        cin>>U[i]>>V[i]>>A[i]>>B[i];
        U[i]--;V[i]--;
    ;}
    for(ll i=0;i<N;i++){
        cin>>C[i]>>D[i]
    ;}
    vector<vector<H>> hen(N, vector<H>(0));;
    for(ll i=0;i<M;i++){
        for(ll j=0;j<=2500;j++){
            hen[U[i]].emplace_back(H{V[i],A[i],B[i]});
            hen[V[i]].emplace_back(H{U[i],A[i],B[i]});
        ;}
    ;}

    //dp[i][j]は都市iにちょうどj円ある状態で存在する最小時間
    vector<vector<ll>> dp(N, vector<ll>(2501, INF));
    dp[0][min(2500L,S)]=0;
    priority_queue<T, vector<T>, greater<T>> pq;
    //pqに格納するのは、T(最小時間、都市、金)
    pq.push(T(0,0,min(2500L,S)));
    while(!pq.empty()){
        T x=pq.top();
        pq.pop();
        ll y=get<0>(x);
        ll z=get<1>(x);
        ll w=get<2>(x);
        if(dp[z][w]<y)continue;
        for(H p: hen[z]){
            ll cos=p.cost;
            ll toto=p.to;
            ll w2=w-cos;
            ll tim=y+p.time;
            if(cos<=w&&dp[toto][w2]>tim){
                dp[toto][w2]=tim;
                pq.push(T(tim,toto,w2));
            }
        ;}
        ll w2=w+C[z];
        ll y2=y+D[z];
        ll Min=min(2500L,w2);
        if(dp[z][Min]>y2){
            dp[z][Min]=y2;
            pq.push(T(y2,z,Min));
        }
    }
    for(ll i=1;i<N;i++){
        ll ans=INF;
        for(ll j=0;j<=2500;j++){
            ans=min(ans,dp[i][j])
        ;}
        cout<<ans<<endl;
    ;}
    
    



    return 0;
}


Measured memory_bytes: 20376
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> vs;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vs.push_back(s);
    }
    vector<vector<int>> v(26, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < vs[i].size(); j++) {
            v[vs[i][j] - 'a'][i]++;
        }
    }
    string res;
    for (int i = 0; i < 26; i++) {
        res += string(*min_element(v[i].begin(), v[i].end()), 'a' + i);
    }
    cout << res << endl;
}


Measured memory_bytes: 3624
n,w=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(n)]
DP=[[0]*(w+1) for _ in range(n+1)]
for i in list(range(n))[::-1]:
  wi,vi=goods[i][0],goods[i][1]
  for j in range(w+1):
    if j<wi:
      DP[i][j]=DP[i+1][j]
    else:
      DP[i][j]=max(DP[i+1][j],DP[i+1][j-wi]+vi)
print(DP[0][w])

Measured memory_bytes: 121064
#include <iostream>
#include <string>
#include <vector>
using i64 = long long;

int main() {
    int n, m, k;
    std::cin >> n >> m >> k;
    std::vector<std::string> b(n);
    for (auto &e : b) std::cin >> e;

    int ret = 0;
    for (int i = 0; i < (1 << n); i++) for (int j = 0; j < (1 << m); j++) {
        int c = 0;
        for (int p = 0; p < n; p++) for (int q = 0; q < m; q++) {
            if (!((1 << p) & i) && !((1 << q) & j) && b[p][q] == '#') c++;
        }
        if (c == k) ret++;
    }

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

    return 0;
}


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


int main(){
    int a,b,c,ans=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=a;i<=b;i++){
        if(c%i==0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3208
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int W, H, N; cin >> W >> H >> N;

    vector<int> X(N), Y(N);
    for(int i=0; i<N; i++) {
        cin >> X[i] >> Y[i];
    }

    int ans = 0;
    for(int i=1; i<N; i++) {
        int diff_x = X[i] - X[i-1];
        int diff_y = Y[i] - Y[i-1];

        if(diff_x >= 0 and diff_y >= 0) {
            int mi = min(diff_x, diff_y);
            diff_x -= mi;
            diff_y -= mi;
            ans += mi;
        }
        else if(diff_x < 0 and diff_y < 0) {
            int ma = max(diff_x, diff_y);
            diff_x -= ma;
            diff_y -= ma;
            ans -= ma;
        }

        ans += abs(diff_x) + abs(diff_y);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int t[52][52] = {};
  string s;
  int h, w;
  int i, j, k;
  int ns[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int ew[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  cin >> h >> w;
  for(i = 1; i <= h; i++){
    cin >> s;
    for(j = 1; j <= w; j++){
      if(s[j-1] == '#'){
        t[i][j] = 9;
      }
    }
  }
  for(i = 0; i <= h+1; i++){
    for(j = 0; j <= w+1; j++){
      if(t[i][j] == 9){
        for(k = 0; k < 8; k++){
          if(t[i + ns[k]][j + ew[k]] != 9)
            t[i + ns[k]][j + ew[k]] += 1;
        }
      }
    }
  }
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      if(t[i][j] == 9)
        putchar('#');
      else
        putchar(t[i][j] + '0');
    }
    putchar('\n');
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i])cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[105],b[105],c[105];
int main(){
	int n,ans1,ans2,k,q,u;
	scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
    for(int i=0;i<=100;i++){
    	for(int j=0;j<=100;j++){
    		for(q=0;q<n;q++){
    			if(c[q]!=0){
    				ans1=abs(i-a[q])+abs(j-b[q])+c[q];
    				break;
				}
			}
			if(q==n){
				for(u=0;u<n;u++){
					if(i==a[u]&&j==b[u]) break;
				}
				if(u==n) printf("%d %d %d",i,j,1);
				return 0;
			}
    		for(k=0;k<n;k++){
				ans2=abs(i-a[k])+abs(j-b[k])+c[k];
    			if(c[k]!=0){
    				if(ans1!=ans2) break;
    				ans1=ans2;
				}
    			else{
    				if(ans1>ans2) break;
				}
			}
			if(k==n){
				printf("%d %d %d",i,j,ans1);
				return 0;
			}
		}
	}
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }
  
  bitset<2000 * 2000 + 1> dp;
  dp[0] = 1;
  for(int i = 0; i < N; ++i){
    dp |= (dp << A[i]);
  }
  
  for(int i = (sum + 1) / 2; i <= 2000 * 2000; ++i){
    if(dp[i]){
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 5076
fun main(args: Array<String>) {

    val (n, d) = readLine()!!.split(" ").map(String::toInt)

    val xList = mutableListOf<List<Int>>()

    repeat(n) {
        xList += readLine()!!.split(" ").map(String::toInt)
    }

    println(fun133b(xList))
}

fun fun133b(xList: MutableList<List<Int>>): Any? {

    var count = 0
    for ((index, x1) in xList.withIndex()) {

        for (index2 in index + 1 until xList.size) {
            val x2 = xList[index2]

            var sum = 0
            for (index3 in 0 until x1.size) {
                sum += (x1[index3] - x2[index3]) * (x1[index3] - x2[index3])
            }

            val nijoList = mutableListOf<Int>()
            for (e in 1..sum) {
                nijoList += e * e
            }

            for (e in nijoList) {
                if (e == sum) {
                    count++
                    break
                }
            }
        }
    }

    return count
}


Measured memory_bytes: 39376
def findNumberOfTriangles(arr, n): 
      
    # Count of triangles 
    count = 0
      
     
    for i in range(n): 
        for j in range(i + 1, n): 
            for k in range(j + 1, n): 
                if (arr[i] + arr[j] > arr[k] and 
                    arr[i] + arr[k] > arr[j] and 
                    arr[k] + arr[j] > arr[i] and
                    arr[i]!=arr[j] and
                    arr[j]!=arr[k] and
                    arr[i]!=arr[k]): 
                    count += 1
    return count 
  
# Driver code 
n=int(input());
arr=list(map(int,input().split()))
  
print(findNumberOfTriangles(arr, n)) 
  

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    int mod = 1000000007;
    string s[2];
    cin >> s[0] >> s[1];

    char preType = (s[0][0] == s[1][0])? 'A':'B';
    int id = (preType == 'A')? 1:2;
    ll ans = (preType == 'A')? 3:6;
    while(id < N){
        if(s[0][id] == s[1][id]){
            if(preType == 'A'){
                ans *= 2;
                ans %= mod;
                preType = 'A';
            }
            else{
                preType = 'A';
            }
            id++;
        }
        else{
            if(preType == 'A'){
                ans *= 2;
                ans %= mod;
                preType = 'B';
            }
            else{
                ans *= 3;
                ans %= mod;
                preType = 'B';
            }
            id += 2;
        }
    }

    cout << ans << endl;
}

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

namespace ConsoleApp15
{
    class Class339
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];

            var div = new List<int>();
            for(int i = 1; i <= Math.Sqrt(M); i++)
            {
                if (M % i == 0)
                {
                    div.Add(i);
                    div.Add(M / i);
                }
            }
            div.Sort();
            Console.WriteLine(div.Where(x=>x<=M/N).Last());
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,k,s;
  cin>>n>>k>>s;
  vector<ll> v(n);
  if(s!=1000000000)
  {
  for(int i=0;i<k;i++)
  {
      v[i]=s;
  }
  for(int i=k;i<n;i++)
  {
      v[i]=s+1;
  }
  }
  else
  {
     for(int i=0;i<k;i++)
  {
      v[i]=s;
  }
  for(int i=k;i<n;i++)
  {
      v[i]=1;
  }
  }
  for(int i=0;i<n;i++)
  {
      cout<<v[i]<<" ";
  }
  cout<<endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	for(int i = 0; i <= n; ++i) {
		if(i * 108 / 100 == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
char s[20];
int main()
{
	scanf("%s",s+1);
    for(int i=1;i<=19;i++)if(s[i]==',')printf(" ");else printf("%c",s[i]);
    printf("\n");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int x=b*10+c;
	if(x%4==0)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val l = readLine()!!.split(' ').map { it.toInt() }
    val n = l[0]
    var x = l[1]/1000 - n
    for (a in 0..n) {
        for (b in 0..(n-a)) {
            if (9*a+4*b == x) {
                println("$a $b ${n-a-b}")
                return
            }
        }
    }
    println("-1 -1 -1")
}


Measured memory_bytes: 38468
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=10000007;

int main() {
  int64_t H,W;
  cin>>H>>W;
  int64_t a=H*W;
  if(a%2==0)a/=2;
  else a=(a+1)/2;
  if(H!=1&&W!=1)cout<<a;
  else cout<<1;

  
  
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, INF))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n = 1000000;
  int INF = 1e9;
  vec dp1(n+1, INF), dp2(n+1, INF);
  vec simen, simen_odd;
  REP(i,1,200){
    int tmp = i*(i+1)*(i+2)/6;
    if(tmp>1000000) break;
    simen.pb(tmp);
    if(tmp%2==1) simen_odd.pb(tmp);
  }
  dp1[0]=0;
  dp2[0]=0;

  REP(i,1,1000000){
    rep(j,simen.size()){
      if(i-simen[j]>= 0) chmin(dp1[i], dp1[i-simen[j]]+1);
    }
    rep(j,simen_odd.size()){
      if(i-simen_odd[j]>= 0) chmin(dp2[i], dp2[i-simen_odd[j]]+1);
    }
  }

  while(1){
    int q;
    cin >> q;
    if(q==0) break;

    prt2(dp1[q], dp2[q]);
  }
}



Measured memory_bytes: 10468
import java.util.Scanner;

public class Main {

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

		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < S.length(); i += 2) {
			sb.append(S.charAt(i));
		}
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 25172
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define reg register
#define inf 0x3f3f3f3f
#define iinf 1e18
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
ll n;
double d,x,ans;
int main()
{
    scanf("%lld%lf%lf",&n,&d,&x);
    for(reg ll i=n;i;i--)
    {
        ans+=d+i*x-0.5*x;
        d=((i*2+2)*d+x*5)/i/2;
        x=(i*2+4)*x/i/2;
    }
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;

    int i = 0;
    int j = 0;

    int ans = 0;
    while(j < n)
    {
        while(j < n && s[j] == '1')
        {
            j++;
        }
        ans = max(ans, j-i);
        while(j < n && s[j] == '0')
        {
            j++;
        }
        k--;
        if(k < 0)
        {
            while(i < n && s[i] == '1')
            {
                i++;
            }
            while(i < n && s[i] == '0')
            {
                i++;
            }
        }
        ans = max(ans, j-i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import heapq

N, M = map(int, input().split())
albeit = []
for i in range(N):
    A, B = map(int, input().split())
    albeit.append((A, B))

albeit.sort(key=lambda x: x[0])

pq = []
j = 0
ans = 0
for i in range(1, M + 1):
    while albeit[j][0] == i:
        heapq.heappush(pq, -albeit[j][1])
        if j < N - 1:
            j += 1
        else:
            break
    if pq:
        ans += -heapq.heappop(pq)

print(ans)


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

using namespace std;

int main(){
	int n, x;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> x;
		a[x-1] = i;
	}
	int sol = 0;
	for(int i = 0; i < n; i++){
		cin >> x;
		sol += x;
	}
	for(int i = 0; i < n-1; i++){
		cin >> x;
		if(a[i+1] == a[i]+1) sol += x;
	}
	cout << sol << "\n";
	return 0;
}


Measured memory_bytes: 256
mod=1000000007
n=int(input())
a=input()

d=[0]
for i in range(1,n):
    if a[i-1]==a[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]==1 and d[i]==0:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

Measured memory_bytes: 38256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

inline int ceiling(int n, int d) {
	return n % d == 0 ? n / d : n / d + 1;
}

int count_pattern(int sum, int max) {
	if (max * 2 < sum)return 0;
	if (sum <= max)return sum + 1;
	return max - (sum - max) + 1;
}

int main() {
	int K, S; cin >> K >> S;
	auto count = 0;
	for (size_t i = 0; i <= min(K, S); i++) {
		count += count_pattern(S - i, K);
	}
	cout << count << endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[30][30];
ll B[30];

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    REP(i, M)
    {
        cin >> B[i];
    }
    ll sum = 0;
    REP(i, N)
    {
        int s = 0;
        REP(j, M)
        {
            ll a;
            cin >> a;
            s += a * B[j];
        }
        if (s + C > 0)
            sum++;
    }
    cout << sum << endl;
    return 0;
}

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

#define int long long

mt19937 rng ((int) chrono::steady_clock::now().time_since_epoch().count());


typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int mod = 1e9+7;
const int ms = 2e5+5;
const int inf = 0x3f3f3f3f;

int n, t[2 * ms];

void update(int p, int value) {
  for(t[p += n] = value; p > 1; p >>= 1) t[p>>1] = (t[p] + t[p^1]) % mod;
}

int query(int l, int r) {
  int res = 0;
  for(l += n, r += n+1; l < r; l >>= 1, r >>= 1) {
    if(l&1) res = (res + t[l++]) % mod;
    if(r&1) res = (res + t[--r]) % mod;
  }
  return res;
}

int arr[ms];
int prio[ms];
set<int> exist;

main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int k;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
    prio[i] = 1;
  }
  int cur = 0;
  int hasZero = 0;
  int ans = 0;
  for(int i = 1; i <= k; i++) {
    cur = (cur + query(arr[i], n-1) * prio[i]);
    update(arr[i], prio[i]);
  }
  if(cur == 0) hasZero = 1;
  else ans++;
  for(int i = k+1; i <= n; i++) {
    int j = i - k;
    update(arr[j], 0);
    int ch = 0;
    int lo = query(0, arr[j]) * prio[j];
    int hi = query(arr[i], n-1) * prio[i];
    cur = (cur + hi - lo);
    update(arr[i], prio[i]);
    // exist.insert(cur);
    if(cur && (lo || hi)) ans++;
    hasZero = hasZero || (cur == 0);
  }
  cout << ans+hasZero << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    while(op!='?'){
      if (op == '+'){
        cout << a+b << endl;
      }
      else if (op == '-'){
        cout << a-b << endl;
      }
      else if (op == '*'){
        cout << a*b << endl;
      }
      else if (op == '/'){
        cout << a/b << endl;
      }
      cin >> a >> op >> b;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int dp[200000];
    int h[200000];

    int n,k;
    cin >> n >> k;
    for(int i=1;i<n+1;i++){
        cin >> h[i] ; 
    }
    for (int j=1;j<k+2;j++){
        dp[j] = abs(h[j]-h[1]);
    }

    if (n < k+2){
        cout << dp[n] << endl;
    }else{


    for(int i=k+2;i<n+1;i++){
        int min_diff = 1000000007;
        for (int j=1;j<k+1;j++){
            int tmp = dp[i-j] + abs(h[i]-h[i-j]);
        
            if ( tmp< min_diff){
                min_diff = tmp;
            }
        }

        dp[i] = min_diff;

    }

    cout << dp[n] << endl;
    }
}



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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int h, w;
    cin >> h >> w;
    if (w == 1 or h == 1) cout << 1 << endl;
    else cout << ((h * w) + 1) / 2 << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	vector<char> a, b;
	for(int i = 0; i < s.size(); ++i){
		if(i + 2 < s.size() && s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 'w'){
			a.push_back(0);
			i += 2;
		}else{
			a.push_back(s[i]);
		}
	}
	while(true){
		bool modified = false;
		b.clear();
		for(int i = 0; i < a.size(); ++i){
			if(
				i + 4 < a.size() && a[i] == 'm' &&
				a[i + 1] == 0 && a[i + 2] == 'e' &&
				a[i + 3] == 0 && a[i + 4] == 'w')
			{
				modified = true;
				b.push_back(0);
				i += 4;
			}else if(
				i + 3 < a.size() && a[i] == 'm' &&
				a[i + 1] == 0 && a[i + 2] == 'e' &&
				a[i + 3] == 'w')
			{
				modified = true;
				b.push_back(0);
				i += 3;
			}else if(
				i + 3 < a.size() && a[i] == 'm' &&
				a[i + 1] == 'e' && a[i + 2] == 0 &&
				a[i + 3] == 'w')
			{
				modified = true;
				b.push_back(0);
				i += 3;
			}else{
				b.push_back(a[i]);
			}
		}
		a.swap(b);
		if(!modified){ break; }
	}
	cout << (a.size() == 1 && a[0] == 0 ? "Cat" : "Rabbit") << endl;
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
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;
}

int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int e = b * d;
	long long int f = b * c;
	long long int g = a * c;
	long long int h = a * d;
	cout << max(max(e, f), max(g, h));
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int like[30][30];

int main() {
  int N, M; cin >> N >> M;
  rep(i,N) {
    int k; cin >> k;
    rep(j,k) {
      int a; cin >> a;
      --a;
      like[i][a] = true;
    }
  }
  int ans = 0;
  rep(j,M) {
    bool alllike = true;
    rep(i,N) {
      if (!like[i][j]) alllike = false;
    }
    if (alllike) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++) {
        int a;cin >> a;
        if(s.count(a)) s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;

    return 0;
}

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


bool isPrime(int number) {
    for(int i = 2; i < number; i++) {
      if(number % i == 0) return false;
    }
  return true;
}

int main() {
  int num; cin >> num;
  
  int ans = num;
  while(!isPrime(ans)) {
    ans++;
  }
  
  cout << ans << endl;
  
  return 0; 
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) {  
        try (Scanner sc = new Scanner(System.in)) { 
            String line = sc.nextLine(); 
            String answer = ""; 
            int length = line.length(); 
            for (int i = 0; i < length; i++) { 
                char ch = line.charAt(i); 
                if(Character.isLowerCase(ch) == true){
                    ch = Character.toUpperCase(line.charAt(i));
                } else if(Character.isLowerCase(ch) == false){
                    ch = Character.toLowerCase(line.charAt(i));
                }
                answer = answer + ch;
            } 
            System.out.println(answer); 
        } 
    }
}



Measured memory_bytes: 31500
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;


bool check(string &s1, string &s2, int pos) {
  int l1 = s1.size();
  int l2 = s2.size();
  if (pos >= 0) {
    for (int i = 0; i < min(l1-pos, l2); ++i) {
      char c1 = s1[i+pos];
      char c2 = s2[i];
      if (c1 == '?' || c2 == '?' || c1 == c2) continue;
      return false;
    }
  }
  else {
    pos = -pos;
    for (int i = 0; i < min(l1, l2-pos); ++i) {
      char c1 = s1[i];
      char c2 = s2[i+pos];
      if (c1 == '?' || c2 == '?' || c1 == c2) continue;
      return false;
    }
  }
  return true;
}

int main() {
  vector<string> ls(3);
  cin >> ls[0] >> ls[1] >> ls[2];
  int m = ls[0].size()+ls[1].size()+ls[2].size();
  int ans = m;
  vector<set<int>> checks(3);
  for (int j = 0; j < 3; ++j) {
    string &s1 = ls[j];
    string &s2 = ls[(j+1)%3];
    string &s3 = ls[(j+2)%3];
    int l1 = s1.size();
    int l2 = s2.size();
    int l3 = s3.size();
    for (int i = -l2+1; i < l1; ++i) {
      if (check(s1, s2, i)) {
        int l = min(0, i);
        int r = max(l1 ,l2+i);
        ans = min(ans, r-l+l3);
        checks[j].insert(i);
      }
    }
    // cerr << j << ":";
    // for (int c : checks[j]) {
    //   cerr << c << " ";
    // }
    // cerr << endl;
  }
  for (int j = 0; j < 3; ++j) {
    string &s1 = ls[j];
    string &s2 = ls[(j+1)%3];
    string &s3 = ls[(j+2)%3];
    int l1 = s1.size();
    int l2 = s2.size();
    int l3 = s3.size();
    for (int c1 : checks[j]) {
      for (int c2 : checks[(j+1)%3]) {
        int c3 = c1+c2;
        int l = min(0, min(c1, c3));
        int r = max(l1, max(l2+c1, l3+c3));
        if (c3 <= -l3 || c3 >= l1) {
          ans = min(ans, r-l);
          continue;
        }
        if (checks[(j+2)%3].find(-c3) != checks[(j+2)%3].end()) { 
          // cerr << r-l << " " << j << " " << c1 << " " << c2 << " " << c3 << endl;
          ans = min(ans, r-l);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
from sys import stdin
x = int(stdin.readline().rstrip())
k = True
a = 0
while k:
    b = a**5 - x
    c = False
    if b < 0:
        b *= (-1)
        c = True
    d = int(b**(1/5))    
    if d ** 5 == b:
        k = False
        break
    a += 1
if c:
    d *= -1
print(a,d)

Measured memory_bytes: 79092
#include <bits/stdc++.h>
 
#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif
 
 
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
 
using namespace std;
 
#define INF 1000000000


class Main{
public:
	ll m, n, c;
	vl vet1;
	vector<vl> vet2;
	ll res;
	Main(){
		cin >> n >> m >> c;
		vet1.resize(m);
		vet2.resize(n, vl(m));
		res = 0;
		for(auto&p:vet1){
			cin >> p;
		}
		for(auto&p:vet2){
			ll aux = c;
			for(int i = 0; i < m; ++i){
				cin >> p[i];
				aux += p[i] * vet1[i];
			}
			if(aux > 0){
				res++;
			}
		}
		cout << res << endl;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	Main MAIN;
	
	return 0;
}

Measured memory_bytes: 256