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

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 200;
const int mo = 1e9 + 7;

int n, k, ans;
char st[N + 5];
bool mark[N + 5];
int x[N + 5], y[N + 5], r[N + 5];

int binom[N + 5][N + 5];

void init() {
    for(int i = 0; i <= N; ++i) {
        binom[i][0] = binom[i][i] = 1;
        for(int j = 1; j < i; ++j) {
            binom[i][j] = (binom[i-1][j] + binom[i-1][j-1]) % mo;
        }
    }
}

int dp[N + 5][N + 5][N + 5];

int calc(int p, int q) {
    memset(dp, 0, sizeof dp);

    int m = n - (p+q-1) - q;

    dp[0][0][0] = 1;
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j <= p; ++j) {
            for(int l = 0; l <= m; ++l) if(dp[i][j][l]) {
                for(int t = 0; j + t <= p && l + (2*i+1) * t <= m; ++t) {
                    if(t && y[p-j-t+1] < (l-j)/2 + t*i) {
                        break;
                    }

                    (dp[i+1][j + t][l + (2*i+1) * t] += 1ll * binom[j + q + t][t] * dp[i][j][l] % mo) %= mo;
                }
            }
        }
    }

    int res = 0;
    for(int i = 0; i <= m; ++i) {
        res = (res + 1ll * binom[n + 2*p + 1][i + 3*p + 2*q] * dp[m][p][i]) % mo;
    }
    return res;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    init();
    read(n), read(k);
    scanf("%s", st + 1);

    for(int i = 1; i <= k; ++i) 
        if(st[i] == 'r') r[++ r[0]] = i;

    for(int i = 0; i <= r[0]; ++i) {
        for(int j = 0; i+j <= r[0]; ++j) {

            memset(mark, 0, sizeof mark);
            for(int t = 1; t <= i+j; ++ t) mark[r[t]] = true;

            int cur = 0, flag = 0;
            for(int t = 1; t <= i; ++ t) {
                chkmax(cur, r[t]);
                while(cur <= k && (st[cur] == 'r' || mark[cur])) ++ cur;
                if(cur > k) { flag = 1; break; }

                mark[x[t] = cur] = true;
            }
            if(flag) continue;

            for(int t = 1; t <= i; ++ t) {
                y[t] = 0;
                for(int l = x[t]; l <= k; ++ l) {
                    y[t] += !mark[l];
                }
            }
            ans = (ans + calc(i, j)) % mo;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 34176
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let max: u32 = iter.next().unwrap().parse().unwrap();
    let start: u32 = iter.next().unwrap().parse().unwrap();
    let end: u32 = iter.next().unwrap().parse().unwrap();

    let mut result = 0;
    for num in 1..max + 1 {
        let sum = num
            .to_string()
            .chars()
            .map(|char| char.to_digit(10).unwrap())
            .sum::<u32>();
        if start <= sum && sum <= end {
            result += num;
        }
    }
    println!("{}", result);
}

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

int main()
{
	int ans = 0;
	string s;
	while(cin >> s){
		string t(s);
		reverse(t.begin(),t.end());
		if(s == t) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(){
  int R, G;
  scanf("%d %d", &R, &G);
  printf("%d\n", 2*G - R);
  return 0;
}

/*
求めるパフォーマンスをxとすると，
  (R + x)/2 = G
が成り立つ．よって，
  x = 2*G - R
*/


Measured memory_bytes: 128
N=int(input())
AB=[]
takahashi=0
aoki=0
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b,a+b])
AB.sort(key=lambda AB:(AB[2],AB[1],AB[0]),reverse=True)
for i in range(N):
    if i%2==0:
        takahashi+=AB[i][0]
    else:
        aoki+=AB[i][1]
print(takahashi-aoki)

Measured memory_bytes: 31580
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#define LL long long
using namespace std;
const LL mod=1e9+7;
struct node{
	LL y,next;
}a[10010];LL len=0,last[5010];
LL n,f[5010][5010][2],g[5010][2],p[5010];
LL fac[5010],inv[5010],tot[5010];
void pre()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(LL i=2;i<=5000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(LL i=2;i<=5000;i++) fac[i]=(LL)fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
	p[0]=1;for(LL i=2;i<=5000;i++) p[i]=(i-1)*p[i-2]%mod;
	//for(int i=1;i<=10;i++) printf("%lld ",p[i]);printf("\n");
}
LL C(LL m,LL n) {return fac[m]*inv[m-n]%mod*inv[n]%mod;}
void ins(LL x,LL y)
{
	a[++len].y=y;
	a[len].next=last[x];last[x]=len;
}
void dfs(LL x,LL fa)
{
	f[x][1][0]=tot[x]=1;
	for(LL i=last[x];i;i=a[i].next)
	{
		LL y=a[i].y;
		if(y==fa) continue;
		dfs(y,x);
		for(LL j=0;j<=tot[x];j++) g[j][0]=f[x][j][0],g[j][1]=f[x][j][1];
		for(LL j=0;j<=tot[x];j++) f[x][j][0]=f[x][j][1]=0;
		for(LL j=0;j<=tot[x];j++) 
		{
			for(LL k=0;k<=tot[y];k++)
			{
				(f[x][j+k][0]+=g[j][0]*f[y][k][0]%mod)%=mod;
				(f[x][j+k][0]+=g[j][1]*f[y][k][1]%mod)%=mod;
				(f[x][j+k][1]+=g[j][0]*f[y][k][1]%mod)%=mod;
				(f[x][j+k][1]+=g[j][1]*f[y][k][0]%mod)%=mod;
				(f[x][j][1]+=g[j][0]*f[y][k][0]%mod*p[k]%mod)%=mod;
				(f[x][j][1]+=g[j][1]*f[y][k][1]%mod*p[k]%mod)%=mod;
				(f[x][j][0]+=g[j][0]*f[y][k][1]%mod*p[k]%mod)%=mod;
				(f[x][j][0]+=g[j][1]*f[y][k][0]%mod*p[k]%mod)%=mod;
			}
		}
		tot[x]+=tot[y];
	}
	//printf("x %lld:\n",x);
	//printf("0:");for(LL i=0;i<=tot[x];i++) printf("%lld ",f[x][i][0]);printf("\n");
	//printf("0:");for(LL i=0;i<=tot[x];i++) printf("%lld ",f[x][i][1]);printf("\n");
}
int main()
{
	pre();
	scanf("%lld",&n);
	for(LL i=1;i<n;i++)
	{
		LL x,y;scanf("%lld %lld",&x,&y);
		ins(x,y);ins(y,x);
	}
	dfs(1,0);
	LL ans=0;
	for(LL i=0;i<=n;i++)
	{
		(ans+=p[i]*f[1][i][0]%mod)%=mod;
		(ans-=p[i]*f[1][i][1]%mod)%=mod;
	}
	printf("%lld",(ans+mod)%mod);
}

Measured memory_bytes: 390656
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
    i64 a;

    constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
    constexpr i64 &value() noexcept { return a; }
    constexpr const i64 &value() const noexcept { return a; }
    constexpr modcal operator+(const modcal rhs) const noexcept
    {
        return modcal(*this) += rhs;
    }
    constexpr modcal operator-(const modcal rhs) const noexcept
    {
        return modcal(*this) -= rhs;
    }
    constexpr modcal operator*(const modcal rhs) const noexcept
    {
        return modcal(*this) *= rhs;
    }
    constexpr modcal operator/(const modcal rhs) noexcept
    {
        return modcal(*this) /= rhs;
    }
    constexpr modcal &operator+=(const modcal rhs) noexcept
    {
        a += rhs.a;
        if (a >= modulus)
        {
            a -= modulus;
        }
        return *this;
    }
    constexpr modcal &operator-=(const modcal rhs) noexcept
    {
        if (a < rhs.a)
        {
            a += modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modcal &operator*=(const modcal rhs) noexcept
    {
        a = a * rhs.a % modulus;
        return *this;
    }
    constexpr modcal &operator/=(modcal rhs) noexcept
    {
        i64 exp = modulus - 2;
        while (exp)
        {
            if (exp % 2)
            {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    void COMninit()
    {
        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 % modulus;
            inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
            finv[i] = finv[i - 1] * inv[i] % modulus;
        }
    }
    i64 COMn(i64 n, i64 k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
    }
    constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};
using modc = modcal<1000000007>;
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    modc n,k;
    cin >> n.a >> k.a;
    n.COMninit();
    i64 cand = n.a - k.a + 1;
    for(i64 i = 1; i <= k.a; i++){
        modc sum = n.COMn(cand, i) * n.COMn(k.a - 1, i - 1);
        cout << sum.a << endl;
    }
}

Measured memory_bytes: 234624
#include <iostream>
using namespace std;
 
char ans(char t){
	if(t == 'G'){return 'D';}
if(t == 'H'){return 'E';}
if(t == 'I'){return 'F';}
if(t == 'J'){return 'G';}
if(t == 'K'){return 'H';}
if(t == 'L'){return 'I';}
if(t == 'M'){return 'J';}
if(t == 'N'){return 'K';}
if(t == 'O'){return 'L';}
if(t == 'P'){return 'M';}
if(t == 'Q'){return 'N';}
if(t == 'R'){return 'O';}
if(t == 'S'){return 'P';}
if(t == 'T'){return 'Q';}
if(t == 'U'){return 'R';}
if(t == 'V'){return 'S';}
if(t == 'W'){return 'T';}
if(t == 'X'){return 'U';}
if(t == 'Y'){return 'V';}
if(t == 'Z'){return 'W';}
if(t == 'A'){return 'X';}
if(t == 'B'){return 'Y';}
if(t == 'C'){return 'Z';}
if(t == 'D'){return 'A';}
if(t == 'E'){return 'B';}
if(t == 'F'){return 'C';}
	}
 
int main() {
	char a[1000];
	int i = 0;
	while(cin >> a[i]){i++;}
	for(int j = 0;j<i;j++){
		cout<<ans(a[j]);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
ll x;
int main()
{
	//cwk;
	cin>>x;
	ll ans=0;
	ans=(x/500)*1000;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    long double a,b;
    cin>>a>>b;
    long double ans=a*b;
    cout<<(ll)ans;
}



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

int main()
{
  int a, b;
  cin >> a >> b;
  
  if(a < b)
    cout << "a < b" << endl;
  else if(a > b)
    cout << "a > b" << endl;
  else if(a == b)
    cout << "a == b" << endl;
 
 return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //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 << '\n';
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
t = gets.chomp.split('')
res = t.length

(0..(s.size - t.size)).each do |i|
  cnt = 0
  t.length.times do |j|
    if s[i+j] != t[j]
      cnt += 1
    end
  end
  res = [res, cnt].min
end
puts res

Measured memory_bytes: 14288
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


vector<int> adj[2222];
int main() {
	IO;
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n-1;++i) {
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
	
	vector<int> ans(n+1);
	auto bfs=[&](int st) {
		queue<pair<int,int>> q;
		vector<int> b(n+1);
		q.push({st,0});
		b[st]=1;
		while(!q.empty()) {
			auto fr=q.front();
			q.pop();
			ans[fr.yy]++;
			for(auto i:adj[fr.xx]) {
				if(!b[i]) {
					b[i]=1;
					q.push({i, fr.yy+1});
				}
			}
		}
	};
	
	for(int i=1;i<=n;++i) bfs(i);
	for(int i=1;i<n;++i) cout<<ans[i]/2<<"\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, m;
	while(cin >> n >> m && (n || m)) {
		bool a[1000+10] = {};
		int cnt = 0;
		int i = 0;
		rep(j,n) {
			while(1) {
				if(!a[i%n+1]) {
					cnt++;
					if(cnt == m) break;
				}
				i++;
			}
			cnt = 0;
			a[i%n+1] = 1;
			i++;
		}
		int ret = (i % n == 0) ? n : (i % n);
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import           Control.Monad
import           Data.Char
import qualified Data.ByteString.Char8 as B
import           Data.Function
import           Data.List
import           Text.Printf

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  [n, m] <- readInts
  pys <- map (\[p, y] -> (p, y)) <$> replicateM m readInts
  mapM_ putStrLn $ solve n pys

solve :: Int -> [(Int, Int)] -> [String]
solve n
  = map fst
  . sortOn snd
  . map (\(i,(j, (p, _))) -> (printf "%06d%06d" p i, j))
  . join
  . map (zip ([1..] :: [Int]))
  . map (sortOn (snd . snd))
  . groupBy ((==) `on` (fst . snd))
  . sortOn (fst . snd)
  . zip ([1..] :: [Int])
  where
    sortOn f = sortBy (compare `on` f)

Measured memory_bytes: 63996
X = int(input())
if X == 2:
    print(2)
    exit()
while True:
    N = int(X**0.5)
    for i in range(1,N):
        if X % (i+1) == 0:
            break
        else:
          if i == N - 1:
            print(X)
            exit()
    X += 1

Measured memory_bytes: 38512
N = int(input())

reverse_Nlist = []
for n in reversed(str(N)):
    reverse_Nlist.append(n)

normal_Nlist = []
for n in str(N):
    normal_Nlist.append(n)

if reverse_Nlist == normal_Nlist:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	int i,len,num,count;
	int flag,temp;
	while(cin>>s)
	{
		len=s.size();
		temp=-1;
		num=0;
		if(s[0]!='A')
		{
			cout<<"WA"<<endl;
			continue;
		}
		else
		{
			for(i=2;i<len-1;i++)
		    {
			    if(s[i]=='C')
			    {
			       	num++;
			       	temp=i;
				}
	      	}
	 	    if(num!=1)
		    {
		    	cout<<"WA"<<endl;
		    	continue;
			}
		    for(i=1;i<len;i++)
		    {
			    if(i!=temp)
			    {
				   if(s[i]>='a'&&s[i]<='z')
				   {
				   	count++;
				   }
			    }
		    }
		    if(count!=len-2)
		    {
			   cout<<"WA"<<endl;
		 	   continue;
		    }
	    }
		cout<<"AC"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define ll long long
map<string,int> s;
string a[maxn],ans[maxn];
int cnt[maxn]={0};
int main(){
    int n;
    cin>>n;
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
        if(s.count(a[i]))cnt[s[a[i]]]++;
        else{
            s[a[i]]=i;
        }
    }
    int ma=0;
    for (int j = 0; j <n ; ++j) {
        if(cnt[j]>ma)ma=cnt[j];
    }
    int pos=0;
    for (int k = 0; k <n ; ++k) {
        if(cnt[k]==ma){
            ans[pos++]=a[k];
        }
    }
    sort(ans,ans+pos);
    for (int l = 0; l <pos ; ++l) {
        cout<<ans[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

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

    int A[N];
    int B[N];

    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }

    int j=0;
    for(int i=0;i<N;i++){
        if(A[i]==B[i]){
            for(int c=0;c<N;j++,c++){
                if(A[i]!=B[j]&&A[j]!=B[i]){
                    swap(B[i],B[j]);
                    break;
                }
                if(j==N-1) j=-1;
            }
            if(A[i]==B[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<N;i++){
        cout<<B[i]<<" ";
    }
    cout<<endl;
}


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

int N, Q;

vector<vector<int>> graph(0, vector<int>());


void rOp(int child, int parent, vector<ll> & score){
    if(parent != -1) score[child] += score[parent];
    for (auto elem : graph[child])
    {
        if(elem == child) continue;
        rOp(elem, child, score);
    }
}

void dfs(int child, int parent, vector<ll> & score){
    for(auto elem : graph[child]){
        if(elem != parent){
            score[elem] += score[child];
            dfs(elem, child, score);
        }
    }
}

int main(void)
{
    cin >> N >> Q;
    graph.resize(N);
    vector<ll> ans(N);

    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        ans[p-1] += (ll) x;
    }

    dfs(0, -1, ans);

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 28248
import java.util.Scanner;

class Main {

	int[] ai = new int [100];

	int n = 0,w;

	public void nu () {

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		if(n >= 0 || n <= 100) {

			for(w = 0; w < n; w++) {

				ai[w] = sc.nextInt();

			}

			for(w = n-1; w > 0; w--) {

				System.out.printf("%d ",ai[w]);

			}

			System.out.println(ai[0]);

		}

	}

	public static void main(String[] args) {

		new Main().nu();

	}

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

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

    rep(i,q){
        string com;
        int a,b;
        cin >> com >> a >> b;
        int len = b - a + 1;
        if(com == "replace"){
            string p;
            cin >> p;
            s.replace(a, len, p);
        }

        else if(com == "reverse"){
            string tmp = s.substr(a, len);
            reverse(all(tmp));
            s.replace(a, len, tmp);
        }

        else if(com == "print"){
            string tmp = s.substr(a, len);
            cout << tmp << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3204
using System;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int W = int.Parse(s[0]);
        int H = int.Parse(s[1]);
        int x = int.Parse(s[2]);
        int y = int.Parse(s[3]);
        int r = int.Parse(s[4]);
        if(x>=r&&x<=W-r)
        {
            if(y>=r&&y<=H-r)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 8940
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll k, a, b;
	cin >> k >> a >> b;
	
	if( b - a <= 2 ) {
		cout << k + 1LL << endl;
	} else {
		if( k <= a - 1 ) {
			cout << k + 1LL << endl;
			return 0;
		}
		
		ll ans = a;
		k -= (a - 1LL);
		ans += k % 2 + (b - a) * max(0LL, k / 2LL);
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3576
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

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

using namespace std;

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(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 FORD(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	int a[200000]={0};
	REP(i, n) {
		cin>>a[i];
	}
	sort (a , a + n);
	REP(i, n) {
		if(a[i]==a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  vector<LL> c(n);
  //p = 1
  LL sum = 0;
  rep(i, n) {
    c[i] = abs(a[i] - b[i]);
    sum += c[i];
  }
  cout << sum << endl;

  //p = 2
  sum = 0;
  rep(i, n) {
    sum += c[i] * c[i];
  }
  cout << setprecision(15) << sqrt((double)sum) << endl;

  //p = 3
  sum = 0;
  rep(i, n) {
    sum += c[i] * c[i] * c[i];
  }
  cout << setprecision(15) << pow((double)sum, 0.33333333333) << endl;

  //p = ...
  LL maxv = 0;
  rep(i, n) maxv = max(maxv, c[i]);
  cout << maxv << endl;
}


Measured memory_bytes: 3416
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    
    ll N,P;cin >> N >> P;
    string S;
    cin >> S;
    
//    reverse(S.begin(),S.end());
    
    vector<ll> d(N);
    for(ll i=0;i<N;i++){
        d[i] = ctoi(S[N-i-1]);
    }
    
    if(10%P==0){
        ll ans=0;
        for(ll i=0;i<N;i++){
            if(d[i]%P==0){
                ans += N-i;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> s(N+1);
    s[0] = 0;
    
    ll ten=1;
    for(ll i=0; i<N; i++){
        
        s[i+1] = (ten * d[i] + s[i])%P;
//        ten *= 10 % P;
        ten = ten*10% P;
    }
    
    vector<ll> kind(P,0);
    
    for(ll i=0;i<N+1;i++){
        kind[s[i]]++;
    }
    
    
    ll cnt=0;
    for(ll i=0;i<P;i++){
        cnt += ((kind[i]-1)*(kind[i]))/2;
    }

    cout << cnt << endl;
    
    return 0;
}




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

int main(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k){
		cout << s << endl;
	}else{
		rep(i,k){
			cout << s[i];
		}
		cout << "..." << endl;
	}
    return 0;
}



Measured memory_bytes: 3628
N = int(input())
A = [int(_) for _ in input().split()]

comfort = 0
A.sort(reverse=True)
top = 0
count = 0
for i in range(1,N):
  if i == 1:
    comfort += A[top]
    top += 1
  else:
    comfort += A[top]
    if count == 1:
      top += 1
      count = 0
    else:
      count = 1
print(comfort)


Measured memory_bytes: 94200
//Littleboy123 Template 1.6
#include <bits/stdc++.h>
using namespace std;
 
//pragmas
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
const long double pi = acos(-1.0);
 
#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
 
void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
void infile(){
    freopen("input.in", "r", stdin);
}
 
void outfile(){
    freopen("output.out", "w", stdout);
}
 
ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1)
        tmp = (tmp * a) % mod;
    return tmp;
}
 
//End of template
 
int main(){
    init();
 
    int n;
    cin >> n;
    FOR(i, 1, 10){
        FOR(j, 1, 10){
            if(i * j == n){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long n, m;
	cin >> n >> m;
	if(m == 1 || n == 1){
		cout << "1\n";
		return 0;
	}
	long long mo = (m + 1) / 2;
	long long me = m / 2; 
	long long no = (n + 1) / 2;
	long long ne = n / 2;
	cout << no * mo + ne * me << endl;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

import bisect

L.sort()
L.append(1001)

ans = 0
for i in range(N - 2):
    for k in range(i + 2, N):
        # if a >= c - a: continue
        j_left = bisect.bisect_right(L, L[k] - L[i])
        if j_left <= i: j_left = i + 1
        if j_left >= k: continue
        #
        if L[j_left] == L[k] - L[i]:
            j_left += 1
        #
        j_right = bisect.bisect_left(L, L[k] + L[i])
        if j_right < 0: continue
        if j_right >= k: j_right = k - 1
        #
        if L[j_right] == L[k] + L[i]:
            j_right -= 1
        #
        # print("#", i, (j_left, j_right), k, '->', (L[j_left], L[j_right]), max(0, j_right - j_left + 1))
        ans += max(0, j_right - j_left + 1)

print(ans)

Measured memory_bytes: 50396
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;


int gcd (int x,int y){
  int b=x%y;
  if(b==0){
    return y;
  }
  else{
    gcd(y,b);
  }
} 


int main (){
  int x,y;
  cin>>x>>y;
  cout<<gcd(max(x,y),min(x,y))<<endl;
}


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


int main(){


    long long n, i, t;

    long long m = 0;

    string k = "Yes";

    vector<long long> h;


    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         h.push_back(t);

         }


    for( i = 0 ; i < n - 1 ; i = i + 1 ){

         if( h.at(i) - h.at(i + 1) > 1 ){

             k = "No";

             break;

             }

         m = max( h.at(i), m );

         if( m - h.at(i + 1) >= 2 ){

             k = "No";

             break;

             }

         }


    cout << k << endl;

    
    return 0;


    }

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

long long num[30] ;

char tmp[200005] ;

int main()
{
    while(~scanf("%s",tmp)){
        int l = strlen(tmp) ;
        memset(num,0,sizeof num);
        long long ans = (long long)(l+1)*l/2 + 1 ;
        for(int i = 0 ; i < l ; i ++){
            num[tmp[i] - 'a'] ++ ;
        }
        for(int i = 0 ; i < 26 ; i ++){
            ans -= num[i]*(num[i]+1)/2 ;
        }
        printf("%lld\n",ans) ;
    }
    return 0 ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=(1LL<<31)-1;
const double pi=acos(-1);
const double eps=1e-10;

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

class SquareDivision{
    private:
        const int BUCKET_SIZE=256;
        ll N, B;
        vector<ll> data;
        vector<bool> lazy_flag;
        vector<ll> lazy_update;

    public:
        void prepare(int n){
            B=(n+BUCKET_SIZE-1)/BUCKET_SIZE;
            N=B*BUCKET_SIZE;
            data.assign(N, INF);
            lazy_flag.assign(B, false);
            lazy_update.assign(B, 0);
        }

        void eval(int k){
            if(lazy_flag[k]){
                lazy_flag[k]=false;
                for(int i=k*BUCKET_SIZE; i<(k+1)*BUCKET_SIZE; i++){
                    data[i]=lazy_update[k];
                }
            }
        }

        // [s, t)
        void update(int s, int t, ll x){
            for(int k=0; k<B; k++){
                int l=k*BUCKET_SIZE, r=(k+1)*BUCKET_SIZE;

                if(r<=s || t<=l) continue;

                if(s<=l && r<=t){
                    lazy_flag[k]=true;
                    lazy_update[k]=x;
                }
                else{
                    eval(k);
                    for(int i=max(s, l); i<min(t, r); i++){
                        data[i]=x;
                    }
                }
            }
        }

        int find(int i){
            int k=i/BUCKET_SIZE;
            eval(k);
            return data[i];
        }
};

signed main(){
    int n, q; cin>>n>>q;
    SquareDivision ans;
    ans.prepare(n);

    while(q--){
        int c; cin>>c;
        if(c==0){
            ll s, t, x; cin>>s>>t>>x;
            ans.update(s, t+1, x);
        }
        else{
            ll x; cin>>x;
            cout << ans.find(x) << endl;
        }
    }
}


Measured memory_bytes: 3596
def amin(_data):
    ans = 0
    dst = 1000000000

    for idx, point in enumerate(checks):
        # x = abs(point[0] - _data[0])
        # y = abs(point[1] - _data[1])
        x = abs(_data[0] - point[0])
        y = abs(_data[1] - point[1])

        _dst = x + y

        if _dst < dst:
            ans = idx + 1
            dst = _dst

    return ans



N, M = list(map(int, input().split()))
points = list()
checks = list()

for _ in range(N):
    data = list(map(int, input().split()))
    points.append(data)

for _ in range(M):
    data = list(map(int, input().split()))
    checks.append(data)

for point in points:
    print(amin(point))


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;
	std::cin >> a >> b >> c;
	
	if( a > b )
		std::swap(a, b);
	
	if( b > c )
		std::swap(b, c);
	
	if( a > b )
		std::swap(a, b);
	
	std::cout << a << " " << b << " " << c << std::endl;
	
	return 0;
}


Measured memory_bytes: 3088
int main(void){
	int n[5],tmp;
	int i,j;
	
	scanf("%d %d %d %d %d",&n[0],&n[1],&n[2],&n[3],&n[4]);
	for(i = 0;i < 5;i++){
		for(j = 0;j < 4;j++){
			if(n[j] < n[j+1]){
				tmp = n[j];
				n[j] = n[j+1];
				n[j+1] = tmp;
			}
		}
	}
	
	for(i = 0;i < 4;i++){
		printf("%d ",n[i]);
	}
	printf("%d\n",n[4]);
	return 0;
}

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


// probability to get AC after x try;
//p(1) = 0.5^m;
//p(2) = (1-p(1))*p(1);
//p(3) = (1-p(2)-p(1))*p(1);



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

  //pre-calc
  double p[100000];
  double sum[100000];
  p[1] = pow(0.5,m);
  sum[1] = p[1];
  for(int i = 2; i < 100000; i++){
    p[i] = (1-sum[i-1])*p[1];
    sum[i] = sum[i-1]+p[i];
  }
  //

  double temp = 0;
  int i = 1;
  double t = 1900*m + 100*(n-m);
  
  while(t*i*p[i] > 0.00000001){
    temp += t*i*p[i];
    //cout <<  i <<" "<< t*i*p[i] << endl;
    i++;
  }

  int ans = int(temp);
  cout << ans+1 << endl;

}


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<int> l;
  int n,k;
  cin >> n >> k;
  int ll;
  for(int i = 0;i < n;i++) {
    cin >> ll;
    l.push(ll);
  }
  int sum = 0;
  for(int i = 0;i < k;i++) {
    sum += l.top();
    l.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final DecimalFormat df = new DecimalFormat("0.0000000000");
	static final int A = 0, B = 1, C = 2, D = 3, E = 4, F = 5, G = 6, H = 7,
			I = 8;
	static final int[][] rooms = {
			//
			{ A, D, B, A }, { B, E, C, A }, { C, F, C, B },//
			{ A, G, E, D }, { B, H, F, D }, { C, I, F, E },//
			{ D, G, H, G }, { E, H, I, G }, { F, I, I, H } };

	public static void main(String[] args) {
		final double pow = Math.pow(4, 15);
		Scanner in = new Scanner(System.in);
		int n;
		int[] now = new int[9];
		int[] next = new int[9];
		while ((n = in.nextInt()) > 0) {
			Arrays.fill(now, 0);
			Arrays.fill(next, 0);
			int s = in.next().charAt(0) - 'A';
			now[s] = 1;
			int t = in.next().charAt(0) - 'A';// 充電器
			int b = in.next().charAt(0) - 'A';// 入れない
			for (int i = 0; i < n; i++) {
				for (int room = 0; room < 9; room++) {
					int val = now[room];
					for (int arrow = 0; arrow < 4; arrow++) {
						if (rooms[room][arrow] != b)
							next[rooms[room][arrow]] += val;
						else
							next[room] += val;
					}

				}
				int[] memo = now;
				now = next;
				next = memo;
				Arrays.fill(next, 0);
			}
			System.out.println(df.format(now[t] / Math.pow(4, n)));
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	int s[110] = { 0 }, t[110] = { 0 };
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		s[i + 1] = a + s[i];
	}
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		t[i + 1] = a + t[i];
	}
	int ans = 0;
	for (int i = 1;i < n + 1;i++) {
		ans = max(ans, s[i] + t[n] - t[i - 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = a * b;
		
		if(ans % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
		
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
int main(){
   int N;
   string c;
   cin>>N;
   cin>>c;
   int wc=0;
   for(int i=0;i<N;i++){
       if(c[i]=='W') wc++;
   }
   int n=0;
   for(int i=N-1;i>N-1-wc;i--){
       if(c[i]=='R') n++;
   }
   cout<<n<<endl;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size()/2; i++) {
      if (s[i] != s[s.size()-i-1]) ans++;
  } 
  cout << ans << endl;  
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n[1000] = {};
	bool f = true;
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++){
		n[(int)s[i]]++;
	}
	for(int i = 0; i < 1000; i++){
		if(!(n[i] == 0 || n[i] == 2)){
			f = false;
		}
	}
	cout << (f?"Yes":"No");
}


Measured memory_bytes: 256
import math
import fractions
import collections
import itertools
N=int(input())
A=list(map(int,input().split()))
A.sort()
#A=[10**5]*(10**5)
#N=10**5
ans=1
flag=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        flag=0
        break
if flag==1:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 88444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
    for(int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;
        while(j>= 0 && A[j] > v){
            A[j+g] = A[j];
            j-=g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[],int n){
    for(int h = 1; ;){
        if(h>n) break;
        G.push_back(h);
        h = 3*h+1;
    }
    
    for(int i = G.size()-1; i >= 0; i--){
        insertionSort(A,n,G[i]);
        
    }
}

int main(){
    cin >> n;
    for(int i = 0; i<n; i++) scanf("%d",&A[i]);
    cnt = 0;
    
    shellSort(A,n);
    
    cout << G.size() << endl;
    for(int i = G.size()-1;i>=0;i--){
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i=0; i<n; i++) printf("%d\n",A[i]);
    return 0;
}


Measured memory_bytes: 7076
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int n;
    cin >> n;
    vector<int> v;
    v.push_back(-1);
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    int res = 0;
    for (int i = 1; i <= n;) {
        if (v[i] == i) {
            if (v[i + 1] == i + 1) {
                res++;
                i += 2;
            } else {
                res++;
                i++;
            }
        } else {
            i++;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 892
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n,m;
  int a[100001];
  int b[100001];
  int c[100001];
  cin>>n>>m;
  for (int i=0;i<m;i++){
    cin>>a[i]>>b[i];
  }
  for (int i=0; i<n;i++){
    c[i]=0;
  }
  for (int i=0; i<m;i++){
    c[a[i]-1]+=1;
    c[b[i]-1]+=1;
  }
  int ans;
  for (int i=0;i<n;i++){
    if (c[i]%2==1) ans+=1;
    }
    if (ans==0) printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void) {

	int a, b, c;
	int max = 0;
	int min = 0;

	scanf("%d %d %d", &a, &b, &c);
	if (a > b) {
		max = a;
		min = b;
	}
	else {
		max = b; 
		min = a;
	}

	if (max >= c && min <= c)printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 128
PROGRAM ATCODER

implicit none
integer :: n, l, i, j
character(len = 100),allocatable :: a(:)
character(len = 100) :: c
character(len = 100*100) :: answer

read(*,*) n, l
allocate (a(n))

do i = 1, n
	read(*,*) a(i)
end do

! ここに計算式
do i = 1, n
	do j = i+1, n
		if (lgt(a(i),a(j)))then
			c = a (i)
			a(i) = a(j)
			a(j) = c
		end if
	end do
end do
! ここに出力結果

answer = trim(a(1))
do i = 2, n
	answer = trim(answer)//trim(a(i))
end do

write(*,'(a)') trim(answer)

END PROGRAM ATCODER

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

long long int fact(long long int k){
    if(k==1) return k;
    else return fact(k-1)*10;
}
int main()
{
    int a;
    int b;
    
    cin >> a;
    cin >> b;
    
    long long int ans = 0;
    if(a>b){
        for(int i=1; i<= a; i++){
            ans += b * fact(i);
        }
    }
    else{
        for(int i=1; i<= b; i++){
            ans += a * fact(i);
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string x;
    int counter[26]={},n;
    while(cin>>x){
      for(int i = 0;i < x.size();i++){
          if ('A' <= x[i] && x[i] <= 'Z'){
            n = x[i]-'A';
            counter[n]++;
          }
          else if ('a' <= x[i] && x[i] <= 'z'){
            n = x[i]-'a';
            counter[n]++;
          }
      }      
    }
    for(int i = 0; i<26 ;i++){
        char a = 'a'+i;
        cout<<a<<" : "<<counter[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>

int data[50];

int fib(int);

int main(){
  int n,i;

  for(i = 0;i < 50;i++){
    data[i] = -1;
  }

  scanf("%d",&n);
  
  printf("%d\n",fib(n));

  return 0;
}

int fib(int n){
  if(n == 0 || n == 1){
    return data[n] = 1;
  }
  if(data[n] != -1){
    return data[n]; 
  }
  return data[n] = fib(n-1) + fib(n-2);
}



Measured memory_bytes: 2108
//https://atcoder.jp/contests/abc153/tasks/abc153_f
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main(){
#if LOCAL&01
    std::ifstream in("./test/sample-3.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,D,A; cin>>N>>D>>A;
    vector<pair<ll,ll>> xhn(N);
    for(auto&& xh:xhn){
        cin>>xh.first>>xh.second;
    }
    sort(xhn.begin(),xhn.end());
    vector<ll> xtbl; xtbl.reserve(N);
    for(const auto& xh:xhn){
        xtbl.push_back(xh.first);
    }
    vector<ll> sub_tbl(N+10,0);

    ll ans=0;
    ll add_val=0;
    ll sub_val=0;
    FOR(i,0,N){
        add_val -= sub_tbl.at(i);

        const auto &d = xhn.at(i);
        ll hp=d.second - add_val;
        if (hp <= 0) continue;
        ll times = (hp + A-1)/A;
        ans += times;
        ll del_val = times * A;
        ll pos = d.first + 2*D;
        auto it = upper_bound(xtbl.begin()+i+1,xtbl.end(),pos);
        //--it;
        ll lim = distance(xtbl.begin(), it);
        // FOR(j,i,lim){
        //     xhn.at(j).second -= del_val;
        // }
        sub_tbl.at(lim) += del_val;
        add_val += del_val;
    }
    cout<<ans<<endl;
    return 0;
}

int main_() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,D,A; cin>>N>>D>>A;
    vector<pair<ll,ll>> xhn(N);
    for(auto&& xh:xhn){
        cin>>xh.first>>xh.second;
    }
    sort(xhn.begin(),xhn.end());
    vector<ll> xtbl; xtbl.reserve(N);
    for(const auto& xh:xhn){
        xtbl.push_back(xh.first);
    }

    ll ans=0;
    FOR(i,0,N){
        const auto &d = xhn.at(i);
        if (d.second <= 0) continue;
        ll times = (d.second + A-1)/A;
        ans += times;
        ll del_val = times * A;
        ll pos = d.first + 2*D;
        auto it = upper_bound(xtbl.begin()+i+1,xtbl.end(),pos);
        //--it;
        ll lim = distance(xtbl.begin(), it);
        FOR(j,i,lim){
            xhn.at(j).second -= del_val;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n;

int main() {
	while (cin >> n, n) {
		unsigned int part = 1, cur = 0;
		
		for_(i,0,n) {
			int p;
			cin >> p;
			cur += p;
		}
		
		priority_queue< int, vector< int >, greater< int > > que;
		
		for_(i,0,n-1) {
			int j;
			cin >> j;
			cur += j;
			que.push(j);
		}
		
		unsigned int ans = cur;
		
		while (!que.empty()) {
			int j = que.top(); que.pop();
			
			++part;
			cur -= j;
			
			ans = max(ans, part * cur);
		}
		
		cout << ans << endl;
	}
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int h, r;
  cin >> h >> r;
  if(h + r == 0) {
    cout << 0 << endl;
    return 0;
  }

  if(h + r > 0) {
    cout << 1 << endl;
    return 0;
  }

  cout << -1 << endl;
}



Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[] masu = new int[n];
			
			for(int i = 0; i < n; i++){
				masu[i] = sc.nextInt();
			}
			
			int cur = 0;
			int count = 0;
			for(int i = 0; i < m; i++){
				if(cur >= n - 1){
					sc.nextInt();
					continue;
				}
				
				cur += sc.nextInt();
				count++;
				
				if(cur >= n - 1){
					continue;
				}else{
					cur += masu[cur];
				}
			}
			
			System.out.println(count);
		}
		
	}

}

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

int main(){
int i,n;
int max,a[100]={0};
while(scanf("%d",&n)!=EOF){
a[n]++;
}
max=0;
for(i=0;i<100;i++){
if(max<a[i]){
max=a[i];
}
}
for(i=0;i<100;i++){
if(a[i]==max){
printf("%d\n",i);
}
}

return 0;
}

Measured memory_bytes: 1024