akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=1000005;
char ch[N];
int ans;
int main(){
	#ifdef Brollan
		//freopen("1.in","r",stdin);
	#endif
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	int x=0,y=0;
	Rep(i,n,1){
		if(ch[i]=='0'){x++; y--;}
		else if(ch[i]=='1'){x--; y++;}
		else {x--; y--;}
		x=max(x,0);
		y=max(y,0);
		ans=max(ans,max(x,y));
	}
	int l=0,r=ans,sum=ans,zt=1;
		For(i,1,n){
			if(l==r)zt=0;
			if(ch[i]=='0'){
				l++; r++; 
				if(r>sum){if(zt)r=sum; else {r=sum-1;}}
			}else if(ch[i]=='1'){
				l--; r--; 
				if(l<0){if(zt)l=0; else {l=1;}}
			}else{
				l--; r++;
				if(r>sum){if(zt)r=sum; else {r=sum-1; }}
				if(l<0){if(zt)l=0; else {l=1; }}
			}
			if(l>sum||r<0){
				sum++; break;
			}
			//cout<<l<<" "<<r<<" mx:"<<mx<<" sum:"<<sum<<" "<<zt<<endl;
		}
	cout<<sum<<endl;
}
/*
20
01

40
50/31
41/22
23/04
14/05
*/

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

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

  long long ans=1e13;
  for (int i = 1; i <= sqrt(n); ++i){
    if (n % i == 0){
       ans=min(ans,i+n/i);
    }
  }
   cout << ans-2 << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<string,int> psi;
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    string sa, sb;
    ll ca=0, cb=0, ce=0;
    for(ll i=0;i<b;i++)
        sa.push_back((char)a+'0');
    for(ll i=0;i<a;i++)
        sb.push_back((char)b+'0');
    ll len=min(sa.length(),sb.length());
    for(ll i=0;i<len;i++)
    {
        if(sa[i]>sb[i])
            ca++;
        else if(sa[i]<sb[i])
            cb++;
        else
            ce++;
    }
    if(ca==len)
    {
        cout<<sb;
        exit(0);
    }
    if(cb==len)
    {
        cout<<sa;
        exit(0);
    }
    if(ce==len)
    {
        cout<<sb;
        exit(0);
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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

    ll a=0;
    ll ans=0;
    ll anss =0;
    ll x=0;
    ll count=0;
    ll i,j;
    vector<ll> b;

    char N;
    cin>>N;


//b.push_back();
   // ll z[N];

if(N=='A'){
    cout << 'T' << endl;
}else if(N=='T'){
    cout << 'A' << endl;
}else if(N=='C'){
    cout << 'G' << endl;
}else if(N=='G'){
    cout << 'C' << endl;
}

    //cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, q, l[100010], r[100010];
string s;
int ta[100010], cnt;
bool mu;

signed main() {
	cin >> n >> q;
	cin >> s;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'C')mu = true;
		else if (s[i] == 'A'&&mu) {
			cnt++;
			mu = false;
		}
		else mu = false;
		ta[i + 1] = cnt;
	}
	rep(i, q) {
		cin >> l[i] >> r[i];
		cout << ta[l[i]] - ta[r[i]] << endl;
	}
	ggr
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

string A;
//dp[i] i番目の要素にとって最速である(手数, 次のidx)
vector<pair<int,int>> dp;
vector<char> memo;
vector<vector<int>> nex;

int saiki(int now){
  //cerr<<now<<endl;
  if(dp[now].second != -1){
    return dp[now].first;
  }
  int mini = INF;
  rep(j,26){
    int ret = saiki(nex[now][j]);
    if(mini > ret){
      dp[now].first = ret + 1;
      dp[now].second = nex[now][j];
      mini = ret;
      memo[now] = j;
    }
  }
  return dp[now].first;
}

