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

int main(){
	int n;
	char Ch;
	int x;
	int a[5][14] = {0};
	cin >> n;
	for (int i = 0; i < n; i++){
			cin >> Ch >> x;
			switch (Ch){
			case 'S':
				a[1][x] = x;
				break;
			case 'H':
				a[2][x] = x;
				break;
			case 'C':
				a[3][x] = x;
				break;
			case 'D':
				a[4][x] = x;
				break;
			default:
				break;
			}
	}
	for (int i = 1; i < 5; i++){
		for (int j = 1; j < 14; j++){
			if (a[i][j] == 0){
				switch (i){
				case 1:
					cout << 'S' << " " << j << endl;
					break;
				case 2:
					cout << 'H' << " " << j << endl;
					break;
				case 3:
					cout << 'C' << " " << j << endl;
					break;
				case 4:
					cout << 'D' << " " << j << endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 200000 + 5
#define Mod 1000000007

int n, Dp[N], Last[N];

int main()
{
	scanf("%d", &n);
	Dp[0] = 1;
	for (int i = 1, x; i <= n; i ++)
	{
		scanf("%d", &x);
		Dp[i] = Dp[i - 1];
		if (Last[x] && Last[x] != i - 1)
			Dp[i] = (Dp[i] + Dp[Last[x]]) % Mod;
		Last[x] = i;
	}
	printf("%d\n", Dp[n]);
	return 0;
}

Measured memory_bytes: 1664
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n, C;
	cin >> n >> C;
	vector<int>s(n), t(n), c(n);
	rep(i, n)cin >> s[i] >> t[i] >> c[i];
	int lim = 2 * 1e5 + 2;
	vector<int>sum(lim, 0);
	for (int i = 1; i <= C; i++) {
		vector<int> d(lim, 0);
		rep(j, n) {
			if (c[j] == i) {
				d[2 * s[j] - 1]++;
				d[2 * t[j]]--;
			}
		}
		vector<int> cumulativeSum(d);
		for (int j = 1; j < lim; j++) {
			cumulativeSum[j] += cumulativeSum[j - 1];
		}
		rep(j, lim)if (cumulativeSum[j] > 0) sum[j]++;
	}
	int mx = *max_element(all(sum));
	std::cout << mx << endl;
	return 0;
}





Measured memory_bytes: 3824
#include <stdio.h>
#include <vector>

using namespace std;

int main() {
    int H, W;

    scanf("%d %d", &H, &W);
    
    vector<vector<char>> T(H, vector<char>(W));
    int i, j;
    char dummy;

    for ( i = 0; i < H; i++ ) {
        scanf("%c", &dummy);

        for (j = 0; j < W; j++ ){
            scanf("%c", &T.at(i).at(j));
        }
    }

    /*
    for ( i = 0; i < H; i++ ) {
        for (j = 0; j < W; j++ ){
            printf("%c", T.at(i).at(j));

            if ( j == W-1 ){
                printf("\n");
            }
        }
    }
    */
   
    int Hr=0, Wr=0;
    bool rm;

    for ( i = 0; i < H; i++ ) {
        rm = true; // when array most be removed, rm = false.  

        for ( j = 0; j < W; j++ ) {
            if ( T.at(i).at(j) == '#')
            break;

            if ( j == W - 1 )
            rm = false;
        }

        if ( rm ) {
            for ( j = 0; j < W; j++ ) {
                T.at(Hr).at(j) = T.at(i).at(j);
            }
            Hr++;
        }
    }

     for ( j = 0; j < W; j++ ) {
        rm = true; 

        for ( i = 0; i < Hr; i++ ) {
            if ( T.at(i).at(j) == '#')
            break;

            if ( i == Hr - 1 )
            rm = false;
        }

        if ( rm ) {
            for ( i = 0; i < Hr; i++ ) {
                T.at(i).at(Wr) = T.at(i).at(j);
            }
            Wr++;
        }
    }   

    for ( i = 0; i < Hr; i++ ) {
        for (j = 0; j < Wr; j++ ){
            printf("%c", T.at(i).at(j));

            if ( j == Wr - 1 ){
                printf("\n");
            }
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;


int main(void) {
    int N, K;
    char S[51];
    
    scanf("%d %d", &N, &K);
    scanf("%s", S);
    
    if(S[K-1] == 'A'){
        S[K-1] = 'a';
    }
    if(S[K-1] == 'B'){
        S[K-1] = 'b';
    }
    if(S[K-1] == 'C'){
        S[K-1] = 'c';
    }
    printf("%s\n", S);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if (N % 2 == 0){
        double l = double(A[N / 2] + A[N / 2 -1]) / 2.0;
        double r = double(B[N / 2] + B[N / 2 -1]) / 2.0;
        cout << int((r - l) * 2.0) + 1 << endl;
    }else{
        cout << (B[N / 2] - A[N / 2]) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5956
#include<stdio.h>
int main(void){
        int n,x,i,j,k,c;
        int a[1024]={0};
        c=0;
	while(1){
             scanf("%d %d",&n,&x);
             if(n==0 && x==0){
                  break;
             }
             for(i=1;i<=n-2;i++){
	          for(j=i+1;j<=n-1;j++){
	               for(k=j+1;k<=n;k++){
	                    if(i+j+k==x){
                                 a[c]++;
                            }
                       }
                  }
             }
             c=c+1;
	}
        for(i=0;i<c;i++){
	     printf("%d\n",a[i]);
        }
	return 0;
}


Measured memory_bytes: 2764
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    kai = set()
    uri = set()
    i = 1
    while i < n:
        if A[i - 1] < A[i]:
            kai.add(i - 1)
            while i < n and A[i - 1] <= A[i]:
                i += 1
            uri.add(i - 1)
            while i < n and A[i - 1] >= A[i]:
                i += 1
        else:
            i += 1

    if len(kai) == 0:
        print(1000)
        exit()

    money = 1000
    kabu = 0
    for i in range(n):
        if i in kai:
            if i == n - 1:
                continue
            kabu, money = divmod(money, A[i])
        elif i in uri:
            money += kabu * A[i]
            kabu = 0
    print(money)


if __name__ == '__main__':
    resolve()


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

using namespace std;
using ll = long long;

int main() {
	cout << fixed << setprecision(20);
	long double a, b, x;
	cin >> a >> b >> x;
	if(2 * x <= a * a * b) {
		cout << atanl(a * b * b / 2 / x) / acos(-1) * 180 << endl;
		return 0;
	}
	x -= a * a * b / 2;
	x = a * a * b / 2 - x;
	auto ans = 90 - atanl(a * a * a / 2 / x) / acos(-1) * 180;
	cout << ans << endl;
	ans = ans - 90;
	ans += 45;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    vector<int> H(n+1);
    int mx = 0;
    rep(i, n) cin >> H[i];
    rep(i,n - 1){
        mx = max(mx, H[i]);
        //deb(mx); deb(H[i + 1]);cerr << abs(mx - H[i + 1]) << '\n';
        if(mx > H[i + 1]  && abs(mx - H[i + 1]) > 1) { cout << "No"; return 0; }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    if(N*A<B){
        cout << N*A << endl;
    }else{
        cout << B << endl;
    }
    return 0;
}

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

string s;
int n;
long long rv = 0;

int main() {

	cin >> s;
	n = s.size();
	for (int i = 0; i < 1 << n - 1; i++) {
		int prev = 0;
		for (int j = 0, bit = i; bit; j++, bit >>= 1) {
			if (bit & 1) {
				long long a = 0;
				for (int k = prev; k < j + 1; k++) {
					a *= 10;
					a += s[k] - '0';
				}
				rv += a;
				prev = j + 1;
			}

		}
		long long a = 0;
		for (int k = prev; k < n; k++) {
			a *= 10;
			a += s[k] - '0';
		}
		rv += a;
	}
	cout << rv << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int q;
    cin >> q;

    vector<int> a;
    while(q--){
        int m;
        cin >> m;

        if(m == 0){
            int x;
            cin >> x;
            a.push_back(x);
        }else if(m == 1){
            int p;
            cin >> p;
            cout << a[p] << endl;
        }else{
            a.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 3912
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = new Integer(sc.next());
        int b = sc.nextInt();
        if (a < b) {
          System.out.println("a < b");
        }else if(a > b) {
          System.out.println("a > b");
        }else if(a == b) {
          System.out.println("a == b");
        }
    }
}

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

    vector < int > vec, ans;
    vector < bool > vis;

    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n,res1,res2,res;
        long long k;    
        cin >> n >> k;
        vec.resize(n + 3);
        vis.resize(n + 3);
        for(int i = 1;i <= n;i++)   cin >> vec[i];
        if(k <= n){
	        res1 = 1;
            int a = k;
	        while(a--){
                res1 = vec[res1];
	        }
        }
        int it = 1,x;
        while(!vis[it]){
            ans.push_back(it);
            vis[it] = true;
            it = vec[it];
            if(vis[it] == true){
                x = it;
            }
        }
        int before = 0;
        for(int s: ans){
            if(s == x)  break;
            before++;
        }
        if(k < before){
            res2 = ans[k];
        }
        else{
            k -= before;
            res2 = k % (ans.size() - before) + before;
            res2 = ans[res2];
        }
            cout << res2 << "\n";

    	return 0;
}

Measured memory_bytes: 5068
import qualified Data.List as L

combinations :: Int -> [a] -> [[a]]
combinations r = filter ((== r) . length) . L.subsequences

count :: (a -> Bool) -> [a] -> Integer
count f = foldr (\ b -> if b then succ else id) 0 . map f

solve :: [Int] -> IO ()
solve [n,s] = print $ count ((== s) . sum) $ combinations n [0..9]
solve _ = undefined

main :: IO ()
main = getContents
    >>= mapM_ solve . takeWhile (/= [0,0]) . map (map read) . map words . lines

Measured memory_bytes: 4112
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long  LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=2e6+10;
LL t,n,m,ans,tot;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

char a[MAXN];

int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,r,ca=0,u=0,v=0,w;
	cin>>a;
	l=strlen(a);
	j=1;
	for(i=1;i<l;i++){
		if(a[i]!=a[i-1])a[j++]=a[i];
	}
	cout<<j-1<<endl;
	return 0;
}



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

int main() {
  string S;
  cin >> S;
  int c = 0;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] == '0') {
      c++;
    } else {
      c--;
    }
  }
  cout << S.size() - abs(c) << endl;
  return 0;
}

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

using namespace std;

const int mod = 998244353;

using int64 = long long;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;

  auto check = [&](int sz) {
    stack< pair< int, int > > mp;
    mp.emplace(1, 0);
    if(A[0] != 1) mp.emplace(A[0], 0);

    for(int i = 1; i < N; i++) {
      bool uku = false;
      while(mp.top().first > A[i]) {
        uku = true;
        mp.pop();
      }
      int cur = A[i];
      while(mp.size() && mp.top().first == cur && mp.top().second + 1 == sz) {
        uku = true;
        --cur;
        mp.pop();
      }

      if(cur == 0) {
        return false;
      } else if(cur == mp.top().first) {
        ++mp.top().second;
      } else if(uku) {
        if(sz == 1) return false;
        mp.emplace(cur, 1);
      } else {
        mp.emplace(cur, 0);
      }
      if(mp.top().first != A[i]) {
        mp.emplace(A[i], 0);
      }
    }
    return true;
  };

  int ok = N, ng = 0;
  while(ok - ng > 1) {
    int md = (ok + ng) / 2;
    if(check(md)) ok = md;
    else ng = md;
  }
  cout << ok << endl;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n, m, k = 0;
	n = gi();
	string s;
	cin >> s;
	for (int i = 0; i + 2 < n; i+=1) 
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++k;
	}
	cout << k << endl;
	return 0;
}



Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int a[M],pos=0,neg=0;
vector<int>p,n;
vector<pi>ses;
void two()
{
    int x=a[1];
    int y=a[2];
    int op1=x-y;
    int op2=y-x;
    if(op1>op2)
    {
        cout<<op1<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else
    {
        cout<<op2<<endl;
        cout<<y<<" "<<x<<endl;
    }
    exit(0);
}
void only_pos()
{
    sort(p.begin(),p.end());
    int x=p[0];
    int sz=p.size();
    for(int i=1;i<sz-1;i++)
    {
        int y=p[i];
        ses.pb(mp(x,y));
        x=x-y;
    }
    ses.pb(mp(p[sz-1],x));
    x=p[sz-1]-x;
    cout<<x<<endl;
    for(auto z:ses)
    {
        cout<<z.fi<<" "<<z.si<<endl;
    }
    exit(0);
}
void only_neg()
{
    sort(n.begin(),n.end());
    int sz=n.size();
    int x=n[sz-1];
    for(int i=0;i<sz-1;i++)
    {
        int y=n[i];
        ses.pb(mp(x,y));
        x=x-y;
    }
    cout<<x<<endl;
    for(auto z:ses)
    {
        cout<<z.fi<<" "<<z.si<<endl;
    }
    exit(0);
}
void work()
{
    sort(p.begin(),p.end());
    sort(n.begin(),n.end());
    int x=n[0];
    for(int i=0;i<pos-1;i++)
    {
        int y=p[i];
        ses.pb(mp(x,y));
        x=x-y;
    }
    int y=p[pos-1];
    ses.pb(mp(y,x));
    y=y-x;
    for(int i=1;i<neg;i++)
    {
        int x=n[i];
        ses.pb(mp(y,x));
        y=y-x;
    }
    cout<<y<<endl;
    for(auto z:ses)
    {
        cout<<z.fi<<" "<<z.si<<endl;
    }

}
 main()

{
    fast
    int t;
    cin>>t;
    f(i,1,t)
    {
        cin>>a[i];
        if(a[i]>=0)pos++,p.pb(a[i]);
        else neg++,n.pb(a[i]);
    }
    if(t==2)two();
    if(neg==0)only_pos();
    if(pos==0)only_neg();
    work();
    return 0;

}





































Measured memory_bytes: 7688
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    k--;
    cout << a[k] << endl;
}


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

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
#define tmp template<class t>

tmp void chmax(t&a,t b){if(a<b)a=b;}
tmp void chmin(t&a,t b){if(a>b)a=b;}

tmp using vc=vector<t>;
tmp using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

tmp ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

tmp void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll read(){ll i;cin>>i;return i;}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-12;
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
auto cmcmp=[](const cm&a,const cm&b){
	if(sgn(a.x-b.x))return a.x<b.x;
	else return sgn(a.y-b.y)<0;
};

struct ln{
	cm a,b;
	cm dir(){return b-a;}
};
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
int ccw(ln a,cm b){return ccw(a.a,a.b,b);}

//(-2)[a,-1](0)[b,1](2)
int bet(cm a,cm b,cm c){
	cm d=b-a;
	ld e=dot(d,c-a);
	if(sgn(e)<=0)return sgn(e)-1;
	return sgn(e-norm(d))+1;
}

ld tri2(cm a,cm b,cm c){
	return crs(b-a,c-a);
}

ld area2(const vc<cm>&a){
	int n=a.size();
	ld b=0;
	rep(i,n)
		b+=crs(a[i],a[(i+1)%n]);
	return b;
}

cm readcm(){
	ld a,b;
	char c;
	cin>>a>>c>>b;
	return cm(a,b);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	vc<cm> s;
	while(1){
		cm a=readcm();
		if(cin.eof())break;
		s.pb(a);
	}
	
	cout<<abs(area2(s)/2)<<endl;
}



Measured memory_bytes: 3284
#include <iostream>
#include <vector>
 
#define pb push_back
typedef long long int ll;
 
using namespace std;
 
const int MAX = 2e5 + 10;
 
vector<ll> a[MAX]; ll ta[MAX]={0}; ll sz=0;ll from[MAX],to[MAX]; ll pos[MAX];
 
ll dfs(ll x,ll y){
    pos[x]=sz;
    
    from[x]=sz;
    
    to[x]=sz;
    sz++;
 
    for(ll z:a[x]){
    	if(z != y){
    	    dfs(z,x);
    	    to[x]=max(to[x],to[z]);
    	}
    }
}
 
int main()
{
	ll n,q; cin>>n>>q;
	for(ll i=0;i<n-1;i++){
		ll u,v; cin>>u>>v; a[u].pb(v); a[v].pb(u);
	}
 	dfs(1,1);
 	for(int i=0;i<q;i++) {
 		int p,x; cin>>p>>x;
 		ta[from[p]] += x;
 		ta[to[p]+1] -= x;
 	}
	
 	for(int i=1;i<n+10;i++) ta[i] += ta[i-1];

 	for(int i=1;i<=n;i++) {
 		cout<<ta[pos[i]]<<" ";
 	} 
	
 
}


Measured memory_bytes: 28928
def main():
    import math
    n = int(input())
    a = sorted(list(map(int,input().split())))
    if n==2:
        print(a[1])
        return
    ans = 0
    g = math.gcd(a[0],a[1])
    ans_list = []
    for i in range(1,int(g**0.5)+1):
        if g%i==0:
            ans_list.append(i)
    ans_list.append(g)
    for an in ans_list:
        cnt = 0
        for i in range(n):
            if a[i] % an != 0:
                cnt += 1
        if cnt < 2:
            if an>ans:
                ans = an
    g = math.gcd(a[1],a[2])
    ans_list = []
    for i in range(1,int(g**0.5)+1):
        if g%i==0:
            ans_list.append(i)
    ans_list.append(g)
    for an in ans_list:
        cnt = 0
        for i in range(n):
            if a[i] % an != 0:
                cnt += 1
        if cnt < 2:
            if an>ans:
                ans = an
    g = math.gcd(a[0],a[2])
    ans_list = []
    for i in range(1,int(g**0.5)+1):
        if g%i==0:
            ans_list.append(i)
    ans_list.append(g)
    for an in ans_list:
        cnt = 0
        for i in range(n):
            if a[i] % an != 0:
                cnt += 1
        if cnt < 2:
            if an>ans:
                ans = an
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 20980
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d.at(i);
  sort(ALL(d));
  int ans = 0;
  if(n % 2 == 0){
    int m1 = d.at(n/2-1), m2 = d.at(n/2);
    ans = m2 - m1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0

s_set=set(s)


for i in range(n):
    s_alpha=s_index[i]
    t_alpha = t_index[i]
    if s_alpha in s_set:
        s_set.remove(s_alpha)
        if not s_count[s_alpha]==t_count[t_alpha]:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 72652
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int a[10];
int main()
{
    IO
    for(int i=1; i<=5; i++)
    {
        cin>>a[i];
        if(a[i]==0)
            cout<<i;
    }
}


Measured memory_bytes: 3616
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var T = cin.ReadLongArray(N);
            Array.Sort(T);
            var ans = T[0];
            for(int i = 1; i < N; i++)
            {
                ans = lcm(ans, T[i]);
            }
            WriteLine(ans);
        }

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

        public long gcd (long a, long b)
        {
            if(b == 0)
            {
                return a;
            }
            return gcd(b, a % b);
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

int main(void){
   
  int N;
  cin >> N;
  
  if(N == 1){
      cout << "Hello World"<< endl;
  }
  else if(N == 2){
      int a,b;
      cin >> a >> b;
      cout << a+b <<endl;
  }
}

Measured memory_bytes: 3624
import sys
input = lambda : sys.stdin.readline().rstrip()

s = input()
t = input()

len_s = len(s)
len_t = len(t)

for i in range(len_s - len_t + 1):
    s1 = s[i:i+len_t]
    cur = 0
    for j in range(len_t):
        if s1[j] == t[j]:
            cur += 1

    if i == 0:
        max_ = cur
    else:
        max_ = max(cur,max_)
out = len_t - max_
print(out)

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

int main() {
 
    int n,m,x;
    cin >> n >> m >> x;
    
    int res[n][m];
    int dp[n];
    
    for(int i = 0 ; i < n ; i++) {
        cin >> dp[i];
        for(int j = 0 ; j < m ; j++) {
            cin >> res[i][j];
        }
    }
    
    int sum = INT_MAX;
    for(int q = 0 ; q < (1 << n) ; q++) {
        
        vector<int> vt1(m, 0);
        int c = 0;
        for(int i = 0 ; i < n ; i++) {
            if((1 << i) & q) {
                c += dp[i];
                for(int j = 0 ; j < m ; j++)
                    vt1[j] += res[i][j];
            }
        }
        
        for(int i = 0 ; i < m ; i++)
            if (vt1[i] < x) c = INT_MAX;
        
        sum = min(sum, c);
    }
    
    cout << ((sum == INT_MAX) ? -1 : sum) << "\n";
    
    return 0;
}


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

using namespace std;

int main(void){
  int n, m;
  int A[100][100], b[100];

  scanf("%d %d", &n, &m);

  for(int i = 0;i < n;++i){
    for(int j = 0;j < m;++j){
      scanf("%d ", &A[i][j]);
    }
  }

  for(int i = 0;i < m;++i){
    scanf("%d", b + i);
  }

  for(int i = 0;i < n;++i){
    int s = 0;
    for(int j = 0;j < m;++j){
      s += A[i][j] * b[j];
    }
    printf("%d\n", s);
  }

  return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

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

    string s;
    cin >> s;

    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
}

Measured memory_bytes: 764
// B - Digits
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, k;
	cin >> n >> k;
	int count = 0;
	for ( ; n > 0; n /= k) count++;
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int x,a,i;

int main(){
	scanf("%d",&x);
	while(x!=0){
		for(i=0;i<9;i++){
			scanf("%d",&a);
			x=x-a;
		}
		printf("%d\n",x);
		scanf("%d",&x);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int N, A;
    vector<long long> a;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A;
        a.push_back(A);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
  
  int N,M,ans;
  
  cin >> N;
  vector<string> s(N);
  
  for (int i = 0 ; i < N ;i++)
    cin >> s.at(i);
    
  cin >> M;
  vector<string> t(M);
  
  for (int i = 0 ; i < M ;i++)
    cin >> t.at(i);
  
  vector<string> words;
  vector<int> num;
  
  
  for (int i = 0 ; i < N ; i++){
    
    bool nonexist = true;
    for (int j = 0 ; j < words.size() ; j++){
      
      if ( s.at(i) == words.at(j) ){
        nonexist = false;
        num.at(j)++;
        break;
      }
      
    }
    
    if (nonexist){
      
      words.push_back( s.at(i) );
      num.push_back(1);
      
    }
    
  }
  
  
  for (int i = 0 ; i < M ; i++){
    
    bool nonexist = true;
    for (int j = 0 ; j < words.size() ; j++){
      
      if ( t.at(i) == words.at(j) ){
        nonexist = false;
        num.at(j)--;
        break;
      }
      
    }
    
    if (nonexist){
      
      words.push_back( t.at(i) );
      num.push_back(-1);
      
    }
    
  }
  
  
  for (int i = 0; i < num.size(); i++){
     if ( num.at(i) > ans )
       ans = num.at(i);
    
     //cout << "mozi: " << words.at(i) << " kazu: " << num.at(i) << endl;
  }
  
  cout << ans << endl;
  
}


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(s[i]=='x' && s[i-1]=='x'){
            cout << i << endl;
            return 0;
        }
    }
    cout << n << endl;
    
}


Measured memory_bytes: 3332
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int h, w;
  while (scanf("%d%d", &h, &w) != EOF && h && w) {
    int S = h*h+w*w;
    bool finished = false;
    for (int i=h+1; i<=150; i++) {
      int W = S - i*i;
      for (int j=i+1; j<150; j++) {
	if (j * j == W) {
	  finished = true;
	  printf("%d %d\n", i, j);
	  goto END;
	}
      }
    }
    while (!finished) {
      S++;
      for (int i=1; i<=150; i++) {
	for (int j=i+1; j<150; j++) {
	  if (S == i*i+j*j) {
	    printf("%d %d\n", i, j);
	    goto END;
	  } else if (S < i*i+j*j) {
	    break;
	  }
	}
      }
    }
  END: continue;
  }
}

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

int main(void){
    int n,min=1000001,max=min*-1,a;
    long long sum=0;
    cin >> n;
    for (int i=n;i--;){
        cin >> a;
        min=(min>a)?a:min,max=(max<a)?a:max,sum+=a;
    }
    cout << min <<" "<< max <<" "<< sum <<endl;
}

Measured memory_bytes: 3128
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, cnt int
	fmt.Scan(&n)

	s := make([]string, n)
	for i := range s {
		var w string
		fmt.Scan(&w)
		s[i] = sortString(w)
	}
	sm := make(map[string]int)
	for _, v := range s {
		cnt += sm[v]
		sm[v]++
	}

	fmt.Println(cnt)
}

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}


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

typedef long long ll;

string str;

ll dfs( ll a, ll b, ll d )	// a : 返す値、b : 足す値, d : 深さ
{
	if( str.size()-1 < d )
	{
		return a + b;
	}
	else
	{
		ll m = dfs( a, b * 10 + str[d] - '0', d + 1 );	// 足さない場合
		ll n = dfs( a + b, str[d]-'0', d + 1 );	// 足す場合
		return m + n;
	}
}

int main()
{
	cin >> str;
	ll ans = dfs( 0, str[0]-'0', 1 );
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define N 100

int n, m;
char a[N], b[N];

int main() {
	scanf("%d%s%s", &m, a + 1, b + 1);
	for(int i = 1; i <= m; ++i) {
		if(a[i] != a[i + 1]) {
			a[++n] = a[i];
			b[n] = b[i];
		}
	}
	ll ans = a[1] == b[1] ? 3 : 6;
	for(int i = 2; i <= n; ++i) {
		if(a[i] == b[i]) {
			if(a[i - 1] == b[i - 1]) {
				ans = ans * 2ll % mod;
			}
		} else {
			if(a[i - 1] == b[i - 1]) {
				ans = ans * 2ll % mod;
			} else {
				ans = ans * 3ll % mod;
			}
		}
	}
	printf("%lld\n", ans % mod);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, a[300300];
ll ans;

int main () {
        cin >> N;
        fo(i, 0, 3*N) cin >> a[i];
        sort(a, a+3*N);
        fo(i, 0, N) ans += a[3*N-1-i*2-1];
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 1408
use std::cmp::*;
use std::io::*;

const MOD: u64 = 1_000_000_007;

mod enumeration {
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }
    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }
        pub fn c(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}

fn modpow(mut x: u64, mut e: u64) -> u64 {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = x * res % MOD;
        }
        x = x * x % MOD;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n = s.len();

    let unko = enumeration::Enumeration::new(n + k + 1, MOD);
    let mut ans = 0;
    for i in n..k + n {
        ans = (ans + unko.c(k + n, i) * modpow(25, (k + n - i) as u64)) % MOD;
    }
    println!("{}", (ans + 1) % MOD);
}


Measured memory_bytes: 53592
import java.util.*;
class Main 
{
  public static void main(String[] args) 
  {
      Scanner sc = new Scanner(System.in);
    String input =sc.next();	
    if(input.equals("Sunny")){
      System.out.println("Cloudy");
     
    } else if(input.equals("Cloudy")) {
      System.out.println("Rainy");
    } else if(input.equals("Rainy")){
      System.out.println("Sunny");
    }
    
  }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char x[100],y[100];
	int i=0;
	while(~scanf("%s %s",&x[i],&y[i]))
	{
	if((x[i]-'0')>(y[i]-'0')) printf(">\n");
	if((x[i]-'0')<(y[i]-'0')) printf("<\n");
	if((x[i]-'0')==(y[i]-'0')) printf("=\n");
	i++;
	}
}

Measured memory_bytes: 128
s, t = input(), input()
f = [-1] * 27
can = True
count = 0
for i in range(len(s)):
    if f[ord(s[i])-ord("a")] == -1:
        f[ord(s[i])-ord("a")] = ord(t[i]) - ord("a")
        count += 1
    elif f[ord(s[i])-ord("a")] == ord(t[i]) - ord("a"):
        continue
    else:
        can = False
        break
if len(set(f)) != count+1:
    can = False
if can:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll h,w,k ; 
	cin >> h >> w >> k ;
	vvc g(h,vc(w)) ;
	for(auto &i:g) for(auto &j:i) cin >> j ;
	ll ans = 0 ;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			ll cnt = 0 ;
			for(int l=0;l<h;l++){
				for(int m=0;m<w;m++){
					if(i&(1<<l)||j&(1<<m)) continue ;
					if(g.at(l).at(m)=='#') cnt++ ;
				}
			}
			if(cnt==k) ans++ ;
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 3588
# coding: utf-8
#Problem Name: Is it a Right Triangle?
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

n = int(raw_input())
for i in range(n):
    side = sorted(map(int,raw_input().split(' ')))
    if side[0]**2 + side[1]**2 - side[2]**2:
        print 'NO'
    else:
        print 'YES'

'''
Sample Input
3
4 3 5
4 3 6
8 8 8
'''

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

/*
1秒間に上下左右いずれかに1しか動かないので、abs(x(i+1)-x(i)) + abs(y(i+1)-y(i))
の解は1秒ごとに偶数か奇数の値を取る。
地点(0,0)から始まるので、1秒後には奇数、2秒後には偶数、と、秒数と同じ偶奇を取る。
よって、t(i+1)とt(i)、(x(i+1),y(i+1))と(x(i),y(i))それぞれの差の偶奇が一致していれば
実現可能ということになる。
*/

int main() {
  int N;
  cin >> N;
  
  vector<int> t(100010), x(100010), y(100010);
  // 差を求めたいのでindex 0は0にしておき, index 1から値を挿入する
  for (int i = 0; i < N; i++) cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
  
  bool possible = true;
  for (int i = 0; i < N; i++) {
    int d_time = t.at(i+1) - t.at(i);
    int d_pos = abs(x.at(i+1) - x.at(i)) + abs(y.at(i+1) - y.at(i));
    if (d_pos > d_time) possible = false;  // d_pos > d_timeの場合もう不可能確定
    if (d_time % 2 != d_pos % 2) possible = false;  // 偶奇不一致の場合不可能
  }
  
  cout << (possible ? "Yes" : "No") << endl;
}

/*
各秒の動きをシミュレーションしても良し。

int current_t = 0, current_x = 0, current_y = 0;  // 初期時刻と位置
bool possible = true;
for (int i = 0; i < N; i++) {
  int t, x, y;
  cin >> t >> x >> y;  // 目的時刻と位置
  for (; current_t < t; current_t++) {
    // x(or y)がcurrent_x(or y)より小さければ戻る(-1)。大きければ進む(1)
    if (current_x != x) current_x += (x < current_x) ? -1 : 1;  // xがずれてるならxを調整
    else current_y += (y < current_y) ? -1 : 1;  // そうでないならyを調整
  }
  // 目的時刻に目的位置に辿り着いていないならfalse
  if (current_x != x || current_y != y) possible = false;
}
*/

Measured memory_bytes: 4536
#include <cstdio>
#include <cstdint>
#include <cstddef>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <queue>
#include <stack>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> d(n);
  for (auto& di: d) scanf("%d", &di);

  int res = 0;
  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < i; ++j)
      res += d[i] * d[j];

  printf("%d\n", res);
}


Measured memory_bytes: 256