akhauriyash/Code-Regression huggingface dataset:
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[100001],v2;

    int visited[100001],dp[100001],ar[100001],ans;

    void dfs(int i)
    {
        //cout<<i<<endl;
        visited[i]=1;
        for(int j=0;j<v[i].size();++j)
            if(visited[v[i][j]]==0)
                dfs(v[i][j]);
        int maxi=0;
        for(int j=0;j<v[i].size();++j)
        {
            maxi=max(maxi,dp[v[i][j]]);
        }
        dp[i]=1+maxi;
        ans=max(ans,1+maxi);
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,m,i,j,a,b;
            cin>>n>>m;
            for(i=1;i<=m;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                ar[b]++;
            }
            for(i=1;i<=n;++i)
            {
                if(ar[i]==0)
                    dfs(i);
            }
            cout<<ans-1<<endl;
        }
        return 0;
    }


Measured memory_bytes: 11648
#include<iostream>
using namespace std;
 
int main(void){
int n,m,l;
cin>>n>>m>>l;
int a[200][200];
int b[200][200];
long long c[200][200]={};
 
for(int i=1;i<=n;i++){
for(int g=1;g<=m;g++){
cin>>a[i][g];
}}
for(int i=1;i<=m;i++){
for(int g=1;g<=l;g++){
cin>>b[i][g];
}}
 
for(int h=1;h<=l;h++){
for(int i=1;i<=n;i++){
for(int g=1;g<=m;g++){
c[i][h]+=a[i][g]*b[g][h];
}}}
 
for(int i=1;i<=n;i++){
for(int g=1;g<=l;g++){
cout<<c[i][g];
if(g<l){cout<<" ";}
}
cout<<endl;
}
 
return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

int D;
vector<int> c(26);
vector<vector<int>> s;
vector<int> spa(26,0);//経過日数
vector<int> t;
vector<set<int>> schedule(26);//各コンテストが何日目に開催されるか
ll contest(int day,int x){//day日にコンテストxを開催した時の満足度の増加量 1-indexed
    ll now=s.at(day-1).at(x-1);
    rep(i,26){
        if(i==x-1){
            spa.at(i)=0;
            continue;
        }
        spa.at(i)++;
        now-=spa.at(i)*c.at(i);
    }
    return now;
}

int main() {
    std::chrono::system_clock::time_point  start, end; // 型は auto で可
 start = std::chrono::system_clock::now();

    cin>>D;
    rep(i,26)cin>>c.at(i);
    s.resize(D,vector<int>(26));
    rep(i,D)rep(j,26){cin>>s.at(i).at(j);}
    t.resize(D);

    //rep(i,D)cin>>t.at(i);
    /*rep(i,D){
        t.at(i)=rand()%26+1;
    }*/
    rep(i,D){
        rep(j,26){
            if(s.at(i).at(j)>s.at(i).at(t.at(i))){
                t.at(i)=j;
            }
        }
        t.at(i)++;
    }

    rep(i,26){
        schedule.at(i).insert(0);
    }
    rep(i,D){
        schedule.at(t.at(i)-1).insert(i+1);
    }
    rep(i,26){
        schedule.at(i).insert(D+1);
    }
    ll ans=0;
    rep(i,D){
        ans+=contest(i+1,t.at(i));
        //cout<<ans<<endl;問題A用
    }
    //改善前のansがもとまっている

    double elapsed;
    
    while(elapsed<500){//時間が許す限り
        int d,q;
        //cin>>d>>q;
        d=rand()%D+1;
        q=rand()%26+1;
        ll oldans=ans;

        int x=t.at(d-1);
        t.at(d-1)=q;
        int bx,nx;
        auto p=lower_bound(schedule.at(x-1).begin(),schedule.at(x-1).end(),d);
        p--;
        bx=*p;
        p++;p++;
        nx=*p;
        schedule.at(x-1).erase(d);
        int bq,nq;
        auto itr=lower_bound(schedule.at(q-1).begin(),schedule.at(q-1).end(),d);
        nq=*itr;
        itr--;
        bq=*itr;
        schedule.at(q-1).insert(d);
        ans+=s.at(d-1).at(q-1)-s.at(d-1).at(x-1);
        ans+=(d-bq)*(nq-d)*c.at(q-1);
        ans-=(d-bx)*(nx-d)*c.at(x-1);
        //cout<<ans<<endl;
        if(ans<oldans){
            schedule.at(x-1).insert(d);
            schedule.at(q-1).erase(d);
            ans=oldans;
        }
        end = std::chrono::system_clock::now();  // 計測終了時間
        elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    }
    rep(i,D){
        cout<<t.at(i)<<endl;
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> S(n);
    REP(i,n) cin >> S[i];

    int q;
    cin >> q;
    vector<int> T(q);
    REP(i,q) cin >> T[i];

    int count = 0;
    REP(i, q){
        if(binary_search(ALL(S), T[i])) count ++;

    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    int n;
    cin>>n;
    readv(a,n);
    map<int, int> dangling;
    int ways=0;
    for(int i=0;i<n;i++)
    {
        int sm = i - a[i];
        int df=  i + a[i];
        ways +=dangling[sm];
        dangling[df]++;
    }
    cout<<ways<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 27476
#include <iostream>
#include <algorithm>

using namespace std;

int N;
long long votes_T = 1, votes_A = 1;

void solve() {
    long long T, A, a, t, times;
    for(int i = 0; i < N; i++) {
        cin >> T >> A;
        a = votes_A / A;
        if(votes_A % A) a++;
        t = votes_T / T;
        if(votes_T % T) t++;        
        times = max(a, t);
        votes_T = times * T; votes_A = times * A;
    }
    cout << votes_T + votes_A << endl;
}

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

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    char c;
    cin >> c;
    cout << (isupper(c) ? "A" : "a") << endl; 
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 3640
//in the name of allah                
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+10;
bool vis[N] , col[N] , bp;
vector<int> g[N];
int dfs(int v , int C){
        int ret=0;
        col[v] = C;
        C = 1-C;
        vis[v] = true;
        for(auto u : g[v])
                if(!vis[u])
                        ret += dfs(u , C);
                else if(col[u] != C)
                        bp = false;
        return ret+1;
}

int32_t main(){
        ios_base::sync_with_stdio(false);cin.tie(NULL);
        int n , m;cin >> n >> 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);
        }
        ll c=0 , c2=0 , c1=0;
        for(int i=0 ; i<n ; i++){
                if(!vis[i]){                       
                        bp = true;
                        int sz = dfs(i , 0);
                        if(sz == 1){
                                c1 ++;                            
                        }else if(bp){                               
                                c2 ++;
                        }else
                                c ++;
                }
        }      
        cout << 2*c2 + c + c2*(c2-1)*2 + c*(c-1) + 2*c*c2 + 2*c1*(n-c1) + c1*c1 << "\n";
        return 0; 
}

Measured memory_bytes: 11776
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int K,X;
    cin>>K>>X;
    if(X<=500*K)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3528
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.Char

step n (acc,cnt) x
    | (n `div` 2) == (acc + x) = (acc+x, cnt+1)
    | otherwise = (acc+x, cnt)

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    ys <- VUM.replicate (10^5+1) 0 :: IO (VUM.IOVector Int)
    VU.forM_ xs $ \x -> do
        VUM.modify ys (+1) x
    ys' <- VU.unsafeFreeze ys :: IO (VU.Vector Int)
    print $ snd $ VU.foldl' (step n) (0,0) ys'

Measured memory_bytes: 7676
h,w = map(int,input().split())
lines = []
for i in range(h):
  line = "." + input() + "."
  lines.append(line)
ans = "Yes"
ss = "." * (w+2)
lines.append(ss)
lines.insert(0,ss)
for j in range(1,h+1):
  for l in range(1,w+1):
    if lines[j][l] == "#" and lines[j-1][l] == "." and lines[j+1][l] == "." and lines[j][l-1] == "." and lines[j][l+1] == ".":
      ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int flag = 0;
    for(int i=1; i<n; i++){
        if(a[i] == a[i-1]) flag = 1;
    }
    if(flag) cout << "NO";
    else cout << "YES";
    return 0;
}

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

int main() {
    long long n, X, ans=10000000000,r,x,y;
    cin >> n >> X;
    vector<long long> vec(n),dis(n);
    for(int i=0; i<n; i++) cin >> vec.at(i);
    vec.push_back(X);
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++) {
        dis.at(i)=vec.at(i+1)-vec.at(i);
        ans=min(ans,dis.at(i));
    }
    for(int i=0; i<n; i++) {
        x=dis.at(i);
        y=ans;
        while(y>0) {
            r=x%y;
            x=y;
            y=r;
        }
        ans=x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int max(int cnt, ...);
inline int min(int cnt, ...);
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin>>a>>b>>c;
	swap(a, b);
	swap(a, c);
	cout<<a<<' '<<b<<' '<<c<<endl; 
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


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

const int maxn=19;
const int mo=1000000007;

int n,m;
int a[maxn],f[maxn][1<<16],fac[1<<16|1],ifac[1<<16|1];

inline int pow(int a,int b,int p){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1)ans=1ll*ans*a%p;
	return ans;
}

inline void prework(int n){
	fac[0]=ifac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mo;
	ifac[n]=pow(fac[n],mo-2,mo);
	for(int i=n-1;i;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mo;
}

inline int C(int n,int m){
	if(n<m||m<0)return 0;
	return 1ll*fac[n]*ifac[m]%mo*ifac[n-m]%mo;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>a[i];
	prework(1<<n);
	f[m+1][0]=1;
	for(int i=m;i>=1;i--)
		for(int j=0;j<(1<<n);j++){
			f[i][j]+=f[i+1][j],f[i][j]%=mo;
			for(int k=0;k<n;k++){
				if((j>>k)&1)continue;
				f[i][j+(1<<k)]+=1ll*f[i+1][j]*C((1<<n)-j-a[i],(1<<k)-1)%mo*fac[1<<k]%mo;
				f[i][j+(1<<k)]%=mo;
			}
		}
	long long ans=0;
	for(int i=0;i<(1<<n);i++){
		int cnt=0;
		for(int j=i;j;j-=j&-j)++cnt;
		if(cnt&1)ans+=mo-1ll*f[1][i]*fac[(1<<n)-i-1]%mo;
		else ans+=1ll*f[1][i]*fac[(1<<n)-i-1]%mo;
	}
	cout<<ans%mo*(1<<n)%mo<<'\n';
	return 0;
}

Measured memory_bytes: 8212
#include <iostream>

int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a==b) {
    if (a!=c) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
  }
  else {
    if (a==c || b==c) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3596
<?php
list($s) = strs();
list($k) = ints();
for ($i = 0; $i < 26; ++$i) $a2n[chr(97 + $i)] = $i;
$n = strlen($s);
// aに出来るものをaにする
for ($i = 0; $i < $n; ++$i) {
    $x = $a2n[$s[$i]];
    if ($x === 0) continue;
    if ($k >= 26 - $x) {
        $s[$i] = 'a';
        $k -= 26 - $x;
    }
}
// 残ったものは全部最後の文字にふる
if ($k > 0) $s[$n - 1] = chr(97 + ($a2n[$s[$n - 1]] + $k) % 26);
echo $s . PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


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

int main(){
  int n;
  cin>>n;
  int a=0;
  int b=0;
  vector<int> c(n);
  for(int i=0;i<n;i++){
      cin>>c[i];
  }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(int i=0;i<n;i++){
      if(i%2==0) a+=c[i];
      else b+=c[i];
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 3608
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n,q;
std::vector<ll> val;
ll ans[maxn];

void solve()
{
	scanf("%d%d",&n,&q);
	val.push_back(n);

	for(int i=1;i<=q;i++)
	{
		ll x;
		scanf("%lld",&x);

		while(val.size()&&val.back()>=x)
		{
			val.pop_back();
		}
		val.push_back(x);
	}
	map<ll,ll>app;
	app[val.back()]=1;

	while(val.size())
	{
		ll k=val.back();
		val.pop_back();

		map<ll,ll>::iterator var = app.upper_bound(k);
		map<ll,ll>::iterator it;
		for(it=var;it!=app.end();it++)
		{
			ll x= it->first;
			ll y= it->second;

			ll p1 = x/k;
			ll p2 = x%k;

			app[p2]+=y;
			app[k]+=y*p1;
		}
		app.erase(var,app.end());
	}
	for(int i=n;i>=1;i--)
	{
		ans[i]=app[i]+ans[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n", ans[i]);
	}
}


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

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

int main(){

	int n, t, ans;

	while(cin >> n) {
		ans = 0;
		for(int a = 0; a < 10; a++) {
			for(int b = 0; b < 10; b++) {
				for(int c = 0; c < 10; c++) {
					t = n - a - b - c;
					if(t >= 0 && t <= 9)
						ans++;
				}
			}
		}
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    char s[5000];
    int i,j,h,K;

    scanf("%s",s);
    scanf("%d",&K);

    char sub[K+1][strlen(s)+1],tmp[strlen(s)+1];
    int a=0,b,flg=1;

    for(i=0;i<K+1;i++){
        strcpy(sub[i],"~");
    }

    for(i=0;i<strlen(s);i++){
        for(j=i;j<i+6;j++){
            a=0;
            for(h=i;h<=j;h++){
                sub[K][a] = s[h];
                a++;
            }
            sub[K][a] = '\0';

            for(b=0;b<K;b++){
                if(strcmp(sub[b], sub[K])==0){
                    flg = 0;
                }
            }
            if(flg != 0){    
                for(a=1;a<K+1;a++){
                    for(b=1;b<K+1;b++){
                        if(strcmp(sub[b-1], sub[b])>0){
                            strcpy(tmp, sub[b-1]);
                            strcpy(sub[b-1], sub[b]);
                            strcpy(sub[b], tmp);
                        }
                    }
                }
            }
            flg=1;

        }
    }

    printf("%s\n",sub[K-1]);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n,0);
    ll total=0;
    rep(i,n)
    {
        ll t;
        cin>>t;
        total+=t;
        a[i]=total;
    }
    map<ll,ll> cc;
    rep(i,n)
    {
        cc[a[i]]++;
    }
    ll ans=0;
    for(auto v:cc)
    {
        if(v.first==0)
        {
            ans+=v.second;
        }
        ans+=(v.second)*(v.second-1)/2;
    }
    cout<<ans;

}


Measured memory_bytes: 17016
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        
        
        while(sc.hasNextLine()){
            String temp = sc.nextLine();
            
            
            
            temp = temp.replaceAll("apple","-");
            temp = temp.replaceAll("peach","apple");
            temp = temp.replaceAll("-","peach");
            System.out.println(temp);
        }
    }
}

Measured memory_bytes: 17104
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int a[] = new int[size];
        int o = 0;
        int b = 0;

        for (int i=0; i<a.length; i++) {
            a[i] = sc.nextInt();
        }

        for (int k=0; k<a.length; k++) {
            if (a[k] % 2 == 0){
                o++;
                if (a[k] % 3 == 0 || a[k] % 5 == 0) {
                b++;
                }
            }
        }

        if (o == b) {
            System.out.println("APPROVED");
        }
        else {
            System.out.println("DENIED");
        }
    }
}


Measured memory_bytes: 24020
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int X = 0;
    int T = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      T += a[i];
    }
    double average = (double)T / (double)N;
    if((Math.ceil(average) - average) >= (average - Math.floor(average))) {
      X = (int)Math.floor(average);
    } else {
      X = (int)Math.ceil(average);
    }
    int cost = 0;
    for(int i = 0; i < N; i++) {
      cost += (int)(Math.pow(a[i] - X, 2));
    }
    System.out.println(cost);
  }
}

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