int main(void){
  cin>>A;
  int n = A.size();
  vector<vector<int>> next;
  A = "0" + A + "0";
  rep(i, n+2){
    next.push_back(vector<int>());
    rep(j,26){
      next[i].push_back(n+1);
    }
  }
  rep(i,n+2){
    dp.push_back({INF,-1});
    memo.push_back(-1);
  }
  dp[n+1].first = 0;
  dp[n+1].second = 0;
  cerr<<"mo"<<endl;
  rep(j,26){
    int idx = n+1;
    REP(i, n+2){
      next[i][j] = idx;
      if(A[i]-'a' == j){
        idx = i;
      }
    }
  }
  /*rep(i,n+2){
    rep(j,26){
      cerr<<next[i][j]<<" ";
    }
    cerr<<endl;
  }*/
  cerr<<"Hoge"<<endl;
  nex = next;
  saiki(0);
  cerr<<"unya"<<endl;
  /*rep(i,n+2){
    cerr<<i<<" "<<dp[i].first<<" "<<dp[i].second<<" "<<(char)(memo[i]+'a')<<endl;
  }*/
  int now = 0;
  while(now != n+1){
    cout<<(char)(memo[now]+'a');
    now = dp[now].second;
  }
  cout<<endl;
  return 0;
}


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

int main(void)
{
    long long N,D;
    cin >> N >> D;

    long long x[210000];
    long long y[210000];

    for(int i =0 ; i<N; i++) cin >> x[i] >> y[i];

    long long dis2;
    long long count=0;
    long long DD = D*D;
    for(int i =0 ; i<N; i++){
       dis2 = x[i]*x[i] + y[i]*y[i];
       if(dis2 <= DD) ++count;
    }

    cout << count << endl;
}


Measured memory_bytes: 6752
N, K = map(int, input().split())
H = [int(h) for h in input().split()]
dp = [N*10**4]*N
dp[0] = 0
for i in range(N):
        x = min(i+K+1, N)
        for j in range(i+1, x):
                dp[j] = min(dp[j], dp[i] + abs(H[i]-H[j]))
print(dp[N-1])

Measured memory_bytes: 52448
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function

main :: IO ()
main = do
  Just (n,_) <- BS.readInt <$> BS.getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'-')) <$> BS.getLine
  let tot = VU.sum as
      oddLeast = VU.minimum $ VU.filter odd as
      oddNum = VU.length $ VU.filter odd as
  print $ (`shiftR` 1) $ if odd oddNum then tot - oddLeast else tot



Measured memory_bytes: 4380
#include<bits/stdc++.h>
#include<queue>
#include<map>
using namespace std;
pair<int, int> mp(int a, int b) {
  if (a > b) swap(a, b);
  return make_pair(a, b);
}
int main () {
  int N;
  cin >> N;
  vector<vector<int>>tree(N);
  map<pair<int, int>, int>F;
  for (int i = 0; i < N - 1; i ++) {
    int a, b;
    cin >> a >> b;
    a --;
    b --;
    tree[a].push_back(b);
    tree[b].push_back(a);
    F[make_pair(a, b)] = i;
  }
  F[make_pair(-1, 0)] = N - 1;
  vector<int>cl(N, 0);
  vector<int>par(N);
  par[0] = -1;
  queue<int>que;
  que.push(0);
  int K = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    int c = 1;
    for (int i = 0; i < (int)tree[u].size(); i ++) {
      int v = tree[u][i];
      //cout << v << endl;
      if (cl[F[mp(u, v)]] == 0) {
        //cout << 'r' << ' ';
        if (cl[F[mp(u, par[u])]] == c) c ++;
        cl[F[mp(u, v)]] = c;
        c ++;
        par[v] = u;
        que.push(v);
      }
    }
    //cout << c;
    if (K < c - 1) K = c - 1;
    //cout << endl;
  }
  //cout << endl;
  cout << K << endl;
  for (int i = 0; i < N - 1; i ++) cout << cl[i] << endl;
}



