akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <set>  
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int ans =0;
  for(int i=0;i<n;i++){
    int a;
    cin >>a;
    ans +=a;
  }
  cout << ans-n;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll K;
  scanf("%lld",&K);
  cout << K*(ll)pow(K-1,N-1) << endl;
}

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


Measured memory_bytes: 256
A,B =[int(i) for i in input().split()]
num = 0
for i in range(A,B+1):
    n = i
    s=[]
    while(n>0):
        s.append(str(n%10))
        n //= 10

    s_rev = ''.join(s[::-1])
    s = ''.join(s)
    if(s == s_rev):
        num += 1
print(num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

const int N = 500 + 5, C = 30 + 5, inf = 1e9;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int g[N][N], d[C][C];
	int n,c;
	cin >> n >> c;
	rep(i,1,c+1){
		rep(j,1,c+1){
			cin >> d[i][j];
		}
	}
	rep(i,1,n+1){
		rep(j,1,n+1){
			cin >> g[i][j];
		}
	}
	vector<vector<pii>> top(3);
	rep(mod,0,3){
		int best = inf;
		rep(col,1,c+1){
			int cur = 0;	
			rep(i,1,n+1){
				rep(j,1,n+1){
					if((i + j) % 3 == mod){
						if(g[i][j] != col){
							cur += d[g[i][j]][col];
						}
					}
				}
			}
			top[mod].push_back({cur, col});
		}
	}
	rep(i,0,3){
		sort(all(top[i]));	
	}
	int ans = inf;
	rep(i,0,3){
		rep(j,0,3){
			rep(k,0,3){
				if(top[0][i].second != top[1][j].second && top[1][j].second != top[2][k].second && top[0][i].second != top[2][k].second){
					gmin(ans, top[0][i].first + top[1][j].first + top[2][k].first);
				}
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int MAXN=1e5+5;
int ans[MAXN];
vi dp[MAXN][2];
vi pref[MAXN][2];
vi suff[MAXN][2];
vvi adj(MAXN);
int N,MOD;

int dfs(int u, int p, int col) {
    int ppos = lower_bound(ALL(adj[u]), p) - adj[u].begin();

    if(dp[u][col][ppos] >= 0)
        return dp[u][col][ppos];

    if(pref[u][col][ppos] < 0) {
        int idx = ppos;
        while(pref[u][col][idx-1] < 0)
            idx--;
        RNG(i,idx,ppos) {
            ll rez = dfs(adj[u][i-1], u, col);
            rez *= pref[u][col][i-1];
            pref[u][col][i] = rez%MOD;
        }
    }
    if(suff[u][col][ppos+1] < 0) {
        int idx = ppos+1;
        while(suff[u][col][idx+1] < 0)
            idx++;
        REV(i,idx,ppos+1) {
            ll rez = dfs(adj[u][i], u, col);
            rez *= suff[u][col][i+1];
            suff[u][col][i] = rez%MOD;
        }
    }

    ll res = 1LL * suff[u][col][ppos+1] * pref[u][col][ppos];
    if(col==0)
        res += dfs(u, p, 1);

    return dp[u][col][ppos]=res%MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin>>N>>MOD;
    FOR(i,N-1)
    {
        int a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    RNG(u,1,N) {
        sort(ALL(adj[u]));
        FOR(i,2) {
            dp[u][i].resize(adj[u].size()+1, -1);
            pref[u][i].resize(adj[u].size()+1, -1);
            suff[u][i].resize(adj[u].size()+1, -1);
            pref[u][i][0] = 1;
            suff[u][i][adj[u].size()] = 1;
        }
    }

    RNG(u,1,N) {
        ll res = 1;
        for(auto to : adj[u])
            res = res * dfs(to, u, 0) % MOD;
        ans[u] = res;
    }

    FOR(i,N) cout<<ans[i+1]<<'\n';

    return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

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

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


void Main() {
	unordered_map<string, int> cnt;
	int N; cin >> N;

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		string S; cin >> S;
		sort(begin(S), end(S));
		ans += cnt[S];
		cnt[S]++;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 10316
#include<bits/stdc++.h>
using namespace std;
int calc(int n)
{
    int i,ans=0;
    while(n)
    {
        ans+=(n%10);
        n/=10;
    }
    return ans;
}
int main()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    for(int i=1;i<=n;i++)
    {
        if(calc(i)>=l&&calc(i)<=r) sum+=i;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;

const double pi = acos(-1.0);

double rem_Length(double b,double c,double param)
{
	double angle = (param*pi)/180;
	double a=sqrt(b*b+c*c-2*b*c*cos(angle));
	return a;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	double a,b,h,m;
	cin>>a>>b>>h>>m;
    double ang1=h*30;
    double ang2=m*6;
    double extra=(m/60)*30;
    ang1+=extra;
    double angle=abs(ang1-ang2);
    double ans=rem_Length(a,b,angle);
    
    cout<<fixed<<setprecision(20)<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 4240
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}


int main(){
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<ll> left(n);
	vector<ll> right(n);
	left[0]=a[0];
	right[n-1]=a[n-1];
	for(int i=1;i<n;i++){
		left[i]=gcd(left[i-1], a[i]);
	}
	for(int i=n-2;i>=0;i--){
		right[i]=gcd(right[i+1], a[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(i==0){
			ans=right[1];
			continue;
		}
		if(i==n-1){
			ans=max(ans,left[n-2]);
			continue;
		}
		ll l=left[i-1];
		ll r=right[i+1];
		ans=max(ans,gcd(l,r));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> p(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> p[i]; }

	for (int i = 1; i <= N; ++i) {
		if (p[i] != i) {
			swap(p[i], p[p[i]]);
			break;
		}
	}

	bool ok = true;
	for (int i = 1; i <= N; ++i) {
		if (p[i] != i) { ok = false; }
	}

	if (ok) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


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

using namespace std;

string S;
int ans=0;

void input(){
  cin >> S;
}

void solve(){
  int n=S.length();
  int tmp=0;
  for(int i=0;i<n;i++){
    if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
      tmp+=1;
      ans=max(tmp,ans);
    }
    else{
      tmp=0;
    }
  }
}

int main(){
  input();
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e4 + 5;
int n;
int p[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  return true;
}

int a[maxn], b[maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    a[i] = n * (i + 1);
    b[i] = n * (n - i);
  }
  for (int i = 0; i < n; i++) {
    a[p[i]] += i;
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  for (int i = 0; i < n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
 
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

 

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right;
	}
     }
  z->parent = y;
  if(y == NIL) //tree is empty
    {
      root = z;
    }
  else if(z->key < y->key)
    {
      y->left = z;
    }
  else
    {
      y->right = z;
    }
}

void inorder(Node u){
  if(u == NIL)
    {
      return ;
    }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    {
      return ;
    }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25140
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int a = cin.next!int,
      b = cin.next!int,
      c = cin.next!int;
  int x = cin.next!int;

  int res;
  foreach (i; 0 .. a + 1) {
    foreach (j; 0 .. b + 1) {
      foreach (k; 0 .. c + 1) {
        res += i * 500 + j * 100 + 50 * k == x;
      }
    }
  }
  writeln(res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    int n,ans=0,a[100005];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(i==a[a[i]]){
            ans++;
        }
    }
    cout<<ans/2<<endl;
    return(0);
}

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

int main(){
	int n, A[100];
	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> A[i];
	
	for ( int i = n-1; i >= 0; i-- ) {
		if ( i != n-1 ) cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3084
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    string s;
    R(s);
    int an=0;
    REPP(i,1,n){
        int d[2][26]={};
        REP(j,i){
            d[0][s[j]-'a']++;
        }
        REPP(j,i,n)d[1][s[j]-'a']++;
        int cnt=0;
        REP(j,26)cnt+=(d[1][j]&&d[0][j]);
        an=max(an,cnt);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 764
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
  
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
  
typedef pair<int, int> pii;
typedef long long ll;
  
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int dp[1010][1010];
signed main() {
    int N, K; cin >> N >> K;
    dp[0][0] = 1;
    for(int i=0; i<N; i++) {
        for(int j=1; j<=i+1; j++) {
            (dp[i+1][j] += dp[i][j-1]) %= MOD;
            (dp[i+1][j] += dp[i][j] * j) %= MOD;
        }
    }
 
    int ans = dp[N][K];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9968
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int A = input[0];
            int B = input[1];
            int middle = (A + B) / 2;
            int sub = A - B;
            if (sub % 2 == 0)
            {
                Console.WriteLine(middle);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


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

struct Card { char suit, value; };

void bubble(struct Card A[], int N)
{
  for ( int i = 0; i < N; i++)
  {
    for ( int j = N - 1; j >= i + 1; j-- )
    {
      if ( A[j].value < A[j-1].value )
      {
        Card t = A[j]; A[j] = A[j-1]; A[j-1]=t;
      }
    }
  }
}

void selection(struct Card A[], int N)
{
  for ( int i = 0; i < N; i++ )
  {
    int minj = i;
    for ( int j = i; j< N; j++ )
    {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N)
{
  for ( int i = 0; i < N; i++ )
  {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}


bool isStable(struct Card C1[], struct Card C2[], int N)
{
  for ( int i = 0; i < N; i++ )
  {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main()
{
  Card C1[100], C2[100];
  int N;
  char ch;
  cin >> N;
  for ( int i = 0; i < N; i++)
  {
    cin >> C1[i]. suit >> C1[i].value;
  }
  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];
  bubble(C1, N);
  selection(C2, N);
  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) )
  {
    cout << "Stable" << endl;
  }
  else
  {
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S.at(0) != 'A' || S.at(1) < 'a' || S.at(S.size() - 1) < 'a')
    {
        cout << "WA" << endl;
        return 0;
    }
    int cCount = 0;
    for (int i = 2; i < S.size() - 1; i++)
    {
        if (S.at(i) == 'C')
        {
            cCount++;
        }
        else if (S.at(i) < 'a')
        {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (cCount == 1)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

class EightQueen
{
public:
  vector<vector<int>> bd;
  EightQueen(){}
  EightQueen( int n ) : bd(n, vector<int>(n)) {}
  int solve();
  bool dfs( int r );
  bool conflict( int r, int c );
};

bool EightQueen::conflict( int r, int c )
{
  for ( auto i = 0; i < 8; ++i )
    for ( auto j = 0; j < 8; ++j )
      {
        if ( bd[i][j] == 0 ) continue;

        if ( i == r ) return false;
        if ( j == c ) return false;
        if ( r - c == i - j ) return false;
        if ( r + c == i + j ) return false;
      }
  return true;
}

bool EightQueen::dfs( int r )
{
  if ( r == 8 ) return true;

  for ( auto c = 0; c < 8; ++c )
    {
      if ( bd[r][c] == 2 )
        {
          if ( dfs( r + 1 ) ) return true;
        }
      else
        {
          if ( conflict( r, c ) )
            {
              bd[r][c] = 1;
              if ( dfs( r + 1 ) ) return true;
              bd[r][c] = 0;
            }
        }
    }
  
  return false;
}

int EightQueen::solve()
{
  dfs( 0 );

  for ( auto r = 0; r < 8; ++r )
    {
      for ( auto c = 0; c < 8; ++c )
        {
          if ( bd[r][c] )
            cout << "Q";
          else
            cout << ".";
        }
      cout << endl;
    }
      
  return 0;
}

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

  EightQueen eq( 8 );

  for ( auto i = 0; i < n; ++i )
    {
      int r, c;
      cin >> r >> c;
      eq.bd[r][c] = 2;
    }
  
  eq.solve();

  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int SG(int x,int k) {
	if (x<k) return 0;
    if (x%k==0) return x/k;
    if ((x%k)%(x/k+1)==0) return x/k;
    return SG(x-(x/k+1)*(1+(x%k)/(x/k+1)),k);
}
int main(){
    int n;
    scanf("%d",&n);
    int ans=0;
    for (int i=1;i<=n;i++) {
        int a,k;
        scanf("%d%d",&a,&k);
        ans^=SG(a,k);
    }
    if (ans!=0) printf("Takahashi\n");
    else printf("Aoki\n");
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
double x[8], y[8], res;

double dist(int a, int b) {
	return sqrt((x[a] - x[b])*(x[a] - x[b]) + (y[a] - y[b])*(y[a] - y[b]));
}

int main() {
	cin >> N;
	vector<int>v;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		v.push_back(i);
	}
	do {
		for (int i = 0; i < N - 1; i++) {
			res += dist(v[i], v[i + 1]);
		}
	} while (next_permutation(v.begin(), v.end()));
	for (int i = 1; i <= N; i++) {
		res /= i;
	}
	printf("%.10f\n", res);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int TC = Integer.parseInt(sc.next(), 10);
        
        while (TC-- > 0) {
            int a = getIntValue(sc.next());
            int b = getIntValue(sc.next());
            System.out.println(convertToMcxi(a + b));
        }
    }
    
    public static int getIntValue(String str) {
        int ret = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isDigit(c)) {
                i++;
                char d = c;
                c = str.charAt(i);
                int val = Integer.parseInt(d+"", 10);
                switch (c) {
                    case 'm': val *= 1000; break;
                    case 'c': val *= 100; break;
                    case 'x': val *= 10; break;
                    default: break;
                }
                ret += val;
            } else {
                switch (c) {
                    case 'm': ret += 1000; break;
                    case 'c': ret += 100; break;
                    case 'x': ret += 10; break;
                    case 'i': ret += 1; break;
                    default: break;
                }
            }
        }
        // System.out.println(str + " " + ret);
        return ret;
    }
    
    public static String convertToMcxi(int num) {
        String ret = "";
        int m = num / 1000;
        num = num % 1000;
        int c = num / 100;
        num = num % 100;
        int x = num / 10;
        num = num % 10;
        
        switch (m) {
            case 0: break;
            case 1: ret += "m"; break;
            default: ret += m + "m"; break;
        }
        switch (c) {
            case 0: break;
            case 1: ret += "c"; break;
            default: ret += c + "c"; break;
        }
        switch (x) {
            case 0: break;
            case 1: ret += "x"; break;
            default: ret += x + "x"; break;
        }
        switch (num) {
            case 0: break;
            case 1: ret += "i"; break;
            default: ret += num + "i"; break;
        }
        return ret;
    }
}




Measured memory_bytes: 39564
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] A = S.toCharArray();
		for(int i = 0; i < S.length(); i++) {
			A[i] = 'x';
		}
		System.out.println(A);
	}
}

Measured memory_bytes: 21844
from itertools import product

s = input()
x, y = list(map(int, input().split()))

a = [0, 1]

fs = s.split("T")
f_num = [len(f) for f in fs]

dir_lst = [[], []]

for i in range(len(f_num)):
    dir_lst[i%2].append(f_num[i])

x_lst = dir_lst[0].copy()
y_lst = dir_lst[1].copy()

nowx = x_lst.pop(0)
x_lst.sort()
while x_lst != []:
    if nowx > x:
        nowx -= x_lst.pop()
    else:
        nowx += x_lst.pop()

y_lst.sort()
nowy = 0
while y_lst != []:
    if nowy > y:
        nowy -= y_lst.pop()
    else:
        nowy += y_lst.pop()

if x == nowx and y == nowy:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#   n??m????????? A ??¨ m??l ????????? B ?????\??????????????????????????§?????? n??l ????????? C ???????????????????????°??????
n, m, l = map(int, input().split())
#   n x m ???????????????
A = [[0 for i in range(m)] for j in range(n)]
#   m x l ???????????????
B = [[0 for i in range(l)] for j in range(m)]
#   n x l ??????(????????????)?????????
C = [[0 for i in range(l)] for j in range(n)]

#   m x n ??????????¨??????\?????????????????????
for i in range(0, n):
    A[i][:m] = map(int, input().split())
    #   print(sheet_nxm)
#   m x n ??????????¨??????\?????????????????????
for i in range(0, m):
    B[i][:l] = map(int, input().split())
    #   print(sheet_mxl)
#   C(n x l)??????????¨???????A????????¨B????????????
for i in range(0, n):
    for j in range(0, l):
        for k in range(0, m):
            C[i][j] += A[i][k] * B[k][j]
#   print(C)
#   C???????????????
for i in range(0, n):
    for j in range(0, l):
        print("{0}".format(C[i][j]), end="")
        if j != l - 1:
            print(" ", end="")
        else:
            print("")

Measured memory_bytes: 9176
#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>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

string S;

int main() {

	cin >> S;
	for (int i = 1; i < S.length(); i++) {
		if (S[i - 1] == S[i])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    long long N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; (N - i) / i > i; i++) {
        ans += (N - i) % i == 0 ? (N - i) / i : 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000003LL)
typedef long long Int;

int n, mi, memo[60000*4], cs[60000][2], w[60000];
vector<int> g[60000];
bool has[60000];

void add(int p, int q) {
    if (p > q) swap(p, q);
    g[p].push_back(q);
}

int pre(int p, int q) {
    if (p+1 == q) return -1;
    const int k = mi++;
    has[k] = false;
    if (g[p].back() == q) {
        has[k] = true;
        g[p].pop_back();
    }
    const int r = g[p].back();
    rep (b, 4) memo[k*4|b] = -1;
    cs[k][0] = pre(p, r);
    cs[k][1] = pre(r, q);
    w[k] = q-p+1;
    return k;
}

int rec(int k, int x, int y) {
    if ((w[k]+x+y)%2) return 0;
    if (k == -1) return x == y;
    const int sig = k*4|x*2|y;
    if (memo[sig] != -1) return memo[sig];
    const int p = cs[k][0], q = cs[k][1];
    Int ans = 0;
    ans += (Int)rec(p, x, 0) * rec(q, 1, y);
    ans += (Int)rec(p, x, 1) * rec(q, 0, y);
    if (x && y && has[k]) {
        ans += (Int)rec(p, 0, 0) * rec(q, 1, 0);
        ans += (Int)rec(p, 0, 1) * rec(q, 0, 0);
    }
    return memo[sig] = ans % MOD;
}

int main() {
    for (;;) {
        int m, a, b;
        scanf("%d%d", &n, &m);
        if (n == 0) return 0;
        rep (_, m) {
            scanf("%d%d", &a, &b);
            add(a-1, b-1);
        }
        rep (i, n) add(i, (i+1)%n);
        rep (i, n) sort(g[i].begin(), g[i].end());
        mi = 0;
        pre(0, n-1);
        printf("%d\n", rec(0, 1, 1));
    }
}

Measured memory_bytes: 12004
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll A, B;
ll search(ll mid){
	return (A * mid / B - A * (mid / B));
}
ll ans;
int main() {
	cin >> A >> B >> N;
	ans = search(min(N, B-1));
	cout<<ans<<endl;
	return 0;
}



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

int main() {
  int n;
  cin>>n;
  int k=0;
  int a=0;
  for(int i=1;k<n;i++){
    a=0;

    for(int j=2;j*j<=5*i+1;j++){

      if((5*i+1)%j==0){a=1;break;}
    }
    if(a==1){continue;}
    else { cout<<5*i+1<<" ";k++;}
    
    }
  cout<<endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int array[] = new int[num];
    int array_min[] = new int[num];
    int min = num + 1;
    for(int i = 0;i < num;i++){
      array[i] = sc.nextInt();
      if(min > array[i]){
        min = array[i];
      }
      array_min[i] = min;
    }
    int count = 0;
    for(int i = 0;i < num;i++){
      if(array_min[i] >= array[i]){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 61452
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, x, l[100], za = 0, ans = 0;
	cin >> n >> x;
	for (int a1 = 0; a1 < n; a1++) {
		cin >> l[a1];
		za = za + l[a1];
		if (za <= x) {
			ans++;
		}
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 256
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(i=0;i<(int)n;i++)
#define rep2(i, a, b) for(i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 100010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	
	fastio;
	char ch;
	cin >> ch;
	printf("%c\n", ch+1);

	return 0;
}

Measured memory_bytes: 256
// ABC153B.cpp
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric> //accumulateに必要
#include <iomanip> //setprecision(桁数指定)に必要
using namespace std;

int main(){
	int H,N;
	cin>>H>>N;
	long long sum = 0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		sum += a;
	}
	string ans;
	if(sum>=H)ans = "Yes";
	else ans = "No";
	cout<<ans<<endl;
}

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(1)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)
#define MAXN 105
#define MAXW (int)(1e5)+5

int n, w, masa, wartosc;
ll plecak[MAXW];
ll INF=(1e18);
ll wynik;

int main()
{
	readUI(&n);
	readUI(&w);
	for (int i=1; i<=w; ++i)
	{
		plecak[i]=-INF;
	}
	for (int i=1; i<=n; ++i)
	{
		readUI(&masa);
		readUI(&wartosc);
		for (int j=w; j>=masa; --j)
		{
			plecak[j]=max(plecak[j], plecak[j-masa]+wartosc);
			wynik=max(wynik, plecak[j]);
		}
	}
	fprintf (out, "%lld\n", wynik);
	return 0;
}
/*
*/




Measured memory_bytes: 1024
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Set (Set)
import qualified Data.Set as Set

main :: IO ()
main = do
  s <- getLine
  [k] <- readInts
  putStrLn $ (sort $ substrings s) !! (k - 1)

substrings :: String -> [String]
substrings s = Set.toList $ substringsRec Set.empty 1 0
  where
    len = length s
    sublist n i = drop i $ take (n + i) s
    substringsRec ss n i =
      if i + n == len
        then if n == len || n == 5
          then ssNext
          else substringsRec ssNext (n + 1) 0
        else substringsRec ssNext n (i + 1)
      where
        ssNext = Set.insert (sublist n i) ss


-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 6396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){

    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
    else cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N=0;
    cin >> N;
    ll r=0,g=0,b=0;
    string S="";
    cin >> S;
    ll count=0;
    
    for(ll i=0;i<N;i++){
        if(S.at(i)=='R') r++;
        if(S.at(i)=='G') g++;
        if(S.at(i)=='B') b++;
    }
    
    for(ll i=0; i<N-2; i++){
        for(ll j=i; j<N-1;j++){
            ll k=2*j-i;
            if(k>N-1){
                continue;
            }
            if(S.at(i)!=S.at(j)&&S.at(j)!=S.at(k)&&S.at(i)!=S.at(k)){
                count++;
            }
        }
    }
    
    cout << r*g*b-count << endl;
}


Measured memory_bytes: 3608
import java.awt.Point;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			n = scanner.nextInt();
			Integer[] x1 = new Integer[n];
			Integer[] y1 = new Integer[n];
			Integer[] x2 = new Integer[n];
			Integer[] y2 = new Integer[n];
			for (int i = 0; i < n; i++) {
				x1[i] = scanner.nextInt();
				y1[i] = scanner.nextInt();
				x2[i] = scanner.nextInt();
				y2[i] = scanner.nextInt();
			}
			w = compress(x1, x2, w);
			h = compress(y1, y2, h);

			boolean[][] a = new boolean[h][w];
			for (int i = 0; i < n; i++) {
				for (int y = y1[i]; y < y2[i]; y++) {
					for (int x = x1[i]; x < x2[i]; x++) {
						a[y][x] = true;
					}
				}
			}
			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (a[i][j])
						continue;
					ans++;
					a[i][j] = true;
					Deque<Point> deque = new ArrayDeque<Point>();
					deque.push(new Point(j, i));
					while (!deque.isEmpty()) {
						Point p = deque.poll();
						for (int[] m : move) {
							int ny = p.y + m[0];
							int nx = p.x + m[1];
							if (!isOK(ny, nx))
								continue;
							if (a[ny][nx])
								continue;
							a[ny][nx] = true;
							deque.push(new Point(nx, ny));
						}
					}
				}
			}
			System.out.println(ans);
		}
	}

	private boolean isOK(int ny, int nx) {
		if (0 <= ny && ny < h && 0 <= nx && nx < w)
			return true;
		return false;
	}

	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	int h, w;
	int n;

	private int compress(Integer[] x1, Integer[] x2, int wh) {
		NavigableSet<Integer> set = new TreeSet<Integer>();
		set.add(0);
		set.add(wh);
		set.addAll(Arrays.asList(x1));
		set.addAll(Arrays.asList(x2));
		Integer[] x = set.toArray(new Integer[0]);
		for (int i = 0; i < n; i++) {
			x1[i] = Arrays.binarySearch(x, x1[i]);
			x2[i] = Arrays.binarySearch(x, x2[i]);
		}
		return x.length - 1;
	}
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const string fe = "Fennec";
const string sn = "Snuke";
const int MAX = 1e5 + 10;
int n;
vector<int> G[MAX];
int color[MAX];

int main() {
  memset(color, -1, sizeof(color));
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  q.emplace(n - 1, 1);
  while (!q.empty()) {
    auto now = q.front();
    q.pop();
    if (color[now.first] == -1) {
      color[now.first] = now.second;
      for (int e : G[now.first]) {
        q.emplace(e, now.second);
      }
    }
  }
  int sum[2] = {};
  for (int i = 0; i < n; i++) {
    sum[color[i]]++;
  }
  cout << (sum[0] > sum[1] ? fe : sn) << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int f,v=0;
    for(int i=2;i>=0;i--){
        cin>>f;
        v|=(f<<i);
    }
    if(v==6||v==1)cout<<"Open"<<endl;
    else cout<<"Close"<<endl;
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"

using namespace std;

string a;
int N; 
int main() {
  N = 0;
  cin >> a;
  if (a[0] == '1') {N = N + 1;}
  if (a[1] == '1') {N = N + 1;}
  if (a[2] == '1') {N = N + 1;}
  cout << N << endl;
}

Measured memory_bytes: 256
@n,@t = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
benefit = []
max = 0
(@n - 1).downto(0) { |n|  
  benefit.push max - arr[n]
  max = arr[n] > max ? arr[n] : max
}

puts benefit.count(benefit.max)

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


void solve(long long N, std::vector<long long> a){
  multimap<long long, long long> tab;

  for(long long i = 1; i <= N; i++) {
    tab.emplace(a[i], i);
  }

  long long count = 0;
  for(long long i = 1; i <= N; i++) {
    auto it = tab.equal_range(i);
    for(auto j = it.first; j != it.second; j++) {
      if(j->second == a[i]) count++;
    }
  }

  cout << count/2 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N+1);
  for(int i = 1 ; i <= N ; i++){
    scanf("%lld",&a[i]);
  }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 7296
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<string.h>

#define		MXCD	100+5

int		main(void)
{
	int		n;
	int		i;
	int		trsum, hnsum;

	char	trstr[MXCD];
	char	hnstr[MXCD];

	scanf("%d",&n);

	trsum = hnsum = 0;
	for(i=0; i<n; i++)
	{
		scanf("%s",trstr);
		scanf("%s",hnstr);

		if( strcmp( trstr, hnstr ) == 0 )
		{
			trsum+=1;
			hnsum+=1;
		}
		else if( strcmp( trstr, hnstr ) > 0)
		{
			trsum+=3;
		}else
		{
			hnsum+=3;
		}
	}
	printf("%d %d\n",trsum, hnsum);

	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9564
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[]) {
	unordered_map<int, unordered_map<int, long long int>> um;
	int n;
	cin >> n;
	int nn = n / 2;
	vector<long long int> v;
	for (int i = 0; i < n; i++) {
		long long int t;
		cin >> t;
		v.push_back(t);
	}

	for (int i = 0; i < n; i++) {
		int l = i, r = n - i - 1;
		int left_rank = nn - r / 2, right_rank = min(nn, l / 2 + 1);
		for (int j = left_rank; j <= right_rank; j++) {
			if (j == 1) {
				um[i][j] = v[i];
			} else {
				bool not_found = true;
				for (int k = 2; k <= 4 && i - k >= 0; k++) {
					if (um[i - k].find(j - 1) != um[i - k].end()) {
						if (not_found) {
							not_found = false;
							um[i][j] = um[i - k][j - 1] + v[i];
						} else {
							um[i][j] = max(um[i][j], um[i - k][j - 1] + v[i]);
						}
					}
				}
			}
		}
	}

	long long int res = -2 * (1e14);
	for (int i = 0; i < n; i++) {
		if (um[i].find(nn) != um[i].end()) {
			res = max(res, um[i][nn]);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 38028