akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10, mod = 1e9+7;
int n,a[N],b[N],cnt[2];
char s[N];

inline void GG(){
	puts("0");exit(0);
}

int main(){
	n=read(),scanf("%s",s+1),n=strlen(s+1);
	if (s[1]=='W') GG();
	a[1]=1;
	For(i,2,n) a[i]=(s[i]!=s[i-1]);
	b[1]=0;
	For(i,2,n){
		if (a[i]) b[i]=b[i-1];
			else b[i]=b[i-1]^1;
	}
	For(i,1,n) cnt[b[i]]++;
	if (cnt[0]!=n/2) GG();
	int tot=0,ans=1;
	Dow(i,n,1){
		if (b[i]==1) ++tot;
			else ans=1ll*ans*tot%mod,--tot;
	}
	For(i,1,n/2) ans=1ll*ans*i%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 5524
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=5e6+5;

signed main(){
    /*B
    int n=re;
    int ans=0;
    ff(i,n){
        if(i%3&&i%5)ans+=i;
    }
    pr(ans);
    */
    int n=re;
    int ans=0;
    ff(i,n)ff(j,n)ff(k,n){
        int t=gcd(i,j);
        t=gcd(t,k);
        ans+=t;
    }
    pr(ans);


    return 0;
}


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

using namespace std;

int p[20000];
int a[20000];
int b[20000];

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

    for (int i = 0; i < n; i++)
        a[i] = i + 1, b[i] = n - i;

    int val = 2 * n;
    for (int i = n - 1; i > 0; i--){
        for (int j = p[i]; j < n; j++)
            a[j] += val;
        for (int j = p[i]; j >= 0; j--)
            b[j] += val;
        val--;
    }

    for (int i = 0; i < n; i++)
        cout << a[i] << ' ';
    cout << '\n';
    for (int i = 0; i < n; i++)
        cout << b[i] << ' ';

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

void call(int n){
  for(int i = 1; i <= n; i++){
    if(i % 3 == 0 || i % 10 == 3){
      cout << " " << i;
    }else{
      int x = i;
      while(x){
	if(x % 10 == 3){
	  cout << " " << i;
	  break;
	}
	x /= 10;
      }
    }
  }
  cout << endl;
}  

int main(){
  int n;
  std::cin >> n;
  call(n);
  return 0;
}



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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

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

signed main(){
	fastio();
    double H, W, x, y; cin >> H >> W >> x >> y;
    double area = H * W;
    int aux = 0;
    if(x + x == H && y + y == W) ++aux;
    cout << fixed << setprecision(9);
    cout << area / 2 << ' ' << aux << '\n';
	return 0;
}

Measured memory_bytes: 3764
card = []
mk = ["S", "H", "C", "D"]
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for i in(0..3)
    for k in(0..12)
        card << mk[i] + " " + num[k].to_s
    end
end

n = gets.to_i
n.times do
    card.delete(gets.chomp)
end
    
puts card

Measured memory_bytes: 8672
def main():
    S = input()
    S = S[::-1]
    ans = ["maerd", "remaerd", "esare", "resare"]
    while S:
        for a in ans:
            if S[:5] in ans:
                S = S.replace(S[:5], "", 1)
                break
            elif S[:6] in ans:
                S = S.replace(S[:6], "", 1)
                break
            elif S[:7] in ans:
                S = S.replace(S[:7], "", 1)
                break
        else:
            return print("NO")
    else:
        return print("YES")


if __name__ == '__main__':
    main()


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

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N)
    {
      cin >> a[i];
    }
  int ans = 1000000000;
  for(int i = -100; i <= 100; i++)
    {
      int tmp_ans = 0;
      rep(j, N)
	{
	  tmp_ans += (i - a[j])*(i - a[j]);
	}
      ans = min(ans, tmp_ans);
    }
  cout << ans << endl;
  return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0){
			return 1;
		}
		else if(strlen(H[h])==0){	
			return 0;
		}
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0){
			return 1;
		}
		else if(strlen(H[h])==0){	
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16084
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

B = []
C = []

l = {}

for i in range(Q):
    b, c = list(map(int, input().split()))

    B.append(b)
    C.append(c)

res = 0
for i in A:
    if i in l:
        l[i] += 1
    else:
        l[i] = 1

    res += i

t = 0
for i in range(Q):
    if B[i] in l:
        t = l[B[i]]


        res += (C[i] - B[i]) * t

        l[B[i]] = 0
        if C[i] in l:
            l[C[i]] += t
        else:
            l[C[i]] = t

    print(res)

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

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef vector<int> V;
typedef vector<V> VV;
const int INF=114514;
int main(){
    int N,E,T;
    cin>>N>>E>>T;T--;
    V dist(N,INF);
    for(int i=0;i<N;i++){
        int b;cin>>b;
        if(b)dist[i]=1;
    }
    V G(E);
    VV edge(E);
    for(int i=0;i<E;i++){
        int C;
        cin>>G[i]>>C;G[i]--;
        edge[i].resize(C);
        for(int j=0;j<C;edge[i][j++]--)cin>>edge[i][j];
    }
    for(bool update=true;update;){
        update=false;
        for(int i=0;i<E;i++){
            int sz=edge[i].size();
            V d=edge[i];
            for(int j=0;j<sz;j++)d[j]=dist[d[j]];
            sort(d.begin(),d.end());
            reverse(d.begin(),d.end());
            int need=0;
            int space=0;
            for(auto &v:d){
                if(space<v){
                    need+=v-space;
                    space+=v-space;
                }
                space--;
            }
            if(need<dist[G[i]]){
                update=true;
                dist[G[i]]=need;
            }
        }
    }
    if(dist[T]==INF)
        cout<<-1<<endl;
    else 
        cout<<dist[T]<<endl;
    return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

constexpr ll MOD = 1e9 + 7;

ll n, m;

ll get_edge_len(ll n, vector<ll> X) {
    ll xall = 0;
    ll k = 0;
    vector<ll> D(n - 1);
    for (ll i = 0; i < n - 1; i++) {
        D[i] = X[i + 1] - X[i];
    }

    ll len = D.size();
    for (ll i = 0; i < len / 2; i++) {
        k += len - 2 * i;
        xall = (xall + ((k * D[i]) % MOD) + MOD) % MOD;
        xall = (xall + ((k * D[len - 1 - i]) % MOD) + MOD) % MOD;
    }

    if (len % 2) {
        ll i = len / 2;
        k += len - 2 * i;
        xall = (xall + ((k * D[i]) % MOD) + MOD) % MOD;
    }

    return xall;
}

int main(void) {
    cin >> n >> m;
    vector<ll> X(n), Y(m);
    for (auto&& x : X) {
        cin >> x;
    }
    for (auto&& y : Y) {
        cin >> y;
    }

    ll xall = 0, yall = 0;

    /*
    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            xall = (xall + X[i] - X[j]) % MOD;
        }
    }

    for (ll i = 0; i < m; i++) {
        for (ll j = i + 1; j < m; j++) {
            yall = (yall + Y[i] - Y[j]) % MOD;
        }
    }

    cout << xall << "," << yall << endl;

    cout << "reset" << endl;
    xall = yall = 0;
    */

    xall = get_edge_len(n, X);
    yall = get_edge_len(m, Y);

    // cout << xall << "," << yall << endl;

    cout << (xall * yall) % MOD << endl;

    return 0;
}



Measured memory_bytes: 3424
from collections import defaultdict

N = int(input())
d = defaultdict(int)

max_num = 0
for _ in range(N):
    s = input()
    d[s] += 1
    max_num = max(max_num, d[s])
#print(d)

ans = []
for s in d.keys():
    if d[s] == max_num:
        ans.append(s)
ans.sort()

for s in ans:
    print(s)

Measured memory_bytes: 95448
#include<iostream>
#include<cstdio>
#include<cstring>
char s[1005];
int w;
int main() {
    scanf("%s%d",s,&w);
    int n=strlen(s);
    int now=0;
    while(now<n) printf("%c",s[now]),now+=w;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


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


int main(){
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> a(n), b(m), v(n+m);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<m; i++) cin >> b[i];

  vector<long long> as(n+1);
  vector<long long> bs(m+1);

  as[0] = 0;
  bs[0] = 0;
  rep(i, 0, n){
    as[i+1] = as[i] + a[i];
  }

  rep(i, 0, m){
    bs[i+1] = bs[i] + b[i];
  }

  long long ans = 0;

  for(int i=0; i<n+1; i++){
    if(as[i] <= k){
      // cout << as[i] << endl;
      long long cnt = upper_bound(all(bs), k-as[i]) - bs.begin();
      // cout << cnt << endl;
      ans = max(ans, i + cnt - 1);
    }
  }

  for(int i=0; i<m+1; i++){
    if(bs[i] <= k){
      long long cnt = upper_bound(all(as), k-bs[i]) - as.begin();
      ans = max(ans, i + cnt - 1);
    }
  }
  cout << ans << endl;
}



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

int isprime(int i){
  int S=sqrt(i);
  int Ans=1;
  for(int j=2; j<=S; j++){
    if(i%j==0){
      Ans=0;
      break;
    }
  }
  return Ans;
}

int main(){
  int N;
  cin >> N;
  vector<int> P(0);
  for(int i=2; i<1000; i++){
    if(isprime(i)==1){
      P.push_back(i);
    }
  }
  int L=P.size();
  vector<int64_t> D(L, 0);
  for(int i=1; i<=N; i++){
    for(int j=0; j<L; j++){
      int M=i;
      while(M%P.at(j)==0){
        D.at(j)++;
        M/=P.at(j);
      }
    }
  }
  int64_t Ans=1;
  for(int64_t i=0; i<L; i++){
    Ans*=D.at(i)+1;
    Ans%=1000000007;
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    else return gcd(b, a%b);
}

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) a[0] = gcd(a[0], a[i]);
    cout << a[0] << endl;
}

Measured memory_bytes: 1024
import os
import sys
from collections import deque
from functools import lru_cache, reduce
from operator import mul

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 1000000007


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    :return:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    :param max:
    :param mod:
    :return:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


N, K = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N - 1)]