Measured memory_bytes: 13056
import java.util.*;
import java.io.*;

public class Main {
 	
  
  public static void main(String abc[]) {
     Main ans = new Main();
     System.out.println(ans.solve());
  }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N+1];
     int i=0;
     long sum=0;
     for(i=1;i<=N;i++) {
        array[i] = sc.nextLong();
        sum += array[i];
     }
     //System.out.println(Arrays.toString(array));
    
     long [][][] dp =new long[3001][3001][2];
     for(i=0;i<3001;i++) {
        for(int j=0;j<3001;j++) {
            dp[i][j][0] = -1;
            dp[i][j][1] = -1;
        }
     }
    
     long X =  solve(dp, array, 1, 1, N);
     long Y = sum-X;
     return X-Y;
  }
  
  private long solve(long[][][] dp, long[] array, int turn, int i, int j) {
     if(i>j) return 0;
     if (dp[i][j][turn] !=-1) return dp[i][j][turn];
     if (turn==1) {
         long left = array[i] + solve(dp, array, 0, i+1, j);
         long right = array[j] + solve(dp, array, 0, i, j-1);
         dp[i][j][turn] = Math.max(left,right);
     } else {
         long left = solve(dp, array, 1, i+1, j);
         long right = solve(dp, array, 1, i, j-1);
         dp[i][j][turn] = Math.min(left, right);
     }
     return dp[i][j][turn];
  }
}


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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

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

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}


struct Edge {int to, dist, cost;};
typedef vector< vector<Edge> > Graph;

int N;
void dijkstra(int start, Graph& graph) {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    vi d(N, INF);
    d[start] = 0;
    que.push(mp(0, start));

    vi pc(N, -1);

    while(!que.empty()) {
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v] > p.first) continue;
        tr(it, graph[v]) {
            if(
                (d[it->to] > d[v] + it->dist) ||
                (d[it->to] == d[v] + it->dist && pc[it->to] > it->cost)
                    )
            {
                d[it->to] = d[v] + it->dist;
                que.push(mp(d[it->to], it->to));
                pc[it->to] = it->cost;
            }
        }
    }

    cout << accumulate(pc.begin() + 1, pc.end(), 0) << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    int M;
    while(cin >> N >> M, (N|M)) {
        Graph graph(N);

        rep(i, M) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u, --v;
            graph[u].push_back(Edge{v, d, c});
            graph[v].push_back(Edge{u, d, c});
        }

        dijkstra(0, graph);
    }

    return 0;
}

Measured memory_bytes: 2216
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
#define MO 1000000007
using namespace std;
int c[MAXN+5],dp[MAXN+5];
int tot[MAXN+5];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	dp[0]=1;
//	if(c[1]!=c[2])
		tot[c[1]]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=tot[c[i]];
//		if(c[i]!=c[i-1])
//			dp[i]=(1LL*dp[i]+1LL*dp[i-1])%MO;
		if(c[i]!=c[i+1])
			tot[c[i+1]]=(1LL*tot[c[i+1]]+1LL*dp[i])%MO;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 2560
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Bits
import qualified Data.ByteString.Char8 as BS

readInt s = case BS.readInt s of
              Just (x, _) -> x

solveNaive :: Int -> Int -> Int -> Int -> Int
solveNaive !a !b !c !x
  | 500 * a + 100 * b + 50 * c < x = 0
  | c == 0 && x `rem` 100 == 50 = 0
  | otherwise = sum [ 1
                    | na <- [0..a]
                    , nb <- [0..b]
                    , nc <- [0..c]
                    , 500 * na + 100 * nb + 50 * nc == x
                    ]

main = do
  a <- readInt <$> BS.getLine
  b <- readInt <$> BS.getLine
  c <- readInt <$> BS.getLine
  x <- readInt <$> BS.getLine
  print $ solveNaive a b c x


Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
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);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