#define sz size
#define pb push_back
#define F first
#define S second
#define mp make_pair

const int N = 3e3 + 123;

string s, t;
int d[N][N];
pair <int, int> p[N][N];
vector <char> ans;
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> s >> t;
	s = "#" + s;
	t = "#" + t;
	for(int i = 1; i < s.sz(); ++i) {
		for(int j = 1; j < t.sz(); ++j) {
			if(s[i] == t[j]) {
				d[i][j] = d[i - 1][j - 1] + 1;
				p[i][j] = mp(i - 1 ,j - 1);
			}
			else {
				if(d[i - 1][j] >= d[i][j - 1]) {
					d[i][j] = d[i - 1][j];
					p[i][j] = mp(i - 1, j);
				}
				else {
					d[i][j] = d[i][j - 1];
					p[i][j] = mp(i, j - 1);
				}
			}
		}
	}
	int n = s.sz() - 1, m = t.sz() - 1;
	while(n > 0 && m > 0) {
		if(s[n] == t[m]) ans.pb(s[n]);
		int k = n;
		n = p[k][m].F;
		m = p[k][m].S;
	}
	for(int i = ans.sz() - 1; i >= 0; -- i) cout << ans[i];
}

Measured memory_bytes: 110976
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct moonlight{
	double eff;
	char l[21];
};
int main(void){
	struct moonlight data[50],tmp;
	int n,p,a,b,c,d,e,f,s,m,i,j;
	double time,income;
	while(1){
		scanf("%d",&n);
		if(!n){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%s %d %d %d %d %d %d %d %d %d",data[i].l,&p,&a,&b,&c,&d,&e,&f,&s,&m);
			time=a+b+c+(d+e)*m;
			income=s*f*m-p;
			data[i].eff=income/time;
		}
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(data[j-1].eff<data[j].eff||data[j-1].eff==data[j].eff&&strcmp(data[j-1].l,data[j].l)>0){
					tmp=data[j-1];
					data[j-1]=data[j];
					data[j]=tmp;
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%s\n",data[i].l);
		}
		puts("#");
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    int n,m;cin>>n>>m;
    vector<int> a(n);
    int i,j,k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int total = accumulate(a.begin(),a.end(),0);
    for(i=0;i<n;i++){
        if(total>(4*m*a[n-1-i])) break;
        if(i>=m) break;
    }

    if(i>=m) cout<<"Yes\n";
    else cout<<"No\n";

    return;
}

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


Measured memory_bytes: 256
// n×mの行列 A と m×l の行列 B を入力し、それらの積である n×l の行列 C を出力するプログラムを作成してください。

import java.util.Scanner;

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

		// n, m, lの読み込み
		String scan_str = scan.nextLine();
		String[] first_str = scan_str.split(" ");
		int n = Integer.parseInt(first_str[0]);
		int m = Integer.parseInt(first_str[1]);
		int l = Integer.parseInt(first_str[2]);

		String[] m_count = new String[m];
		String[] l_count = new String[l];

		long[][] A = new long[n][m];
		long[][] B = new long[m][l];
		long[][] C = new long[n][l];

		// ループカウンタ
		int i = 0;
		int j = 0;
		int k = 0;

		// 行列 A の読み込み
		for(i=0; i<n; i++){
			scan_str = scan.nextLine();
			m_count = scan_str.split(" ");
			for(j=0; j<m; j++){
				A[i][j] = Long.parseLong(m_count[j]);
			}
		}

		// 行列 B の読み込み
		for(i=0; i<m; i++){
			scan_str = scan.nextLine();
			l_count = scan_str.split(" ");
			for(j=0; j<l; j++){
				B[i][j] = Long.parseLong(l_count[j]);
			}
		}
		// 行列 C の算出
		for(i=0; i<n; i++){
			for(j=0; j<l; j++){
				for(k=0; k<m; k++){
					C[i][j] = C[i][j] + (A[i][k] * B[k][j]);
				}
				if(j == (l-1)){
					System.out.println(C[i][j]);
				}else {
					System.out.print(C[i][j] + " ");
				}
			}
		}
	}
}


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