factorials = get_factorials(max=K, mod=MOD)
invs = mod_invs(K, MOD)


def mod_inv(a, mod):
    """
    a の逆元
    :param int a:
    :param int mod:
    :return:
    """
    return pow(a, mod - 2, mod)


@lru_cache(maxsize=None)
def npr(n, r, mod=None):
    """
    :param int n:
    :param int r:
    :param int mod: 3 以上の素数であること
    :rtype: int
    """
    if n < r:
        return 0

    # 何度も呼ぶ場合は最大の n 以下の階乗を事前に計算しておくといい
    # return factorials[n] * mod_inv(factorials[r], mod) * mod_inv(factorials[n - r], mod) % mod
    if r == 0:
        return 1

    return factorials[n] * mod_inv(factorials[n-r], mod) % MOD


if N == 1:
    print(K)
    exit()

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
# 葉っぱを探す
leaf = None
for i in range(N):
    if len(graph[i]) == 1:
        leaf = i
        break

v = graph[leaf][0]
ans = npr(K, len(graph[v]) + 1, MOD)
seen = [False] * (N + 1)
seen[v] = True
que = deque()
for u in graph[v]:
    que.append(u)
    seen[u] = True

while que:
    v = que.popleft()
    seen[v] = True
    if len(graph[v]) == 1:
        continue
    ans *= npr(K - 2, len(graph[v]) - 1, MOD)
    ans %= MOD
    for u in graph[v]:
        if not seen[u]:
            que.append(u)