//xのn乗をmで余りを取る
ll mod_pow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1LL;
	}
	else if (n % 2 == 0) {
		return mod_pow(x * x % m, n / 2, m);
	}
	else {
		return (x * mod_pow(x, n - 1, m)) % m;
	}
}

int main() {

	string s;
	cin >> s;


	ll ans = 0;
	ll one = 0;

	for (int i = 0; i < s.size(); i++)
	{
		ll len = (ll)s.size() - i - 1;
		if (s[i] == '1') {
			ans += mod_pow(2, one, MOD) * mod_pow(3LL, len, MOD);
			ans %= MOD;
			one++;
		}
	}
	ans += mod_pow(2LL, one, MOD);
	ans %= MOD;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int main () {
    string s;

    cin >> s;

    for (char &c : s) {
        if (c == '?')
            c = 'D';
    }

    cout << s << endl;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3764
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
     printf("a < b\n");
    }else if(a > b){
     printf("a > b\n");
    }else if(a == b){
    printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

int32_t main(){
    int n;
    string s;
    cin >>n >>s;
    for(int i = 0; i < SZ(s); i ++){
        s[i] = ((s[i] - 'A' + n)% 26) + 'A';
    }
    cout <<s <<endl;
    return false;
}


Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/
#define MOD (ll)(1e9 + 7)

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll h, w;
    cin >> h >> w;
    char s[h][w];

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> s[i][j];

    ll dp[h][w] = {};

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 && j == 0)
                dp[i][j] = 1;
            else if (s[i][j] == '.')
            {
                if (i > 0)
                {
                    dp[i][j] += dp[i - 1][j];
                    dp[i][j] %= MOD;
                }
                if (j > 0)
                {
                    dp[i][j] += dp[i][j - 1];
                    dp[i][j] %= MOD;
                }
            }
        }
    }

    cout << dp[h - 1][w - 1] << "\n";
}


Measured memory_bytes: 9088
import java.util.*;

public class Main{

    void solve(){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int out = 0;
        for(int i = a; i <= b; i++){
            StringBuilder s = new StringBuilder(Integer.toString(i));
            if(s.toString().equals(s.reverse().toString())) out++;
        }
        System.out.println(out);
    }


    public static void main(String[] args){
        new Main().solve();
    }
}


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

int main() {
  string name;
  cin >> name;
  if (name == "a" || name == "b" || name == "c" || name == "d" || name == "e" || name == "f" || name == "g" || name == "h" || name == "i" || name == "j" || name == "k" || name == "l" || name == "m" || name == "n" || name == "o" || name == "p" || name == "q" || name == "r" || name == "s" || name == "t" || name == "u" || name == "v" || name == "w" || name == "x" || name == "y" || name == "z"){
    cout << "a" << endl;
  }
  else {
    cout << "A" << endl;
  }
}

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