int main() {
	long long int k,n;
	cin>>k>>n;
	long long int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];

	int diff = 0;
	for(int i=0;i<n-1;i++){
		if(arr[i+1]-arr[i] > diff)
			diff = arr[i+1]-arr[i];
	}
	if((k - arr[n-1])+arr[0] > diff)
			diff = (k - arr[n-1])+arr[0];
	cout<<k-diff<<endl;
	return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int IN[200000];
vector<int> G[200000];
bool used[200000];
int T[200000];
vector<int> vs;

int dfs1(int x) {
  if (used[x]) return x;
  used[x] = true;
  return dfs1(IN[x]);
}
int mex1(set<int> s) {
  int i = 0;
  while (true) {
    if (s.find(i) == s.end()) return i;
    i++;
  }
}
int mex2(set<int> s) {
  int i = 0;
  int ctr = 0;
  while (true) {
    if (s.find(i) == s.end()) {
      ctr++;
      if (ctr == 2) return i;
    }
    i++;
  }
}

int dfs2(int x, int p) {
  if (T[x] != -1) return T[x];
  set<int> V;
  for (int t : G[x]) {
    if (t == p) continue;
    V.insert(dfs2(t, -1));
  }
  return mex1(V);
}
set<int> dfs2s(int x, int p) {
  set<int> V;
  for (int t : G[x]) {
    if (t == p) continue;
    V.insert(dfs2(t, -1));
  }
  return V;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    int p;
    cin >> p;
    p--;
    G[p].pb(i);
    IN[i] = p;
  }
  int V = dfs1(0);
  int s = V;
  vs.pb(V);
  int ctr = 0;
  while (true) {
    s = IN[s];
    if (s == V) break;
    vs.pb(s);
    ctr++;
    if (ctr>N) return 1;
  }
  assert(IN[vs.back()] == V);

  rep(i, N) T[i] = -1;
  set<int> mp = dfs2s(V, vs.back());
  vector<int> cand;
  cand.pb(mex1(mp));
  cand.pb(mex2(mp));
  for (int w : cand) {
    rep(i, N) T[i] = -1;
    T[V] = w;
    int last = -1;
    for (int x : vs) {
      if (x == V) continue;
      last = dfs2(x, -1);
      T[x] = last;
    }
    set<int> xmp(mp);
    xmp.insert(last);
    if (mex1(xmp) == w) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}