print(ans)


Measured memory_bytes: 78812
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int K;
    in(K);

    int L;
    if (K % 7 == 0)
    {
        L = 9 * (K / 7);
    }
    else
    {
        L = 9 * K;
    }

    int tmp = 1;
    repse(i, 1, L)
    {
        tmp *= 10;
        tmp %= L;

        if (tmp == 1)
        {
            outl(i);
            return 0;
        }
    }

    outl(-1);

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
 
int main(void){
    long long L, R;
    long long x = 2019;
    long long y = 0;
    long long diff = 0;
    
    cin >> L >> R;
    diff = R-L;
    
    if (diff==1) {
        cout << (L*R)%2019;
        return 0;
    } else if (diff>=2019) {
        cout << 0;
        return 0;
    } else {
        for (long long i = L; i < R; i++) {
            for (long long j = i+1; j < R + 1; j++) {
                y = (i*j)%2019;
                if (x >= y) {
                    x = y;
                }
            }
        }
        cout << x;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
using namespace std;

int main(){
    stack<int> s;
    string input;
    cin >> input;
    s.push(atoi(input.c_str()));
    int temp;
    while ( (cin >> input)) {
        if (input[0] == '+'){
            temp = s.top();
            s.pop();
            temp += s.top();
            s.pop();
            s.push(temp);
        }
        else if (input[0] == '-'){
            temp = -1 * s.top();
            s.pop();
            temp += s.top();
            s.pop();
            s.push(temp);
        }
        else if (input[0] == '*'){
            temp = s.top();
            s.pop();
            temp *= s.top();
            s.pop();
            s.push(temp);
        }
        else {
            s.push(atoi(input.c_str()));
        }
    }
    cout << s.top() << endl;
}


Measured memory_bytes: 3184
def main():
    S = list(str(input()))

    total = 0
    mask = 0
    n = len(S)
    while mask < (1<<(n-1)):
        i = 0
        s = S[:]
        while i < n-1:
            if mask & (1<<i):
                s[i] = s[i] + '+'
            i += 1
        total += eval(''.join(s))
        mask += 1

    print(total)

main()


Measured memory_bytes: 3060
//Ash180-AtCoder:3 A - αlphabet [Beginner Contest 171]
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define clock cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
#define forie(a,n) for(int i=(a);i<=(n);i++)
#define forje(b,m) for(int j=(b);j<=(m);j++)
#define forke(c,g) for(int k=(c);k<=(g);k++)
#define ffe(a,n,b,m) forie(a,n) forje(b,m)
#define fori(n) for(int i=0;i<n;++i)
#define forj(n) for (int j=0;j<n;++j)
#define fork(n) for (int k=0;k<n;++k)
#define rev(s)  reverse(s.begin(), s.end()) 
#define initblock(v,d) memset(v,d,sizeof(v))
#define ll long long
#define ull unsigned long long
#define re return 
using namespace std;
void Ash() 
{ 	
#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin); freopen("error.txt", "w", stderr); freopen("output.txt", "w", stdout); 
#endif 
}
void solve() { char c; cin >> c; (c >= 97 ? cout << 'a' : cout << 'A'); }
int main()   { fast; Ash(); solve(); clock; return 0; } 


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

string s;
set<int>st;
bool b;

int main() {
	cin >> s;
	for (int i = 0; i != s.size(); ++i)
		st.insert(i);
	for (auto it = st.begin(); it != --st.end(); ++it) {
		if (it != st.begin()) {
			auto jt = it, kt = it;
			--jt;
			++kt;
			if (s[*jt] != s[*kt]) {
				it = st.erase(it);
				--it;
				if (it != st.begin())
					--it;
				b ^= true;
			}
		}
	}
	if (b)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 4992
s = str(input())
count = 0
m = 0
for i in s:
    if i in "A":
        count += 1
    elif i in "C":
        count += 1
    elif i in "G":
        count += 1
    elif i in "T":
        count += 1
    else:
        count = 0
    m = max(m, count)
print(m)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i,j,k,n;
	string ss,st;
	cin>>ss>>st;
    n=max(st.length(),ss.length());
	for(i=0;i<n;i++){
		if(ss[i]>0)cout<<ss[i];
		if(st[i]>0)cout<<st[i];
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long n = lread();
    auto L = aryread();
    L.sort();
    bool b = L[0 .. $ - 1].sum() <= L[$ - 1];
    writeln(b ? "No" : "Yes");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
  vector<int> v(9);
  for(int i = 0; i < 9; ++i) scanf("%d", &v[i]);
  if(v[1]-v[0] == v[4]-v[3] && v[4]-v[3] == v[7]-v[6] && v[2]-v[1] == v[5]-v[4] && v[5]-v[4] == v[8]-v[7] && v[3]-v[0] == v[4]-v[1] && v[4]-v[1] == v[5]-v[2] && v[6]-v[3] == v[7]-v[4] && v[7]-v[4] == v[8]-v[5]) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

 
int main(){
  string s="APPROVED";
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a.at(i);
  
  rep(i,n){
      if(a.at(i)%2==0){
          if(a.at(i)%3!=0&&a.at(i)%5!=0)s="DENIED";
      }
  }
  cout<<s<<endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int S, W;
  cin >> S >> W;
  if(W >= S) {
    fin("unsafe");
  } else {
    fin("safe");
  }

}

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

int main() {
	int N;
  	cin >> N;
  	
  	int r,l;
    int x;
  
  	for (int i=0; i<N; i++){
    	cin >> l >> r;
      	x += r-l+1;
    }
  
  	cout << x;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

typedef pair<double, int> P;

int main() {
  ll K;
  cin >> K;
  vector<P> snuke{{1e15-1, 9*15}};
  while (snuke.back().first > 1) {
    double rnum = snuke.back().first;
    int rsum = snuke.back().second;
    rep(i, 14) {
       double lnum = rnum-pow(10, i);
       if (lnum < 0)
         continue;
       int lsum = 0;
       ll tmp = lnum;
       while (tmp) {
         lsum += tmp%10;
         tmp /= 10;
       }
       if (lnum/lsum <= rnum/rsum) {
         snuke.push_back({lnum, lsum});
         break;
       }
    }
  }
  reverse(snuke.begin(), snuke.end());
  rep(i, K)
    cout << (ll)snuke[i].first << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,i,j,a[4],p;
 j=0;
 p=0;
  cin>>n;
  for(i=1000;i>=1;i=i/10)
  {
    a[j]=(n/i);
    n=n%i;
    
    ++j;
  }
  for(i=0;i<3;i++)
  {
    if(a[i]==a[i+1])
    { cout<<"Bad";
    break;}
     else
        {p++;}
  }
  if(p==3)
    cout<<"Good";
  return 0;
}



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

int main() {
    int n, m;
    while (cin >> n >> m, n || m) {
        vector<int> v1(n), v2(m);
        int d = 0;
        for (int i=0; i<n; ++i) {
            cin >> v1[i];
            d += v1[i];
        }
        for (int i=0; i<m; ++i) {
            cin >> v2[i];
            d -= v2[i];
        }
        int t = 999, ret1 = 999, ret2 = 999;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<m; ++j) {
                if ((v1[i] - v2[j]) * 2 == d && v1[i] + v2[j] < t) {
                    t = v1[i] + v2[j];
                    ret1 = v1[i];
                    ret2 = v2[j];
                }
            }
        }
        if (ret1 == 999 && ret2 == 999) {
            cout << -1 << endl;
        } else {
            cout << ret1 << " " << ret2 << endl;
        }
    }
    return 0;
}

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

using namespace std;
using namespace atcoder;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

struct Point {
	int x, y, num;
};

int main() {
	int N;
	cin >> N;
	vector<Point> pos(N);

	dsu uf(N);

	fenwick_tree<int> fwt(N);

	vector<int> maxy(N);

	vector<int> m(N + 1);
	set<int> done;
	for (int i = 0; i < N; i++) {
		cin >> pos[i].x >> pos[i].y;
		pos[i].num = i;
	}

	sort(pos.begin(), pos.end(), [](const Point& l, const Point& r) {
		return l.x < r.x;
	});

	for (int i = 0; i < N; i++) {
		m[pos[i].y] = i;
		maxy[i] = pos[i].y;
	}

	int mi = N;
	int LMT = N;

	for (int i = 1; i <= N; i++) {
		fwt.add(m[i], 1);
		if (mi < m[i])continue;
		if (fwt.sum(m[i] + 1, N) + m[i] + 1 >= N) {
			LMT = m[i];
			continue;
		}
		for (int j = m[i] + 1; j < LMT; j++) {
			if (uf.same(pos[m[i]].num, pos[j].num))break;
			if (pos[m[i]].y < maxy[j]) {
				uf.merge(pos[m[i]].num, pos[j].num);
				maxy[m[i]] = maxy[j];

				if (pos[j].y != maxy[j])break;
			}
			else {

			}
		}
		mi = m[i];
	}

	//for (auto i : pos) {
	//	cerr << i.num << " " << i.x << " " << i.y << endl;
	//}

	//for (int i = 1; i <= N; i++) {
	//	cerr << m[i] << "\n";
	//}

	for (int i = 0; i < N; i++) {
		cout << uf.size(i) << "\n";
	}
	cout << flush;
	return 0;
}



Measured memory_bytes: 8748
///বিসমিল্লাহির_রহমানির_রহীম
#include<bits/stdc++.h>
#define     pie                          acos(-1.0)
#define     N                            2000015
#define     eps                          1e-9
#define     ff                           first
#define     ss                           second
#define     nl                           '\n'
#define     mod                          1000000007
#define     sp                           ' '
#define     CLR(a)                       memset(a,0,sizeof(a))
#define     SET(a)                       memset(a,-1,sizeof(a))
#define     all(x)                       x.begin(),x.end()
#define     allr(x)                      x.rbegin(),x.rend()
#define     sz(x)                        (int)(x).size()
#define     Fast_Read                    ios_base::sync_with_stdio(false); cin.tie(nullptr);  cout.tie(nullptr);
#define     Precision(x)                 cout.setf(ios::fixed); cout.precision(x);
#define     bug                          cout<<"debug"<<nl;
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline double dxt(){double aaa;scanf("%lf",&aaa);return aaa;}
#ifdef obaydullah
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
void solve(){
    int n=nxt();
    priority_queue<double> v;
    for(int i=0;i<n;i++){
        v.push(-dxt());
    }
    while(sz(v)){
        double one=v.top();
        one=-one;
        v.pop();
        if(!sz(v)){
            cout<<one<<endl;
            return;
        }
        double two=-(v.top());
        v.pop();
        v.push(-((one+two)/2.0));

    }

}
int main(){
    //Fast_Read
    Precision(10)
    #ifdef obaydullah
        double start_time = clock();
        ///freopen ("output.txt","w",stdout);
        ///freopen ("input.txt","r",stdin);
    #endif
    int tc=1;
    ///cin>>tc;
    while(tc--){
      solve();
    }
    #ifdef obaydullah
        double end_time = clock();
        cerr<<"Time = "<<fixed<<setprecision(10)<<(end_time - start_time) / CLOCKS_PER_SEC<<'\n';
    #endif

    return 0;
}


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

long long int dp[100001][101][2] = {0}, arr[100001] = {0};

long long int getsum(int index, int n, int flag, int sum, int k){
    if(index>n){
        if(sum==0) return 1;
        return 0;
    }

    if(dp[index][sum][flag]!=-1){
        return dp[index][sum][flag];
    }
    int limit = 0;
    if(flag) limit = arr[index];
    else limit = 9;
    long long int ans = 0;
    for(int i = 0; i <= limit; i++){
       if(i==limit && flag){
            ans = (ans+(getsum(index + 1, n, 1, (sum + i)%k, k)%mod))%mod;
       }
       else{
           ans = (ans+(getsum(index + 1, n, 0, (sum + i)%k, k)%mod))%mod;
       }
    }
    return dp[index][sum][flag] = ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k;
    string s;
    cin >> s >> k;
    
        memset(dp, -1, sizeof(dp));
        for(int i = 1; i <= s.size(); i++){
            arr[i] = s[i-1]-'0';
        }
        cout << (getsum(1, s.size(), 1, 0, k)-1+mod)%mod;
        
    return 0;
}

Measured memory_bytes: 162468
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
#define MAX 500

class Point{
    public:
    int x, y;
    Point(int x=0, int y=0):x(x), y(y){}
};

int R;

bool isClose(Point p1, Point p2 ){
    return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) <= 16*R*R;
}

main(){
    int AN, BN;
    vector<Point> A[MAX][MAX];
    vector<Point> B[MAX][MAX];
    const int di[13] = {0, 1, 1, 0, -1, -1, -1, 0, 1, 2, 0, -2, 0};
    const int dj[13] = {0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 2, 0, -2};
    int x, y;
    while(1){
	cin >> AN >> BN >> R;
	if ( AN == 0 && BN == 0 && R == 0 ) break;

	rep(i, MAX) rep(j, MAX) {
	    A[i][j].clear();
	    B[i][j].clear();
	}
	rep(i, AN){
	    scanf("%d %d", &x, &y); A[x/20][y/20].push_back(Point(x, y));
	}
	rep(i, BN){
	    scanf("%d %d", &x, &y); B[x/20][y/20].push_back(Point(x, y));
	}
	
	int sum = 0;

	rep(i, MAX) rep(j, MAX){
	    rep(k, A[i][j].size()){
		Point s = A[i][j][k];
		int ni, nj;
		for ( int ti = -2; ti <= 2; ti++ ) for ( int tj = -2; tj <= 2; tj++ ){
		    ni = i + ti;
		    nj = j + tj;
		    if ( ni < 0 || nj < 0 || ni >= MAX || nj >= MAX ) continue;
		    rep(l, B[ni][nj].size()){
			Point t = B[ni][nj][l];
			if ( isClose(s, t) ) sum++;
		    }
		}
	    }

	}

	cout << sum << endl;
    }
    

}

Measured memory_bytes: 12000
H, W, M = map(int, input().split())

cnt_h = [0] * (H + 1)
cnt_w = [0] * (W + 1)
points = set()
for m in range(M):
    h, w = map(int, input().split())
    cnt_h[h] += 1
    cnt_w[w] += 1
    points.add((h, w))

H_max = max(cnt_h)
W_max = max(cnt_w)

H_max_num = [i for i, cnt in enumerate(cnt_h) if cnt == H_max]
W_max_num = [i for i, cnt in enumerate(cnt_w) if cnt == W_max]

flag = 0
for h_num in H_max_num:
    for w_num in W_max_num:
        if (h_num, w_num) not in points:
            print(H_max + W_max)
            exit()

print(H_max + W_max -1)

Measured memory_bytes: 176952
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long int;

ll dp[110][110][110], enc[110][110];
const ll INF = 1e14;
void chmin(ll &A, ll B) { A = min(A, B); }

int main() {
  ll N, P; scanf("%lld%lld", &N, &P);

  vector<ll> X(N), Y(N);
  for(int i=0; i<N; i++) {
    scanf("%lld%lld", &X[i], &Y[i]);
    enc[i][0] = max(0LL, Y[i] - X[i]);
    for(int j=1; j<=i; j++) {
      ll HP = max(0LL, X[i] - enc[i-1][j-1]);
      enc[i][j] = max(0LL, Y[i] - HP);
    }
  }

  fill(dp[0][0], dp[110][0], INF);
  dp[0][0][0] = 0;

  for(int i=0; i<N; i++) {
    for(int j=0; j<=i; j++) {
      for(int k=0; k<N; k++) {
        if(dp[i][j][k] == INF) continue;
        // encourage
        chmin(dp[i+1][j+1][k+1], dp[i][j][k] + enc[i][j]);

        // do not
        chmin(dp[i+1][0][k], dp[i][j][k]);
      }
    }
  }

  int ans = 0;
  for(int i=0; i<=N; i++) {
    for(int j=0; j<=N; j++) {
      if(dp[N][i][j] <= P) ans = max(ans, j);
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 21;


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	str s;
	cin >> n >> s;
	s = s + '!';
	ll ans = n - 1;
	ll c0 = 0,c1 = 0;
	for(auto x : s) c0 += (x == '.');
	for(int i = 0; i <= n; i++){
		ans = min(ans, c0 + c1);
		
		c0 -= (s[i] == '.');
		c1 += (s[i] == '#');
	}
	cout << ans;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 788
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e7+10;
const int M=1e7;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int n;read(n);
    while(n)
    {
        if(n%10==7) return puts("Yes"),0;
        n/=10;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include <stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
#include<stack>
#include<queue>
#include<time.h>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;

string s;
ll ans,num,len;

ll dfs(ll i, ll cul,ll plus) {
	ll sum=0;
	//iがlenに達したら、終了
	if (i == len) {
		return cul+plus;
	}
	//足さない
	sum += dfs(i + 1, 10 * cul + int(s[i])-48,plus);
	//culを足す
	if (i > 0)sum += dfs(i + 1, int(s[i]) - 48,plus+cul);

	return sum;
}

int main(void)
{
	cin >> s;
	len = s.length();
	ans=dfs(0,0,0);
	ct(ans);
	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
s=s[::-1]
while n:
    if s.startswith("maerd"):
        n -= 5
        s = s[5:]
    elif s.startswith("remaerd"):
        n -= 7
        s = s[7:]
    elif s.startswith("esare"):
        n -= 5
        s = s[5:]
    elif s.startswith("resare"):
        n -= 6
        s = s[6:]
    else:
        break
print("YES" if n == 0 else "NO")


Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int NumberofDegits(long n)
{
    int num = 0;
    while (n > 0)
    {
        num++;
        n /= 10;
    }

    return num;
}

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

    long a, b;

    int f = 0;

    int MIN = INT32_MAX;

    for (int i = 1; i <= 100000; i++)
    {
        if (N % i == 0)
        {
            a = i;
            b = N / i;

            int a_d = NumberofDegits(a);
            int b_d = NumberofDegits(b);

            f = max(a_d, b_d);
            if (MIN > f) MIN = f;
        }
    }

    cout << MIN << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<bool>> s(h, vector<bool>(w, false));
	for(int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			s[i][j] = c != '#';
		}

	vector<vector<int>> dp(h + 1, vector<int>(w + 1, 0));
	for (int i = h - 1; i >= 0; i--)
		for (int j = w - 1; j >= 0; j--)
			if (i == h - 1)
			{
				dp[i][j] = dp[i][j + 1];
				if (s[i][j])
					continue;
				if (j == w - 1)
					dp[i][j]++;
				else if (s[i][j + 1])
					dp[i][j]++;
			}
			else if (j == w - 1)
			{
				dp[i][j] = dp[i + 1][j];
				if (s[i][j])
					continue;
				if (i == h - 1)
					dp[i][j]++;
				else if (s[i + 1][j])
					dp[i][j]++;
			}
			else
			{
				int p, q;
				if (!s[i][j])
				{
					if (dp[i + 1][j] + (s[i + 1][j] ? 1 : 0) > dp[i][j + 1] + (s[i][j + 1] ? 1 : 0))
						p = i, q = j + 1;
					else
						p = i + 1, q = j;
				}
				else if (dp[i + 1][j] > dp[i][j + 1])
					p = i, q = j + 1;
				else
					p = i + 1, q = j;
				dp[i][j] = dp[p][q];
				if (s[i][j])
					continue;
				if (s[p][q])
					dp[i][j]++;
			}
		
	printf("%d", dp[0][0]);

	return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
#define mod 1000000007
typedef long long ll;
using namespace std;
ll dp[201][100001]={},n,ans=0;
int x,s[200];
int main(){
    scanf("%lld %d",&n,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    dp[0][x]=1;
    sort(s,s+n);
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=x;j++){
            if(dp[i][j]){
                for(ll k=0;k<n;k++){
                    if(s[k]>j){
                        dp[i+1][j]+=dp[i][j]*(n-k-i);
                        dp[i+1][j]%=mod;
                        break;
                    }
                    else{
                        dp[i+1][j%s[k]]+=dp[i][j];
                        dp[i+1][j%s[k]]%=mod;
                    }
                }
            }
        }
    }
    for(ll i=0;i<=x;i++){
        ans+=i*dp[n][i];
        ans%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 154240
def main():

    N = int(input())
    A = input()
    B = input()
    C = input()

    count = 0
    for i in range(N):
        if A[i] == B[i] == C[i]:
            pass
        elif A[i] == B[i]:
            count += 1
        elif A[i] == C[i]:
            count += 1
        elif B[i] == C[i]:
            count += 1
        else:
            count += 2
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
struct edge{int to;ll cost;};
vector<edge> G[SIZE];
bool used[SIZE];
int color[SIZE];

void dfs(int v){
  used[v] = true;
  for(auto to : G[v]){
    if(used[to.to])continue;
    color[to.to] = color[v];
    if(to.cost%2 == 1) color[to.to] *= -1;
    dfs(to.to);
  }
}

int main(){
  cin >> n;
  rep(i,0,n-1){
    int u,v;
    ll w;
    cin >> u >> v >> w;
    G[u].push_back((edge){v,w});
    G[v].push_back((edge){u,w});
  }
  color[1] = 1;
  dfs(1);
  rep(i,1,n+1){
    cout << (color[i]==1?1:0) << endl;
  }

  return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 10010;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
int n,k,h[200001],ans;
signed main()
{
	n = read(), k = read();
	k=n-k;
	rep(i, 1, n) h[i] = read();
	sort(h+1,h+n+1);
	rep(i, 1, k) ans += h[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char str[] = sc.next().toCharArray();
		
		for(int i = 0; i < str.length; i++) {
			str[i] = (char)((str[i] - 'A' + n)%26 + 'A');
		}
		System.out.println(str);
	}

}


Measured memory_bytes: 23252