int nPk(int n, int k) {
  int ans = 1;
  for (int i = n; i > n - k; i--) ans *= i;
  return ans;
}

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

  vector<vector<int>> hudr(100);

  for (int i = 1; i <= n; i++) {
    if (i % 10 == 0) continue;
    string tmp = to_string(i);
    int s = tmp[0] - '0';
    int l = tmp[tmp.size() - 1] - '0';
    hudr[s * 10 + l].push_back(i);
  }

  for (int i = 11; i <= 99; i++) {
    if (hudr[i].size() == 1) {
      if (i <= n || hudr[i][0] <= 9) continue;
      hudr[i].pop_back();
    }
  }
  /*
  for (int i = 11; i <= 99; i++) {
    cout << i << " " << hudr[i].size() << endl;
  }
  */
  /*
  int ans = 0;
  for (int i = 11; i <= 99; i++) {
    if (hudr[i].size() == 1) ans++;
    else {
      if (i % 10 == i / 10) ans += nPk(hudr[i].size(), 2) + hudr[i].size();
      else {
        ans += hudr[i].size();
      }
    }
  }
  
  cout << ans << endl;
  */
  int ans = 0;

  for (int i = 11; i <= 99; i++) {
    if (i % 10 == 0) continue;
    //if (i % 10 != i / 10 && i >= 51) continue;
    int idx = 0;
    idx = i / 10 + (i % 10) * 10;
    ans += hudr[i].size() * hudr[idx].size();
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	int S, W;
	cin >> S >> W;

	cout << ((S <= W) ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s;
  cin>>s;
  int n = s.size();
  string ans = "";
  REP(i, n){
    ans += 'x';
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<algorithm>
#include<map>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
int a[maxn],mp[maxn]={0};

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];mp[a[i]]++;
	} 
	sort(a,a+n);int ans=0;
	for(int i=0;i<n;i++){
		if(mp[a[i]]>1) continue;
		int f=0;
		for(int j=1;j<=sqrt(a[i]);j++){
			if(a[i]%j==0){
				if(j!=a[i]&&mp[j]){
					f=1;break;
				}
				if(a[i]/j!=a[i]&&mp[a[i]/j]){
					f=1;break;
				}
			}
		}
		if(!f) ans++;
	} 
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 7792
fun main(args: Array<String>) {
  val (n, m, aTotal, bTotal) = readLine()!!.split(" ").map(String::toInt)
  var a = aTotal
  var b = bTotal
  val board = Array(n, { CharArray(m, { '.' }) })
  if (n % 2 == 1) {
    for (x in 0 until (m / 2)) {
      if (a > 0) {
        board[n - 1][2 * x] = '<'
        board[n - 1][2 * x + 1] = '>'
        a--
      }
    }
  }
  if (m % 2 == 1) {
    for (y in 0 until (n / 2)) {
      if (b > 0) {
        board[2 * y][m - 1] = '^'
        board[2 * y + 1][m - 1] = 'v'
        b--
      }
    }
  }
  val bn = n / 2
  val bm = m / 2
  for (y in 0 until bn) {
    for (x in 0 until bm) {
      if (a >= 2) {
        board[2 * y][2 * x] = '<'
        board[2 * y][2 * x + 1] = '>'
        board[2 * y + 1][2 * x] = '<'
        board[2 * y + 1][2 * x + 1] = '>'
        a -= 2
      } else if (b >= 2) {
        board[2 * y][2 * x] = '^'
        board[2 * y + 1][2 * x] = 'v'
        board[2 * y][2 * x + 1] = '^'
        board[2 * y + 1][2 * x + 1] = 'v'
        b -= 2
      } else if (a == 1 && b == 1 && y == bn - 1 && x == bm - 1 && n % 2 == 1 && m % 2 == 1) {
        // This is the trick part.
        if (board[2 * y][2 * x + 2] == '^') {
          board[2 * y][2 * x + 2] = '.'
          board[2 * y + 1][2 * x + 2] = '^'
          board[2 * y + 2][2 * x + 2] = 'v'
        }
        board[2 * y][2 * x] = '^'
        board[2 * y + 1][2 * x] = 'v'
        board[2 * y][2 * x + 1] = '<'
        board[2 * y][2 * x + 2] = '>'
        a--
        b--

      } else if (a == 1) {
        board[2 * y][2 * x] = '<'
        board[2 * y][2 * x + 1] = '>'
        a--
      } else if (b == 1) {
        board[2 * y][2 * x] = '^'
        board[2 * y + 1][2 * x] = 'v'
        b--
      }
    }
  }

  if (a > 0 || b > 0) {
    println("NO")
    return
  }
  println("YES")
  for (y in 0 until n) {
    println(String(board[y]))
  }
}

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

int main() {
  string r,g,b;
  cin>>r>>g>>b;
  int s=stoi(g+b);
  if(s%4 == 0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

using LL = long long;
using D = double;

LL N, M, L;
vector<vector<LL>> CARD;

LL partition(LL n, LL k) {
  static map<pair<LL, LL>, LL> memo;
  auto m = make_pair(n, k);
  if(memo.count(m)) return memo[m];
  if(k == 1) return 1;
  LL res = 0;
  for(LL i = 1; k - 1 <= n - i; ++i) res += partition(n - i, k - 1);
  return memo[m] = res;
}

LL combination(LL n, LL r) {
  static map<pair<LL, LL>, LL> memo;
  auto m = make_pair(n, r);
  if(memo.count(m)) return memo[m];
  return memo[m] = (r % n == 0 ? 1 : combination(n - 1, r - 1) + combination(n - 1, r));
}

bool valid(auto c, auto& hand) {
  if(c == 3) return true;

  if(CARD[c].empty()) return valid(c + 1, hand);

  for(auto i = 0; i + CARD[c].size() - 1 < hand.size(); ++i) {
    bool ok = true;
    for(auto j = 0; j < CARD[c].size(); ++j) if(hand[i + j] < CARD[c][j]) ok = false;
    if(!ok) continue;

    for(auto j = 0; j < CARD[c].size(); ++j) hand[i + j] -= CARD[c][j];
    ok = valid(c + 1, hand);
    for(auto j = 0; j < CARD[c].size(); ++j) hand[i + j] += CARD[c][j];

//     if(ok)cout<<"OK"<<endl;
    if(ok) return true;
  }
  return false;
}

LL count(auto& hand) {
//   return 1;
  LL res = 1;
  LL zero = 0;
  for(auto i: hand) {
    res *= combination(N, i);
    if(i == 0) ++zero;
  }
  if(zero) res *= partition(M - (hand.size() - zero), zero);
  return res;
}

LL dfs(auto& hand, LL remain, LL last) {
  LL res = 0;

  if(hand.size() > M) return 0;

  if(remain == 0) {
//     for(auto i:hand)cout<<" "<<i;cout<<endl;
    if(count(begin(hand), end(hand), 0ll) == 0) {
      if(hand.size() == M) if(valid(0, hand)) res += count(hand);
    } else {
      if(valid(0, hand)) res += count(hand);
    }
  }

  for(auto i = 0ll; i <= min(N, remain); ++i) {
    if(i == 0 && last == 0) continue;
    hand.emplace_back(i);
    res += dfs(hand, remain - i, i);
    hand.pop_back();
  }

  return res;
}

D solve() {
  for(auto c: CARD) if(c.size() > M) return 0;

  vector<LL> hand;
  D fit = dfs(hand, L, -1);
  D total = combination(N * M, L);
//   return fit;
  return fit / total;
}

int main() {
  while(cin >> N >> M >> L, N | M | L) {
    CARD = vector<vector<LL>>(3);

    for(auto i = 0; i < L; ++i) {
      string s;
      cin >> s;

      if(s.front() == '*') continue;

      auto& c = CARD[s.front() - 'a'];
      c.resize(max(c.size(), s.size()), 0);
      ++c[s.size() - 1];
    }

    cout << setprecision(10) << fixed << solve() << endl;
  }
}

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

int main(){
  vector<char> len = {'a','b','c','d','e','f','g','h',
                      'i','j','k','l','m','n','o','p',
                      'q','r','s','t','u','v','w','x','y','z'};
  char s;
  cin >> s;
  for(int i = 0;i < 26;i++){
  	if(len.at(i) == s){
      s = len.at(i+1);
    	break;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t; 
    map<char, ll> score;
    score['r'] = r;
    score['s'] = s;
    score['p'] = p;
    string win = "";
    rep(i, n){
        if(t[i] == 'r'){ win += 'p'; }
        else if(t[i] == 's'){ win += 'r'; }
        else { win += 's'; }
    }
    ll ans = 0;
    rep(i, n){
        if(i - k >= 0 && t[i] == t[i-k]){
            t[i] = ' ';
        }else{
            ans += score[win[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

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

struct StList
{
  int  m_iKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_iKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int a_iNumber, StList &a_roHead) :
    m_iKey(a_iNumber), m_poPrev(&a_roHead), m_poNext(a_roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &a_roHead, StList &a_roTrail)
{
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      StList *poList = new StList(iNumber, a_roHead);
      a_roHead.m_poNext->m_poPrev = poList;
      a_roHead.m_poNext = poList;
    }
    else if (acCommand[6] == 'F')
    {
      StList *poList = a_roHead.m_poNext;
      poList->m_poNext->m_poPrev = poList->m_poPrev;
      a_roHead.m_poNext          = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[6] == 'L')
    {
      StList *poList = a_roTrail.m_poPrev;
      a_roTrail.m_poPrev         = poList->m_poPrev;
      poList->m_poPrev->m_poNext = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      StList *poList = a_roHead.m_poNext;
      while (poList != &a_roTrail)
      {
        if (poList->m_iKey == iNumber)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &a_roHead, StList &a_roTrail)
{
  StList *poList = a_roHead.m_poNext;
  while (poList != &a_roTrail)
  {
    if (poList != a_roHead.m_poNext) cout << " ";
    cout << poList->m_iKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32460
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int n = Integer.parseInt(scan.nextLine());
        
        out.println(n % 2 == 0 ? n / 2 : n / 2 + 1);
        out.close();
        
    }
}

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

int main(){
  //小数点以下12ケタを表示させるためのおまじない
  cout<<fixed<<setprecision(12);
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;

  double X=pow(x1-x2,2);
  double Y=pow(y1-y2,2);
  cout<< sqrt( X+Y ) <<endl;
  return 0;  
}



Measured memory_bytes: 3268
def d():
    s = input()
    count = 0
    for i in range(1, 60):
        ans = 2019 * i
        if '0' not in str(ans):
            count += 1
            print(i, ans)

    print(count)

def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        s[i] = input()
    s.sort()
    count = 1
    for i in range(1, n):
        if s[i - 1] != s[i]:
            count += 1
    print(count)

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')



a()

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

int main(){
  int H,W;
  cin>>H>>W;
  char S[H][W];
  int N[H][W];
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin>>S[i][j];
    }
  }
  
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      int count = 0;
      if(S[i][j]=='#'){
         N[i][j]=9;
        continue;
         }
      for(int m=i-1;m<i+2;m++){
        for(int n=j-1;n<j+2;n++){
          if((m<0)||(n<0)||(m==H)||(n==W)){
            continue;
          }
          if (S[m][n]=='#'){
            count++;
          }
        }
      }
      N[i][j]=count;
    }
  }
  
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if(N[i][j]==9){
        cout<<"#";
      }
      else cout<<N[i][j];
    }
    cout<<endl;
  }
  
  return 0;
}

      
  
  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<stack>

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define scantype int
#define lli long long int
#define N 100003

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}

using namespace std;

void scan(scantype &x);

int main(void)
{
  int n;
  cin>>n;
  lli a[n];
  for(int i=0;i<n;i++)scanf("%lld",&a[i]);

  stack< pair<lli,int> > stk;

  stk.push({a[n-1],n-1});
  int next[n];

  next[n-1]=n;

  for(int i=n-2;i>=0;i--)
  {
       while(!stk.empty() && stk.top().first>=a[i])
              stk.pop();

       if(stk.empty()) next[i] = n;
       else next[i] = stk.top().second;

       stk.push({a[i],i});
  }

  lli res[n+1];

  res[n-1] = a[n-1];
  res[n]=0;

  for(int i=n-2;i>=0;i--)
  {
         res[i] = a[i]* (lli)(next[i]-i) + res[next[i]];
  }
  lli fres=0;

  for(int i=0;i<n;i++)fres+=res[i];
  cout<<fres;
  return 0;
}









void scan(scantype &x)
{
    /*register int c = getchar(); //for positive
    x = 0;
    for(;(c<48 || c>57);c = getchar());
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}*/

    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 7424
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	int k = 0, res = 0;
	while (k < s.size())
	{
		int cnt = 0;
		while (k < s.size() && s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T')
		{
			++cnt;
			++k;
		}
		chmax(res, cnt);
		++k;
	}
	cout << res << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S == "SUN") cout << 7 << endl;
    if(S == "MON") cout << 6 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int arr[22][22];
int cache[1ll<<22];
int mod=1e9+7;
int dp(int bit)
{
    if(bit+1==(1ll<<n))
        return 1;
    int &ans=cache[bit];
    if(ans!=-1)
        return ans;
    ans=0;
    int row=__builtin_popcount(bit);
    for(int i=0;i<n;i++)
        if(arr[row][i] && !((1ll<<i)&bit))
            ans+=dp(bit|(1ll<<i));
    ans%=mod;
    return ans;
}
int32_t main() 
{
    IOS;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
    memset(cache,-1,sizeof(cache));
    print(dp(0));
}


Measured memory_bytes: 36360
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
#+++++
import itertools
n=int(input())
a={}
for _ in range(n):
	s=input().strip()
	t=a.get(s[0], 0)
	a[s[0]]=t+1

ans=0
for x,y,z in itertools.combinations(list('MARCH'), 3):
	ans+=a.get(x, 0)*a.get(y, 0)*a.get(z, 0)
	
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

#define N 30

int main(void) {
    int n, m, a[N] = {0}, len, cnt = 0, k;

    scanf("%d %d", &n, &m);
    
    for(int i = 0; i < n; i++) {
        scanf("%d", &len);
        for(int j = 0; j < len; j++) {
            scanf("%d", &k);
            a[k - 1] += 1;  
        }
    }

    for(int i = 0; i < N; i++) {
        if(a[i] == n) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int* a = new int[n];
    for(int i = 0; i < n - 1; i++)
    {
        cin >> a[i];
    }

    int* sub = new int[n];
    for(int i = 0; i < n; i++)
    {
        sub[i] = 0;
    }

    for(int i = 0; i < n - 1; i++)
    {
        sub[a[i] - 1]++;
    }

    for(int i = 0; i < n; i++)
    {
        cout << sub[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5180
A, B, C, D = input()
o = ["+", "-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      s = A + o[i] + B + o[j] + C + o [k] + D
      if eval(s) == 7:
        print(s + "=7")
        exit()

Measured memory_bytes: 3064
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

print(bus)

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

const int INF=100000000;

int main() {
   int n;
   cin>>n;
   int sum=0,mm=0,a;
   for (int i = 0; i < n; ++i){
      cin>>a;
      sum+=a;
      mm=max(a,mm);
   }

   cout<<sum-mm/2<<endl;

}


Measured memory_bytes: 256
n = int(input())
listA = list(map(int, input().split()))
count = 0
isBroken = False


while True:
    for i in range(n):
        if listA[i] % 2 == 0:
            listA[i] //= 2
        else:
          isBroken = True
          break
    if isBroken:
        break
    else:
        count += 1


print(count)

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

using namespace std;

int main()
{
    int i, j;
    int n; cin >> n;
    vector<int> d(n); for (i=0; i<n; i++) cin >> d.at(i);
    vector<int> different(1, d.at(0));
    
    int d_size = different.size();
    bool different_tf = true;
    for (i=0; i<n; i++)
    {
        d_size = different.size();
        different_tf = true;
        for (j=0; j<d_size; j++)
        {
            if (different.at(j) == d.at(i)) different_tf = false;
        }
        if (different_tf) different.push_back(d.at(i));
    }
    cout << different.size() << endl;
}

Measured memory_bytes: 3636