Measured memory_bytes: 12788
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
using namespace std;

bool judge(string &str) {
  stack<char> s;
  char c;
  for(int i = 0; i < str.size(); ++i) {
    if(str[i] == '(' || str[i] == '[') {
      s.push(str[i]);
    } else if(str[i] == ')') {
      if(s.empty()) return false;
      c = s.top();
      s.pop();
      if(c != '(') return false;
    } else if(str[i] == ']') {
      if(s.empty()) return false;
      c = s.top();
      s.pop();
      if(c != '[') return false;
    }
  }
  return s.empty();
}

int main() {
  string str;
  while(getline(cin, str) && str != ".") {
    if(judge(str)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int Ah,As,Bh,Bs;
	cin>>Ah>>As>>Bh>>Bs;
	
	for (int i=1;;++i){
		Bh=Bh-As;
		if (Bh<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		Ah=Ah-Bs;
		if (Ah<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) ((a,0,sizeof(a)))
typedef long long ll;
int n,m,a,b;
int main(){
    scanf("%d%d%d%d",&n,&m,&a,&b);
    for(int i=0,x;i<n;i++){
        scanf("%d",&x);
        a=max(a,x);
    }
    for(int i=0,x;i<m;i++){
        scanf("%d",&x);
        b=min(x,b);
    }
    printf(a<b?"No War\n":"War\n");
    return 0;
}

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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail =(tail+1)%LEN;
}

P dequeue(){
  P s;
  s = Q[head];
  head = (head+1)%LEN;
  return s;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head = 1;
  tail = n+1;
  /*printf("処理を開始\n");  */ //dedug
  while(n!=0){
    u = dequeue();
    c = u.t - q;
    
    if(c <= 0){
      elaps += u.t;
	printf("%s %d\n",u.name,elaps);
      n--;
    }
    else{
      u.t -= q; 
      elaps += q;
      enqueue(u);
    }
    
  }
  
  return 0;
}



Measured memory_bytes: 11856
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();
		}

		int k = a[0];
		int count = 0;

		while(k != 2 && count <= N) {
		k = a[k-1];
		count += 1;
		}

		if(k==2) {
			System.out.println(count + 1);
		}else {
			System.out.println(-1);
		}

	}

}


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

using namespace std;

const int MAX = 30001;
int T;
vector<int> P;
bool prime[MAX];

void make(){

  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;
  for(int i = 0; i*i < MAX; i++)
    if(prime[i]) for(int j = 2; i*j < MAX; j++) prime[i*j] = false;

  for(int i = 0; i < MAX; i++)
    if(prime[i]) P.push_back(i);
}
int main(){
  make();
  while(cin >> T && T){
    int ans = 0;

   for(int i = 0; i < P.size()&&P[i] < T; i++)
    for(int j = i; j < P.size()&&P[i]+P[j] < T; j++)
      if(T-P[i]-P[j] >= P[j] && prime[T-P[i]-P[j]] && P[i]+P[j] > T-P[i]-P[j]) ans++;
      
   cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
int n, m, Dp[1010][1010];
char Grid[1010][1010];

const int Mod = 1e9 + 7;

int Solve(int i, int j)
{
    if (i == n-1 && j == m-1) return 1;

    int &ret = Dp[i][j];
    if (ret != -1) return ret;

    int C1 = 0, C2 = 0;
    if (j+1 < m && Grid[i][j+1] == '.') C1 = Solve(i, j+1)%Mod;
    if (i+1 < n && Grid[i+1][j] == '.') C2 = Solve(i+1, j)%Mod;

    return ret = (C1%Mod + C2%Mod)%Mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    memset(Dp, -1, sizeof Dp);

    cin >> n >> m;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
            cin >> Grid[i][j];

    int Answer = Solve(0, 0);
    cout << Answer%Mod << '\n';
    return 0;
}


Measured memory_bytes: 5376
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, K] = nextIntArray()
    const [R,S,P] = nextIntArray()
    const T = next()
    const score = (char) => {
        if(char === 'r') return P
        if(char === 's') return R
        if(char === 'p') return S
    }
    let ans = 0
    for(let i = 0; i<K; i++){
        let game = []
        let pos = i
        while(pos<N){
            game.push(T[pos])
            pos += K
        }
        let sub = 0
        if(game.length > 0){
            for(let i = 0; i<game.length; i++){
                if(game[i] !== game[i-1]){
                    sub += score(game[i])
                } else if(game[i] == game[i-1]){
                    game[i] = "x"
                }
            }
        }
        ans += sub
    }
    console.log(ans)
}

Main()


Measured memory_bytes: 36072
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int m = sc.nextInt();
            if ((n | k | m) == 0)
                break;
            List<Integer> ns = new ArrayList<Integer>();
            for (int i = 1; i <= n; i++)
                ns.add(i);
            int rest = n;
            int i = m - 1;
            while (true) {
                rest--;
                if (rest == 0) {
                    System.out.println(ns.get(i));
                    break;
                }
                ns.remove(i);
                i = (i - 1 + k) % ns.size();
            }
        }
    }
}

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

using namespace std;

vector<int> v;

int zlicz;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int c2 = c;

    for(int i = a; i <= b; i++)
    {


    if(c == 0 && c2 != 0 && c2+i-1 >= b) cout<<i<<endl;
    if(c > 0) {cout<<i<<endl; c--;}

    }


    return 0;
}


Measured memory_bytes: 256
import Data.Set as Set
import Control.Monad

main = do
  n <- read <$> getLine
  xs <- forM [1..n] $ \t -> do
    read <$> getLine
  putStrLn . show $ solve empty xs

solve :: Set Int -> [Int] -> Int
solve set [] = size set
solve set (x:xs) = if x `member` set then solve (delete x set) xs else solve (insert x set) xs


Measured memory_bytes: 71036
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll dp[110][10];
const int MOD = 1000000007;
int main(){
    int H,W,K;cin >> H >> W >> K;K--;
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int bit = 0;bit<1<<(W-1);bit++){
                bool ok = true;
                for(int k=0;k<W-2;k++){
                    if(bit&(1<<k)&&bit&(1<<(k+1)))ok=false;
                }
                if(!ok)continue;
                int nj = j;
                if(bit&(1<<j))nj=j+1;
                if(j>0&&bit&(1<<(j-1)))nj=j-1;
                dp[i+1][nj] = (dp[i+1][nj]+dp[i][j])%MOD;
            }
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}

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

using namespace std;

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

    long long h[n];

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

    long long ans[n];

    memset(ans,-1,sizeof ans);
    ans[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j>=n)break;
            if(ans[i+j]==-1){
                ans[i+j]=abs(h[i]-h[i+j])+ans[i];
                continue;
            }
            ans[i+j]=min(ans[i+j],ans[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<ans[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,c=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
		c=c+a[i]*a[j];
		cout<<c<<endl;
		return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,dp[200005],fix[200005],maxx;
vector <long long> v[200005];
void dfs(long long x,long long y) {
           if(fix[x]==1) return;
           fix[x]=1;
           for(long long i=0;i<v[x].size();i++) {
                      if(v[x][i]==y) continue;
                      dfs(v[x][i],x);
                      dp[x]=max(dp[x],dp[v[x][i]]);
           }
           dp[x]++;
}
int main() {
           cin>>n>>m;
           for(long long i=1;i<=m;i++) {
                      cin>>a>>b;
                      v[a].push_back(b);
           }
           for(long long i=1;i<=n;i++) {
                      if(fix[i]==1) continue;
                      dfs(i,0);
           }
           for(long long i=1;i<=n;i++) {
                      maxx=max(maxx,dp[i]);
           }
           cout<<maxx-1;
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n;
    char ch;
    set<char>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>ch;
        s.insert(ch);
    }
    cout<<(s.size()==3?"Three":"Four")<<endl;
}


Measured memory_bytes: 3636
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

int x,y,z;
multiset<string>S;
multiset<string>::iterator it;

int main()
{
	scanf("%d%d%d",&x,&y,&z);
	for(int i=1;i<=x;i++) S.insert("a");
	for(int i=1;i<=y;i++) S.insert("b");
	for(int i=1;i<=z;i++) S.insert("c");
	while(S.size()>1)
	{
		it=S.end(); it--;
		string ss=(*S.begin())+(*it);
		S.erase(S.begin());
		S.erase(it);
		S.insert(ss);
	}
	cout<<(*S.begin())<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vin a(n);
  rep(i,0,n){
   cin>>a[i];
    a[i]--;
  }
  int c[110000]; rep(i,0,110000) c[i]=0;
  c[0]=1;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int u=q.front();
    int r=a[q.front()];
    q.pop();
    if(c[r]!=0) continue;
    c[r]=1+c[u];
    q.push(r);
   // cout<<r<<endl;
  }
  if(c[1]==0)
  cout<<-1<<endl;
  else{
    cout<<c[1]-1<<endl; 
  }
}

Measured memory_bytes: 4068
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		// 計算
		int result = 0;
		result = (n-1)*(m-1);
		
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 23764
n, m, l = map(int, input().split())

A = []
B = []
C = [[] for i in range(n)]

for i in range(n):
    tmp_row = list(map(int, input().split()))
    A.append(tmp_row)

for i in range(m):
    tmp_row = list(map(int, input().split()))
    B.append(tmp_row)

for i in range(n):
    for bj in zip(*B):
        c = sum(aik * bjk for aik, bjk in zip(A[i], bj))
        C[i].append(c)
        
for i in C:
    print(*i)

Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define CINT(x) int x; cin >> x;
typedef long long int ll;


int main() {
	CINT(x);
	CINT(a);
	CINT(b);
	(x -= a) %= b;
	cout << x << endl;
}

Measured memory_bytes: 256
MOD = 998244353
N, M, K = map(int, input().split())
Mp = [0]*(K+1)
nck = [0]*(K+1)
nck[0] = 1
ans = 0
comb = 1
for i in range(K+1):
  t = 1
  t *= M
  t %= MOD
  t *= pow(M-1, N-1-i, MOD)
  t %= MOD
  t *= comb
  t %= MOD
  ans += t
  ans %= MOD
  comb *= N-1-i
  comb %= MOD
  comb *= pow(i+1, MOD-2, MOD)
  comb %= MOD
  
print(ans)

Measured memory_bytes: 11972
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);
    
    int n; cin>>n;    
    ll aa=1,bb=1;
    
    REP(i,n){
      ll a,b; cin>>a>>b;
      ll k1=aa/a;
      ll k2=bb/b;
      if(aa%a!=0LL) k1++;
      if(bb%b!=0LL) k2++;
      aa=max(k1,k2)*a;
      bb=max(k1,k2)*b;
    }
    
    cout << aa+bb <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
typedef long long LL;
using namespace std;
 
int main(int argc, char **argv) {
	LL w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed;
	cout.precision(9);
	cout << (double) (w * h) / 2. << ' ' << (2 * x == w && 2 * y == h) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;

  int ans = 1;

  char c = s[0];
  FOR(i, 1, n) {
    if(c != s[i]) {
      ans++;
      c = s[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		long r = Long.MAX_VALUE;
		// min(i,j)<=nのルート<=10^6
		for(long i=1; i*i<=n; i++) {
			if(n%i != 0) continue;
			long j = n/i;
			r = Math.min(r, i+j-2);
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
int pre[maxn];
int main() {
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 200000
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  int A[MAX_N];
  int B[MAX_N];
  rep(i, N) {
    cin >> A[i];
    B[i] = A[i] - (i + 1);
  }
  sort(B, B + N);

  int b = B[N / 2];
  int64_t Ans = 0;
  rep(i, N) { Ans += abs(B[i] - b); }
  cout << Ans << endl;
  return 0;
}

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

int main(){
  int64_t X;
  cin >> X;
  for(int i=-118;i<=119;i++){
    for(int j=-119;j<=118;j++){
      if(pow(i,5)-pow(j,5)==X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4064
#include <unordered_map>
  #include <functional>
  #include <algorithm>
  #include <iostream>
  #include <climits>
  #include <vector>
  #include <stack>
  #include <queue>
  #include <map>
  #include <set>
  #define mod 1000000007
  using namespace std;
  #define ll long long int
  void solve() 
{ 
    string s1,s2;
    cin>>s1>>s2;
  
    int n = s1.size(), m = s2.size(); 
    
    int ans = INT_MAX; 
  
    for (int i = 0; i <n - m + 1; i++) { 
        int minRemovedChar = 0; 
  
        for (int j = 0; j < m; j++) { 
            if (s2[j] != s1[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        ans = min(minRemovedChar, ans); 
    } 
  
    cout<<ans; 
} 
  

  int main()
  {
    solve();
  }

Measured memory_bytes: 3592
//
//  main.cpp
//  ABC158C
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int A,B;
    cin>>A>>B;
    int price=1;

    while(price<=1000){
        int tax_8=price*0.08; //消費税8%のとき
        int tax_10=price*0.1; //消費税10%のとき
        if (A==tax_8&&B==tax_10) {
            cout <<price<<endl;
            return 0;
        }
        price++;
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256